fix(web): render the chat session tree from parent/sub-session lineage

The sidebar treated every workspace session as a root and only nested the
manifest sub-agents, so sub-session files showed up as siblings (the same child
twice); sub-sessions the plugin marked hidden were listed anyway.

- build the tree from `parentId` in a pure `buildSessionTree` model: orphans are
  promoted to roots, cycles and duplicate ids are guarded, real child-session
  rows win over the manifest projection, and the routed row force-opens its
  ancestors
- honour the plugin's `:PiSessions` visibility (`visible: false`) with a "show
  hidden sub-sessions" toggle, the routed-row exception and a dedicated
  all-hidden empty state
- keep tree metadata across WS snapshots, reducer events, id migration and
  parent removal; prefer a root row for the `/chat` index and add a "back to
  parent" action
- document the session-row and `pi2:subagents` list metadata in the protocol
This commit is contained in:
yuez committed 2026-10-22 16:45:09 +08:00
1 parent 7e780515ac
commit 06e70204e7
15 files changed
+1133 -240

No files matched your search

+16
View File
@@ -138,6 +138,22 @@
.tree-row .badge {
margin-left: var(--space-1);
}
/* Child sessions: indentation only, no vertical guides — muted and smaller. */
.tree-row--sub .t-name {
font-size: 0.8125rem;
font-weight: 500;
}
.tree-row--sub:not(.selected) .t-name {
color: var(--muted-foreground);
}
.tree-row[data-hidden="true"] .t-name {
/* Muted, not illegible: keep body text above the WCAG AA contrast floor. */
opacity: 0.85;
}
.icon-btn.is-on {
background: var(--accent);
color: var(--foreground);
}
.tree-toggle {
align-items: center;
width: 1.1rem;