Skip to content

Edit and resubmit any past message #254

Closed

Description

@currentbits

Inspired by Zed's editable message history.

Let the user edit any past user message and resubmit from that point: rewind the conversation (and optionally the worktree via checkpoint) to just before that message, then run the edited version. Often a cheaper course correction than checkpoint archaeology.

Activity

  1. added
    enhancementNew feature or request
    and removed on Aug 17, 2026
  2. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/edit-and-resubmit-any-past-message-00986e (not merged).

    How it works. threads.rewind truncates the transcript at a chosen past user message, clears sessionId and sets a one-shot replayContext. A CLI session cannot be rewound, so the next turn starts a fresh session seeded with a digest of the retained tail — reusing the existing hand-off prefix builder with the thread itself as source (never via handoffFrom, which drives crew sweeps and the OTel ancestor walk). Rewind starts no run: the renderer follows with the ordinary runs.start, which appends the edited text. Usage/spend history is never rewritten. restoreFiles additionally hard-resets the worktree.

    UI: an Edit affordance on user bubbles opens an inline editor (Esc cancels, Cmd/Ctrl+Enter submits), then a confirm dialog naming how many messages will be dropped, with an opt-in "also restore files" shown only when the thread has a worktree. Transcript-only stays the one-click path.

    Three checkpoint hazards found and fixed during review:

    1. Checkpoints are numbered by counting checkpoint commits, and a turn that changes nothing creates none — so mapping user-message count to turn N restored the wrong tree. A scan of the live store found this in real threads. Now selected by commit time.
    2. listCheckpoints walked all reachable history, so a thread that merged a worker branch saw that branch's checkpoints (one live thread has 8 checkpoints but max turn 3). An automatic reset could land on the fork's tree and discard the merge. Now --first-parent, fixed at the shared function so the existing restore UI benefits too.
    3. Rewind persisted with the debounced save(); a crash in that window left files rewound and the old transcript resurrected. Now saveNow().

    Also: the detail refetches right after a rewind (a failed follow-up start otherwise left dropped messages on screen), and attachments are carried through the resubmit like Retry turn does.

    Tests: electron/test/rewind.test.js (real git repos, including a skipped clean turn and a merged foreign checkpoint), test/editResubmit.test.ts, test/editResubmitWiring.test.tsx. Core 38/38, renderer 865/865, electron 1046/1047 — the one failure is the web-integration reconnect suite that also fails on main. The occasional memory-server trust-ranking failure is a pre-existing flake, reproduced on an untouched main checkout.

  3. added a commit that references this issue on Aug 17, 2026
  4. added and removed on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions