feat(diff): per-diff terminal width, auto_resize_terminal opt-out, and lifecycle events#270
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70383e938b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…le events Implements issue #242. Adds three layered, backward-compatible controls for the Claude terminal during diff review: - terminal.diff_split_width_percentage: optional terminal width while a diff is open (falls back to split_width_percentage; default nil keeps current behavior). - diff_opts.auto_resize_terminal (default true): when false, the plugin leaves the terminal width untouched so users own it themselves. - User autocmds ClaudeCodeDiffOpened / ClaudeCodeDiffClosed (always emitted, pcall-guarded) carrying a data payload, so configs can react to the diff lifecycle without monkey-patching private functions. The five existing terminal-resize sites are consolidated behind one gated helper; events fire exactly once per open/close. Change-Id: I4a712a576cd1a3bd203e3f3659784bb8122f31c0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Kosiewski <tk@coder.com>
70383e9 to
d4bfab3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4bfab3402
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…eeze-width Per review feedback (#270): when auto_resize_terminal=false the plugin applies no width policy, but the diff layout still runs `wincmd =` (equalizing splits), so opt-out means "own the width via the ClaudeCodeDiffOpened/Closed events" (which fire after layout, so a handler's resize wins) rather than "freeze the width". Tighten the helper comment and README wording to match. Change-Id: I2ab94caf160ae7e1fe57c3917ba00ce628aaf52b Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review Re-requesting on |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Closes #242.
Currently
terminal.split_width_percentagecontrols the Claude terminal width both when idle and while a diff is open, coupling two preferences that often want different values (wide for chatting, narrow while reviewing a diff). This PR adds three layered, fully backward-compatible controls:terminal.diff_split_width_percentage(defaultnil) — optional terminal width while a diff is open. Falls back tosplit_width_percentagewhen unset, so behavior is unchanged by default. This is the zero-Lua path for the original request.diff_opts.auto_resize_terminal(defaulttrue) — whenfalse, the plugin leaves the terminal width untouched across the diff lifecycle so you can own it yourself.UserautocmdsClaudeCodeDiffOpened/ClaudeCodeDiffClosed(always emitted, pcall-guarded) carrying a data payload — so configs can react to diffs opening/closing (resize, relayout, statusline, etc.) without monkey-patching private functions. This mirrors the existingClaudeCodeSendCompleteevent convention added in [BUG] focus_after_send has no effect with provider = "none" #228.The five existing terminal-resize sites are consolidated behind a single gated helper (
resize_terminal_for_diff); the events fire exactly once per open/close at the single setup/cleanup points, so they also cover the:q-reject (#266) and disconnect-auto-close (#248) paths.Design notes
This follows the triage discussion on #242: events are the durable, idiomatic mechanism (same shape as
diffview.nvim'sDiffviewViewOpened/Closedand this plugin's ownClaudeCodeSendComplete), with the width key as convenient sugar and the opt-out flag as the clean "I own the layout" escape hatch. Nothing is removed and the default behavior is byte-identical.event.dataforClaudeCodeDiffOpened:tab_name,file_path,new_file_path,is_new_file,diff_window,target_window,terminal_window,tab_number. ForClaudeCodeDiffClosed:tab_name,file_path,reason(a best-effort human-readable label, not a stable enum).Opt-out + event example
Test plan
mise run all— full suite green, lint + format clean.diff_split_width_spec),auto_resize_terminalgate +resize_terminal_for_diffgating (enabled/disabled/floating/invalid/nil) + lifecycle-event payloads via the recorder convention (diff_auto_resize_events_spec), plusconfig/terminalvalidation for the new options.auto_resize_terminal=trueshrinks the terminal to the diff width and restores the idle width on close;=falseleaves width untouched while events still fire.auto_resize_terminal=falsea userClaudeCodeDiffOpenedhandler owned the width instead.Docs
README gains a "Diff Lifecycle Events" section and the new config options;
CLAUDE.md,dev-config.lua, and type annotations updated.🤖 Generated with Claude Code