Repository navigation
Validate ORCA_TERMINAL_HANDLE and remint stale orchestration terminals via pane key - #7514
Conversation
Long-lived shells can retain a stale ORCA_TERMINAL_HANDLE environment variable after the runtime remints a pane handle. This can cause commands to bake obsolete terminal handles into coordinator preambles or tasks. - Check if the environment-provided handle is live via terminal.show before using it in dispatch, task-create, or run operations. - Fall back to resolving the active terminal/implicit sender if the environment handle is stale. - Map raw "no_active_terminal" errors to a helpful user-facing error message suggesting the use of the "--from" flag.
Resolve stale environment-provided terminal handles using the caller's pane key (ORCA_PANE_KEY) via terminal.resolvePane instead of falling back to the active focused terminal. This prevents commands from being dispatched from or credited to the wrong terminal pane if focus has changed. Additionally, handle graph or pane resolution failures gracefully during task creation since creator handles are best-effort lineage metadata.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesThis PR updates orchestration CLI terminal-handle resolution. Coordinator commands now validate Sequence Diagram(s)sequenceDiagram
participant Command
participant resolveOrchestrationTerminalHandle
participant terminal
participant RuntimeClientError
Command->>resolveOrchestrationTerminalHandle: request from handle (validateEnvHandle)
resolveOrchestrationTerminalHandle->>terminal: show(ORCA_TERMINAL_HANDLE)
terminal-->>resolveOrchestrationTerminalHandle: stale/gone error
resolveOrchestrationTerminalHandle->>terminal: resolvePane(orchestration pane)
alt live pane found
terminal-->>resolveOrchestrationTerminalHandle: live coordinator handle
else no active sender
resolveOrchestrationTerminalHandle->>RuntimeClientError: throw no_active_sender_terminal
end
Related issues: None provided. Related PRs: None provided. Suggested labels: cli, orchestration, testing Suggested reviewers: None provided. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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.
🧹 Nitpick comments (1)
src/cli/handlers/orchestration.test.ts (1)
276-431: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting shared helpers for the repeated stale-handle-remint mock chains.
Multiple tests (e.g., Lines 276-313, 368-400, 402-430, 576-602) repeat the same three-call mock chain (
terminal_handle_stale→resolvePanesuccess → downstream RPC) with only the endpoint/result varying, and similarly for the failure paths (Lines 315-335, 337-366, 511-537, 539-561). Extracting small helpers likestubStaleHandleRemint(liveHandle)/stubStaleHandleRemintFailure(errorCode)would reduce duplication and make future changes to the remint contract cheaper to update across the suite.Also applies to: 433-602
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2c0d29db-8a24-43e0-9e0c-77acc16201aa
📒 Files selected for processing (2)
src/cli/handlers/orchestration.test.tssrc/cli/handlers/orchestration.ts
Consolidate repetitive mocking boilerplate for stale terminal handle reminting and failure flows using new helper functions.
|
looking into it |
…s via pane key (stablyai#7514) * Validate ORCA_TERMINAL_HANDLE and fall back to active terminal if stale Long-lived shells can retain a stale ORCA_TERMINAL_HANDLE environment variable after the runtime remints a pane handle. This can cause commands to bake obsolete terminal handles into coordinator preambles or tasks. - Check if the environment-provided handle is live via terminal.show before using it in dispatch, task-create, or run operations. - Fall back to resolving the active terminal/implicit sender if the environment handle is stale. - Map raw "no_active_terminal" errors to a helpful user-facing error message suggesting the use of the "--from" flag. * Remint stale orchestration terminals via pane key instead of focus Resolve stale environment-provided terminal handles using the caller's pane key (ORCA_PANE_KEY) via terminal.resolvePane instead of falling back to the active focused terminal. This prevents commands from being dispatched from or credited to the wrong terminal pane if focus has changed. Additionally, handle graph or pane resolution failures gracefully during task creation since creator handles are best-effort lineage metadata. * refactor orchestration tests to use helper stubs for stale handles Consolidate repetitive mocking boilerplate for stale terminal handle reminting and failure flows using new helper functions.
Summary
This PR improves terminal handle resolution for orchestration commands by validating
ORCA_TERMINAL_HANDLEand falling back to reminting pane-specific terminals usingORCA_PANE_KEYif the environment handle is stale.ORCA_TERMINAL_HANDLEis live before using it as the coordinator or task creator terminal.ORCA_PANE_KEYto preserve user identity and avoid blind fallback.no_active_sender_terminalmessages.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI Review Report
The review checked validation logic for environment handle staleness and active terminal fallback mechanisms. It verified that critical dispatch/run failures properly block, while non-critical metadata queries (like task creator metadata) gracefully fail-safe. Cross-platform compatibility for macOS, Linux, and Windows was reviewed; the resolution relies entirely on standard shell environment variables and platform-agnostic client RPC commands.
Security Audit
Security analysis confirmed that validation functions and terminal handles are handled entirely as typed structured values inside client RPCs without raw string interpolation or shell expansion, avoiding execution or command injection risks.
Notes
No platform-specific risks or follow-up work.