Repository navigation
Conversation
📝 WalkthroughWalkthroughThe OpenCode hook plugin now resolves parent sessions and tracks active child sessions to route busy, idle, and error events. Parent idle transitions are suppressed while child sessions remain active and emitted after children reach terminal states. Synthetic text 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/opencode/hook-service.ts (1)
302-329: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftBlanket early-return for resolved-parent events silently drops
permission.asked/question.askedfrom children, and drops all events (not just idle) on a transient parent-lookup failure.Two related gaps in this gate:
- When
parentSessionIDis truthy (confirmed child), the code returns unconditionally at line 328 before ever reaching thepermission.asked/question.askedhandlers (lines 331-349). If a background subagent needs permission approval or asks the user a question, that request is silently dropped — the user is never notified, so the child (and therefore the parent, viahasActiveChildren) can hang indefinitely waiting on a response that will never be surfaced. This goes beyond the PR's stated intent of ignoring only "child-only lifecycle events and synthetic message parts."- When
getParentSessionIDfails (network/SDK hiccup) for a root session,parentSessionID === undefinedtriggers an early return for that entire event — not just idle/error handling. If this happens to be the session's finalsession.idle, the pane can get stuck "busy" forever, since lookup failures aren't cached and no later event will necessarily re-trigger the transition. Fail-closed makes sense for idle/done transitions specifically (to avoid false completion), but doesn't need to suppressSessionBusy/MessagePart/permission events too.Consider narrowing the early return so it only affects the idle/error/status-transition logic, and let
permission.asked/question.askedbubble through even for child sessions (e.g., tagged with the parent context) instead of being dropped outright.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5e9a5e2e-9666-481e-a64f-f8182202169e
📒 Files selected for processing (3)
src/main/opencode/hook-plugin-message-part-throttle.test.tssrc/main/opencode/hook-service.test.tssrc/main/opencode/hook-service.ts
|
Ready for first review — fixes #9692 (OpenCode background subagent activity keeps parent busy). MERGEABLE on current |
7174dd0 to
ac67f1b
Compare
|
Closing as superseded by current Evidence on
That is the same class of fix this PR landed ( |
|
Superseded by main openCode parentID/child-session tracking (see prior comment). |
Summary
Fixes #9692
Relationship to #11017
#11017 (
54ed8c231, merged 2026-07-28) hardened OpenCode lifecycle status delivery insrc/main/opencode/hook-service.tsand added the lifecycle-delivery, child-attention, fail-open-ownership, and message-part-throttle suites. This branch is rebased on top of it and extends those same suites.Issue #9692 stayed open because that work does not roll a background child's busy or retrying state up to its parent: the parent still reads idle while a subagent is running. This PR adds the missing
activeChildByKeyrollup that keeps the parent busy for the lifetime of any active child, plus thepart.syntheticmessage-part filter that stops a synthetic text part overwriting a real preview.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused verification passed: 33 OpenCode hook/plugin tests, changed-file oxlint/format/max-lines checks, and
pnpm run build:desktop. The full repository test command was not run; the changed behaviour is covered by the focused suites.AI Review Report
An independent AI reviewer returned spec-compliance
PASSand code-qualityAPPROVEDwith no confirmed findings. It traced the complete child busy/retry/idle/error sequence, parent-id bookkeeping, root-idle suppression, synthetic-part filtering, cleanup, and regression coverage.The review explicitly checked cross-platform compatibility for macOS, Linux, and Windows. This change is platform-neutral event bookkeeping and does not alter shortcuts, labels, filesystem paths, shell behaviour, or Electron platform branches.
Security Audit
Reviewed event parsing, session-id ownership, map/set cleanup, and untrusted synthetic-part handling. The change executes no commands, opens no paths, changes no authentication or IPC boundary, adds no dependency, and stores only transient session identifiers in memory.
Notes
The implementation intentionally does not emit child lifecycle events as independent Orca session state. Child activity contributes only to its parent session's busy/idle decision.
ELI5
OpenCode parent sessions looked idle while background subagents were still working. The parent now stays busy until its child sessions finish, so wait/idle automation does not fire early.