Skip to content

fix(antigravity): preserve continuation through slow Windows terminal startup - #21770

Merged
nwparker merged 2 commits into
nwparker/agy-legacy-setupfrom
nwparker/agy-windows-spawn-budget
Sep 21, 2026
Merged

nwparker merged 2 commits into
nwparker/agy-legacy-setupfrom
nwparker/agy-windows-spawn-budget

Conversation

@nwparker

@nwparker nwparker commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1216 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1207
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​278 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​269

ELI5

On Windows, Continue in New Session could open Antigravity with an empty input box and report that the context could not be sent. Orca gave up waiting for the terminal just before Windows finished starting it.

What Changed

Antigravity terminal binding now gets at least its configured composer-readiness budget (60 seconds by default), instead of the ordinary eight seconds. After binding, the existing execution-host composer check still decides whether context may be sent. Other agents keep their eight-second binding limit.

Why

Reproduced twice in the exact branch build on awin. In the instrumented run, Windows registered the new PTY 8,307 ms after the tab appeared; the eight-second timeout had already abandoned delivery. Extending the existing bounded wait covers that observed failure without changing terminal-screen detection or permitting a paste before readiness. A missing PTY still times out and unsubscribes. Default Antigravity binding plus composer waits can now total up to two minutes.

Linked Issue

Refs #17408, #18088. Follow-up to #21657, stacked on #21682.

Visual Proof

Before: actual Windows continuation session opens with an empty composer; the handoff never arrives. The captured notification said “The new Antigravity session started, but its context could not be sent.”

Windows continuation before

After: the rebuilt Windows renderer retained the context even when the PTY took 8,330 ms to bind. The actual dialog delivered the handoff, agy read the disposable checkout, answered that the previous verification was complete, and returned to an idle composer.

Windows continuation after

Testing

  • Regression using the observed 8,307 ms PTY-binding delay fails before the fix and passes afterward.
  • 60 focused tests pass, including no paste before host readiness, no process-only fallback, absent-PTY timeout and unsubscribe, and the unchanged eight-second limit for another agent.
  • Renderer typecheck, changed-code quality, and commit lint/format hooks pass.
  • Rebuilt Windows renderer repeats the actual dialog flow successfully; all 60 focused tests also pass natively on Windows.
  • CI complete.

Review

Only the renderer's bounded wait changes. Existing host ownership, capability checks, pane identity, trust-dialog refusal and verified input delivery remain authoritative. No path, shell, credential, wire, or status-store changes. Folder workspaces use the same tab path. Live Linux/WSL/SSH continuation is not claimed.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Checklist

  • Focused change with user-facing before/after, mechanism, and rationale.
  • Reviewed timeout cleanup and host boundaries.
  • Before/after rendered verification complete.
  • Relevant local tests and typecheck pass; CI covers broader build/platform gates.

@nwparker

Copy link
Copy Markdown
Contributor Author

Independent verification update:

  • Installed agy 1.2.7 returned the exact sentinel AGY_WINDOWS_CONTINUATION_LIVE_OK.
  • Windows continuation regression suite: 6 passed.
  • pnpm tc:web passed.
  • Changed-code quality passed with 0 new findings.
  • CI run 35500472097 passed typecheck, static analysis, all 8 test shards, verify, and both packages.

Scoped verdict: Approve stacked with #21657. The PR’s rendered awin before/after proof covers the observed 8.3-second PTY binding case; WSL/SSH/paired-host continuation remains unverified.

@nwparker

Copy link
Copy Markdown
Contributor Author

Independent verification (2026-09-20):

  • Continuation and Windows-hook focused tests: 7 passed, 3 Windows-specific cases skipped locally on macOS.
  • pnpm tc:web passed.
  • pnpm run check:code-quality:changed origin/main passed with 0 new findings across 166 changed files.
  • Installed agy 1.2.7 authenticated exact sentinel returned AGY_WINDOWS_OK.
  • Full CI 35500472097 is green across all shards, typecheck, analysis, macOS/Windows packages, and verify. The PR includes awin before/after visual evidence for the slow-start case.

Verdict: approve with #21657 in stack order for the observed slow Windows PTY startup. WSL/SSH/paired-host behavior remains unverified. No merge performed.

@nwparker

Copy link
Copy Markdown
Contributor Author

ELI5 / evidence / trade-offs audit

ELI5: If agy takes a while to start, Orca keeps waiting and then continues the same task instead of giving up too early.

