Repository navigation
Conversation
opencode run treats any active session under the root as pending work, but only woke on a turn ending in a job session. A child created with parentID (for example by a plugin) kept the run waiting forever after it finished. Wake on a turn ending in any session the run owns.
There was a problem hiding this comment.
This fixes the hang. I ran the #62636 reproduction from source. On the base, opencode run --session <root> was killed by the 45 s timeout while a parentID child was still busy. With this change it exits 0 as soon as the child finishes. The two control cases (child without parentID, and a child that finished first) still exit 0 right away. noninteractive.test.ts passes, and the new test hangs and fails on the base code. tsc -b passes.
The wait loop takes state.ended.promise before it waits or calls background(). So a child that finishes during or after the active() read still wakes it, even though the ownership check is async. ownsSession already maps lookup failures to false, so there is no unhandled rejection. The extra cost is at most one cached session.get per new session that finishes.
Public API unchanged: this is internal to the run command.
Issue for this PR
Closes #62636
Type of change
What does this PR do?
opencode runwaits for child sessions created withparentID, but only woke up when a job's session finished. Now it also wakes up when such a child finishes, so it exits.How did you verify your code works?
Added a test that hangs without the fix and passes with it.
Checklist