Skip to content

Commit 465afa1

Browse files
committed
fix(tui): swallow 404 when auto-syncing referenced subagent session
The Task tool component auto-syncs the referenced subagent session in onMount. The sync calls sdk.client.session.get with throwOnError: true, which throws Session not found if the subagent session has been deleted. Because the call is fire-and-forget (`void sync.session.sync(...)`), the rejection becomes an unhandled rejection on the TUI process, which logs "process error" and exits with code 1. A single orphaned subagent task in the message history is enough to make the parent session unloadable. Swallow the rejection at the call site. Sessions whose subagent rows are gone simply render without the inlined subagent message preview, which is the same behavior as before sync resolves.
1 parent 7703786 commit 465afa1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/routes/session

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,8 +2061,11 @@ function Task(props: ToolProps<typeof TaskTool>) {
20612061
const sync = useSync()
20622062

20632063
onMount(() => {
2064-
if (props.metadata.sessionId && !sync.data.message[props.metadata.sessionId]?.length)
2065-
void sync.session.sync(props.metadata.sessionId)
2064+
const sessionId = props.metadata.sessionId
2065+
if (!sessionId || sync.data.message[sessionId]?.length) return
2066+
// Subagent sessions can be removed (deleted, cleaned up, never persisted),
2067+
// so swallow 404s here; the Task tool still renders without a message preview.
2068+
sync.session.sync(sessionId).catch(() => {})
20662069
})
20672070

20682071
const messages = createMemo(() => sync.data.message[props.metadata.sessionId ?? ""] ?? [])

0 commit comments

Comments
 (0)