Skip to content

Bind worker dispatch authority to the live pane - #21836

Closed
AtejiMan wants to merge 1 commit into
stablyai:mainfrom
AtejiMan:AtejiMan/my219-authoritative-pane
Closed

AtejiMan wants to merge 1 commit into
stablyai:mainfrom
AtejiMan:AtejiMan/my219-authoritative-pane

Conversation

@AtejiMan

Copy link
Copy Markdown
Contributor

ELI5

A supervised worker can receive its task in one pane while Orca accidentally authorizes a different pane remembered by the same terminal process. This change makes the pane that receives the task the pane that can report progress and completion.

What Changed

For leaf-backed terminal handles, dispatch authority now uses the handle's live leaf pane instead of the PTY's retained pane binding. Runtime-owned PTY handles keep their existing behavior. A regression test recreates a live worker leaf with a stale sibling PTY binding and verifies the Task/Dispatch capability against the same terminal handle, pane, and process identity.

Why

The task preamble is delivered through the exact terminal handle, and lifecycle commands derive their caller pane from that handle. Binding the capability from the same live leaf closes the mismatch without changing prompt timing or the OpenCode boot-splash handling in #20451.

Linked Issue

Addresses the wrong-pane worker lifecycle failure in #17741. The separate OpenCode boot-splash race remains covered by #20451.

Visual Proof

N/A — this changes orchestration identity binding and has no visible UI.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • ORCA_BACKGROUND_LAUNCH=1 vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime-orchestration-dispatch-authority.test.ts src/main/runtime/rpc/methods/orchestration/messaging/send.test.ts src/main/runtime/rpc/methods/orchestration/worker/worker-start-terminal-target.test.ts src/main/runtime/rpc/methods/orchestration/worker/worker-start-prompt-contract.test.ts — 54 passed
  • node config/scripts/check-changed-code-quality.mjs — passed
  • tsc --noEmit -p config/tsconfig.node.json — blocked by eight unrelated unresolved ambient build constants in telemetry/diagnostics; no changed-file type errors were reported
  • Tested on Windows; the change is path- and platform-neutral and preserves the SSH/runtime-owned handle branch.

AI Disclosure

Implemented with OpenAI Codex (GPT-5).

Review

Please focus on the leaf-backed versus runtime-owned handle branch in getOrchestrationDispatchAuthority and the stale PTY-pane regression fixture.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The fix adds no wire fields, storage schema, platform-specific behavior, or renderer changes. Capability verification remains fail-closed when the live leaf or pane cannot be resolved.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9a011342-7342-4b50-a87b-b0238275a027

📥 Commits

Reviewing files that changed from the base of the PR and between 68b1128 and bd0da60.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime-get-orchestration-dispatch-authority.ts
  • src/main/runtime/orca-runtime-orchestration-dispatch-authority.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

getOrchestrationDispatchAuthority now resolves the pane key from the live PTY or live terminal handle. The returned authority uses this resolved key. A new Vitest test verifies behavior when PTY metadata is stale and confirms dispatch capability validation with the live pane key and current process incarnation.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: binding worker dispatch authority to the live pane.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, identifies the linked issue, documents the lack of visual changes, lists automated testing, and records the unrelated T…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Leaf-backed dispatch authority now follows the live pane — In getOrchestrationDispatchAuthority, runtime-owned pty: handles keep their retained PTY binding, while a leaf-backed handle takes paneKey from getPaneKeyForTerminalHandle(handle) (the live leaf) instead of the PTY record's retained paneKey. That aligns the authority with the caller identity already returned by getTerminalPaneKey / getLiveTerminalPaneKey, closing the mismatch in #17741 where the worker sent from its real pane but the capability was bound to a stale one.
  • Regression test recreates the stale-sibling binding — A live leaf handle is issued, then the PTY record's tabId/paneKey are repointed at a stale sibling pane; the test asserts the resolved authority paneKey is the live pane and completes an end-to-end prepareStartingWorkerAuthority → verifyDispatchCapability round-trip.

I confirmed the test is load-bearing: reverting the production hunk to the previous pty.paneKey resolution makes it fail with the stale 3333…:4444… key, so it genuinely pins the fix rather than passing vacuously. The structured-worker branch, fail-closed behavior, and the runtime-owned handle path are all untouched, and the change is platform-neutral (SSH/WSL host scope still comes from the PTY record).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@AtejiMan AtejiMan closed this by deleting the head repository Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant