Files
magpie/internal
yetone c079b9ad7e claude: an interactive run's side question is branched before, not told whole (bbfatx on X)
Claude Code asks for a prompt suggestion as the conversation plus one
more user message (#1638). A claude -p run takes that aside and goes on;
on the next real turn the bridge rewinds it to the line before the aside
(behindKey/behindTurn and --resume-session-at). An interactive run
ignores --resume-session-at, so the bridge aborted it and told the next
turn whole to a new run: every turn after a suggestion wrote the whole
conversation into the cache again. That is bbfatx's second suggestion
(save a checkpoint at a history prefix and fork from the deepest one) in
the one place where it rewrites the cache today.

Now the run remembers the last session line it wrote before each turn
(lastLine, backLine, behindLine). When the next real turn finds an
interactive run behind an aside, the bridge cuts a copy of the run's
session at that line before the abort removes the file (branchAt, the
cut copy from the previous commit), and the new run resumes the copy in
interactive mode and is told only the new message.

Run (mote, at this tree):
- go test -tags nogui -count=1 -timeout 30m -run
  "Claude|Bridge|ToolChoice|Subscription|Retire|Rewrit|Fork|Branch|Shelf|Shelve"
  ./internal/gateway: ok (70.7s)
- go test -tags nogui -count=1 ./internal/claudetui: ok
- gofmt -l internal/: clean

Broken by hand (TestClaudeInteractiveSideQuestionBranchesBeforeIt):
- the old code (HEAD 37ff7356f): red, the turn after the suggestion is
  "had 0 turn 1" (told whole to a fresh run).
- backLine left "": red, "had 0".
- cut at the run's last line (after the suggestion) instead of the line
  before it: red, "had 6".

Not tried: a real interactive Claude Code prompt suggestion end to end;
the test uses the fake claude with the helper stand-in. The cut copy
itself was measured with real Claude Code 2.1.316 in the previous commit.

Not taken from the suggestion: a general store of checkpoints by history
prefix. The bridge already keeps one run per conversation and resumes it
at the line it is behind; the only case that lost the prefix was the
interactive aside, so only that case gets a cut. Prompt and system text
sent upstream are unchanged.
2026-11-01 16:33:07 +08:00
..
…
…
…
…
…