emdash icon indicating copy to clipboard operation
emdash copied to clipboard

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

Open rasitakyol opened this issue 6 months ago β€’ 8 comments

Description

Every time emdash spawns an agent session, HookConfigWriter.prepareHookConfig() writes notification hook configs into the project/worktree cwd:

  • .claude/settings.local.json β€” adds Notification and Stop hook entries pointing at emdash's local POST endpoint (carries EMDASH_HOOK_PORT / EMDASH_HOOK_TOKEN markers).
  • .codex/config.toml β€” sets notify = [...] to the bundled notify script.
  • .opencode/plugins/emdash-notifications.js, .pi/extensions/emdash-hook.ts for those providers.

There is currently no setting that disables this injection. The two related toggles do not gate it:

Setting Effect
notifications.enabled Only suppresses Notification.show() (OS toast). The hook file is still written.
localProject.writeAgentConfigToGitIgnore Only controls whether the path is added to .gitignore. The hook file is still written.

Why this is a problem

  • It silently mutates user-owned config files (.claude/settings.local.json is meant for user-specific permissions, not tool-managed hooks).
  • It runs on every fresh LocalConversationProvider instance β€” disabling per-task caching via preparedHookProviders is per-instance and resets across tasks/sessions.
  • Users who don't want their projects coupled to a running emdash daemon (e.g. they share the worktree with other agents, run agents directly, or audit their repo for unexpected files) have no opt-out short of patching the asar or making the files immutable (chmod 444 / chflags uchg), both of which produce silent write failures emdash logs as warnings.

Reproduction

  1. emdash 1.1.10, macOS.
  2. Open any project, start a Claude or Codex task.
  3. cat .claude/settings.local.json β€” the hooks block now contains an entry referencing EMDASH_HOOK_PORT. Same for .codex/config.toml (notify = ...).
  4. Toggle off notifications.enabled and writeAgentConfigToGitIgnore from Settings.
  5. Start a new task β€” the hook entries are re-written.

Source pointers (1.1.10, packed out/main/index.js)

  • class HookConfigWriter β€” writeClaudeHooks / writeCodexNotify / writeForProvider / writeAll.
  • Caller: LocalConversationProvider.prepareHookConfig invoked from startSession. The guard only checks writeAgentConfigToGitIgnore for .gitignore writes, never gates the config file write itself.

Proposed fix

Add a new setting (e.g. localProject.injectAgentNotificationHooks: boolean, default true to preserve current behavior) and short-circuit prepareHookConfig when it's false. Optionally per-provider granularity ({ claude: false, codex: true }) for users who want notifications for one provider but not another.

A "clean up existing emdash hook entries from this project" action in Settings would also be helpful, since users who toggle this off will have stale entries from previous runs.

emdash version

1.1.10

OS

macOS (Darwin 25.3.0)

rasitakyol avatar May 09 '26 12:05 rasitakyol

Hi @rasitakyol, Thanks for flagging this. We will add a setting for opting out of the automatic hook injection.

arnestrickmann avatar May 10 '26 23:05 arnestrickmann

+1 on this, this has been super annoying, and intrusive.

VinhLe1410 avatar May 19 '26 13:05 VinhLe1410

on it! will have something ready by eod :)

if there is anything else that yall would love to have fixed, just tag me!

janburzinski avatar May 19 '26 13:05 janburzinski

@janburzinski I was definitely too sleepy when posting the comment πŸ’€. I was using Superset, not Emdash, and they keep adding hooks to my agents' configs. I'm sorry, somehow I found myself here. Probably will use Emdash just to see though haha...

VinhLe1410 avatar May 20 '26 07:05 VinhLe1410

haha no problem! would love for you to try emdash

if you find any bug/inconvenience just tag me i'll fix it instantly ☺️ @VinhLe1410

janburzinski avatar May 20 '26 07:05 janburzinski

Hi, checking in on "will have something ready by eod," did that happen? 😌 Also, I'm using Pi, and I would still like Emdash to write the hook (and keep it updated), but just in my home directory, not per worktree.

alecmev avatar Jun 08 '26 22:06 alecmev

Hi @alecmev, Apologies, and thanks for the bump! This slipped through for some reason after the initial follow-up.

We should def. implement this setting and it sits on our list: We’ll take another look and follow up with an implementation path here. @janburzinski

arnestrickmann avatar Jun 08 '26 22:06 arnestrickmann

closing as this as resolved

jschwxrz avatar Sep 01 '26 14:09 jschwxrz