Files
oh-my-opencode/src/tools/background-task
bellman 779e2d2f10 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)
2026-05-24 02:04:38 +09:00
..