Skip to content

feat(settings): add hook injection opt-out#2875

Open
rasitakyol wants to merge 1 commit into
generalaction:mainfrom
rasitakyol:agent/hook-injection-opt-out
Open

feat(settings): add hook injection opt-out#2875
rasitakyol wants to merge 1 commit into
generalaction:mainfrom
rasitakyol:agent/hook-injection-opt-out

Conversation

@rasitakyol

Copy link
Copy Markdown
Contributor

Description

Adds a default-on repository setting that lets users opt out of Emdash-managed agent notification hooks for local tasks.

When disabled, Emdash skips persistent config/plugin and .gitignore writes, does not modify Kimi's inline --config, and omits EMDASH_HOOK_* plus EMDASH_PTY_ID from the spawned agent environment. Existing managed entries are left untouched, so toggling the setting does not destructively rewrite user config.

The injection preference is kept separate from installation success: default-on sessions retain the previous environment behavior even if refreshing a hook file fails.

Related issues

Closes #1944

Testing

  • Desktop Node suite: 1,981/1,981 passed.
  • Local conversation regression suite: 33/33 passed.
  • Kimi command tests: 2/2 passed.
  • Desktop, core, and plugins typecheck, lint, and format checks passed.
  • git diff --check passed.
  • A concurrent full-app run had one unrelated IssueSelector 5-second timeout; that test passed immediately when rerun alone.

Screenshot/Recording

Not included; the change adds one repository settings row and is covered by build/type checks.

Checklist

  • I have read the contributing guidelines
  • I have added tests that prove the fix is effective
  • I have run the relevant checks locally
  • I have searched for existing pull requests and found no duplicate

@rasitakyol
rasitakyol marked this pull request as ready for review July 15, 2026 14:37
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a repository setting for opting out of Emdash-managed agent notification hooks. The main changes are:

  • Adds a default-on local repository setting and settings UI.
  • Skips hook installation, command configuration, and hook environment variables when disabled.
  • Preserves default-on behavior when hook installation fails.
  • Updates Kimi command generation and adds coverage for both setting states.

Confidence Score: 5/5

This looks safe to merge.

  • Existing stored settings receive the new default through the settings merge path.
  • Explicit opt-out consistently skips configuration writes, Kimi command changes, and hook environment variables.
  • Hook installation failures preserve the intended default-on process environment.
  • No blocking issues were found in the changed code.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/main/core/agent-hooks/hook-config-service.ts Separates the injection preference from hook installation success and skips configuration writes after an explicit opt-out.
apps/emdash-desktop/src/main/core/conversations/impl/local-conversation.ts Propagates the preference into command construction and gates hook-related process environment variables.
apps/emdash-desktop/src/main/core/settings/schema.ts Adds the hook-injection boolean to local repository settings.
apps/emdash-desktop/src/main/core/settings/settings-registry.ts Defines hook injection as enabled by default, including for existing stored setting deltas.
apps/emdash-desktop/src/renderer/features/settings/components/RepositorySettingsCard.tsx Adds the repository-level switch and reset control for hook injection.
packages/core/src/agents/plugins/capabilities/prompt.ts Extends command construction context with the optional hook-injection preference.
packages/plugins/src/agents/impl/kimi/index.ts Preserves Kimi's command unchanged when managed hook injection is explicitly disabled.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start local conversation] --> B[Read repository settings]
  B --> C{Hook injection enabled?}
  C -->|Yes| D[Refresh provider hook configuration]
  C -->|No| E[Skip hook configuration]
  D --> F[Build provider command with hook injection enabled]
  E --> G[Build provider command with hook injection disabled]
  F --> H[Spawn agent with hook environment]
  G --> I[Spawn agent without hook environment]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
  A[Start local conversation] --> B[Read repository settings]
  B --> C{Hook injection enabled?}
  C -->|Yes| D[Refresh provider hook configuration]
  C -->|No| E[Skip hook configuration]
  D --> F[Build provider command with hook injection enabled]
  E --> G[Build provider command with hook injection disabled]
  F --> H[Spawn agent with hook environment]
  G --> I[Spawn agent without hook environment]
Loading

Reviews (1): Last reviewed commit: "feat(settings): add hook injection opt-o..." | Re-trigger Greptile

@arnestrickmann

Copy link
Copy Markdown
Contributor

Thanks for the PR, @rasitakyol - we'll review and follow up with feedback here timely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat]: Add setting to disable automatic hook config injection (.claude/settings.local.json, .codex/config.toml)

2 participants