Skip to content

fix(vega): report the emulator console reply when a screenshot writes no PNG - #1350

Closed
latekvo wants to merge 9 commits into
mainfrom
fix/vega-screenshot-console-ko
Closed

latekvo wants to merge 9 commits into
mainfrom
fix/vega-screenshot-console-ko

Conversation

@latekvo

@latekvo latekvo commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #1338

adb emu exits 0 when the emulator console refuses a command; the only sign is a KO: line on stdout. Vega capture dropped that output. The no-PNG error now carries the reply on one line. When the reply ends in KO: unknown command (the console never authenticated adb: token missing, a symlink, or mismatched), it also names the token file adb reads. runEmuConsole (shake, fold) reports the whole reply too, so a token mismatch keeps its auth line.

The message reaches screenshot and flow snapshot: steps; settle and failed-step captures swallow capture errors by design.

Tool-server token Before After
mismatched emulator console wrote no PNG to /var/…/vega-shot-q9pnX7 for emulator-5554 emulator console wrote no PNG for emulator-5554: KO: authentication token does not match ~/.emulator_console_auth_token; KO: unknown command, try 'help' (adb authenticates to the console with <HOME>/.emulator_console_auth_token, which must be a regular file, not a symlink, holding the emulator's token)
missing or symlink same emulator console wrote no PNG for emulator-5554: KO: unknown command, try 'help' (adb authenticates to the console with <HOME>/.emulator_console_auth_token, …)
empty reply same emulator console wrote no PNG for emulator-5554: empty reply

No docs update needed.

Verification

Real VVD (emulator-5554), branch dist, tool-server started with HOME pointing at a mismatched token, POST /tools/screenshot:

{"error":"[Tool:screenshot] emulator console wrote no PNG for emulator-5554: KO: authentication token does not match ~/.emulator_console_auth_token; KO: unknown command, try 'help' (adb authenticates to the console with /…/badhome/.emulator_console_auth_token, which must be a regular file, not a symlink, holding the emulator's token)","error_code":"VEGA_SCREENSHOT_FAILED","error_kind":"unknown"}

Raw adb emu screenrecord screenshot replies on that VVD (all exit 0): matching token OK\r\n + PNG; mismatched KO: authentication token does not match …\r\nKO: unknown command, try 'help'\r\n; missing or symlinked token KO: unknown command, try 'help'\r\n. captureVegaScreenshotPng and runEmuConsole from dist were run against each; the matching token still returns a PNG.

New tests in test/vega-screen.test.ts and test/emulator-console.test.ts fail on the pre-fix code; mutating the hint condition (any KO:, any line) or dropping it from runEmuConsole fails them too.

Checks: tsc --build, typecheck:tests, prettier, eslint, knip pass; tool-server vitest (6 shards) passes except flows/e2e-tool-aliases (81 vs 83 ids), which fails the same way locally on main and passes on CI.

… no PNG

adb emu exits 0 when the console refuses a command; the only sign is a KO: line on stdout. Include that reply in the no-PNG error so an auth-token mismatch reaches the user. Closes #1338.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…a capture

A missing or symlinked token makes adb skip auth, and the console then
answers the screenshot with only 'KO: unknown command'. Join the reply onto
one line, say when it is empty, and name the token file adb reads.
runEmuConsole reports the whole reply too, so a token mismatch no longer
loses its auth line behind the trailing verdict.

@latekvo latekvo left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Diplomat, Opus 5.5]: Review of the console-reply change, findings already fixed on the branch and answered in each thread. Two PR-description claims were also corrected: coverage was narrowed to screenshot and flow snapshot: steps (settle and failed-step captures swallow capture errors), and the verification no longer shows a single-line KO reply, since real adb prints two lines on a token mismatch. Out of scope, filed as #1589: a temp dir path with a space makes the capture fail with ...: OK and leaves a stray PNG in the emulator's cwd.

@latekvo
latekvo marked this pull request as ready for review October 24, 2026 23:05
…follows it

libbase defines O_NOFOLLOW as 0 on Windows, so a symlinked token works there.
Also pin that other KO: unknown replies get no token hint.

@latekvo latekvo left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Diplomat, Opus 5.5]: Second pass over the console-reply change: claims checked against AOSP adb/libbase source, sibling adb emu call sites, failure paths, telemetry export, and 13 mutants against the tool-server tests. One new finding below, plus a test gap on the existing hint-condition thread; both fixed on the branch. Out of scope, filed as #1698: the preview window's "Shut down" reports success when the console refuses adb emu kill.

@latekvo

latekvo commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Folded into #1753 as 9e88b93, to review together with the other capture fixes.

@latekvo latekvo closed this Nov 4, 2026
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.

Vega screenshot drops the emulator console's KO reply and fails with only 'emulator console wrote no PNG'

1 participant