Proof: macOS/Windows tests and awin before/after evidence pass; no additional UI artifact was produced for this timing path.

User-facing trade-off: Slow hosts can remain in a waiting state longer before a failure is reported.

This note scopes the claim to the evidence above; it does not claim untested remote, SSH, WSL, or vendor combinations.

* fix(antigravity): publish captured command approvals to Chat

* fix(antigravity): bind native hook screen evidence to runtime terminal

* fix(antigravity): settle cancelled approvals at the idle composer

* fix(antigravity): clear approval while accepted commands run
@nwparker
nwparker marked this pull request as ready for review September 21, 2026 01:04
@nwparker
nwparker merged commit 07226e5 into nwparker/agy-legacy-setup Sep 21, 2026
0 of 3 checks passed

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

Important

The Windows PTY-budget fix is sound and well covered. One real correctness gap in the accompanying approval-screen publisher — a connected PTY that no longer holds its pane can clear or overwrite that pane's live permission prompt — plus a doc/behavior mismatch on the new budget coupling.

Reviewed changes

Reviewed the full 26-file diff: commit b4e4c264e9 (the PR's stated change) and the merged 85f6d81594 (#21776's approval feature).

  • Antigravity PTY-spawn budget — spawnTimeoutMs becomes max(8000, readinessTimeoutMs) for antigravity, so a PTY that binds at ~8.3 s is no longer abandoned; other agents keep 8 s.
  • Command-approval screen classifier — isAntigravityCommandApprovalScreen plus blockedReason: 'agent-approval-prompt' in classifyTerminalScreenReadiness, with four captured Windows agy transcripts.
  • Screen-permission publication — AntigravityScreenPermissionPublisher schedules a screen read per PTY chunk, and AgentHookServer.ingestAntigravityScreenPermission writes/clears the approval into the canonical status store.
  • Host wiring — onTerminalScreenPermission wired in main-process-runtime-service.ts and orcad-entry.ts.

ℹ️ The description covers only one of the two commits in the diff

nwparker/agy-chat-permission (#21776) was merged into this branch, so the head commit and roughly 1,400 of the 1,494 added lines are the command-approval feature — not the renderer wait. The description's "Only the renderer's bounded wait changes" is therefore inaccurate, and a reader coming to the diff cold would not know to expect the new runtime publisher, the dual-host onTerminalScreenPermission wiring, or the {"approval":{…}} interactivePrompt shape now published to the status store. Worth updating the description (or noting the merge) so the reviewed scope matches the diff.

Technical details
# Description vs. reviewed scope

## Affected sites
- `src/main/runtime/antigravity-screen-permission-publisher.ts` — new runtime publisher.
- `src/main/runtime/orca-runtime-visible-snapshot-preview.ts:20-43` — new wiring.
- `src/main/agent-hooks/server/server-ingest-antigravity-screen.ts` — new store writer.
- `src/main/startup/main-process-runtime-service.ts:88`, `src/main/orcad/orcad-entry.ts:236` — new host callbacks.

## Required outcome
- The PR description should account for the merged `#21776` delta, or the branch should be rebased so the diff matches the stated change.

ℹ️ Nitpicks

  • The antigravity case of bounds missing-PTY waits for $agent at $timeoutMs ms (antigravity-continuation-delivery.test.ts:90-112) advances the full 60 s and then only asserts the promise resolved false, so it passes with either an 8 s or a 60 s bound; only the claude case actually pins its bound. The first new test does pin antigravity at 8,307 ms, so coverage is not absent — just this case's name promises more than it checks.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +26 to +32
const terminalHandle = this.getAgentStatusTerminalHandleForPaneKey(pty.paneKey)
const row = this.getAgentProviderSessionRowsForPaneFn?.(pty.paneKey)?.find(
(candidate) =>
candidate.providerSessionOnly !== true && candidate.agentType === 'antigravity'
)
// Native hooks identify the pane; the runtime owns its live terminal binding.
return row && terminalHandle ? { ...row, terminalHandle } : null

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.

baseline resolves the status row and terminal handle from the scheduled PTY's recorded paneKey, but never checks that the scheduled PTY still holds that pane. A connected PTY the graph has since rebound away from its pane (the codebase's own "orphaned" state — see ptyHoldsRecordedSurface) therefore reads the pane's current row while reading its own screen, and the ingest guards cannot tell: baseline.terminalHandle is derived from the pane, so it always equals previous.terminalHandle.

Technical details
# Cross-pane attribution in the Antigravity screen publisher

