Skip to content

Fork a Chat UI chat from any finished response - #38326

Merged
brennanb2025 merged 82 commits into
mainfrom
brennanb2025/native-chat-fork
Nov 6, 2026
Merged

brennanb2025 merged 82 commits into
mainfrom
brennanb2025/native-chat-fork

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In Chat UI there was no way to branch a conversation. Every existing "fork" left Chat UI: "Resume in New Terminal" makes a real fork but always in a terminal, and "Fork Agent Session…" pastes the chat's text into a brand-new agent in a new worktree, so it's a new conversation, not a fork. You couldn't try a different direction from an earlier answer and keep the original chat as it was.

What this changes for users

  • Finished assistant responses in Chat UI get a Fork from this response button (fork icon). On desktop it sits in the response's hover row right after Copy, on the turn's last reply. On the phone, a fork icon sits next to the Copy icon under each response; tapping it does the same.
  • A turn stopped partway through a tool step keeps Copy and Fork on its last text reply. If a collapsed turn ends on an image-only reply, that reply shows Fork without Copy.
  • Clicking it opens a new chat tab right after the source tab. The new chat is the agent's own copy of the conversation through the end of that response's turn, so the agent remembers everything up to that point (tool results included) and nothing after it. It uses the same worktree, agent, model and permission mode.
  • The new chat is named " fork". A Forked from divider sits where the inherited history ends, and clicking the name opens the source chat. Renaming the source updates the divider.
  • The source chat is never changed or stopped. You can fork an earlier response while the agent is still working on a later one.
  • Claude and Codex can fork from any finished response. OpenCode and OMP, when the installed version supports it, offer it only on the latest response. Agents that can't fork natively don't show the button.
  • If a fork fails, one toast names the agent and says what to do; no tab opens. If the host's reply is lost, Orca says the fork may have opened and asks you to check Session History.

How it works

  • Phones read the host's agent list (now allowed for paired phones) to learn which agents can fork; a failed read retries and reads again after a reconnect.
  • Chat create gets a fork source (the source chat and the chosen response). Hosts advertise support with a new create capability, and older hosts never see the field.
  • On the host, the chosen response is resolved to the agent's exact native cut point: Claude forks its own transcript up to the end of that turn (in a worker thread so a large chat can't stall the host), and Codex forks its thread through that turn, with an exact "before the next turn" cut or a copy-then-trim fallback for older imported history. The copy is opened as an ordinary chat through the existing adopt path, so its history is read from the copy itself.
  • The forked chat's record stores which chat and response it came from, plus where its inherited history ends. The divider is derived from that when history is read, so it survives restarts, and a rewind or clear inside the fork keeps it in the right place.

Plan

This change touches saved data (a new record field), the create wire format, and chat adoption. The plan and both independent reviews are in the lane notes; the architecture was settled by an independent decider.

