Skip to content

fix(orchestration): deliver replyable messages to background PTYs - #8057

Open
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:bbingz/fix-replyable-agent-review-routing
Open

fix(orchestration): deliver replyable messages to background PTYs#8057
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:bbingz/fix-replyable-agent-review-routing

Conversation

@bbingz

@bbingz bbingz commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

An orchestration message sent to a background agent silently never arrives in the pane — the decision gate stores the row without push-on-idle injection.

Repro (two lines):

  1. Spawn a background agent (createTerminal / CLI without a renderer leaf) and leave it idle.
  2. Send an orchestration message to its handle → row is stored, but the agent never sees the inject until a manual check.

deliverPendingMessagesForHandle only resolved renderer leaves. Synthetic background-PTY handles (tabId pty:<id>) never mint a leaf, so push-on-idle parked forever. This minimal re-cut:

  • falls through to a live connected idle PTY via getLivePtyForHandle when the leaf path misses
  • pushes on the PTY's working→idle title transition the same way leaves already do
  • keeps coordinator and Cursor Agent no-auto-Enter, delivered-vs-read stamping, and the single-flight map
  • skips the background path when a renderer leaf already owns the same handle (no dual inject)

Old branch docs (docs/reference/2026-07-10-*.md) and the multi-commit stack are dropped; one commit on current main.

Screenshots

No visual change.

Testing

  • Focused pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts filtered to delivery regressions: 12 passed (3 new background cases + existing already-idle / coordinator / Cursor / no-replay / non-Cursor auto-submit)
  • pnpm lint (not re-run in this re-cut session)
  • pnpm typecheck (not re-run)
  • pnpm test (full suite not re-run)
  • pnpm build (not re-run)
  • Added background-PTY already-idle, busy→idle, and Cursor no-auto-submit regressions

AI Review Report

Self-review of the re-cut: compared against main's modern leaf deliverPendingMessages (flight map, settle, Enter delay) rather than the July dual-path refactor. Verified Enter is a real '\r', leaf-first then background fallthrough, and leaf-owns-same-handle skip so adopted PTYs do not double-inject. Cross-platform: delivery is main-process PTY write only — no shortcuts, paths, or shell differences.

Security Audit

No new surface. Continues writing orchestration-formatted payloads into PTYs the runtime already owns; no new IPC, auth, path, or dependency surface. Cursor/coordinator no-auto-Enter paths preserved so injected text is not auto-submitted into user-owned prompts.

Notes

ELI5

Mail to a background agent used to sit in the inbox forever. Now Orca also looks up the background terminal and types the message in when the agent is idle, without double-sending if the pane is already on screen.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds routing guidance and tests that select terminal send, orchestration ask, or orchestration send/reply according to the required return path. Documents timeout, handle, and group-address constraints. Extends runtime pending-message delivery to synthetic background PTYs, including idle-transition delivery, Cursor Agent no-auto-submit behavior, and deduplication when a PTY is adopted by a renderer leaf.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the primary runtime change: delivering replyable orchestration messages to background PTYs.
Description check ✅ Passed The description includes all required sections, explains the change, documents testing status, and includes AI review, security, and platform notes.

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e2227787-aa5e-4d19-a772-5c0fba6f46ae

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9dbba and e65630f.

📒 Files selected for processing (8)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • skills/orca-cli/SKILL.md
  • skills/orchestration/SKILL.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread config/scripts/orca-cli-skill-guidance.test.mjs Outdated
Comment thread config/scripts/orchestration-skill-guidance.test.mjs Outdated
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from a324bc9 to b8c57ce Compare July 10, 2026 10:05

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: be45841f-0f7f-4035-9f2c-cee72a1c0ff0

📥 Commits

Reviewing files that changed from the base of the PR and between a324bc9 and b8c57ce.

📒 Files selected for processing (8)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • skills/orca-cli/SKILL.md
  • skills/orchestration/SKILL.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
✅ Files skipped from review due to trivial changes (3)
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • skills/orchestration/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread skills/orca-cli/SKILL.md Outdated
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 10, 2026 16:47
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch 3 times, most recently from 2147e6b to 3e193a3 Compare July 12, 2026 10:06
@bbingz

bbingz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main. Resolved skill/docs conflicts by keeping main agent-first + full worktree-id guidance (OMP/Pi/Grok, startupTerminal.handle) and PR replyable review routing (orchestration ask/send/reply contract).

@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:39
@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (34c160442f9e77d8162b4c54ecd9b39f0ba6a4f2). Conflicts resolved in: skills/orca-cli/SKILL.md (kept main's discovery stub), src/main/runtime/orca-runtime.ts (preserved background-PTY delivery + in-flight fencing with main lifecycle cleanup). Ported replyable-routing contract into skill-guides/ + regenerated bundled guides. Ready for re-review.

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch 3 times, most recently from cdd9892 to 504a83c Compare July 23, 2026 02:37
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack note

Rebased onto latest main (force-with-lease).

  • Kept background-PTY orchestration delivery path (onPtyExit keep main surfaces + clearOrchestrationDeliveryForPty)
  • Tests: orca-runtime.test.ts 861 passed after rebase

No intentional behavior change vs pre-restack tip beyond resolving main drift.

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from 504a83c to fea5063 Compare July 23, 2026 03:29
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack + review guide (community, awaiting maintainer)

Rebased onto latest main (force-with-lease). 12 commits, behind=0.

What this PR still uniquely does

Main can deliver replyable orchestration messages to renderer leaf handles when the pane is already idle. It does not push to synthetic background PTY handles (pty:…) that have no leaf.

This PR adds:

  • Resolve live background PTY for pending delivery (not only getLiveLeafForHandle)
  • Deliver on working→idle for those PTYs
  • Fence pending attempts / avoid duplicate ask retries after adoption
  • Skill-guide / docs contract for replyable routing via orchestration

Not in scope / already on main

Depends on

Suggested review focus

  • orca-runtime delivery path for synthetic handles (hot file — rebase carefully if main moves)
  • Once-only delivery after PTY adoption
  • Cursor no-auto-submit behavior for replyable asks

Tests (local)

  • orca-runtime.test.ts861 passed after rebase

We cannot merge; ready for upstream review when convenient.

Push-on-idle only resolved renderer leaves, so orchestration mail to
synthetic background-PTY handles stayed parked until a manual check.
Fall through to live connected idle PTYs; keep coordinator/Cursor
no-auto-Enter and delivered-vs-read stamping.
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from f5b7e87 to d91064a Compare August 6, 2026 02:21
@bbingz bbingz changed the title Deliver replyable orchestration messages to background PTYs fix(orchestration): deliver replyable messages to background PTYs Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants