From 3a0b61275fc7d97d8e683c485f5c52389a083d7f Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 15 Oct 2026 08:23:43 +0800 Subject: [PATCH] gui: the Sessions page nests subagents under their session and opens each one's conversation; Codex threads nest under their parent_session (#2261, infinitr0us) Only main sessions sit at the top of the Sessions page now. - A session with subagents shows an "N subagents" fold under its row. It starts folded. - Unfolding neither opens the session nor moves the page. - The rows are indented by the depth of the subagent that started them. - Clicking a row opens its conversation in place, via /api/sessions/transcript?sub=. - Codex threads with a parent_session nest under that session, to any depth. - The parent chain is guarded against loops and capped at a depth of 8. - A thread whose parent isn't listed stays at the top. - A folder's count and its select-all include the nested threads. - Searching opens the folds that hold matches. Opening a nested session from elsewhere opens its ancestors' folds. - New strings ("{n} subagent", "{n} subagents") in zh, en, zh-TW, ja and de. - No native select and no left-border accent. The nested list is a bordered card. - docs/subsystems/gateway-sessions.md describes the subagents field, the sub= route and the page. What was run, at this head before the rebase (5618ade1e): - internal/gui/tests/sessions-subagents.test.cjs (new): 40/40 pass in Chromium and WebKit, at widths 1100 and 420, in all 5 languages. - It checks the fold, the indentation and order, that the transcript is called with sub= and read once, and Codex nesting with a loop and a missing parent. - Its tidy check covers: no select, no left border, nothing wider than the page. - Related GUI tests (sessions*, sess*, session*, i18n, routing-session, account-mask, click-scroll): 451/451 pass. - Broken by hand, each restored afterwards: - Without nest(), the Codex test fails. - Without the fold, both tests fail. - Without &sub=, the Claude test fails. - usage-agents-hide and usage-fold fail the same way on origin/main bc470c6b6, with or without this change. They are filed as #2211 and #2163. - The full suite, go test -p 4 -timeout 40m ./... under a temp HOME at 5618ade1e with this change: green (exit 0). - gofmt -l is clean. go vet passes for darwin, linux (-tags nogui) and windows. - Real use: a sandbox magpie (temp HOME, ports 3486/3487) against read-only copies of real sessions. - Claude Code: the 5-subagent fold, and a real nested subagent indented one step whose conversation opened. - Codex: a real exec rollout pair, with the child's session_meta source rewritten to thread_spawn of the parent. Only the parent is at the top, and the child's details and conversation open in place. - Found on the way, and the same on main: a Codex Image Session Helper rollout is listed but can't be opened ("no such session"). Filed as #2273. Rebased onto 69d7ee33a, whose new commits touch none of these files. Rerun at the rebased head: - go test ./internal/sessions ./internal/gui: pass. - sessions-subagents: 40/40. - i18n-keys, sessions-* and claude-cloud-drift: 371/371. - gofmt -l is clean. Not tried: - A real Codex rollout written as a subagent: none on this Mac, so the copied rollout above stands in. - Real OpenCode children and real Kimi sessions. - The GUI on Linux (WebKitGTK) and Windows. --- docs/subsystems/gateway-sessions.md | 46 +++- .../gui/assets/plugins/sessions/client.js | 170 +++++++++++++- internal/gui/assets/plugins/sessions/i18n.js | 8 + .../gui/assets/plugins/sessions/sessions.css | 19 ++ .../gui/tests/sessions-subagents.test.cjs | 216 ++++++++++++++++++ 5 files changed, 445 insertions(+), 14 deletions(-) create mode 100644 internal/gui/tests/sessions-subagents.test.cjs diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.md index 588c7dbf8..a0e309112 100644 --- a/docs/subsystems/gateway-sessions.md +++ b/docs/subsystems/gateway-sessions.md @@ -366,8 +366,8 @@ files gets `Subagent` from the file's name, `/subagents/agent-.json or `/subagents/workflows//agent-.jsonl` (`sessions.SubagentOf`), so no cache version changes, and `ParentAgent` from the `parentAgentId` of the `agent-.meta.json` beside it, which Claude Code -writes for a subagent a subagent started (`sessions.SubagentParent`, read once -a file; a meta file not read is unknown and read again). A gateway row matched +writes for a subagent a subagent started (`sessions.SubagentParent`, through +`ccMeta`: read once a file; a meta file not read is unknown and read again). A gateway row matched to a file row keeps the gateway's own. Both were checked against Claude Code 2.1.296 spawning a subagent from a subagent. @@ -380,6 +380,48 @@ metadata, gateway-only entries and conflicting identities set `role` to `unknown` and do not acquire a guessed parent or root. These fields are omitted for other agents. This is Codex-specific (#1591). +A session whose agent keeps its subagents' conversations beside its own +lists them in `subagents` on the sessions API (`/api/sessions`, `one`, `manage`; #2261, +[`subagents.go`](../../internal/sessions/subagents.go)), only for agents with +a transcript, oldest first. Each has `id`, `title` (the task it was given), +`kind` (the agent it ran as), `parent` (the subagent that started it, empty +for the session) and `start`/`last`; its file is never sent. + +- Claude Code, Qoder and Qoder CN: each `subagents/agent-.jsonl` (and + under `workflows//`), with `agentType`, `description` and + `parentAgentId` from the meta file beside it (`ccMeta`). With no meta file + (Qoder), the title is the file's first user line (`ccTask`, at most 16 + lines read). `agent-acompact-.jsonl` is a compaction's own run and is + left out. +- OpenCode: a child session (`parent_id`, from the JSON store or + `opencode.db`) is a subagent of its root, not a session of its own; + `ocRoots` records its parent. Its title splits 1.x's + ` (@ subagent)`; 2.x titles it the description alone + (task tool, opencode 2.0.25), and a default `Child session -