Skip to content

fix(orchestration): line-settle delay for antigravity multiline paste - #21665

Merged
nwparker merged 3 commits into
stablyai:mainfrom
ContextualWisdomLab:fix/cursor-worker-start-paste-submit-retry
Sep 21, 2026
Merged

nwparker merged 3 commits into
stablyai:mainfrom
ContextualWisdomLab:fix/cursor-worker-start-paste-submit-retry

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Antigravity CLI가 긴 붙여넣기를 받을 때 화면에 줄이 천천히 펼쳐집니다. Orca는 바이트 전송이 끝나자마자 Enter를 보내서, 입력창이 아직 다 그려지기 전에 제출을 시도할 수 있었습니다. 이 PR은 줄 수에 비례해 Enter를 늦춥니다.

What Changed

Before: 101줄 paste(agy 1.2.4)에서 Orca는 ~500ms 후 Enter를 보냄. TUI는 ↑ N more lines 접힌 뒤 수 초에 걸쳐 줄을 펼침. input_accepted는 즉시 반환되지만 화면은 계속 늘어남.

After: submitLineSettleMsPerLine: 45로 줄 수만큼 Enter 전 대기 시간을 추가. resolveAgentPromptSubmitDelayForAgent()가 agent prompt 경로와 plain terminal send --enter 모두에 적용.

Mechanism: getAgentPromptSubmitDelayMs()에 line-settle 항 추가, promptForSchedule로 main-process writer에 전달.

Out of scope (deferred): cursor worker-start Enter retry — live 재현·검증 전 보류 (review 5255806892).

Why

증거(slow-input-observation.json, long-send.json): 전송은 정상(4685B accepted), 병목은 AGY TUI의 다줄 확장. byte-ingest만으로는 부족.

Linked Issue

Fixes # (follow-up issue TBD — coordinator dispatch)

Visual Proof

N/A — PTY submit timing only; no UI chrome change.

Testing

  • pnpm test src/main/runtime/agent-prompt-line-settle.test.ts
  • pnpm test src/shared/agent-prompt-injection.test.ts
  • pnpm test src/main/runtime/agent-prompt-submission-runtime.test.ts
  • Manual: agy 1.2.x 101-line send without rescue Enter (macOS, live Orca not replaced)

Platform: macOS (deterministic tests); manual probe target macOS.

AI Disclosure

Cursor agent assisted implementation; human-reviewed per review 5255806892.

Review

Agent skill upstream boundary

  • Not applicable — no skill-installer or registry changes.

Notes

  • Reverted accidental pnpm-lock.yaml churn from branch.
  • Removed unverified cursor/antigravity submitRetryDelayMs from main-process path per review.
  • New tests in agent-prompt-line-settle.test.ts (keeps 900+ line submission suite from growing).
  • Live installed Orca 1.4.204 not modified.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A visual proof with reason
  • Self-reviewed for correctness
  • Cross-platform: line-settle applies to all platforms; byte ingest path unchanged for non-configured agents
  • pnpm lint / full CI — partial local unit tests only

Worker-start dispatches through bracketed paste in the main process; cursor-agent
can leave long prompts as "Pasted text +N lines" and swallow the first Enter.
Apply the same submitRetryDelayMs path Codex uses in the renderer, but only for
agents without the Claude/Codex render gate so hook turn-start reservation stays intact.

Co-authored-by: Cursor <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 19, 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: 272d55f3-9f14-4ca1-8a4c-b51bd4310737

📥 Commits

Reviewing files that changed from the base of the PR and between b9e3311 and 0960f64.

📒 Files selected for processing (4)
  • src/main/runtime/agent-prompt-line-settle.test.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts
  • src/shared/tui-agent-config.ts
💤 Files with no reviewable changes (1)
  • src/main/runtime/agent-prompt-submission-runtime.test.ts

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


📝 Walkthrough

Walkthrough

