Summary
Make the Claude Code integration permission-mode aware: when Claude Code is in auto-accept mode (permission_mode = acceptEdits or bypassPermissions), skip both the diff preview and the review gate, since there is no real accept/reject moment to line the preview up with.
Follow-up to #74.
Background
Claude Code's PreToolUse hook payload includes a permission_mode field (values: default, plan, acceptEdits, auto, dontAsk, bypassPermissions). The plugin already receives this — the claudecode normaliser (lua/code-preview/pre_tool/normalisers.lua) is essentially identity, so raw.permission_mode is available in pre_tool.handle().
Today, diff.defer_claude_permissions = true only suppresses the forced permissionDecision: "ask" JSON (lua/code-preview/pre_tool/emitters.lua). It does not stop the diff from opening — diff.show_diff() is an unconditional side effect in present_single_file() (lua/code-preview/pre_tool/init.lua). It's also global, not mode-aware.
Proposal
- Read
permission_mode from the Claude Code hook payload and thread it through normalise() → handle().
- When the mode is auto-accept (
acceptEdits / bypassPermissions), skip both:
- the diff side effect (
show_diff), and
- the permission emit (already effectively a no-op in those modes, but make intent explicit).
- Gate the behaviour behind an opt-in config flag (e.g.
diff.skip_in_auto_accept) so existing behaviour is preserved by default. Final flag name TBD.
- Claude Code only — other backends own their own gate (per ADR-0002).
Open questions
- Flag name + default (
skip_in_auto_accept? default off?).
- Which modes count as "auto-accept" — just
acceptEdits/bypassPermissions, or also auto/dontAsk?
- Should the changes registry / neo-tree decoration still update when the diff is skipped, or stay fully silent?
- Worth an ADR, given it interacts with the ADR-0002 force-gate decision.
Acceptance
- With the flag enabled and Claude Code in auto-accept mode, no diff opens and no gate prompt fires.
- With the flag disabled (default), behaviour is unchanged.
- Normal (
default) mode is unaffected regardless of the flag.
Summary
Make the Claude Code integration permission-mode aware: when Claude Code is in auto-accept mode (
permission_mode=acceptEditsorbypassPermissions), skip both the diff preview and the review gate, since there is no real accept/reject moment to line the preview up with.Follow-up to #74.
Background
Claude Code's
PreToolUsehook payload includes apermission_modefield (values:default,plan,acceptEdits,auto,dontAsk,bypassPermissions). The plugin already receives this — theclaudecodenormaliser (lua/code-preview/pre_tool/normalisers.lua) is essentially identity, soraw.permission_modeis available inpre_tool.handle().Today,
diff.defer_claude_permissions = trueonly suppresses the forcedpermissionDecision: "ask"JSON (lua/code-preview/pre_tool/emitters.lua). It does not stop the diff from opening —diff.show_diff()is an unconditional side effect inpresent_single_file()(lua/code-preview/pre_tool/init.lua). It's also global, not mode-aware.Proposal
permission_modefrom the Claude Code hook payload and thread it throughnormalise()→handle().acceptEdits/bypassPermissions), skip both:show_diff), anddiff.skip_in_auto_accept) so existing behaviour is preserved by default. Final flag name TBD.Open questions
skip_in_auto_accept? default off?).acceptEdits/bypassPermissions, or alsoauto/dontAsk?Acceptance
default) mode is unaffected regardless of the flag.