Repository navigation
Fork a thread from a specific message (#158) - #1565
Conversation
Fork at a message boundary: copy the transcript prefix into the new thread. Claude threads resume a forked CLI session cut at that message (--resume <src> --fork-session --resume-session-at <uuid>); other providers, or messages without a recorded chain uuid, start a fresh session seeded from the copied prefix. A native fork that fails before getting its own session falls back to the seeded path so a retry never resumes the source session. Adds a Fork from here action on assistant messages. Closes #158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbc13a0e16
ℹ️ 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".
| if (assistantMsgId && typeof ev.uuid === "string" && ev.uuid) { | ||
| store.updateMessage(threadId, assistantMsgId, { | ||
| claudeUuid: ev.uuid, | ||
| }); |
There was a problem hiding this comment.
Avoid using an event UUID for split assistant rows
When Claude emits one assistant event containing both text and a tool_use, this stamps the displayed text row with the UUID of the entire event, while ingestToolUse subsequently creates a separate tool row. Forking from that text row copies the transcript only through the text, but native --resume-session-at resumes after the whole underlying event, potentially including an unseen tool request without its later tool_result; the fork's actual context therefore differs from its displayed transcript and may begin with a dangling tool call. Use the seeded fallback for mixed-block events or associate the UUID only with a row representing the end of the complete event.
Useful? React with 👍 / 👎.
| const failedThread = store.getThread(threadId); | ||
| const forkFallback = | ||
| failedThread && failedThread.forkSessionAt | ||
| ? { sessionId: null, forkSessionAt: null, replayContext: true } | ||
| : {}; |
There was a problem hiding this comment.
Clear stale fork markers before handling later failures
If a newly created Claude message fork is switched to Codex or another provider before its first run, setProvider clears the inherited sessionId but leaves forkSessionAt; a successful non-Claude run then records its own session without clearing that marker because only Claude's init handler does so. Any later, unrelated failure satisfies this predicate and discards the valid non-Claude session, forcing a lossy transcript replay on retry. Clear forkSessionAt whenever the native fork is invalidated, or constrain this fallback to a still-armed Claude source session.
Useful? React with 👍 / 👎.
store.test.js pins the full thread shape, so it needs forkSessionAt. threadView.test.tsx is at the 20s per-file cap on Windows CI; the Fork from here tests move to their own file against MessageBlock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # electron/providers.js
Closes #158.
What
handoffFromprovenance chip links back to the source.--resume <src> --fork-session --resume-session-at <uuid>. Verified live on claude 2.1.283: new session id, truncated at the cut, source session untouched, works from another cwd, uuids preserved (fork-of-fork works).replayContext, the same path rewind uses.--resumes the source session. An armed fork also keeps its session id when its worktree materialises.How
uuid(claudeUuid).forkThread({ messageId })validates before creating anything and armsforkSessionAt(one-shot, cleared by the forked session'sinit).Caveats
--resume-session-atis a hidden CLI flag. If a release drops it, the fallback costs one failed turn.Tests
electron/test/fork-handoff.test.js: service cases plus runner cases against a fake claude bin (exact argv, uuid stamp, cut cleared, failure fallback). 22/22 pass.test/threadView.test.tsx: button forks with{ messageId }and is hidden while working.🤖 Generated with Claude Code