Repository navigation
Edit and resubmit any past user message (#254) - #387
Merged
currentbits merged 12 commits intoAug 17, 2026
Merged
Conversation
Shared IPC contract only: RewindResult, ThreadInfo.replayContext, threads.rewind doc, wireClient proxy, devCoder fixture twin. Co-Authored-By: Claude Opus 5 <[email protected]>
…oder/fork-edit-and-resubmit-any-past-message-e4dd81
…oder/fork-edit-and-resubmit-any-past-message-310cdb
Truncate the transcript and work-log at a user message, clear the CLI session, and arm a one-shot replay of the retained tail. Optional restoreFiles hard-resets the worktree via the existing checkpoint path.
Inline editor on user bubbles, confirm, then threads.rewind followed by the existing startRun path. Transcript-only rewind is the default; restoreFiles is an opt-in when the thread has a worktree.
Clean turns skip a checkpoint number, so mapping retained user messages onto coder-checkpoint turn N restored the wrong tree. Select the newest checkpoint whose commit time is at or before the edited message. Persist with saveNow so a crash cannot resurrect the dropped transcript against already-reset files.
…nto coder/edit-and-resubmit-any-past-message-00986e
Editing the words of a message must not silently drop the images it came with; Retry turn already re-sends them. Co-Authored-By: Claude Opus 5 <[email protected]>
Merged worker branches make their coder-checkpoint commits reachable. Walking them lets rewind (and the restore UI) hard-reset onto the fork's tree. --first-parent keeps the shared list on this thread's own line, which is what restoreCheckpoint already claimed to do.
…nto coder/edit-and-resubmit-any-past-message-00986e
Co-Authored-By: Claude Opus 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/edit-and-resubmit-any-past-message-00986e
branch
October 3, 2026 16:07
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.
Closes #254. Inspired by Zed's editable message history: edit any past user message and re-run from that point, instead of doing checkpoint archaeology to undo a wrong turn.
What changed
threads.rewind(new IPC). Truncates the transcript at a chosen past user message — that message and everything after it — plus the work-log items belonging to the dropped runs. It clearssessionIdand sets a one-shotreplayContext: a provider CLI session cannot be rewound, so the next turn starts a fresh session and the runner seeds its prompt with a digest of the retained tail. That reuses the existing hand-off prefix builder with the thread itself as source; it deliberately does not sethandoffFromto the thread's own id, because that field drives orchestrator crew sweeps and the OTel ancestor walk, where a self-reference risks a cycle.Rewind starts no run. The renderer follows with the ordinary
runs.start, which appends the edited text as a new user message — so there is one run-start path, not two. Usage and spend history are never rewritten: that money was really spent.Optional file rewind. With
restoreFiles, the worktree is hard-reset to the newest checkpoint at or before the edited message, through the existing guardedrestoreCheckpointpath. No worktree or no matching checkpoint is not an error — the transcript still rewinds andrestoredShacomes back null.UI. User bubbles gain an Edit affordance that opens an inline editor prefilled with the original text (focus on open, Escape cancels, Cmd/Ctrl+Enter submits). Because resubmitting destroys later transcript, a confirm dialog names how many messages will be dropped; it reuses the existing confirm overlay and
useEscapeCloserather than introducing a modal system. The "also restore files" option appears only when the thread has a worktree and is off by default, keeping transcript-only rewind the one-click path. Attachments on the edited message are carried through, as Retry turn already does.Checkpoint hazards found and fixed
A read-only scan of the live store surfaced two problems the test suite could not have shown, both of which made the automatic file reset land on the wrong tree:
maybeCreateCheckpointnumbers a checkpoint by counting existing checkpoint commits, and returns early when the worktree is clean — so a turn that changes nothing skips a number. Mapping retained user messages ontoturn Ntherefore restored the wrong state; 2 of 6 sampled live threads had the mismatch. Selection is now by commit time.listCheckpointswalked all reachable history, so a thread that merged a worker branch saw that worker's checkpoints, with repeating turn numbers — one live thread has 8 checkpoint commits against a max turn of 3. Restoring one would hard-reset onto the fork's tree and discard the merge. Fixed with--first-parentat the shared function, so the pre-existing checkpoint-restore UI is covered too; that is what therestoreCheckpointguard already claimed to do.Two smaller correctness fixes: rewind persists with
saveNow()(the debouncedsave()left a window where a crash would resurrect the dropped transcript against already-reset files), and the renderer refetches the detail right after a rewind (otherwise a follow-up run that fails to start leaves the dropped messages on screen, looking as though nothing happened).Tests
electron/test/rewind.test.jsdrives real git repos, including a turn that leaves the worktree clean and a foreign checkpoint merged in with a commit time that would fool a naive newest-at-or-before pick.test/editResubmit.test.tscovers the pure decisions;test/editResubmitWiring.test.tsxasserts the call order and arguments (rewind before start, neither on cancel, attachments preserved). Both regression tests were confirmed to fail without their fixes.Core 38/38, renderer 865/865, electron 1046/1047 — the single failure is the
wireClient × webBridgereconnect suite, which fails identically onmain. An occasionalmemory-servertrust-ranking failure is a pre-existing flake, reproduced on an untouched main checkout; this branch does not touchmemory-server.🤖 Generated with Claude Code