Repository navigation
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Detector + tail-window moved to
src/shared—terminal-credential-prompt-detectionandterminal-wait-tail-windowrelocate so the main-process detector and the new renderer guard share one implementation rather than a drifting copy. - Single visible-screen projection —
terminal-visible-screen-projection.tsbecomes the one definition of "what the screen says" (readTerminalVisibleLines→collapseTerminalComposerDraftRows→ non-blank join), andHeadlessEmulator.getVisibleLines()/projectTerminalVisibleLines/visibleNonBlankTerminalLinesall delegate to it. - Renderer paste guard —
isAgentPasteBlockedByCredentialPromptreads a pane's live xterm through a new ptyId-keyed registry populated inbindRegisterPaneSerializer, andsendBracketedPasteToAgentrefuses the write before it reacheswindow.api.pty.write. - Reasoned failure callback —
onTimeout→onUndelivered('readiness-timeout' | 'credential-prompt')solaunch-work-item-direct,new-workspace, andagent-background-draft-deliverysurface an accurate toast on a credential refusal instead of the misleading "took too long to start". - One corpus, three lanes — the 56-screen corpus is extracted to
src/shared/terminal-credential-prompt-corpus.tsand drives the shared detector suite, the main wait-vocabulary suite, and the renderer paste-lane suite.
I traced the renderer↔main equivalence directly: buildTerminalVisibleScreenText and the main-process visible-screen probe both reduce to collapseTerminalComposerDraftRows(readTerminalVisibleLines(...), detectTerminalComposerDraft(readTerminalCursorLineContext(...))), and findCredentialPromptIndex bounds both lanes to the same last-4-non-blank-lines window — so there is no false-negative divergence, and a divergence would err toward the safe "renderer blocks more" direction. The TerminalVisibleScreenSource = TerminalCursorContextSource alias is satisfied by both @xterm/headless and the renderer parity fixture. Ran the new renderer, src/shared, and src/main suites (236 tests) — all green.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reported every credential refusal —
submitPromptToAgentPtyandsendBracketedPasteToRunningAgentnow accept anonUndeliveredcallback via a newdeliverBracketedPastehelper, so the automation-reuse entry point (the one paste caller with no readiness wait) records a credential refusal in telemetry instead of dropping it silently. - Split the shared corpus into three files —
terminal-live-credential-surfaces-corpus,terminal-legitimate-agent-screens-corpus, andterminal-agent-auth-summary-screens-corpus, so thesrc/shareddetector suite no longer needs thesrc/mainwait-vocabulary imports. - Proved cross-emulator parity —
pty-visible-screen-emulator-parity.test.tsdrives all 56 corpus screens through the real@xterm/xtermrenderer emulator and pins itsbuildTerminalVisibleScreenTextbyte-identical to@xterm/headless, closing the gap where the prior equivalence proof ran only on the headless emulator. - Renamed the paste notice —
createPasteReadinessTimeoutNotice→createPasteUndeliveredNoticewith anonUndelivered(failure)signature that routes credential refusals to the credential toast and timeouts to the readiness toast.
Verified the new suites green: parity test (148), undelivered-notice test (4), and credential-prompt draft test (7, including the refusal-vs-timeout distinction).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
5274745 to
833d9f0
Compare
bdacef9 to
135a60e
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Grew the corpus to 105 screens across a fourth file — new
terminal-auth-mention-screens-corpus.ts(21 bottom-row auth-mention screens: commit subjects, changelog bullets, checklists, localized narration, the antigravity sibling dialogs) joinsLEGITIMATE_AGENT_SCREENS, while six non-English/vendor credential surfaces (antigravity sign-in menu, German/zh-TW/Japanese sudo via the untranslated[sudo]tag, aider env-var ask, crush onboarding dialog) join the must-refuse side. - Pinned the prefilter honest and linear — two new shared-detector tests assert the sentinel regex is a superset over both corpora (any screen the index matches survives the prefilter) and stays under 500ms on adversarial long lines.
- Stopped swallowing refusals after navigation —
createPasteUndeliveredNoticenow toasts a credential refusal even after the user switched worktrees or closed the tab, where it previously vanished with no toast, no fallback and no telemetry.
I traced the notice change end-to-end: the currentTab?.ptyId === null early-return is deliberately strict, so a closed tab (currentTab === undefined) no longer silently drops a credential refusal, and notified is set before the toast so the deferred caller's wasNotified() still suppresses a duplicate. The new non-English sudo surfaces are detected through the untranslated [sudo] tag, which is consistent with the detector's English-only noun scope. Ran the four touched suites (notice, shared detector, projection, emulator parity) — 540 tests, all green.
ℹ️ Stale PR-description numbers
The description still says "The corpus is three files, one per side" and "148 assertions — 74 byte-identity comparisons", but this commit split off terminal-auth-mention-screens-corpus.ts (four files now) and grew the corpus to 105 screens, so the parity suite now runs 210 tests. Worth a refresh since the body is the PR's proof-of-work narrative.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
135a60e to
2e1eef9
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Added a formatted-source screen category to the shared corpus —
terminal-source-output-screens-corpus.tsfolds ~30 mined formatted-source screens (oxfmt ternary consequents,.loginproperty accesses, and wrapped comments ending on credential nouns) intoLEGITIMATE_AGENT_SCREENS, so the renderer lane now refuses none of them. - Added a generative vocabulary cross-product suite —
terminal-credential-vocabulary-shapes.tsderives plain phrases from the detector's own regex sources, and the new test crosses every term against twelve non-prompt shapes above each agent's composer caret, plus an identifier-corroboration probe that pins the.login/.credentialproperty-access lookbehinds.
The detector-side fixes these commits pin (the ask verb leading its row, the .login/.credential lookbehinds, composer-caret suppression of the question-row rule, and comment-marker exclusion) landed on the base branch #19978; this increment carries the renderer-lane corpus and the generative proof of them. I traced the lookbehind and composer-caret logic against the corpus (the #19749 dialog whose bottom row is a bare > still refuses through isCredentialPromptLine, which returns before the composer-caret fallback is consulted) and it is sound. Ran the three touched shared suites — terminal-credential-vocabulary-shapes, terminal-credential-prompt-detection, and terminal-visible-screen-projection — 406 tests, all green.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
2e1eef9 to
7b9f547
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
-
Composer-REGION suppression now proven in the renderer lane —
AGENT_COMPOSER_TAILSmodels the footers real agents draw beneath their caret (Codex model footer, OpenCode status bar, droid key-hint row, plus antigravity / command-code / cursor-agent / crush / aider / grok chrome) with-barevariants for the caret-on-bottom-row case, and two newbare identifier ternarycorpus screens (? loginover a codex caret + model footer,? authorizationover an opencode caret + status bar) pin the region logic: either would refuse if the suppression were still keyed on the literal bottom row. -
asPropertyAccessidentifier form corrected — space-stripping became_, so nouns whose separator the vocabulary requires (access[ _-]tokens?) now reach the./\wlookbehind instead of matching nothing; the newidentifierMatchableTermsfilters to terms whose identifier form the vocabulary still matches, and the suite assertslive.length >= 10so the identifier-corroboration probe cannot pass vacuously.
I traced the two new screens through findCredentialPromptIndex: ? login sets sawAuthQuestion, but nonBlank.slice(-COMPOSER_REGION_ROWS) reaches the codex caret above the footer, so bottomRowIsComposerCaret is true and the screen clears. Reverting COMPOSER_REGION_ROWS to 1 fails exactly those two screens, so the coverage is not theatre. Ran the three touched shared suites (vocabulary-shapes, detection, projection) — 412 tests green.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
7b9f547 to
9b403e4
Compare
The renderer paste lane writes through window.api.pty.write, which never reaches writeTerminalAgentPrompt, so the main-process agent_prompt_blocked fence could not see it. Its only gate was DECSET 2004 plus render-quiet -- a signal a TUI drawing its own sign-in dialog satisfies perfectly. Move the credential detector and its tail-window primitives to src/shared so both processes run one implementation, read the pane's own xterm buffer through the same visible-screen projection the main-process probe uses, and refuse the write when the detector fires. The refusal is reported through the lane's existing undelivered-prompt surface, so nothing is dropped silently.
…mulator projection `submitPromptToAgentPty` and `sendBracketedPasteToRunningAgent` collapsed a credential refusal to `false` and never called `onUndelivered`, so the automation dispatch path abandoned a session reuse with no record at all. Both now route through `deliverBracketedPaste`; the dispatch site tracks the refusal without a toast, because it recovers by launching a fresh background session. Quick launch — the highest-volume entry point — showed the readiness-timeout wording and `paste_readiness_timeout` telemetry for a credential refusal. The notice now takes the failure and routes it, which is what the `onUndelivered` rename was for; renamed to match what it reports. The equivalence proof rendered only through `@xterm/headless`, while the pane that feeds the guard is `@xterm/xterm` on a neighbouring beta. Added a parity suite driving the corpus through the real renderer emulator: both project the same bytes, so the skew is immaterial and a future divergence now fails a test. Split the corpus by side to stay under max-lines.
…r swallow a refusal The three corpus modules this commit's parent extracted are what the renderer lane, the main lane and the cross-emulator projection proof all read, so the screens the detector fix was tuned against have to live here rather than in the main-process test file they came from. Adds the mention corpus -- auth wording landing on the bottom row with no composer caret under it, which is the one place the prompt-shape rules have to make a judgement call -- plus the sentinel superset-over-both-corpora invariant and its hot-path budget. A credential refusal now also survives a workspace switch. The cancel suppression in `createPasteUndeliveredNotice` sets `notified`, which turns off the deferred caller's fallback toast too (launch-agent-session-continuation.ts:113), so that was the one path where a refusal -- false positive included -- lost the user's prompt with no toast, no fallback and no record. Navigating away is evidence the user stopped caring about a stalled readiness wait; it is not consent to lose a prompt the guard withheld.
Mining 16,206 distinct credential-vocabulary lines out of this repo's own tracked files and placing each one row above a real agent composer caret produced **100 refusals across 25 distinct lines**, on Codex, Claude Code and OpenCode. The corpus had `rg` hits and diffs, which carry their own chrome, but no plain formatted source -- and that is the category that leaked. 24 of the 25 are the same shape. `AUTH_QUESTION_ROW_RE` rests on "prose never starts with a bare `?`", which is true and irrelevant: oxfmt puts a ternary's consequent on its own row as `? someValue`, and **5,666 tracked files have one**. `sawAuthQuestion` then returns unconditionally, with no position requirement, so a composer caret directly below could not clear it. Nine of those matched only because `\b(?:log[ -]?in)\b` reads `user.login` as the auth verb. The 25th is the other rule: `CREDENTIAL_ASK_PREFIX_RE` was unanchored, so an ask verb anywhere in a row made a row-final credential noun a prompt -- `// Why: a merely missing or expired bundle must not enter the credential` is a real wrapped comment in this repo, and terminal wrapping makes ending on a noun routine. Three fixes, same discipline as the flow rule already uses: - the ask verb must LEAD its row, modulo decoration and a menu number, so `2. Paste an API key` still reads as a prompt and 60 characters of prose before `enter the` does not; - `.login` is a property access, not an auth verb; - a known composer caret on the bottom row suppresses the question-row rule, because an agent sitting at its own prompt is not asking anyone anything. The caret set deliberately includes a bare `>`. It only suppresses the question-row rule, and the #19749 sign-in dialog -- whose own bottom row is `>` -- matches through `isCredentialPromptLine`, which returns first. Verified: that dialog and the auth-method menu both still refuse. Mined-corpus refusals 100 -> 0, with the mined lines added as a new corpus category so the next widening has to refuse them. Sentinel budget unchanged at 16.2ms/500ms.
…shapes Three false-positive classes have now reached a PR past a two-sided corpus, and every one was a term the corpus ALREADY contained, sitting in a position nobody had written down: narration position, then localized punctuation, then formatted source. A curated corpus can only assert what someone thought of, so a fourth was a matter of time. This is the generative half. It expands the detector's own vocabulary sources into plain phrases and crosses every term against the shapes a term appears in when it is output rather than a prompt -- ternary consequent, comment, jsdoc, string literal, diff line, rg hit, test name, markdown table, echoed task prompt -- above each agent's composer caret. It grows by itself: add a noun to CREDENTIAL_NOUN_SOURCE and it is immediately checked in every shape. Why this rather than replaying lines mined from tracked files, which is how the last class was found: that corpus drifts as the repo changes, so an unrelated PR could turn it red, and it costs a full file walk per run. Deriving from the detector's vocabulary is deterministic, depends only on the detector, bounded at ~1,400 evaluations, and runs in 12ms. It earns its place immediately. On its first run it found a FOURTH class: `candidate.credential` set the credential-noun flag, because only the auth-verb regex had been taught that a dot means a property access. That flag is what corroborates an otherwise-inert bottom row, so an identifier alone could refuse a screen that was only printing source. Fixed the same way, and `.` only -- `\\w` would have broken the env-var ask (`OPENAI_API_KEY`). Writing the probe for it surfaced a fifth: ` // Sign in with the provider console to continue` read as a dialog leading its row, because the decoration run accepted a comment marker. A dialog decorates with box rules, bullets, carets and menu numbers, never with `//` or `*`. Two things the suite guards against in itself: a positive control asserting every noun still refuses in a real ask, so the negative cases cannot pass by the detector having stopped working; and probe rows chosen to carry no auth verb of their own, because a row like `Waiting for you to sign in` corroborates itself and would prove nothing about what else is on screen. All seven mutations -- the five fixes above plus round one's flow-rule position discipline and a fully disabled detector -- turn it red.
…m questions Re-verification found the last fix incomplete: 18 refusals survived, all one root cause. `COMPOSER_CARET_ROW_RE` suppressed only when the caret was the literal bottom row, and no agent draws it there -- Codex puts a model footer under it, OpenCode a status bar, droid a key-hint row, Command Code and grok their own chrome. FP-A survived for Codex and OpenCode, both gating agents. cursor-agent and antigravity passed only because four chrome rows pushed the trigger outside the window, which is luck, not a defence. My own `AGENT_COMPOSER_TAILS` caused this: I hand-wrote idealised tails ending on the caret while the real forms were already sitting in the corpus modules. That is the exact failure this file exists to prevent -- invented screens share the blind spots of whoever invented them. The tails now come from the captured chrome, and droid, cursor, command-code, grok, antigravity, crush and aider are added. Two fixes, because position alone cannot separate these: `? How would you like to authenticate?` above its two option rows and `? prevAssignees.filter(...)` above a caret and a status bar sit at the SAME offset from the bottom. - Suppression scans the last three non-blank rows for a caret, not the bottom row. - A `?` row that is code-shaped (quotes, braces, brackets, `=>`, `!==`, a `foo.bar` access) is not a question. Parentheses stay legal -- real prompts write `(Use arrow keys)`. The third vacuous probe, predicted and now fixed: `asPropertyAccess` collapsed spaces, so `access token` became `accesstoken`, which the vocabulary never matches -- 19 of 24 terms proved nothing about the lookbehind they claimed to exercise. Identifiers keep their separator, and the suite asserts how many terms are actually live rather than trusting the loop ran. Making it live immediately exposed a real gap: `candidate.personal_access_token` still corroborated, because the dot precedes `personal`, not `access_token`. The noun lookbehind now spans the identifier to its opening dot. Still only `.` -- `OPENAI_API_KEY` has none and is a real ask. Mined-corpus refusals: 16,297 lines x 13 real tails = 211,861 screens, 0 refusals. All ten controls hold, including the #19749 sign-in menu, the auth-method menu and the device-code dialog. Sentinel budget 16.8ms/500ms.
…see it
Re-verification found condition B failing on my own fix. `(?<!\.[a-z0-9_$]*)` is
quadratic: the engine retries the lookbehind from every position in an identifier
run, so doubling the run quadruples the cost. Measured here at 512/1024/4096
characters: 79us / 286us / 4572us, against 47 / 88 / 354 bounded. Bounding it to
`{0,40}` restores linearity and reproduces the unbounded verdict on every
correctness case, `candidate.personal_access_token` and `OPENAI_API_KEY` included.
The durable half is why the budget test did not catch it, which took two attempts
to get right:
- the existing budget drives `TERMINAL_CREDENTIAL_PROMPT_SENTINEL_RE`, built from
the RAW noun source with no lookbehind, so it is structurally blind to the rule
that has one;
- driving `findCredentialPromptIndex` instead does not help either, because
`MAX_CREDENTIAL_LINE_LENGTH` caps every row at 512 and the gap between a linear
and a quadratic lookbehind is only ~1.7x there. A test above the cap measures
the cap and passes regardless; a test below it cannot discriminate.
So the budget now drives the noun regex directly and asserts the complexity CLASS
at 1024 vs 4096. The containment stays a safety margin instead of being the only
thing holding, and the mutation back to `*` turns it red.
That 512 cap is now documented as load-bearing for complexity rather than only for
throughput, since every lookbehind-bearing rule depends on it.
Also dropped `[` and `]` from the code-shape class. A bracketed confirm default —
`? Authenticate with the CLI? [Y/n]` — is a mainstream convention (apt, readline,
enquirer) and was reading as source. The code rows that carry brackets all carry a
brace, a quote or a property access too, so nothing regressed: 16,309 mined lines
x 13 real tails = 212,017 screens, still 0 refusals, and both confirm shapes are
pinned as must-refuse.
…d exists
`{0,40}` was one character from wrong. The divergence boundary is exactly 41
characters between the opening dot and the noun, and
`settings.defaultOrganizationServiceAccountClientApiKey` sits at 39 — a real
identifier shape in this codebase, clearing the bound by one. Identifiers grow.
The quadratic behaviour comes from `*`, not from the size of the bound, so a
larger number costs nothing: 1024 -> 4096 grows 4.20x at 64 against 14.21x
unbounded, and all eight correctness cases are unchanged. Widened to 64 with the
reasoning written down, because `{0,64}` reads as arbitrary otherwise and the
obvious "simplification" is back to `*`.
Also documented, on AGENT_COMPOSER_TAILS, the invariant that actually matters for
this suite: its tails must come from captured chrome and must never be
hand-written. Four rounds of review found a live false-positive class in the first
three, and every one was idealised test input rather than wrong reasoning about
the detector. This array caused the third — hand-written ending on the caret,
which is what a composer "obviously" looks like, when every real agent draws a
footer under it. A generative suite is only as good as the ground truth it
generates against; invented screens share the blind spots of whoever invented
them, which is the exact failure a generative suite exists to eliminate.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Added a complexity-budget test for the noun lookbehind —
keeps the lookbehind-bearing rules linear, not just the sentineldrivesCREDENTIAL_NOUN_RE_FOR_BUDGETdirectly and asserts the complexity class (quadrupled < base * 8at 1024 vs 4096), pinning the{0,40}bound so a quadratic regression can no longer hide behind the sentinel (which has no lookbehind) or the 512-char row cap. - Pinned two bracketed-confirm surfaces as must-refuse —
? Authenticate with the CLI? [Y/n]and? Sign in with GitHub? [y/N]joinLIVE_CREDENTIAL_SURFACES, pinning the removal of[/]from the code-shape class.
The source change itself (bounded {0,40} lookbehind, CREDENTIAL_NOUN_RE_FOR_BUDGET export, [/] drop) lands on the parent branch (#19978); this commit carries the coverage across the lane split. Ran the shared detection suite (141 tests, all green) and mutated the lookbehind back to * — the budget test fails (7.9ms vs a 4.06ms threshold), so the coverage is not theatre.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
9b403e4 to
85f9f96
Compare
⏸️ Paused — draft. CI is fully green; the concern is maintainability.CI: 24 pass, 15 skipped, 0 fail. Both verification conditions independently cleared. This is not being paused because something is broken. The honest problem43 files is misleading, but the real number is still too high. Most of the diff is the mechanical That detector now carries ~8 interacting rules, each added to close a hole found by the previous review round. Nobody outside the session that wrote it understands the interactions. The concrete evidence that this matters: four consecutive rounds, and in three of them an independent verifier found a live false-positive class that the author's own tests had just cleared. Not through faulty reasoning — every time, through idealised test inputs. A detector that passes because someone adversarial keeps looking is not the same as a detector that is correct by construction, and the next person to touch this will not have that adversary. What this PR gets right, and should survive any redesign
Coverage, stated honestlyThe fence sits at exactly one place and is reached only when Also unchanged: fail-open when no pane is registered, which concentrates on automation dispatch (background timer, unviewed worktree, cold-parked pane). That path has no readiness wait at all today, so this is a gap the guard does not close rather than false confidence it creates. Why pausedSee #19978 for the full reasoning. Short version: a real password prompt disables echo at the termios layer — ground truth rather than inference — and Orca has no echo detection anywhere. Nobody asked whether a text detector was the right instrument, because the task was always framed as fixing the detector. If the hard signal is available, most of the rule surface here disappears. To un-draftMerges with #19978 or not at all. Un-draft when the echo/termios question is settled either way. |

Stacked on #19978 — targets
nwparker/credential-prompt-write-guard, notmain. Review #19978 first.Scope — one more write path, not all of them
This PR closes the renderer paste lane. It does not make Orca refuse credential-prompt writes generally. With this and #19978 merged, the picture is:
sendTerminalAgentPrompt→writeTerminalAgentPrompt(CLI--text --enter, worker start,dispatch --inject, coordinator auto-dispatch, federated preamble)window.api.pty.writefrom the renderer (agent-paste-draft.ts) — quick launch, submit-after-ready, work-item launch, folder-workspace startupruntime.sendTerminal(runtime-terminal-writer.ts) — ownership lease onlyterminal.sendorca terminal send --text Xwithout--enterterminal.sendTextmailbox-pointer-pty-write.ts:26The main-process fence is reached only when
agentPrompt === true && hasText && enter === true && interrupt !== true && client.type === 'desktop'(terminal-send-method.ts:192). Mobile fails that last condition outright and is entirely unfenced — a phone sendingterminal.sendwith text and enter takes thesendTerminalpath and meets no credential check. "My phone is protected too" is exactly the wrong inference to draw from this stack.The
--enterasymmetry is a decision, not an omission:--textwithout--enteris how you legitimately answer a credential prompt, so fencing it would make it impossible to type a password into the very dialog the detector recognises. See #19978 for the full reasoning; please don't "fix" it without replacing the escape hatch.None of the unfenced paths were fenced before this stack either, so the uncovered surface is incompleteness, not regression.
What this closes
#19978 added credential/auth vocabulary to
detectTerminalWaitBlockedReason, which makes the existingwriteTerminalAgentPromptfence throwagent_prompt_blockedbefore bytes reach the PTY. That fence only sits on theOrcaRuntimeServicelane.sendBracketedPasteToAgent(src/renderer/src/lib/agent-paste-draft.ts) writes throughwindow.api.pty.write, bypassingOrcaRuntimeServiceentirely, so it can never reachagent_prompt_blocked. Its only gate waswaitForAgentDraftInputReady— DECSET 2004 plus render-quiet — which a TUI drawing its own sign-in dialog satisfies perfectly.That lane backs quick launch,
submit-after-ready, work-item launch, folder-workspace startup and fix-checks. It is the most-used launch-with-prompt path in the product, and #19978 alone did not cover it. This PR completes that PR's coverage; it does not duplicate it.When it fires, the user's task prompt is submitted to an auth provider as a credential attempt, and — because the daemon records raw PTY output unredacted — an echoing prompt also writes it into the session transcript.
ELI5
There are two separate routes by which Orca types your task prompt into an agent's terminal. #19978 stopped one of them typing into a sign-in box. This is the other one — the route behind quick launch, work-item launch,
submit-after-readyand folder-workspace startup, which is the one most people actually hit. Same hazard: if a password or API-key prompt is on screen when Orca decides to type, your task goes into it and gets submitted.The awkward part is that this route sees the terminal as a grid of character cells, not as a stream of text, so "the last few lines on screen" is a genuinely different operation on each side. Writing a second detector for the grid would have been the easy fix and the wrong one — two judgements that agree right up until they don't is precisely what caused the crash in #19745. Instead both sides now call one detector over one shared definition of "what the screen currently says", and a test proves the two produce byte-identical text across all 74 screens in the corpus.
The other half of "refuse" is telling you. A prompt that vanishes with no toast is its own bug, so every refusal on this lane now reaches its caller with a reason, and every caller says the true thing about it.
One honest limit: if no terminal pane is attached yet, there is no screen to read, and the paste is allowed rather than blocked. Absence of evidence isn't treated as evidence of a clean screen — but it isn't treated as danger either, because that would block most ordinary launches.
The detector moved to
src/shared; there is no second copyterminal-credential-prompt-detection.tsand itsterminal-wait-tail-windowdependency movedsrc/main/runtime/ → src/shared/. Both processes now run one implementation.Per AGENTS.md's "Reuse Before Reimplementing" rule, this deliberately does not fork a renderer-side copy. A divergent second detector is precisely the drift class that produced #19745's original bug — two readiness judgements that agreed until they didn't.
The same reasoning drove two smaller dedups that fell out of it:
HeadlessEmulator.getVisibleLines()andvisibleNonBlankTerminalLinesnow delegate to the shared projection module, andprojectTerminalVisibleLinescalls the same sharedcollapseTerminalComposerDraftRowsthe renderer path does, rather than keeping a parallel copy of the row walk.The equivalence proof
This is the strongest thing in the PR, and the reason to look at
src/shared/terminal-visible-screen-projection.test.tsfirst.The main-process detector reads a tail string built from PTY output. The renderer holds an xterm.js grid. "The last N non-blank rows of a grid" is not the same operation as "the tail of a string", and a detector fed a differently-shaped string is a detector that silently stops working — it keeps passing its own unit tests while protecting nothing.
src/shared/terminal-visible-screen-projection.tsis now the single definition of "what the visible screen says": viewport row walk (viewportY … viewportY + rows,translateToString(true)) →trimEnd→ drop blanks →join('\n'), plus the composer-draft row collapse. That is exactly the string the main-process visible-screen probe feedsdetectTerminalWaitBlockedReason(projection.tail.join('\n')). The renderer lowercases before callingfindCredentialPromptIndex, matchingdetectTerminalWaitBlockedReason's own normalization.The test renders all 126 corpus screens into a real
createRendererParityTerminal— the repo's existing renderer-parity xterm fixture — and requires the extracted string to be byte-identical to the main-shaped corpus join, and to produce the same detector verdict.Specific hazards covered as named cases:
I also checked the composer-draft collapse empirically: it never fires on any corpus screen, nor on caret-prefixed credential fields (
❯ Enter your password:), so it cannot mask a live prompt.The proof now runs against the emulator the renderer actually uses
A readiness review pointed out the equivalence proof rendered through
@xterm/headless(package.json,6.1.0-beta.302), while the pane that actually feeds this guard is@xterm/xterm(6.1.0-beta.303). Different packages on neighbouring betas — byte identity proven against one says nothing about the other.Rather than pin a version (which goes stale silently the next time either moves),
src/renderer/src/components/terminal-pane/pty-visible-screen-emulator-parity.test.tsdrives the whole corpus through the real renderer emulator under happy-dom and pins the two projections to each other: 148 assertions — 74 byte-identity comparisons between@xterm/xterm6.1.0-beta.303 and@xterm/headless6.1.0-beta.302, plus a detector verdict per screen in both directions. All pass.So: the skew is immaterial for this input class, and a future divergence now fails CI instead of quietly invalidating the proof.
Every refusal now reaches its caller
sendBracketedPasteToAgentreturns'delivered' | 'not-delivered' | 'credential-prompt', anddeliverBracketedPasteforwards acredential-promptoutcome to the caller'sonUndelivered. Two exported entry points skipped that and collapsed the outcome straight to=== 'delivered', so a refusal there was a silently dropped user prompt — which is exactly the bug this guard's own notice module exists to prevent:submitPromptToAgentPty— the automation dispatch path (automation-dispatch-handler.ts).sendBracketedPasteToRunningAgent.Both now take
onUndeliveredand route throughdeliverBracketedPaste.At the automation dispatch site the refusal is tracked, not toasted, and deliberately so:
!submittedthere falls through tolaunchAgentBackgroundSession, so the prompt still lands in a fresh session and a toast would be a lie in the other direction.trackAgentPasteCredentialPromptRefusalrecords it without inventing a user-facing failure. That split is why the notice module now exposes the telemetry call separately from the toast.onUndeliveredfinished at the last call site#19978's review and the earlier revision of this PR renamed
onTimeout→onUndelivered(failure)precisely so a credential refusal would stop being reported as a timeout. One site still didn't honour it:launch-agent-in-new-tab.ts— quick launch, the highest-volume entry point — passedtimeoutNotice.onTimeout, which ignores the failure argument, so a credential refusal showed the readiness-timeout wording and emittederror_class: 'paste_readiness_timeout'telemetry. Same class of lie the rename was meant to fix.launch-agent-paste-timeout-notice.ts→launch-agent-paste-undelivered-notice.ts, andcreatePasteUndeliveredNoticenow takes the failure and routes it: a credential refusal gets the credential toast and no timeout telemetry, a readiness timeout is unchanged. The existing suppression rules are preserved — silent when the PTY never spawned (so the caller owns the sole notice), and marked-notified-but-silent once the user has closed the tab or switched worktrees. Four new tests pin all four branches.The lane's failure callback carries a reason (
'readiness-timeout' | 'credential-prompt') at every site now. This is a correctness fix to a user-facing message, not cosmetics:launch-work-item-direct's existing toast reads "Agent took too long to start. The workspace is ready — paste the prompt when the agent is idle." For a credential refusal that is simply false — the agent started fine and is sitting at a sign-in wall. Every existing failure surface still fires; the credential case now gets accurate advice. No new i18n keys — the credential toast reuses an already-translated string, so all five locales stay correct.The mechanical rename across six test files is most of this PR's line count.
Results
rghits on credential-shaped source, diffs adding credential strings, test output) plus the 18 agent-auth-summary screens fix(runtime): refuse an agent-prompt write into a live credential prompt #19978's review found, which is the category the original corpus lacked entirely. See fix(runtime): refuse an agent-prompt write into a live credential prompt #19978 for those 18 verbatim.gh auth login, Claude/login).return false(feature removed).toLowerCase()dropped before the detectorslice(-4)row window instead of non-blank projectionviewportYsubmitPromptToAgentPty/sendBracketedPasteToRunningAgentreverted to collapsing the outcomecreatePasteUndeliveredNoticeM8 is the one worth noting: without a test on the pane-registration wiring, deleting one line in
pane-serializer-register.tswould make the guard dead code that still passes every other test in this PR.Suite sizes after the change: shared detector 110, main wait-vocabulary 108, projection equivalence 214, cross-emulator parity 210, renderer guard 109, paste-lane 7, undelivered notice 6.
Full runs:
tc:node/tc:web/tc:cliclean (run one at a time),oxlint srcclean,src/main/runtime+src/shared+src/renderer/src/lib+src/renderer/src/components/terminal-pane+src/renderer/src/hooksgreen (1,338 and 5,415 passing respectively across the two broad sweeps).check:code-quality:changed: 0 new findings across 58 changed files.No
max-linesdisable anywhere. Two files hit the limit during this work and were split rather than exempted:headless-emulator.tsby extractingcollapseTerminalComposerDraftRowsinto shared (which removed the last duplicated collapse rather than buying headroom), and the shared corpus by side — see below.The corpus is three files, one per side
Adding the 18 agent-auth-summary screens pushed
src/shared/terminal-credential-prompt-corpus.tspastmax-lines. It is now split by what each file contains, not by size:terminal-live-credential-surfaces-corpus.ts— the 35 must-refuse screens, plus the sharedTerminalCredentialPromptCasetype.terminal-legitimate-agent-screens-corpus.ts— the must-allow screens; exportsLEGITIMATE_AGENT_SCREENSas the concatenation, so consumers are unchanged apart from the import path.terminal-agent-auth-summary-screens-corpus.ts— the 18 screens that read like a credential dialog to any rule that only looks for auth wording.All five consumers (shared detector suite, main wait-vocabulary suite, projection equivalence suite, cross-emulator parity suite, renderer guard suite) import from the new paths. One corpus, four lanes.
Detector changes carried in from #19978
The shared detector is fixed on the parent branch; this PR carries the corpus across the lane split. Three things a reviewer of the renderer lane should know, because they change what this lane refuses:
2. Paste an API keyover a bare>caret — the F19749-1 dialog) was refused here and passed there. Fixed on the parent; the superset invariant now runs over both corpora against the index's own verdict rather than only over screens we already expected to block.git log --onelineending onfeat(auth): sign in with GitHub, a changelog bullet, a checklist item,Waiting for you to review the diff, and CJK/German narration. An action phrase must now lead its row. Because this lane has no retry, a false positive here costs the user a re-paste, so these matter more here than in the main lane.False positives found after review, and how they were found
Counts and suite sizes in this body are at time of writing; they have gone stale twice already
as the corpus grew.
Five false-positive classes reached this PR past a two-sided corpus that read 100% clean. Every one
was a term the corpus already contained, sitting in a position nobody had written down — which
is the failure mode of a curated corpus, not an accident.
The one that matters most: formatted source code
Replaying 16,206 credential-vocabulary lines mined from this repo's own tracked files, each placed
one row above a real agent composer caret, produced 100 refusals across 25 distinct lines on
Codex, Claude Code and OpenCode. The corpus had
rghits and diffs, which carry their own chrome,but no plain formatted source.
24 of the 25 are one shape:
AUTH_QUESTION_ROW_RErests on the comment "Prose never starts with a bare?". That is true ofprose and irrelevant: oxfmt puts a ternary's consequent on its own row exactly that way, and
5,666 tracked files in this repo contain such a line.
sawAuthQuestionthen returnedunconditionally, with no position requirement, so a composer caret directly below could not clear
it. Any agent printing Orca's own source tripped it. Nine of the 25 matched only because
\b(?:log[ -]?in)\breadsuser.loginas the auth verb.The 25th is a different rule and a real wrapped comment in this repo:
CREDENTIAL_ASK_PREFIX_REwas unanchored, so an ask verb anywhere in a row made a row-finalcredential noun a prompt. Terminal wrapping makes ending on a noun routine.
Why
isLastRowis NOT the gate on the ask-prefix pathThe obvious simplification is to require the ask-prefix path to be the last row, matching the
bare-label rule. Do not do this — it silently deletes the dialog this guard exists for. In the
Antigravity sign-in menu the credential row is not the last row:
2. Paste an API keyis a prompt because end-of-row counts as a terminator. Gate it onisLastRowand the #19749 dialog stops being detected. The rule used instead is position of a different kind:
the ask verb must lead its row, modulo decoration and a menu number.
2. Paste an API keyleads; sixty characters of prose before
enter thedoes not.Two more, found by the generative suite this PR adds
candidate.credentialset the credential-noun flag, because only the auth-verb regex had beentaught that a dot means a property access. That flag corroborates an otherwise-inert bottom row, so
an identifier alone could refuse a screen that was only printing source. Excluded
.and.only:\wwould break the env-var ask (OPENAI_API_KEY), which is a real prompt.// Sign in with the provider console to continueread as a dialog leading its row, because thedecoration run accepted a comment marker. A dialog decorates with box rules, bullets, carets and
menu numbers, never with
//or*.The mechanism, not just the fixes
terminal-credential-vocabulary-shapes.test.tsexpands the detector's own vocabulary sourcesinto plain phrases and crosses every term against the shapes a term takes when it is output rather
than a prompt, above each agent's composer caret. It grows by itself: add a noun to
CREDENTIAL_NOUN_SOURCEand it is checked in every shape on the next run.It is deterministic (depends only on the detector, not on repo contents), bounded (~1,400
evaluations, 12ms), and it carries a positive control asserting every noun still refuses in a real
ask, so the negative cases cannot pass by the detector having quietly stopped working. All seven
mutations — the five fixes above, the earlier flow-rule position discipline, and a fully disabled
detector — turn it red.
Validation against real recorded output
The detector now runs clean over all 11 captured PTY transcripts in the repo — the eight real
agytranscripts added by #19983 (includingantigravity-ready-api-key-gemini-model, whose readychrome names an API key) and the three cursor-agent captures. Zero false positives on real recorded
agent output.
Agents with no evidence behind them
Coverage rests on recorded or reconstructed output for Codex, Claude Code, Gemini, OpenCode,
cursor-agent, Antigravity and Command Code. 25 agents have no transcript. Five are title-only —
pi,omp,hermes,copilot,devin— and twenty have nothing at all. Their chrome isunverified against this detector in either direction.
Shapes this detector does not catch, measured
Independent verification compared this detector against the previous revision and found 12 shapes
that stopped being refused. All 12 behave exactly as
origin/maindoes, which has no credentialdetection at all, so they are incompleteness against an intermediate commit on this branch rather
than a regression against the merge target. Naming them instead of quietly re-tuning:
? Authenticate with the CLI? [Y/n]. A bracketed confirmdefault is a mainstream convention (apt, readline, enquirer), and
[/]have been dropped fromthe code-shape class.
(y/N)with parentheses always worked.github.com,[email protected]) reading as aproperty access. Real git credential prompts are unaffected — they route through
GIT_CREDENTIAL_RE(Username for 'https://github.com':) and stay refused — so the residue isauth-adjacent prose that mentions a hostname, which was never a live prompt.
A complexity hazard that the budget test could not see
Worth reading before touching any rule here. The noun lookbehind was briefly written as
(?<!\.[a-z0-9_$]*), which is quadratic: the engine retries it from every position in anidentifier run, so doubling the run quadruples the cost — measured 79µs / 286µs / 4572µs at
512 / 1024 / 4096 characters.
The budget test did not catch it, for two compounding reasons:
TERMINAL_CREDENTIAL_PROMPT_SENTINEL_RE, which is built from the raw noun sourceand carries no lookbehind, so it is structurally blind to the rule that has one;
findCredentialPromptIndexinstead does not help either, becauseMAX_CREDENTIAL_LINE_LENGTHcaps every row at 512 characters, and at that length a quadraticlookbehind is only ~1.7× a linear one. A test above the cap measures the cap; a test below it
cannot discriminate.
The bound is
{0,64}— it must exceed the longest realistic dot-to-noun distance (39 in this repo today) while staying bounded. The durable part is that the budget now drives the noun regex directly andasserts the complexity class at 1024 vs 4096, so the 512 cap is a safety margin rather than the
only thing holding — and that cap is documented where it is defined as load-bearing for complexity,
not merely for throughput.
What this detector does in a plain shell pane, by design
Mined into a shell pane — no agent composer anywhere on screen — rather than above a composer,
20,350 rows produce 25 refusals from 18 distinct rows, a bottom-row rate of 0.12%, stable
across verification passes. Every one is either the deliberate bottom-row bare-label rule
(
credentialIds: Set<string>,apiKey,credentialError:) or one of this detector's own corpusstrings quoted in source.
This is intended, not a defect, and a reader should know it: a shell pane whose bottom row is
credential-shaped source will occasionally be refused. The bare-label rule exists because
Password:on the bottom row is exactly whatdocker login,sudoandgitprint, and nothingon screen distinguishes that from a printed manifest. The refusal is transient — it clears as soon
as the shell repaints a new bottom row — and it surfaces synchronously with a named reason rather
than hanging.
One known constructible case is deliberately not fixed: a
?row carrying only brackets(
? [signIn, signOut],? credentials[index]) can refuse in a shell pane with no composer below,because
[/]were removed from the code-shape class so that bracketed confirm defaults(
? Authenticate with the CLI? [Y/n]) keep working. All eight real instances in this repo alsocarry a dot access and stay code-shaped, and a sweep of 20,350 shell-pane rows found zero
occurrences of the bare shape. Adding another shape rule to catch something that does not occur is
how the previous rounds of surface area got added.
Deliberate residual gap — this is not fail-closed
No registered pane ⇒ no evidence ⇒ the paste is allowed.
The guard reads the pane's live xterm through a ptyId registry populated when a pane binds its PTY. If no pane currently owns that ptyId,
readPtyVisibleScreenTextreturnsnull, and the guard treats that as absence of evidence rather than evidence of a clean screen.Refusing there would block every launch whose pane has not mounted yet, which is a large fraction of ordinary launches. Runtime-routed writes still meet the main-process fence from #19978. This is tested (
allows the paste when no pane owns the PTY) and commented at the call site, and mutation M3 pins it. Please don't read this lane as fail-closed.It is also not rare, and it is not uniform — measured rather than estimated:
automation-dispatch-handler.ts:112→submitPromptToAgentPty)So the hole concentrates on the one path where an unattended write into a credential prompt is worst, because nobody is watching. The mitigating fact: automation dispatch has no readiness wait at all today — it writes blind, before this PR — so the guard does not make that path worse, it just fails to help there. That is incompleteness, not false confidence created by this PR.
Closing it structurally means giving the guard the same ptyId-keyed PTY data sidecar that
waitForAgentDraftInputReadyalready uses, so it stops depending on a mounted pane. That is real work, not a tweak, and it is not attempted here.Checked against #20034, and the earlier claim in this body was wrong. An earlier revision said
#20034 (
perf(terminal): mount only the visible pane on a worktree switch) widened this hole. Itdoes not.
ACTIVATION_DEFERRED_ADMISSION_LIMIT = 4reproduces exactly the warm set the old eagermount threshold produced, so steady-state pane coverage is unchanged; only the timing moved, with
mounts landing on idle frames in roughly a one-second window after a switch. The hole is the same
one it always was: worktrees holding more than four deferred tabs, and worktrees never visited at
all. That predates #20034.
Residual risk — read this before merging
src/main/runtime/orchestration/mailbox-pointer-pty-write.ts(the mailbox pointer lane, which gates on an idle edge only). The mailbox lane carries fixed orchestration pointer text, not a user task prompt, so neither the secret-typing nor the transcript-echo harm applies — worth a follow-up, not a blocker. Neither should be implied closed.Notes for reviewers
src/sharedconstraint the next person will hit. fix(runtime): refuse an agent-prompt write into a live credential prompt #19978's detector test asserted throughdetectTerminalWaitBlockedReason, so after the move it was asrc/sharedtest importingsrc/main. Bothtsconfig.tc.web.jsonandtsconfig.tc.cli.jsonincludesrc/shared/**/*with no test exclusion, so that import breakstc:webandtc:cli. Resolved by extracting the corpus tosrc/shared(verbatim; precedent:terminal-title-classification-corpus.ts) and splitting the assertions — pure-detector cases stay in shared, wait-vocabulary cases move tosrc/main/runtime/terminal-credential-prompt-wait-vocabulary.test.ts. Every original case is preserved, and the corpus now also runs a negative pass on the main lane.sendBracketedPasteToRunningAgentstill has no production caller. It is no longer left alone: it now routes its refusal throughonUndeliveredlike every other entry point, so the next caller inherits the contract rather than the silent drop.check:code-quality:changedfinding inmobile/src/components/mobile-selectable-text-ios.test.tsxis not from this diff — it's inherited from the branch stack's older base. Type-aware lint scoped to the files this PR touches is clean. Don't chase it.Follow-up, not done here
sendBracketedPasteToRunningAgent(agent-paste-draft.ts:205) has zero production callers — only tests. It is also a latent bug: it passes nosettings, sosendBracketedPasteToAgentfalls back to the global store instead of the tab's runtime owner, which would target the wrong runtime for an SSH tab. It should be deleted rather than guarded, but doing so churns six test blocks in the middle of this review, so it is called out here instead.Why stacked rather than standalone
This cannot stand alone: it consumes the detector, and the
src/sharedmove rewrites #19978's own imports. I also considered splitting move-from-guard, and deliberately did not — the move is only justified by the consumer that follows it, and a pure-refactor PR whose motivation lives in another PR is harder to review, not easier.