The change adds agent-aware prompt timing. Antigravity keeps a 45 ms per-line settlement delay. Configured Enter retries are removed. Terminal prompt writes resolve delays from the active agent and prompt text. Submission results report one submit. Tests cover multiline settlement timing and agent-specific delay resolution.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the user impact, mechanism, rationale, testing, scope, and platform considerations. However, the required Linked Issue field still contains a placeholder instead of an issue n… Replace "Fixes # (follow-up issue TBD — coordinator dispatch)" with the actual linked issue number. Complete or explicitly document the remaining manual and full validation steps before merge.
✅ Passed checks (3 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 identifies the main change: adding a line-settle delay for Antigravity multiline paste submission.
Full details: Description check

Explanation

The description explains the user impact, mechanism, rationale, testing, scope, and platform considerations. However, the required Linked Issue field still contains a placeholder instead of an issue number, and manual and full-suite validation remain incomplete.

  • Fix all pre-merge checks with AI

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.

Important

The retry path can revoke an already-accepted worker start: the post-Enter permission assertion throws agent_prompt_blocked, which tears the worker down instead of settling it ready. Details inline.

Reviewed changes

  • Cursor gets a submit retry — submitRetryDelayMs: 1200 added to cursor in src/shared/tui-agent-config.ts.
  • Main-process writer retries Enter — writeTerminalAgentPrompt sends one blind \r after the delay for non-omp, non-render-gate agents, and now threads a submits count through every receipt.
  • Tests — two new cases pin that cursor retries once and that agents without the field do not.

ℹ️ The cursor retry has no captured transcript behind it

The change assumes two things about cursor-agent that no artifact in this repo demonstrates: that it swallows the first Enter after a long bracketed paste, and that a stray second Enter 1.2s later is a no-op. docs/reference/agent-pty-transcript-capture.md explicitly calls the existing cursor-agent-*.txt fixtures wording-only and "not evidence for anything else," and AGENTS.md requires a captured transcript before encoding terminal-behavior rules. A stray Enter is only harmless if cursor's composer is genuinely empty and idle — that is exactly what a transcript would settle. If a recording is not practical, please at least state in the PR that the second Enter is blind and unverified, so the next person debugging a duplicated submission has the caveat.

Technical details
# Missing transcript evidence

## Affected sites
- `src/shared/tui-agent-config.ts:229` — the new `submitRetryDelayMs: 1200` encodes the assumption.
- `docs/reference/agent-pty-transcript-capture.md:124` — "The three `cursor-agent-*.txt` fixtures
  contain **no escape bytes and no carriage returns** ... not evidence for anything else."

## Required outcome
- Either attach a cursor-agent transcript that shows the first Enter being swallowed and a later
  Enter being inert, or record the blind-retry caveat where the config is documented.

## Open questions for the human
- Was `cursor-agent` verified manually (as the unchecked test-plan item suggests)? If so, was the
  case where the *first* Enter already landed exercised?

ℹ️ Nitpicks

  • The retry blocks onInputAccepted and verification for a fixed +1200ms on every cursor prompt, including follow-ups to an already-working agent. That is a latency cost paid even when the first Enter landed.

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

Comment thread src/shared/tui-agent-config.ts Resolved
Antigravity 1.2.x expands long bracketed paste slowly ("↑ N more lines") while
Orca only waited for byte ingest (~500 ms on macOS). Add submitLineSettleMsPerLine
and retry Enter for antigravity; wire agent-aware submit scheduling through the
main-process prompt writer and plain terminal.send suffix path.

Co-authored-by: Cursor <[email protected]>

@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

pnpm lint is red on this branch: the tests added here push src/main/runtime/agent-prompt-submission-runtime.test.ts to 840 counted lines against the 800-line test budget, so CI's Lint step (pnpm exec oxlint --format github, .github/workflows/pr.yml:135) fails. Split the suite rather than disabling max-lines.

Reviewed changes

  • Antigravity gets line-aware submit timing — submitLineSettleMsPerLine: 45 and submitRetryDelayMs: 2500 on the antigravity config, with getAgentPromptSubmitDelayMs gaining line-settle options and a new resolveAgentPromptSubmitDelayForAgent that resolves them per agent.
  • Agent-aware scheduling reaches both writers — the main-process prompt writer resolves the pre-Enter delay from the raw prompt via options.promptForSchedule, and the plain terminal.send suffix path passes the pty's agent through a new RuntimeTerminalWriter getAgent callback.
  • Plumbing — RuntimeAgentPromptWriteOptions.promptForSchedule carries the raw prompt from sendTerminalAgentPrompt; RuntimeTerminalWriter is wired to getPtyAgent in orca-runtime-runtime-id.ts.
  • Tests — an antigravity line-settle runtime test and a per-line unit test.

ℹ️ The antigravity timing has no committed transcript behind it

The PR body cites REPORT.md, slow-input-observation.json, and long-send.json as evidence, but none are in the repo. AGENTS.md and docs/reference/agent-pty-transcript-capture.md require a captured transcript before encoding terminal-behavior rules, and the committed antigravity-*.txt fixtures were recorded against agy 1.1.25, not the 1.2.4 this change targets. Without the recording, 45 ms/line and the 2500 ms retry are unfalsifiable and the "a stray Enter is a no-op" premise stays unverified.

Technical details
# Missing capture for the antigravity timing change

## Affected sites
- `src/shared/tui-agent-config.ts:171-174` — `submitLineSettleMsPerLine: 45` and
  `submitRetryDelayMs: 2500` encode the assumption.
- `docs/reference/agent-pty-transcript-capture.md:110-128` — the committed
  `antigravity-*.txt` fixtures are `agy` 1.1.25 and only wording-based rules rest on them.

## Required outcome
- Either commit the `agy` 1.2.4 recording showing the collapsed paste expanding and a
  later Enter being inert, or state in the PR that both values are blind and unverified.

ℹ️ Interactive antigravity pastes get the retry without the line-settle delay

sendBracketedPasteToAgent reads submitRetryDelayMs but not submitLineSettleMsPerLine, so an interactive antigravity draft paste still fires its first Enter on the render-quiet signal and then a blind retry 2.5 s later, regardless of prompt length — while the main-process worker-start path now waits line-settle first. If the interactive path is meant to get the same fix, it needs the line-aware delay too; if not, the asymmetry is worth stating so the retry on a still-expanding paste is not read as intentional.

Technical details
# Renderer antigravity retry is not line-aware

## Affected sites
- `src/renderer/src/lib/agent-paste-draft.ts:205` — reads
  `TUI_AGENT_CONFIG[agent]?.submitRetryDelayMs`; never reads `submitLineSettleMsPerLine`.
- `src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts:88-96` — waits
  `resolveAgentPromptSubmitDelayForAgent(...)` before the first Enter.

## Required outcome
- Decide whether interactive antigravity pastes should also wait line-settle before their
  first Enter, or document that the renderer retry is intentionally timing-blind.

ℹ️ Nitpicks

  • pnpm-lock.yaml gains @pnpm/exe under packageManagerDependencies (plus package/snapshot entries) with no matching package.json change and no relation to this fix; please revert it unless it is intentional.
  • src/main/runtime/agent-prompt-submission-runtime.test.ts:7-9 is a second import from ../../shared/agent-prompt-injection; fold resolveAgentPromptSubmitDelayForAgent into the existing import on lines 2-6.

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

Address PR review: revert accidental pnpm-lock.yaml churn, remove cursor and
antigravity submitRetryDelayMs until live-verified, keep submitLineSettleMsPerLine
for agy multiline paste, and move the regression test out of the 900+ line runtime
submission suite.

Co-authored-by: Cursor <[email protected]>
@seonghobae seonghobae changed the title fix(orchestration): retry Enter after cursor-agent worker-start paste fix(orchestration): line-settle delay for antigravity multiline paste Sep 19, 2026

@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

  • Dropped the cursor submit retry — submitRetryDelayMs: 1200 and the retry-Enter block in writeTerminalAgentPrompt are gone, so a permission prompt during the retry window can no longer revoke an already-accepted worker start.
  • Dropped the antigravity retry — submitRetryDelayMs: 2500 removed; submitLineSettleMsPerLine: 45 is now the only antigravity timing knob.
  • Split the line-settle test out — the antigravity runtime case moved to agent-prompt-line-settle.test.ts, bringing agent-prompt-submission-runtime.test.ts back under the 800-line oxlint budget (oxlint passes at this head).
  • Reverted the unrelated pnpm-lock.yaml churn — the @pnpm/exe entries are gone.

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

@nwparker

Copy link
Copy Markdown
Contributor

Independent verification (2026-09-20):

  • Focused tests: 58/58 passed across line-settle, prompt injection, and submission-runtime suites.
  • pnpm tc:node passed.
  • pnpm run check:code-quality:changed origin/main passed with 0 new findings across 10 changed files.
  • Live authenticated agy 1.2.7 TUI probe: an interactive session accepted a 101-line multiline prompt and returned the exact sentinel AGY_TUI_OK. The prompt was captured only for local verification; no transcript, account data, or conversation ID is being published.
  • The live probe confirms current agy multiline acceptance, but it does not independently establish a before/after latency delta for Orca's writer.

Verdict: approve the deterministic line-settle implementation for the tested prompt-submission path, with the live 101-line TUI result as supporting evidence. Do not claim measured latency improvement or cross-host proof from this run. No merge performed.

@nwparker

Copy link
Copy Markdown
Contributor

ELI5 / evidence / trade-offs audit

ELI5: Long messages are sent to agy as one complete request instead of being cut off or split unpredictably.

Proof: 58/58 focused tests, typecheck/quality, and a live 101-line exact-sentinel agy probe pass; visual proof is not applicable to transport plumbing.

User-facing trade-off: Long prompts still depend on agy's input limits; no latency improvement is claimed.

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

@nwparker

Copy link
Copy Markdown
Contributor

Windows verification update (2026-09-20)

Plain English: agy slowly expands a long pasted message in its input box. Orca now waits roughly 45 ms per logical line before pressing Enter, so a 101-line request gets about 4.5 seconds of line-settle time plus the normal paste delay. It sends one Enter; this final commit deliberately removed the unverified blind retry.

On PR head 0960f6429c, the focused suite passed on native Windows/Node: 21 tests in 2 files (agent-prompt-line-settle.test.ts and agent-prompt-injection.test.ts). This verifies scheduling on Windows; it does not claim a live authenticated 101-line agy generation on Windows.

Merge risk is now low for the scheduling change. The trade-off is a longer wait for long prompts; no latency improvement is claimed.

@nwparker

Copy link
Copy Markdown
Contributor

What is the agy bug? Plain-English root cause

agy 1.2.x accepts a bracketed paste quickly, but its TUI does not immediately expand every pasted line into the editable composer. For a long prompt it briefly shows a collapsed state such as Pasted text +N lines / ↑ N more lines, then expands the lines over time.

Orca used to measure only how long it took to write the bytes into the PTY. When that byte timer ended, Orca pressed Enter while agy was still expanding the composer. The Enter could be consumed before the full prompt was submit-ready, leaving a partial or unsubmitted task.

This PR waits 45 ms per logical line before the one Enter. It is a timing workaround around agy's rendering/ingestion behavior, not a change to the prompt contents and not a second retry. The final commit removed the unverified blind retry. The trade-off is that long prompts wait longer before submission; short prompts are affected much less.

Evidence: the captured 101-line agy observation showed bytes accepted while the visible composer continued expanding; the Windows PR-head scheduling suite passed 21/21. A live authenticated Windows 101-line generation was not claimed.

@nwparker

Copy link
Copy Markdown
Contributor

reasonable fix. Wish agy wasn't like this but thanks

@nwparker

Copy link
Copy Markdown
Contributor

Review-bot follow-up

The automated review reported description-template/docstring-coverage warnings, but no actionable code defect. The PR now has the requested ELI5, scope, platform limits, and verification evidence in the discussion. The changed functions are small predicate/scheduling paths covered by focused tests; adding boilerplate docstrings would not change behavior or improve the contract. CI, typecheck, static analysis, and the relevant runtime tests are green.

The remaining manual/remote scenarios are explicitly documented as out of scope for this PR.

@nwparker
nwparker merged commit ea5152f into stablyai:main Sep 21, 2026
1 check passed
Jinwoo-H added a commit that referenced this pull request Sep 21, 2026
…policy case (#21874)

#21665 gave antigravity a per-line settle before Enter, so the delay the
test computed from bytes alone is 45 ms short of what the runtime waits.
Under fake timers that leaves the submit pending until the real 30 s
timeout, which is what every PR's node shard 8/8 has been failing on
since it landed. The case now derives the expected delay from the agent's
policy, so a future per-agent term moves the expectation with it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
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.

2 participants