Repository navigation
feat(peers): fork chats on a paired Mac from desktop - #350
Conversation
Adds the forkChat and fork-summary peer operations, gates them on the host's chat-fork-v1 and chat-fork-summary-v1 features, and wires Fork from here, Edit in fork and Fork with summary into the remote chat pane with the lineage row, the summary card and the send hold. A fork whose answer is lost is retried under the same idempotency key, so the host replays it instead of copying again. Edit in fork seeds only the prompt text; files the host staged for it are released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Two recovery paths need fixes before merging: reopening a pane can duplicate an unconfirmed fork, and summary actions on another client can leave this pane's composer blocked.
Reviewed changes: Reviewed the complete desktop paired-Mac fork implementation against the stacked feat/chat-fork-remote base.
- Peer operations: Added validated fork and summary-control requests, conditional/idempotency headers, and protocol response parsing.
- Host controls: Added feature/grant-gated adapter capabilities, lineage/prefill mapping, and session-level fork retry handling.
- Remote UI: Added transcript fork actions, summary confirmation and controls, lineage navigation, text prefill, and summary-based composer holds.
- Coverage: Reviewed the new IPC-to-host integration tests, operation/parser tests, renderer assertions, and CI test registration.
Verification: all 131 remote-chat tests, all 30 peer-operation/protocol tests, and TypeScript checking passed. Separate production-code reproductions confirmed both findings below; the repository worktree remains unchanged.
gpt-6.1-sol | 𝕏
Hermes Review BotConfidence: 5 Engine: SummaryEnables the desktop client to fork chats running on a paired Mac, extending remote peer operations with Confidence Score: 5/5Fully traced and verified end-to-end across protocol request validation, IPC handlers, host adapters, session controls, idempotency ledger state transitions, and React Query cache invalidation against OpenAPI fixtures. 📁 Important Files Changed
FindingsNo findings. Sequence DiagramsequenceDiagram
autonumber
actor User
participant Pane as RemoteChatPane (Renderer)
participant Control as ChatSessionControl
participant Ledger as ChatIntentLedger
participant Adapter as RemoteHostAdapter
participant Manager as PeerHostManager (Main)
participant Host as Paired Mac Host
User->>Pane: Click "Fork from here" / "Edit in fork"
Pane->>Control: fork({ messageId, position, summary? }, revision)
Control->>Ledger: forkKey(ref, signature) / beginFork(ref, intent)
Control->>Adapter: fork(chatId, { messageId, position, revision, idempotencyKey })
Adapter->>Manager: transport.call("forkChat", request)
Manager->>Host: POST /chats/{id}/fork (If-Match, Idempotency-Key)
alt Successful Fork
Host-->>Manager: 201 Created { chat, prefill? }
Manager-->>Adapter: Return parsed fork result
Adapter-->>Control: HostForkedChat
Control->>Ledger: settleFork(ref, idempotencyKey)
Control-->>Pane: HostForkedChat
opt Edit in fork prefill
Pane->>Pane: saveComposerDraftText() & releaseAttachments()
end
Pane->>Pane: onOpenChat(forked.id)
else Lost Acknowledgment (outcome_unknown)
Host--xManager: Network timeout / drop
Manager-->>Adapter: outcome_unknown error
Adapter-->>Control: HostChatControlError (outcome_unknown)
Note over Control,Ledger: Key retained in ledger for identical signature
Control-->>Pane: Re-throw outcome_unknown
Pane->>User: Toast prompt to retry safely
end
[]
|
The Remote contract now calls the summary focus `focus`. The peer bridge sends and validates `summary.focus`, and maps the host's `focus` back to the desktop's `instructions` when it reads fork lineage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
ℹ️ No new issues found in this delta. Approval remains withheld while the existing recovery threads are open.
Reviewed changes: Reviewed the changes since 34a31f8e, including the base-branch merge and the fork-summary wire-name correction.
- Corrected outgoing summary focus: Mapped desktop
instructionsto wirefocusand aligned main-process validation with the host contract. - Restored incoming summary focus: Mapped wire
focusback to desktopinstructionsbefore parsing lineage, preserving the focus across reads and retries. - Aligned integration fixtures: Used the host's typed summary-state conflict and safe cancellation message, and updated request-validation cases for the wire field.
Verification: all 99 focused peer-operation, fork-integration, protocol, and host-chat tests passed; all 131 remote-chat tests passed; npx tsc --noEmit -p . passed. The repository worktree is unchanged.
gpt-6.1-sol | 𝕏
…hanged elsewhere A fork whose answer was lost kept its idempotency key only on the pane's session control, so reopening the chat and retrying minted a new key and the host made a second copy. The key now lives in the window's chat intent ledger, scoped to host and chat, like other unresolved chat mutations. The fork lineage read again only while a pending summary's row moved, and compared the feed's metadata token with the chat's content revision. A failed summary retried or skipped on another device stayed failed here and kept the composer held. The lineage now records the feed revision it was read at and reads again whenever that moves while the summary is pending or failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
A delayed summary-action response can overwrite newer lineage and leave the composer blocked after the summary has finished.
Reviewed changes: Reviewed the recovery changes in 56071b93 against the previously reviewed 55cfb3b6 state.
- Moved fork retry keys into the window-scoped intent ledger so identical retries survive pane/control replacement.
- Added feed-revision tracking to lineage reads and refreshed both pending and failed summaries when their feed row changes.
- Extended behavioral coverage for reopening after a lost fork answer and cross-device summary retry/skip transitions.
Verification: all 132 remote-chat tests, all 99 focused peer-operation/fork/protocol/host-chat tests, and TypeScript checking passed. A separate mounted production-hook reproduction confirmed the late-response race described inline; the repository worktree is unchanged.
gpt-6.1-sol | 𝕏
…ummary A Retry's answer was stamped with the feed revision current when it arrived. If the summary finished and the pane had already read "ready" meanwhile, the late "pending" answer replaced it and kept the composer held with no further read. Summary actions now record the row revision when they start; an answer whose row moved in the meantime triggers a fresh read instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed 56071b93..dd506060, focusing on summary-action response ordering and the previously reported composer-hold race.
- Captured action-start authority: Recorded the feed revision before awaiting a summary action, rather than assigning the latest revision to its response.
- Reconciled late responses: Invalidated and re-read lineage when the feed moved during the action, preserving newer cached summary state.
- Extended mounted behavioral coverage: Checked that a delayed pending response cannot replace a ready summary or restore the send hold, and that an unchanged-row response still applies directly.
Verification: all 133 remote-chat tests, all 99 focused peer-operation/fork/protocol/host-chat tests, and TypeScript checking passed. The repository worktree is unchanged. Hosted CI was still running; macOS Electron E2E was not run in this Linux environment.
gpt-6.1-sol | 𝕏
# Conflicts: # .memory/chat-fork.md

