feat(opencode): map question.asked to waiting state (#1406)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -80,6 +80,21 @@ describe('OpenCode hook plugin source', () => {
|
||||
expect(source).toContain('cachedEndpointValues = null;')
|
||||
})
|
||||
|
||||
it('forwards question.asked as AskUserQuestion so the pane flips to waiting', () => {
|
||||
// Why: OpenCode exposes two separate plugin events for human-in-the-loop
|
||||
// moments — `permission.asked` (blocks on tool approval) and
|
||||
// `question.asked` (the agent called an ask-the-user tool). The plugin
|
||||
// must forward both so the server-side normalizer can map each to
|
||||
// `waiting` and render the red indicator. Dropping `question.asked`
|
||||
// leaves the pane stuck in `working` while the agent is actually idle,
|
||||
// waiting on a human reply — exactly the bug three other OpenCode
|
||||
// integrations (cmux, t3code, open-vibe-island) all handle.
|
||||
const source = _internals.getOpenCodePluginSource()
|
||||
|
||||
expect(source).toContain('if (event.type === "question.asked")')
|
||||
expect(source).toContain('await post("AskUserQuestion", event.properties || {});')
|
||||
})
|
||||
|
||||
it('guards endpoint-file parse warnings with a process-lifetime latch', () => {
|
||||
// Why: ENOENT is the normal pre-install case and must stay silent, but a
|
||||
// malformed/unreadable file (EACCES, EIO, parse error) would otherwise
|
||||
|
||||
@@ -259,6 +259,18 @@ function getOpenCodePluginSource(): string {
|
||||
' return;',
|
||||
' }',
|
||||
'',
|
||||
' if (event.type === "question.asked") {',
|
||||
' // Why: question.asked fires when OpenCode uses an ask-the-user tool',
|
||||
' // (distinct from permission.asked, which blocks on tool approval).',
|
||||
' // The agent is idle-but-waiting on a human reply, not running, so we',
|
||||
' // must flip the pane to the same red "needs attention" state used for',
|
||||
' // permission requests. Like permission.asked, do not touch lastStatus',
|
||||
' // so the next SessionBusy/SessionIdle after the user answers still',
|
||||
' // fires and restores the normal working/done flow.',
|
||||
' await post("AskUserQuestion", event.properties || {});',
|
||||
' return;',
|
||||
' }',
|
||||
'',
|
||||
' if (event.type === "message.updated") {',
|
||||
' // Why: role is already cached above the isChildSession await so the',
|
||||
' // back-to-back message.part.updated for the same messageID is not',
|
||||
|
||||
Reference in New Issue
Block a user