[PR #11340] feat(tui): add Claude Code-style --fork flag to duplicate sessions before continuing (resolves #11137) #13741

Closed
opened 2026-02-16 18:18:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11340

State: closed
Merged: Yes


What does this PR do?

  • Add Claude CodeStyle --fork-session CLI flag for session forking with --continue or --session
  • Simlilar behaviour as Claude Code's --fork-session switch offer familiarity to converts from Claude Code.
  • Forked sessions get the same automatic (fork #N) title suffixes via existing Session.fork() that forking via the /fork command or TUI message modal receive
  • Validates that --fork is correctly paired with either --continue or --session
  • Works with both the interacture TUI and opencode run commands
  • Graceful handling for edge cases (such as no session being available to fork) is included
  • Applies to both attach mode and bootstrap mode

Resolves #11137.

Supported syntax examples:

opencode --continue --fork
Start the TUI, continuing and forking (duplicating) the last session

opencode run --continue --fork "tell me a better joke"
Run one prompt, continuing and forking (duplicating) the last session

opencode run --fork "tell me a better joke"
Same as previous, but using terse syntax for the --continue switch

opencode --fork --session ses_3f2424a04ffeu0ZUiE12HfD2OI
Fork a particular session.

opencode --fork --session ses_that_doesnt_exist
Fails gracefully: OpenCode starts, but displays a Failed to fork session toast.

opencode run --fork --session ses_that_doesnt_exist "I'm not gonna work."
Fails gracefully: an Error: Session not found message is written to STDERR and an exit code of 1 is used.

How did you verify your code works?

Manual testing, bun test, bun typecheck

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11340 **State:** closed **Merged:** Yes --- ### What does this PR do? - Add Claude CodeStyle --fork-session CLI flag for session forking with --continue or --session - Simlilar behaviour as Claude Code's `--fork-session` switch offer familiarity to converts from Claude Code. - Forked sessions get the same automatic (fork #N) title suffixes via existing Session.fork() that forking via the `/fork` command or TUI message modal receive - Validates that `--fork` is correctly paired with either `--continue` or `--session` - Works with both the interacture TUI and `opencode run` commands - Graceful handling for edge cases (such as no session being available to fork) is included - Applies to both attach mode and bootstrap mode Resolves #11137. #### Supported syntax examples: `opencode --continue --fork` Start the TUI, continuing and forking (duplicating) the last session `opencode run --continue --fork "tell me a better joke"` Run one prompt, continuing and forking (duplicating) the last session `opencode run --fork "tell me a better joke"` Same as previous, but using terse syntax for the --continue switch `opencode --fork --session ses_3f2424a04ffeu0ZUiE12HfD2OI` Fork a particular session. `opencode --fork --session ses_that_doesnt_exist` Fails gracefully: OpenCode starts, but displays a `Failed to fork session` toast. `opencode run --fork --session ses_that_doesnt_exist "I'm not gonna work."` Fails gracefully: an `Error: Session not found` message is written to STDERR and an exit code of 1 is used. ### How did you verify your code works? Manual testing, `bun test`, `bun typecheck`
yindo added the pull-request label 2026-02-16 18:18:34 -05:00
yindo closed this issue 2026-02-16 18:18:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13741