Add session forking capability
This PR adds session forking across CLI, backend API, and desktop UI. Users can now fork a session to create an independent copy and explore different conversation paths.
Forking lets you preserve conversation history while trying different approaches. For example, when debugging an issue, you can fork at a decision point to test different solutions without losing your original thread. Similar to how Claude Code handles session forking.
- Added
POST /sessions/{id}/forkendpoint that usesSessionManager::fork_session()to copy sessions with the same name - Implemented
--forkCLI flag (requires--resume) with support for session ID, name, or path identifiers - Fixed
copy_session()to preserveprovider_nameandmodel_configwhen copying - Created
useForkSessionhook that handles errors, loading states, and passes correct params tocreateChatWindow - Added fork buttons in
SessionListViewandChatInputthat open forked sessions in new windows - Added
test_fork_session()to verify conversation and metadata preservation
Addresses #5865
Just reiterating what @DOsinga said the desktop now has fork session support in chat
@DOsinga @zanesq just simplified the PR based your feedback, what do y'all think now? I named this "fork" since that's what Claude Code calls the equivalent functionality I'm trying to implement, but I think I made it confusing since there's already a "Fork Session" in goose UI. what I want here is really "duplicate" instead of "fork"
| truncate | copy | Result | Use Case |
|---|---|---|---|
false |
true |
Full session copy | Duplicate for parallel work (my use case for this PR) |
true |
false |
Edit in place | Truncate current session (existing Edit in Place UI option) |
true |
true |
Branch at point | Copy + truncate at timestamp (exiting Fork Session UI option) |