Skip to content

Chat sidebar: nest sessions into a parent→children tree (drag-and-drop) - #305

Open
arsenmuk wants to merge 2 commits into
arsenmuk/archived-sessions-groupfrom
arsenmuk/session-hierarchy
Open

Chat sidebar: nest sessions into a parent→children tree (drag-and-drop)#305
arsenmuk wants to merge 2 commits into
arsenmuk/archived-sessions-groupfrom
arsenmuk/session-hierarchy

Conversation

@arsenmuk

@arsenmuk arsenmuk commented Aug 11, 2026

Copy link
Copy Markdown
Member

Adds a parent→children hierarchy to the chat session sidebar, built on the existing sessions.parent_session_id column (no schema change).

What you can do

  • Drag a session onto another to nest it as a child — the drop-target row highlights while hovering.
  • A parent shows an expand/collapse chevron in place of its icon; children render indented beneath it, to any depth. When collapsed it badges its hidden direct-child count (mirrors the group-header counters).
  • Nesting appears wherever the parent renders, including the pinned Starred group. Archived / System sessions stay only in their own groups.
  • Un-parent two ways: the row's ⋯ menu → "Remove from parent", or drop a nested row onto the "remove from parent" strip that appears while dragging one (native event-bubbling, no position math).
  • Expand state persists in localStorage; the active session's ancestors auto-expand so it's never hidden. Existing forks (which already set parent_session_id) nest automatically.

Server

  • PATCH /api/sessions/{id} now accepts parent_session_id (null clears it → top-level), guarded against self-parent, unknown parent, cycles, and the created fork window so a display drag can never turn a not-yet-started session into a fork.
  • The field already rides in the feed payload, so an unlimited page size renders the full tree; the client only draws what the server returns (an orphan whose parent isn't in the payload falls back to top-level).

Drag-and-drop uses native HTML5 DnD (no new dependency). Tests: tests/test_session_parent_patch.py (set / clear / self / unknown / cycle / fork-window / deep-chain); frontend tsc -b + build clean.

Stacked on #269 (its branch is this PR's base until it merges).

🤖 Generated with Claude Code

Screenshot 2026-08-11 at 15 31 10

arsenmuk and others added 2 commits August 11, 2026 12:03
Reuse the existing sessions.parent_session_id column (v003) as a display
hierarchy: drag one session row onto another to nest it as a child. A parent
shows an expand/collapse chevron in place of its icon and its children render
indented — unbounded depth, the client draws exactly the hierarchy the server
returns. Children nest wherever the parent renders, including the pinned
Starred group. Archived/System stay in their own groups, untouched.

Un-parent via the row menu "Remove from parent" or by dropping a nested row
onto the "remove from parent" strip that appears while dragging one. Expand
state persists in localStorage; the active session's ancestors auto-expand so
it is never hidden inside a collapsed parent.

Backend: PATCH /api/sessions/{id} now accepts parent_session_id (null clears
it), guarded against self-parent, unknown parent, cycles, and the 'created'
fork window so a display drag never turns a not-yet-started session into a
fork. parent_session_id already rides in the feed payload (SELECT *), so an
unlimited page size shows the full tree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror the GroupHeader counter — a collapsed parent row badges its direct-child
count (faint, right of the title), hidden again once expanded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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