feat(chat): fork-on-send — switch harness mid-conversation via linked sessions

Closed
SA
2mo ago
+522-13

Implements protocol §7 forkSession end to end, per the design ratified in plans/chat-harness-adapters.md §4b.

Runtime: forkSession creates a new session inheriting scope/cwd with forkedFromSessionId lineage (additive 0001 migration); the source journal projects to markdown (projectTranscriptForHandoff, tail-truncating at 30k chars) and rides as a <prior_conversation> preamble on the fork's first prompt only — composed above the adapters, which stay ignorant. Router resolves cwd from the source session's scope. 138 runtime tests green.

Pane: the harness chip is now a live picker — selecting the other harness arms the composer with a visible hint ("next message continues in codex — a new linked session seeded with this transcript"); send forks, routes the prompt through the existing first-prompt handoff, and follows to the new session. SessionPicker shows "forked from " lineage and moves + New session to the top; ⌘⇧T opens chat-v3 when the chat-v3 flag is on. 124 desktop v2-workspace tests green.

Honest-handoff semantics per design: the fork seeds the account of the conversation (rendered transcript), never the source model's working memory — no harness can read another's native store. Same primitive later powers edit-a-message and regenerate.

Known nit: on fork-send the source session's composer draft isn't cleared (you navigate away; the draft remains under the old session's key). IOU-ledger item.

https://claude.ai/code/session_01XRFCEPsfmJHu2SenDKYJ2h


Summary by cubic

Enable fork-on-send: switch harness mid-chat by forking a linked session that inherits scope/cwd and seeds only the next message with a tail‑truncated transcript. Updates the Chat V3 UI to pick a harness, show a hint, and auto-follow to the new session.

  • New Features

    • Runtime: adds forkSession to create a new session with forkedFromSessionId; projects the source transcript to markdown (30k char tail) and injects it as a <prior_conversation> preamble on the first prompt only; router resolves cwd from the source session; adapters stay unchanged.
    • Desktop: harness chip becomes a picker that arms the composer and shows a “continues in …” hint; Send forks, routes the prompt via the existing first-prompt handoff, and navigates to the fork; SessionPicker shows lineage (“forked from …”); ⌘⇧T opens Chat V3 when FEATURE_FLAGS.CHAT_V3 is on.
  • Migration

    • Add forked_from_session_id to chat_sessions_local (run DB migration 0001).

Summary by CodeRabbit

  • New Features
    • Fork an active chat into a new session while selecting a different harness.
    • Carry relevant conversation context into forked sessions and continue with a new prompt.
    • View which session a fork originated from in the session picker.
    • Choose the target harness directly from the session header.
    • The new-chat shortcut opens the updated chat experience when enabled.