Skip to content

feat(sessions): add side chats in the session's side panel - #251

Merged
GoDiao merged 1 commit into
mainfrom
feat/side-chat
Nov 14, 2026
Merged

GoDiao merged 1 commit into
mainfrom
feat/side-chat

Conversation

@GoDiao

@GoDiao GoDiao commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What this does

Adds side chats: ask about something without interrupting a session. A side chat is a full session forked from the session's latest message, in the same working folder, with the same tools. It opens as a tab in the session's side panel, is named btw: <first message>, and can be renamed, detached into a regular forked session, or closed (which deletes it). Deleting a session deletes its side chats. The design is in docs/features/side-chat/tech-design.md.

70 files, +3135 / −1101, no dependency or lockfile change.

Server

  • Parent kind side. POST /api/sessions/:id/branch takes kind: 'side' without a target message; the fork gets a side chat note, and open tool calls are answered with it.
  • One function per operation in sessionLinksService: forkSession (branch route, StartSession fork and side chats), removeSessions (single delete, batch delete, discardSession) and detachSideChat; sessionService.setSessionParent rewrites every session-meta that carries a parent.
  • Deletes stop each CLI process before removing its file and report side chats that could not be removed in a separate sideChatFailures field. Detach refuses a running side chat (409). Starts are blocked while a session is being deleted or detached (SESSION_DELETED, SESSION_DETACHING).
  • GET /api/sessions/:id/side-chats, PATCH /api/sessions/:id {detach: true}. The session list, search and board pickers leave side chats out; ListSessions shows a session its own side chats so it can message them.
  • The btw: … title is set from the first user message, once, and never over a name the user gave.

Desktop

  • SessionConversation is extracted from ActiveSession and shared by the main view and side chat tabs. Chat components now take an explicit sessionId; the "fall back to the active tab" paths are gone.
  • CLI tasks are stored per session.
  • Side chat tabs: every side chat connects (titles and run state), only the visible one prewarms. Pages, browser and file tabs a side chat opens go to the parent's panel and keep the side chat as their owner, without taking the active tab. Cmd+. stops the conversation that has the focus.
  • RenameSessionDialog is shared by the session header menu and the side chat tab menu.

Fixes found on the way (both in the CHANGELOG)

  • Discarding a fork that failed to start removed the parent's worktree, because the fork copies the parent's repository record. Worktree records now carry worktreeOwnerSessionId, and only the creating session removes the worktree.
  • Repository sessions (chosen branch or new worktree) were never prewarmed again after their first start, nor were their forks. Only a new one whose branch or worktree is not set up yet skips prewarm now.

Decisions worth reviewing

  • The session list slices a page, then drops side chats. Filtering first would read the relation of every file on each call. A page can therefore come back short; total stays the file count, and the paging callers loop on it.
  • Side chat → parent is derived from open side chat tabs, not from the desktop session list, which holds the newest 100 sessions and never contains side chats. Each client reconciles its tabs with the server when the parent's panel opens.
  • Two clients: if one detaches a side chat while another still shows its tab, closing it there deletes the now-regular session. Accepted for now; the fix needs a guarded delete variant.

Tests

Every behaviour change has a test that was run against the code with the change reverted and failed, then passed with it restored. Coverage is listed in the design doc's Tests section.

Gates from .github/workflows/ci.yml, run locally on macOS with Bun 1.4.2:

  • bun test: 2639 pass, 11 fail. The same 11 fail on main on this machine (slash-command merging, ripgrep resolution, and the tests that load Claude Code agents and skills from the local environment).
  • cd desktop && bun run lint: pass.
  • cd desktop && bun run test -- --run: 227 files, 2827 pass, 4 skipped.
  • bun test --randomize --seed=1 on the touched server test files: pass apart from the same two slash-command tests.

A side chat is a full session forked from the parent's latest message,
in the same working folder. It opens as a tab in the parent's workspace
panel, is named `btw: <first message>`, and can be renamed, detached
into a regular forked session, or closed (which deletes it). Deleting a
session deletes its side chats.

Server:
- parent kind `side`; the branch route takes `kind: 'side'` without a
  target message, adds a side chat note and answers open tool calls.
- `forkSession`, `removeSessions` and `setSessionParent` hold the fork,
  delete and relation-rewrite logic. Deletes report side chats that
  could not be removed separately (`sideChatFailures`).
- `GET /api/sessions/:id/side-chats` and `PATCH {detach: true}`. Detach
  refuses a running side chat and blocks CLI starts while the relation
  is rewritten (`SESSION_DETACHING`).
- side chats stay out of the session list, search and `ListSessions`,
  except a session's own side chats in `ListSessions`.
- discarding a fork no longer removes the parent's worktree: only the
  session that created a worktree (`worktreeOwnerSessionId`) removes it.
- repository sessions that already have messages are prewarmed again.

Desktop:
- `SessionConversation` is the conversation view shared by the main
  session and side chat tabs; chat components take an explicit
  `sessionId` instead of the active tab.
- CLI tasks are kept per session.
- side chat tabs: all connect, only the visible one prewarms; pages,
  browser and file tabs a side chat opens go to the parent panel without
  taking the active tab; Cmd+. stops the focused conversation.
- `RenameSessionDialog` is shared by the session header menu and the
  side chat tab menu.
@GoDiao
GoDiao merged commit ee90358 into main Nov 14, 2026
4 checks passed
@GoDiao
GoDiao deleted the feat/side-chat branch November 14, 2026 17:11
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