From d8981c7ba00a722c897d7270b7f421418512a784 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 4 Nov 2026 16:07:30 +0100 Subject: [PATCH] feat(p2): sidebar branch rows behind the session's expand control Branch rows are hidden until the session row's expand control (the subagents' chevron) opens them, above the subagents; the control also appears for a session with two or more branches and no subagents, with the branch count beside the subagent count. Showing a subagent still expands the list; showing any other non-main conversation no longer does (right after a /tree switch the page shows the new branch before the row names it main). --- apps/p2/docs/tree.md | 4 ++- apps/p2/src/web/Drawer.tsx | 42 ++++++++++++++++++++----------- apps/p2/src/web/style.css | 6 +++++ apps/p2/test/p2/ui-drawer.test.ts | 24 ++++++++++++++++++ apps/p2/test/p2/ui-tree.test.ts | 21 +++++++++++++--- 5 files changed, 79 insertions(+), 18 deletions(-) diff --git a/apps/p2/docs/tree.md b/apps/p2/docs/tree.md index df965bfd2..0a557957d 100644 --- a/apps/p2/docs/tree.md +++ b/apps/p2/docs/tree.md @@ -115,7 +115,9 @@ node: - Web: "Edit" beside the owner's view of a user message (on hover; always shown on touch screens) and "Branch from here" under an answer, in the main conversation. Under the session in the sidebar, from two branches on, one row per branch (`Sessions` rows' `branches`: the stored labels, null for the session title, newest first in a stable order, - the current one marked in place); choosing one switches the session to its end (`SessionTree.select`). The worker + the current one marked in place), behind the session row's expand control, which also shows its subagents + (collapsed by default, expanded while a subagent is shown); choosing one switches the session to its end + (`SessionTree.select`). The worker reports `p2.main` (`treeSelf`: `main` and the branches with their labels) at start and whenever a commit changes it. - Search indexes each branch's own entries (after its fork point). diff --git a/apps/p2/src/web/Drawer.tsx b/apps/p2/src/web/Drawer.tsx index d2aba978f..af88549b2 100644 --- a/apps/p2/src/web/Drawer.tsx +++ b/apps/p2/src/web/Drawer.tsx @@ -71,8 +71,8 @@ function ThemeButton() { } /** - * A session's `/tree` branches (docs/tree.md), from two on, newest first in a stable order: switching only moves the - * "current" mark. Choosing another branch switches the session to it (`onBranch`, the owner's); the pencil beside a + * A session's `/tree` branches (docs/tree.md), newest first in a stable order: switching only moves the "current" mark. + * Shown from two branches on, behind the session row's expand control (`hidden` while collapsed). Choosing another branch switches the session to it (`onBranch`, the owner's); the pencil beside a * row renames it (`onRenameBranch`). A branch without a label (conversation 1's default) shows the session title. */ function BranchRows({ @@ -82,6 +82,7 @@ function BranchRows({ onOpen, onBranch, onRenameBranch, + hidden, }: { session: SessionSummary; conversationId: number; @@ -89,10 +90,10 @@ function BranchRows({ onOpen: (id: string, conversationId?: number) => void; onBranch: (id: string, conversationId: number) => void; onRenameBranch?: (id: string, conversationId: number) => void; + hidden: boolean; }) { - if (session.branches.length < 2) return null; return ( -
+ - {onBranch && !archived && ( + {branches && (