Skip to content

fix(agent-status): keep a finished turn done when the agent reports an approval at idle - #32015

Merged
AmoabaKelvin merged 6 commits into
mainfrom
keep-settled-turn-done-over-osc7501-block
Oct 22, 2026
Merged

AmoabaKelvin merged 6 commits into
mainfrom
keep-settled-turn-done-over-osc7501-block

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132 $\color{#cf222e}{\Huge{\mathbf{−}}}$​33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​99
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 $\color{#cf222e}{\Huge{\mathbf{−}}}$​38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53

ELI5

When an Antigravity turn writes a file, agy finishes and goes back to its idle prompt, but then tells the terminal "approve plan" for its review footer. Orca believed it. The finished row showed "Needs approval", and two minutes later turned into "Waiting for input - Approve plan". Now a finished turn stays finished, and real approval prompts still show.

What Changed

Before: after agy's Stop hook marked the row done, agy's OSC 7501 report blocked:kind=permission:msg=Approve plan arrived about 200ms later.

  • The report's facet put an orange "Needs approval: Approve plan" on the done row at once.
  • After 120s with no hooks, the hook-silence recheck replaced done with waiting "Approve plan", which turned the card, the dot and the tab orange.

After: the row stays done with no attention, however long the session sits idle.

Mechanism:

  • Precedence (hook-precedence.ts): programStatusHookYieldEndsAt now returns when an OSC 7501 projection stops yielding to the hook row, instead of a yes/no answer evaluated twice. After a hook-settled done, hook silence is normal, so an approval or question from the program yields for good. It wins only once the program has reported new work since the Stop (a turn the hooks missed). In that case it takes the row at once.
  • New-work evidence (facet-store.ts, noteState): records when the program last entered working. It reads the lifecycle reports in byte order, not the chunk's net facet, so a working followed by a block in one chunk still counts. A record removal counts as a turn boundary.
  • Presentation (presentation.ts, shared by the sidebar, dashboard and orca worktree ps): an approval or question facet only raises attention on a running row. Sign-in and unnamed blocks still show on a finished row, as before. The dashboard's own blocked-row line now applies only to blocked rows.

Why

The facts were combined in the wrong place. The hook-silence rule assumed silent hooks are stale, but after a Stop they are silent by design. The fix sits in the precedence rule every OSC 7501 agent goes through (Claude Code, Codex, Grok, pi, omp, agy), with no Antigravity string match.

I considered setting AGY_CLI_OSC7501=off in Antigravity panes and decided against it. The protocol design keeps OSC 7501 alongside hooks on purpose, as a facet for sign-in, progress and messages, and as the fallback when hooks are off or missing on an SSH host. Turning it off for one agent would lose that, and the next OSC 7501 agent with a post-turn block would hit the same bug.

Linked Issue

Fixes #31548
Fixes #31547

Linear: STA-11569

Visual Proof

Hidden dev builds of main and this branch, side by side. In a terminal pane, a script replays agy's wire using the pane's own hook env: PreInvocation hook, OSC 7501 working, Stop hook, then 200ms later the exact OSC 7501 bytes from the issue. Each build is captured right after the sequence and again about 2m10s later.

Right after the turn After 2m10s idle
Before (main) before-t0 before-t2m10
After (this PR) after-t0 after-t2m10

Testing

  • I manually tested these changes locally (macOS, hidden dev builds, replayed agy wire as above; agy itself isn't installed here)
  • Automated tests added/updated

Regression tests in server-program-status-hook-yield.test.ts go through the real AgentHookServer. Each one fails without its part of the fix:

The precedence unit suite moved to the new return value. A dashboard test pins that a done row shows no approval line.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: plain TypeScript rules; no platform branches.
  • SSH / remote / orcad / orca serve: all hosts run the same AgentHookServer ingest, so the fix applies wherever OSC 7501 is projected.
  • Mobile: mobile reads row state only. It no longer sees the false waiting.
  • Compatibility: no wire or persisted-state change. An older client against a newer host gets the correct row state. A newer client against an older host gets the attention fix, but the host still flips the row after 120s.
  • Performance: one map lookup per OSC 7501 report, and the done-row case no longer arms a 2-minute timer.

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)

@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 22, 2026 21:33
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5096a118-b7d7-4272-bc14-5fd3a94209de
📥 Commits

Reviewing files that changed from the base of the PR and between d053ff9 and 41f1caa.

📒 Files selected for processing: 11
  • src/main/agent-hooks/README.md
  • src/main/agent-hooks/server-program-status-hook-yield.test.ts
  • src/main/agent-hooks/server/program-status/facet-store.ts
  • src/main/agent-hooks/server/program-status/hook-precedence.test.ts
  • src/main/agent-hooks/server/program-status/hook-precedence.ts
  • src/main/agent-hooks/server/server-ingest-terminal.ts
  • src/renderer/src/components/dashboard/DashboardAgentRow.test.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/shared/program-status/agent-status-projector.ts
  • src/shared/program-status/presentation.ts
  • src/shared/program-status/protocol.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Program status presentation now distinguishes turn-scoped permission and question facets. Hook precedence now uses a yield end time and recorded program working time. Terminal ingestion records program lifecycle state and schedules rechecks for finite yields. Tests cover settled turns, missed hook events, new program work, and attention presentation. Dashboard rows can show blocked-status attention when a tool preview is present.

Fixed issue severity: <fixed_issue_severity>Medium</fixed_issue_severity>

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 41f1c

No actionable merge-blocking issue was identified; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 10 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description is complete and directly addresses the required sections. It explains the user impact, implementation, rationale, linked issues, visual proof, testing, compatibility considerations, an…
Title check Passed The title clearly and concisely describes the primary change: keeping a finished turn in the done state when the agent reports an approval while idle.
Linked Issues check Passed The changes meet the coding requirements of [#31547] and [#31548]. programStatusHookYieldEndsAt keeps a hook-settled done row from yielding to a post-turn waiting approval or question unless the…
Out of Scope Changes check Passed The changes stay within the linked issue scope. The hook precedence, facet lifecycle tracking, shared presentation rule, protocol classification, dashboard behavior, documentation, and tests all suppo…
Full details: Description check

Explanation

The description is complete and directly addresses the required sections. It explains the user impact, implementation, rationale, linked issues, visual proof, testing, compatibility considerations, and checklist status. The build and validation commands remain unchecked, but the description states that CI may cover them, which is acceptable for a mostly complete description.

Full details: Linked Issues check

Explanation

The changes meet the coding requirements of [#31547] and [#31548]. programStatusHookYieldEndsAt keeps a hook-settled done row from yielding to a post-turn waiting approval or question unless the program entered working after the hook. AgentHookServerIngestTerminal records program lifecycle state before removal handling and applies the yield deadline. resolveProgramStatusPresentation suppresses turn-scoped approval and question attention on done rows while preserving attention during working and for non-turn-scoped blocks. The added regression and dashboard tests cover the idle replay, genuine prompts, missed-hook work, removal boundaries, and the finished-row presentation.

Full details: Out of Scope Changes check

Explanation

The changes stay within the linked issue scope. The hook precedence, facet lifecycle tracking, shared presentation rule, protocol classification, dashboard behavior, documentation, and tests all support correct handling of OSC 7501 blocks after a turn completes. No unrelated production behavior or unrelated tests are identified in the reviewed changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 10 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@AmoabaKelvin
AmoabaKelvin merged commit 1ac2c6a into main Oct 22, 2026
76 of 77 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the keep-settled-turn-done-over-osc7501-block branch October 22, 2026 22:58
@totally-tim

Copy link
Copy Markdown

Thanks for fixing my issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants