feat: /fork slash command — fork session from a point in the timeline #297

Closed
opened 2026-07-12 01:32:28 +02:00 by dries · 0 comments
Owner

Part of OpenCode command parity (transparent-layer goal). OpenCode's TUI has /fork (title "Fork session") which branches the conversation into a new child session, optionally from a chosen message in the timeline (DialogForkFromTimeline).

Approach: proxy the OpenCode SDK — do NOT reimplement

OpenCode's SDK exposes sdk.client.session.fork({ sessionID }) and a variant that forks from a specific message. Proxy it through the OpenCode adapter (internal/platforms/opencode) and route the mutation via sessionsvc, same pattern as #293 (/undo /redo).

Scope

  • Adapter method + sessionsvc mutation that calls session.fork on the live instance.
  • Add fork to BUILTIN_COMMANDS (frontend/src/lib/commands/builtinCommands.ts).
  • Minimal first cut: fork the whole session (fork from HEAD). Follow-up: pick a message in the thread to fork from (parity with DialogForkFromTimeline).
  • Requires a live OpenCode instance; gate/message when not running.
  • On success, navigate to (or offer to open) the new forked session.

Notes

Forked sessions are OpenCode child sessions — confirm how they surface in ocman's session list and whether the existing parent-id resolution (db.GetSessionParentIDs) already handles them.

Part of OpenCode command parity (transparent-layer goal). OpenCode's TUI has `/fork` (title "Fork session") which branches the conversation into a new child session, optionally from a chosen message in the timeline (DialogForkFromTimeline). ## Approach: proxy the OpenCode SDK — do NOT reimplement OpenCode's SDK exposes `sdk.client.session.fork({ sessionID })` and a variant that forks from a specific message. Proxy it through the OpenCode adapter (internal/platforms/opencode) and route the mutation via sessionsvc, same pattern as #293 (/undo /redo). ## Scope - Adapter method + sessionsvc mutation that calls session.fork on the live instance. - Add `fork` to `BUILTIN_COMMANDS` (frontend/src/lib/commands/builtinCommands.ts). - Minimal first cut: fork the whole session (fork from HEAD). Follow-up: pick a message in the thread to fork from (parity with DialogForkFromTimeline). - Requires a **live** OpenCode instance; gate/message when not running. - On success, navigate to (or offer to open) the new forked session. ## Notes Forked sessions are OpenCode child sessions — confirm how they surface in ocman's session list and whether the existing parent-id resolution (db.GetSessionParentIDs) already handles them.
dries closed this issue 2026-07-13 13:05:40 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#297
No description provided.