Differences from the common pattern

  • Fork opens as a new tab next to the source instead of replacing the current view. Intended: Orca has tabs, and the source stays one click away.
  • The fork's history is read from the agent's forked transcript instead of copied by Orca. Intended: Orca rebuilds and catches up a chat's history from the agent transcript after restart, so a copied history would duplicate or drift.
  • No /fork command yet. Intended (owner ruling): per-message fork first.
  • Pi doesn't fork yet. Temporary: it needs Pi's own fork support, tracked in Rewind Pi chats with Pi's own fork #37944.
  • Fork's place in the hover row (desktop) and beside Copy (phone) is held even when a response can't fork, instead of the button being left out. Intended (owner ruling: the UI doesn't shift while loading): fork support is learned after the row draws, so dropping the button would slide the other controls. On responses that can't fork, the slot stays empty.
  • On desktop, Fork shows on a turn's last reply, not on every reply in the turn. Intended: Fork lives in the existing hover row, which belongs to the turn's last reply, and a fork copies through the end of the turn either way.
  • On the phone, fork sits beside Copy rather than in the long-press menu. Intended (owner ruling): long-press on the phone is text selection, so the menu never opened.
  • Claude's copy ends at the last saved entry of the selected turn, including tool results. Intended: stopping at the assistant's last message can leave a saved tool result out of the copy.
  • Grok has no fork action yet, including in chats started in Orca. Temporary: Orca can't yet tell from Grok's imported history whether its last response finished, so a fork could copy an unfinished turn. Follow-up, tracked in STA-14003: read Grok's own turn-completion events during import, then turn the action on.

Verification

QA with real Claude and Codex runs on the final head; results are posted in the status comment.

Files Added Deleted Net
Test 39 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4040 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4030
Prod 158 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3963 $\color{#cf222e}{\Huge{\mathbf{−}}}$​474 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3489

brennanb2025 and others added 30 commits November 4, 2026 17:49
Adds the create-time fork source, the host fork capability, the agent fork
level, the forked-from record relationship and the forked-from divider row.
A launch with forkFrom {sessionId, throughItemId} keeps it on the create call,
the saved launch record, reload, retry and its holders, sends no new-chat
options, and is refused before create on a host that does not advertise forks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Finished root responses offer "Fork from this response" where the host and
agent can fork: disabled while support is unknown or a fork is opening, opened
in a new tab right after the source, with one toast naming the agent on
failure. The forked-from row draws as a divider linking to its source.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The sheet offers "Fork from this response" with the desktop's eligibility and
host capability, creates the fork through the phone's chat create, and draws
the forked-from divider with a link to the source chat.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A displayed row can be a tool call or a status projected as a plan while
reading as a response; both clients now check the journal row's own kind.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The phone names its source tab as the create's placement and the host takes
that tab's group; a paired desktop sends the address captured at the click
when the fork has no tab of its own yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…a line

The action on a response the turn continues past hangs from a line of no
height, as the reply controls hang into the gap, so tool-heavy turns keep
their spacing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The options read already says whether the installed agent forks; an observed
no hides the action, an unanswered read keeps it disabled, and yes enables it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The forked-from link now asks the controller's existing opener for the source
by history id, so it follows that opener's host, selection and reveal rules
instead of navigating on its own.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The floated action covered the start of the next row. It now sits beside the
response's last line, in a gutter as tall as the prose, so it adds no line and
never reaches the following row.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
First adoption put every unseen tab at the end of its group, so a fork the host
published after its source landed last. A new tab now follows its nearest host
predecessor when that tab is here; tabs already adopted keep the user's order.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rst frame

The gutter came and went with the fork offer, so prose reflowed when a turn
finished or support resolved. A pane that draws forks now keeps it on all root
responses, and the fork sits only there, not also beside Copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
brennanb2025 and others added 14 commits November 5, 2026 12:31
The divider's separator role and row label hid the source chat button inside it; the rules are now decorative and the text and button read normally.
…hat-fork

# Conflicts:
#	mobile/src/session/MobileSessionActiveContent.tsx
An empty actions group still shifted the time by the icons' edge margin on rows with no copy, fork or rewind.
The fork button sat alone in a right gutter far from the other row actions.
It now joins the response's existing hover controls next to Copy, where those
controls show, and the gutter is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…the Fork slot

A turn whose last prose was followed by tool or thought rows showed no Copy
and no Fork anywhere until it was collapsed. The actions now belong to the
turn's last prose row, decided when the transcript's rows are built, and keep
the gap below it whole so they never cover the next row. Root responses also
keep an empty Fork slot when not offered, so resolving support never moves
the row's other actions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An image-only reply after the turn's text took the response actions but could
not draw them, so the text lost Copy and Fork. Slot construction now picks the
turn's last reply by the same words the row draws and copies.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…text is folded

A collapsed turn that ends in an image hides its earlier text, so no drawn row
could show the response actions and Fork vanished. Each turn's actions now go
to its last drawn response with words, else its last with images. Copy and its
context-menu target appear only where there are words to copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@brennanb2025
brennanb2025 marked this pull request as draft November 6, 2026 06:15
@brennanb2025
brennanb2025 marked this pull request as ready for review November 6, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant