fix: extract_cli_args misses bare --resume and leaves --continue (claude)#29
Open
cannonpalms wants to merge 1 commit into
Open
fix: extract_cli_args misses bare --resume and leaves --continue (claude)#29cannonpalms wants to merge 1 commit into
cannonpalms wants to merge 1 commit into
Conversation
…ude) The claude branch of extract_cli_args in scripts/save-assistant-sessions.sh had two bugs that combined to corrupt cli_args across save/restore cycles: 1. The regex `s/--resume[= ] *[^ ]*//` required `[= ]` after --resume, so a bare `--resume` at end-of-args (produced by `claude --resume` interactive picker invocations or the `/resume` slash command) survived extraction. Subsequent restores built `command claude ... --resume --resume <uuid>`, after which claude's self-re-exec left a stray UUID positional in argv -- which claude treats as the first user prompt for the resumed conversation. The stray UUID then perpetuated across saves. Fix: make the value group optional and require the first char of a space-separated value to be non-dash, so `--resume --foo` doesn't greedily consume `--foo` either. 2. `--continue` / `-c` was preserved. Once the plugin supplies `--resume <session_id>` the `--continue` flag is redundant and risks falling back to "most recent in cwd" if `--resume` fails to resolve. Fix: strip `--continue` / `-c` unconditionally. Closes timvw#28.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in
extract_cli_argsforclaudeinscripts/save-assistant-sessions.sh:--resumenot stripped. The old regexs/--resume[= ] *[^ ]*//requires[= ]after--resume, so a bare--resumeat end-of-args (produced byclaude --resumeinteractive-picker invocations or the/resumeslash command) survives extraction and corrupts subsequent restores. New regex makes the value group optional and forbids consuming a following flag as the value.--continue/-cnot stripped. Once the plugin supplies--resume <session_id>,--continueis ambiguous baggage -- it conflicts in spirit and may fall back to "most recent in cwd" if--resumefails to resolve.The combined bug produces a feedback loop: the restored claude's cmdline ends up with a stray UUID positional (claude treats it as the first user prompt of the resumed conversation), the next save captures that stray UUID into
cli_args, and the corruption perpetuates across cold-starts.Closes #28 -- see the issue for a full reproduction, root-cause walkthrough, and notes on remediation for users already in the stuck state.
Test plan
Verified each input below against the patched
extract_cli_args(after the binary-name strip on line 380, so the inputs below represent the post-binary-strip arg string):--dangerously-skip-permissions --resume eaf5f4d6-bd5f-49a8-ba6d-fe69af2dd537--dangerously-skip-permissions--resume <uuid>--dangerously-skip-permissions --dangerously-skip-permissions --resume--dangerously-skip-permissions --dangerously-skip-permissions--resumeat EOS (the bug)--dangerously-skip-permissions --dangerously-skip-permissions eaf5f4d6-bd5f-49a8-ba6d-fe69af2dd537 --resume eaf5f4d6-bd5f-49a8-ba6d-fe69af2dd537--dangerously-skip-permissions --dangerously-skip-permissions eaf5f4d6-bd5f-49a8-ba6d-fe69af2dd537--resume <uuid>tail is stripped; the leading stray UUID still requires user remediation (see issue)--resume --model claude-opus-4-7--model claude-opus-4-7--dangerously-skip-permissions --resume=eaf5f4d6-bd5f-49a8-ba6d-fe69af2dd537--dangerously-skip-permissions--dangerously-skip-permissions --dangerously-skip-permissions --continue--dangerously-skip-permissions --dangerously-skip-permissions--continuestripped--add-dir /a --add-dir /b--add-dir /a --add-dir /bScope
The
opencodeandcodexbranches ofextract_cli_args(lines 404, 408) share the same regex pattern and likely have the analogous bare-flag and greedy-value bugs. Happy to add those fixes in a follow-up if you'd like -- I've kept this PR scoped to claude since that's what I verified end-to-end against a real claude process.