Skip to content

test(webui): the native acceptance waits for the shell before it types the command - #35

Merged
modacker merged 1 commit into
mainfrom
fix/webui-native-shell-readiness
Nov 11, 2026
Merged

modacker merged 1 commit into
mainfrom
fix/webui-native-shell-readiness

Conversation

@modacker

@modacker modacker commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Change

The native-terminal acceptance types its command into a terminal as soon as the terminal exists, and then waits five seconds for the command's echo. On the Windows runner the shell behind the terminal is not ready at that point: PowerShell needed about four seconds before it printed its first prompt, and about five before it rendered the line that had been typed into it. Bytes written before the shell is reading wait in the pty's input buffer, so the five seconds the assertion has are spent on the shell's start-up rather than on the echo, and the assertion fails on a command that was never wrong.

The failing run's trace carries the timeline: the write at T0, the prompt at T0+3957ms, the echoed line at T0+4983ms, and the timeout at T0+4991ms. When the wait gave up, the buffer held the echoed command and no output line -- the command had not been executed yet. This is the failure recorded in #33.

The case now waits for the shell before it types anything, with two signals in order: whether the shell has printed anything at all (no prompt text, so the same wait works for PowerShell and for sh), and then a probe the shell executes. The probe is what decides, because "the shell has started" is not yet "the shell is reading" -- the prompt arrived about a second before PowerShell began reading. The probe's marker is split the way the command's own marker is split, so the shell's echo of the probe cannot pass for an answer; only its execution can.

Nothing is loosened. The assertion is unchanged and still gets the same five seconds for the echo; the new budget is a precondition on the write, spent on the shell's start-up. No retry was added, no case was skipped, and the expected string did not change. A wait that runs out says what it was waiting for and shows the output the terminal did produce.

Validation

  • Checks run and results (include the revision/profile where relevant):
    • CI run 42992507142 on this revision (941b4b8): ubuntu-latest, windows-latest and macos-latest all green.
    • The native acceptance case on this machine (macOS): 3 consecutive runs, each one passed (2.7s, 2.6s, 2.7s), the last two against this branch.
    • node --check packages/webui/test/browser/native-runtime.spec.mjs: pass.
  • The earlier red of this branch on macOS (run 42985068220) was not this change: it failed in the Vitest stage on packages/webui/test/integration/agent-transcript.test.ts, while this branch's own case passed in that same run's Playwright stage (native-runtime.spec.mjs:201 V04/V06, 5.6s). That Vitest flake is tracked in [Bug]: the agent-transcript case fails on the Windows runner and the failure leaves no evidence behind #32, and this revision is rebased onto main so the run carries the panel-state diagnostic merged in test(webui): the agent transcript names the browser panel's state when no frame arrives #34.
  • Performance: basic -- the automatic 100-round check. No perf:full label: the change is outside the paths the performance rules in CONTRIBUTING.md list, and it is not a performance optimization.
  • NOT RUN, platform limitations and live-service boundaries:
    • The Windows branch was first exercised by CI, not by hand. This machine is macOS, so the win32 probe has never been run by a person here; the judgement the wait makes is the same on both platforms -- "did the shell execute this and print the answer" -- and only the probe's syntax differs. CI run 42992507142 is the first execution of that branch on Windows, and it passed.
    • The case's own timeout is 90 seconds. The readiness wait is 20 seconds per terminal and the case uses two terminals, so even the worst case stays well inside that budget.

Publication and contribution checks

  • I have permission to contribute these changes under the existing licenses applicable to the changed files/packages; imported material and its provenance are identified and existing notices are preserved.
  • No credentials, account data, real user content, internal source history or private review material is included.
  • Added/removed source files were reviewed before regenerating release/public-source.json; new tests are declared in test/vitest-suites.json where applicable. -- no source file was added or removed, so release/public-source.json is unchanged; no vitest file was added, so no suite declaration is needed.
  • Shared English/Chinese documentation and capability/verification records are updated where applicable. -- no shared documentation describes this acceptance, and the product's behaviour is unchanged.

Maintainer handoff

Publication scope or license changes (if any): none.

Shared-source port: not needed. The change is inside packages/webui, which does not exist upstream; per packages/webui/docs/agents/issue-tracker.md nothing in this repository is published to upstream.

…s the command

The native-terminal acceptance writes its command into a terminal as soon as
the terminal exists, and then waits five seconds for the command's echo. On
the Windows runner the shell behind the terminal is not ready at that point:
PowerShell needed about four seconds before it printed its first prompt, and
about five before it rendered the line that had been typed into it. Bytes
written before the shell is reading wait in the pty's input buffer, so the
five seconds the assertion has are spent on the shell's start-up instead of
on the echo, and the assertion fails on a command that was never wrong.

The failing run's trace carries the timeline: the write at T0, the prompt at
T0+3957ms, the echoed line at T0+4983ms, and the timeout at T0+4991ms. At the
moment the wait gave up the buffer held the echoed command and no output
line, so the command had not been executed yet.

The case now waits for the shell before it types anything. Two signals, in
order: whether the shell has printed anything at all (no prompt text, so the
same wait works for PowerShell and for sh), and then a probe the shell
executes. The probe is what decides, because "the shell has started" is not
yet "the shell is reading" -- the prompt arrived about a second before
PowerShell began reading. The probe's marker is split the way the command's
own marker is split, so the shell's echo of the probe cannot pass for an
answer; only its execution can.

Nothing is loosened. The assertion is unchanged and still gets the same five
seconds for the echo; the new budget is a precondition on the write, spent
on the shell's start-up. No retry was added, no case was skipped, and the
expected string did not change. A wait that runs out says what it was
waiting for and shows the output the terminal did produce.

The failure this fixes is recorded in #33.
@modacker
modacker force-pushed the fix/webui-native-shell-readiness branch from 3e4feb7 to 941b4b8 Compare November 11, 2026 09:07
@modacker
modacker merged commit defc233 into main Nov 11, 2026
3 checks passed
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