fix(task): capture late-arriving sessionId so TUI subagent entry is clickable (#4252)
The OpenCode TUI renders background subagent session entries using `props.metadata.sessionId` as the navigation target. When the wait-loop in delegate-task and background-task tools exits before the session is assigned, but the session is created moments later (before metadata publish), the published metadata had `sessionId: undefined`, leaving the TUI entry stuck spinning with no clickable target. Add a single late-fallback `manager.getTask(task.id)?.sessionId` check between the wait-loop exit and metadata publish in both paths. This closes the narrow race window that produced the symptom in #4252. Regression test: `late-session-id-capture.test.ts` mocks the exact race (launch returns no sessionId; getTask returns it after the wait loop). Verified: - npm run build: PASS - npm test: exit code 0 (one unrelated pre-existing failure in sisyphus-task > browserProvider propagation re: agent-browser skill)
This commit is contained in:
@@ -94,6 +94,13 @@ export function createBackgroundTask(
|
||||
await delay(WAIT_FOR_SESSION_INTERVAL_MS)
|
||||
}
|
||||
|
||||
// Capture late-arriving sessionId between the wait-loop exit and
|
||||
// metadata publish so the OpenCode TUI subagent entry has a navigable
|
||||
// target (issue #4252).
|
||||
if (!sessionId) {
|
||||
sessionId = manager.getTask(task.id)?.sessionId
|
||||
}
|
||||
|
||||
const bgMeta = {
|
||||
title: args.description,
|
||||
metadata: {
|
||||
|
||||
Reference in New Issue
Block a user