Summary
This lets the desktop fork chats that live on a paired Mac. It follows the chat fork plan (
docs/plans/completed/chat-fork-plan.md, Desktop → Paired Macs) and is stacked on #349, which adds the Remote fork routes.forkChat:POST /chats/{id}/forkwithIf-MatchandIdempotency-Key, and a strictly checked body.retryForkSummary,skipForkSummaryandcancelForkSummaryon/chats/{id}/fork-summary/*.forkandforkSummarycapabilities.forkwhen it advertiseschat-fork-v1and the device haschat:write.forkSummaryalso needschat-fork-summary-v1.ForkSummaryCard, with cancel, retry and skip. A pending or failed summary holds the composer.Known limits
Tests
main/services/peer-remote-chat-fork.test.ts. It runs end to end through the real main IPC,PeerHostManager, the operation builder and parsers, and the host's realAidenRemoteChatService. It covers:peer-operation.test.ts: request shape and body validation for the new operations.remote-chat-view.test.tsx: which actions are offered, that they are disabled during a run, the lineage row with the summary card and send hold, and the error wording.npx tsc --noEmit -p .npm run test:remote-chat(131 pass)npm run test:ci-policyFlaky test
tests/e2e/browser.spec.ts:19, "browser user and automation share a sandboxed page, annotations and isolated profiles". This PR doesn't touch the browser.browser.spec.ts:212, abrowser:commandIPC call rejected with "Browser action timed out." It passed on retry Use catalog-driven runtime model limits #1, so--fail-on-flaky-testsfailed the job.🤖 Generated with Claude Code