Skip to content

feat: fork session (Ctrl+Shift+K) - #34

Merged
mmxgn merged 2 commits into
mainfrom
feat/fork-session
Aug 11, 2026
Merged

feat: fork session (Ctrl+Shift+K)#34
mmxgn merged 2 commits into
mainfrom
feat/fork-session

Conversation

@mmxgn

@mmxgn mmxgn commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the "Show Diff" row button with a Fork button
  • Clicking Fork (or pressing Ctrl+Shift+K) sends /fork to the current Claude terminal, then watches ~/.claude/projects/<encoded-cwd>/ via GFileMonitor for the new .jsonl that Claude creates
  • Once detected, spawns claude --resume <uuid> as a child session with its own VTE, stack entry, and selectable sidebar row — indented under the parent
  • Fork sessions are saved to sessions.txt with a 4th pipe field (fork_parent_dir) and restored on startup via a two-pass load
  • Clicking a recent directory from the session picker also restores any saved forks for that directory
  • app.show-diff (Ctrl+Shift+D) remains accessible; shortcut bar updated from ^⇧D Diff^⇧K Fork

Closes #10

Test plan

  • Build: nix build succeeds
  • Fork flow: open a Claude session → hover row → click Fork → second indented agent row appears within ~5s
  • Keyboard shortcut: Ctrl+Shift+K on selected session triggers fork
  • Persistence: restart gattn → parent and fork both restore
  • Recents: open from recents → parent and fork both launch
  • Diff still works: Ctrl+Shift+D opens the diff view

mmxgn added 2 commits August 11, 2026 21:45
… restore forks

- Replace the 'Show Diff' row button with a Fork button (^⇧K / Ctrl+Shift+K)
- Fork button sends /fork to the Claude terminal; GFileMonitor on
  ~/.claude/projects/<encoded-cwd>/ detects the new .jsonl and spawns
  claude --resume <uuid> as a child session with its own VTE
- Fork sessions are indented under their parent in the sidebar,
  selectable, and have their own terminal/stack entry (unlike robots)
- sessions.txt gains a 4th pipe field (fork_parent_dir) so forks survive
  restart; two-pass startup restores parent→fork hierarchy
- Clicking a recent directory also restores any saved forks for that dir
- app.show-diff (Ctrl+Shift+D) remains accessible; not shown in shortcut bar
Replace GFileMonitor/polling detection with direct lookup: find the
most-recently-modified .jsonl in the parent's claude projects dir and
spawn `claude --resume <uuid>`, giving the fork the full conversation
history. Drop the dead on_diff_btn_clicked handler from sidebar.c.
@mmxgn
mmxgn merged commit e5c008e into main Aug 11, 2026
4 of 6 checks passed
@mmxgn
mmxgn deleted the feat/fork-session branch August 11, 2026 20:23
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.

feat: add icon for when Claude is compacting discussion

1 participant