Skip to content

Add fork-from-message for branching conversations#39

Draft
amknight wants to merge 1 commit into
minghinmatthewlam:mainfrom
amknight:fork-conversation-from-message
Draft

Add fork-from-message for branching conversations#39
amknight wants to merge 1 commit into
minghinmatthewlam:mainfrom
amknight:fork-conversation-from-message

Conversation

@amknight

@amknight amknight commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Adds a Codex-style fork-from-message affordance for branching conversations.

Hovering an assistant response reveals a subtle Fork control just below it. Clicking it opens a dialog to branch the conversation into a new sidebar thread containing history up to and including that response, with an empty composer. The original thread is left untouched.

The dialog offers a worktree choice (same worktree or a new worktree), mirroring the existing new-thread environment toggle and building on the existing tree/branch infrastructure.

Changes

  • session-driver: ForkPosition ("before" | "at" | "after"), ForkSessionOptions/ForkSessionResult, forkSession on the driver interface.
  • pi-sdk-driver: forkSession implementation using the native getBranch + createBranchedSession primitives; "after" positions the branch at the end of the selected turn (empty composer).
  • electron: forkThread IPC wiring (main.ts, preload.ts, app-store.ts, app-store-worktree.ts) — purely additive; no config/userData/provider changes.
  • renderer: fork control on assistant messages (timeline-item.tsx, conversation-timeline.tsx), fork-modal.tsx, App.tsx wiring, icon + styles.
  • tests: tests/core/fork-from-message.spec.ts (real Electron surface); on-demand tests/demo/fork-demo.spec.ts (excluded from default discovery via testIgnore).

Verification

  • pnpm --dir apps/desktop run typecheck — passes (renderer + electron).
  • Core Playwright spec exercises hover → fork → new sidebar session with truncated history + empty composer (isolated temp userData/agent dirs).
  • Manually verified on the real Electron dev surface against real session history.

Notes

  • Fork affordance lives on assistant messages (Codex parity) to avoid dangling user-turn state.
  • A ~15s demo video was recorded locally (videos/fork-from-message-demo.webm); not committed to keep the tree free of binaries — can attach to this PR on request.

Adds a Codex-style fork affordance on assistant messages. Hovering an
assistant response reveals a subtle Fork control below it; clicking opens
a dialog to branch the conversation into a new sidebar thread containing
history up to and including that response, with an empty composer.

The dialog offers a worktree choice (same worktree or a new worktree),
mirroring the new-thread environment toggle and building on the existing
tree/branch infrastructure.

- session-driver: ForkPosition ("before"|"at"|"after"), ForkSessionOptions/Result
- pi-sdk-driver: forkSession using native getBranch + createBranchedSession
- electron: forkThread IPC wiring (additive; no config/userData changes)
- renderer: fork button (timeline), fork-modal, App wiring, styles
- tests: core fork-from-message spec; on-demand demo spec (ignored by default)
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

@amknight is attempting to deploy a commit to the dev Team on Vercel.

A member of the Team first needs to authorize it.

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