## Affected sites
- `src/main/runtime/orca-runtime-visible-snapshot-preview.ts:26-32` — `baseline(ptyId)` reads `pty.paneKey` and resolves the pane's current row/handle without confirming `ptyId` still holds that pane.
- `src/main/agent-hooks/server/server-ingest-antigravity-screen.ts:26-27` — the `terminalHandle` mismatch guard compares the pane's current handle on both sides, so it cannot catch a different source PTY.

## Failure
1. Pane `P` is bound to `ptyB`; its screen shows the agy dialog, so the publisher writes `state: 'waiting'` with `interactivePrompt` `{"approval":{"source":"antigravity-screen",…}}`, `observation: O`, `terminalHandle: HB`.
2. `ptyA` is still connected but its recorded `paneKey` is `P` (the graph rebound `P` to `ptyB`; `recordPtySurfaceClaim` never clears the old claim). `ptyA` emits output → `schedule(ptyA)` → `baseline(ptyA)` returns `{ ...row_P, terminalHandle: HB }`, `readScreen(ptyA)` returns ptyA's idle composer, `isCurrent(ptyA, …)` passes.
3. `publish({ baseline, command: null, clearedState: 'done' })` → ingest sees a matching observation, a matching handle and `ownsPrompt === true`, and clears ptyB's still-live prompt to `done`. The mirror case publishes an approval for a dialog ptyB never showed.

## Required outcome
- A screen read from a PTY must only be attributed to a pane that PTY still holds, or the observation must carry the source PTY's own terminal handle so the existing mismatch guard can reject it.

## Suggested approach (optional)
- Gate `baseline` on `ptyHoldsRecordedSurface(pty, this.ptySurfaceTopology())`, or require `this.getPtyRecordForPaneKey(pty.paneKey)?.ptyId === ptyId`, and add a regression for an orphaned connected PTY.

## Open questions for the human
- The only open reachability question is how often an orphaned PTY is simultaneously connected and emitting; the mechanism itself is verified in the current code.

Comment on lines +100 to +104
// Windows Antigravity launches can bind their PTY after the ordinary eight-second budget.
spawnTimeoutMs:
agent === 'antigravity'
? Math.max(PTY_SPAWN_TIMEOUT_MS, readinessTimeoutMs)
: PTY_SPAWN_TIMEOUT_MS,

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.

For antigravity the PTY-spawn budget is now the composer budget, so a launch whose PTY never appears reports failure at 60 s instead of 8 s (the start-timeout toast and markNativeChatLaunchPromptFailed move with it), while the JSDoc at line 63-64 and the new comment at line 39 still say the two budgets are separate and that timeoutMs overrides only the readiness budget.

Technical details
# Antigravity spawn and composer budgets are now coupled

## Affected sites
- `src/renderer/src/lib/agent-paste-draft.ts:100-104` — `spawnTimeoutMs = max(8000, readinessTimeoutMs)` for antigravity.
- `src/renderer/src/lib/agent-paste-draft.ts:39` — comment: "PTY binding and composer readiness have separate budgets (STA-3367)".
- `src/renderer/src/lib/agent-paste-draft.ts:63-64` — JSDoc: "`timeoutMs` overrides the readiness budget only; waiting for the PTY to spawn keeps its own budget."

## Required outcome
- The comment/JSDoc and the code should agree on whether an explicit `timeoutMs` also extends the PTY-spawn wait, and a genuinely failed Antigravity launch should not wait the full composer budget before its failure verdict.

## Open questions for the human
- Is 60 s the intended worst case for a missing PTY, or should the missing-PTY budget stay short (e.g. 8-20 s) while only a late-appearing PTY earns the extended composer budget? The current code cannot distinguish the two, so this is a product call.

nwparker added a commit that referenced this pull request Sep 21, 2026
* feat(agents): deprecate Gemini CLI setup in favor of Antigravity

* fix(i18n): register Gemini deprecation copy

* fix(i18n): refresh runtime catalog after legacy setup labels

* test(agents): expect legacy Gemini label in skill coverage

* fix(antigravity): preserve continuation through slow Windows terminal startup (#21770)

* fix(antigravity): retain handoffs through slow Windows PTY binding

* fix(antigravity): show command approvals in Chat (#21776)

* fix(antigravity): publish captured command approvals to Chat

* fix(antigravity): bind native hook screen evidence to runtime terminal

* fix(antigravity): settle cancelled approvals at the idle composer

* fix(antigravity): clear approval while accepted commands run
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