From 94b788859490d2ee1aa6ea23169dd84a8eea695e Mon Sep 17 00:00:00 2001 From: guazi04 Date: Wed, 4 Mar 2026 15:55:22 +0800 Subject: [PATCH] fix(tui): fix nested subagent navigation and restore click-to-navigate on tasks Two regressions from #15607 are fixed: 1. Nested subagent navigation: moveFirstChild() used the children() memo which computes siblings of the current session, not its children. Added a separate subagents memo that finds sessions whose parentID matches the current session ID, so session_child_first works at any nesting depth. 2. Click-to-navigate on tasks: Task component was switched from BlockTool to InlineTool which removed the onClick handler. Restored BlockTool with onClick when the task has a sessionId, enabling direct navigation to a specific subagent session. InlineTool is still used as fallback when no sessionId exists. The existing children() memo is preserved unchanged for permissions and questions aggregation which needs sibling-level data. Closes #15972 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .../src/cli/cmd/tui/routes/session/index.tsx | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index e2747ad3b7a0..661ac4d238b9 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -128,6 +128,11 @@ export function Session() { .filter((x) => x.parentID === parentID || x.id === parentID) .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) }) + const subagents = createMemo(() => { + return sync.data.session + .filter((x) => x.parentID === route.sessionID) + .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) + }) const messages = createMemo(() => sync.data.message[route.sessionID] ?? []) const permissions = createMemo(() => { if (session()?.parentID) return [] @@ -316,20 +321,14 @@ export function Session() { const local = useLocal() function moveFirstChild() { - if (children().length === 1) return - const next = children().find((x) => !!x.parentID) - if (next) { - navigate({ - type: "session", - sessionID: next.id, - }) - } + const next = subagents()[0] + if (!next) return + navigate({ type: "session", sessionID: next.id }) } function moveChild(direction: number) { - if (children().length === 1) return - const sessions = children().filter((x) => !!x.parentID) + if (sessions.length === 0) return let next = sessions.findIndex((x) => x.id === session()?.id) + direction if (next >= sessions.length) next = 0 @@ -1990,16 +1989,35 @@ function Task(props: ToolProps) { return content.join("\n") }) + const lines = createMemo(() => content().split("\n")) + const body = createMemo(() => lines().slice(1).join("\n")) + return ( - - {content()} - + + + navigate({ type: "session", sessionID: props.metadata.sessionId! })} + > + + {body()} + + + + + + {content()} + + + ) }