Repository navigation
feat(review): capture-tui — rendering claims get pixels, not prose (Phase 2) #8388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
be8ad2d
feat(review): capture-tui — rendering claims get pixels, not prose (P…
wenshao 25c325a
Merge branch 'main' into feat/review-capture-tui
wenshao 254e8ac
fix(review): capture-tui round-1 review fixes — refusal contract, arg…
wenshao c6b4964
fix(review): capture-tui round-2 review fixes — NaN durations, wedged…
wenshao ac04c0b
fix(review): capture-tui probes the binary, not `which`
wenshao fb3c6de
test(review): make capture-tui's no-tmux refusal testable everywhere
wenshao a389db3
fix(review): capture-tui bot-round-2 fixes — mkdir refusal, ladder co…
wenshao 71d74d2
fix(review): capture-tui bot-round-3 fixes — pane holder, logical mat…
wenshao 14d25e7
fix(review): capture-tui bot-round-4 fixes — holder tail-proofing, ev…
wenshao c238027
style(review): drop expect() message arg — vitest/valid-expect allows…
wenshao 9fe1d5f
feat(review): capture-tui --ready — gate keystrokes on a rendered marker
wenshao 88b34e6
Merge branch 'main' into feat/review-capture-tui
qwen-code-dev-bot 99a4b5e
fix(review): capture-tui phase-2 review fixes — no stale artifacts, t…
wenshao 6d62c58
Merge remote-tracking branch 'origin/main' into feat/review-capture-tui
qwen-code-dev-bot 2eb45c0
fix(review): capture-tui bot-round-5 fixes — the timed-out review's f…
wenshao f573380
Merge branch 'feat/review-capture-tui' of https://github.com/QwenLM/q…
qwen-code-dev-bot a5f3578
style(review): drop expect() message args — vitest/valid-expect allow…
wenshao 6f89e58
fix(tests): sync qwen-resolve-workflow expectations with externalized…
qwen-code-dev-bot 3840f7d
fix(review): capture-tui bot-round-6 fixes — clear-first ordering, si…
wenshao a661b1f
test(ci): pin the timeout-advice branch CONDITION (R4-21)
wenshao 55c9887
Merge remote-tracking branch 'origin/main' into feat/review-capture-tui
wenshao e46c9a0
fix(review): correct the -N version claim the R4-2 fix missed (JSDoc)
wenshao 805fad2
Merge branch 'main' into feat/review-capture-tui
wenshao 2cf87df
fix(review): stabilize capture-tui evidence tests and reap orphans (#…
qwen-code-dev-bot 3bbab46
fix(tests): gate install-script zip packaging tests on POSIX zip avai…
qwen-code-dev-bot b864370
fix(review): capture-tui bot-round-7 fixes — the R5 ledger from the s…
wenshao d78b67d
fix(review): capture-tui R5 findings — holder SIGINT, png size, zip g…
qwen-code-dev-bot 2f5d7cb
Merge branch 'main' into feat/review-capture-tui
qwen-code-dev-bot 59ccbbd
fix(review): capture-tui round-8 follow-through — the C-c race and th…
wenshao 22b9da1
fix(review): capture-tui round-9 follow-through — the -L position pin…
wenshao 9c5d734
Merge remote-tracking branch 'origin/main' into feat/review-capture-tui
d78759f
fix(review): capture-tui round-9 fixes — holder loop, escaped sentine…
wenshao dacd3ed
fix(review): probe deadline as a seam, pinned against a hanging shim …
wenshao 8a2c06e
fix(review): pin the escaped-readyFile and loop-hold Critical fixes (…
wenshao 5d830e0
test(core): glob external-path test uses a dedicated empty dir, not /tmp
wenshao 7606107
fix(review): capture-tui round-10 fixes — layer-0 trap, wedged-vs-abs…
wenshao fa23ef4
test(review): pin the render-window signal disposition end to end
wenshao e719bc6
fix(review): capture-tui round-11 fixes — SIGKILL belts, dual-base sw…
wenshao d43932e
test(review): cleanup kill assertions carry the SIGKILL belt option
wenshao cc83296
Merge remote-tracking branch 'origin/main' into feat/review-capture-tui
wenshao 1c58cba
fix(review): capture-tui round-12 fixes — belt-cut reap, capture-shap…
wenshao 8b9a1f4
fix(review): capture-tui round-13 fix — REAP set pin lives outside th…
wenshao b8edd8c
fix(review): never recursively delete at artifact paths — a directory…
wenshao 9aede43
fix(review): statSync import for the blocker-survival pins
wenshao 3208d23
fix(review): capture-tui round-12 suggestions — dual-base truth, belt…
wenshao 401987d
Merge remote-tracking branch 'origin/main' into feat/review-capture-tui
wenshao fb662c7
fix(review): capture-tui round-14 — land the pins the replies claimed…
wenshao dd490b0
Merge branch 'main' into feat/review-capture-tui
qwen-code-dev-bot 8bacf5b
fix(review): drain queued signals via setImmediate — a 0ms timer race…
wenshao 9d12f4a
fix(review): round-13 criticals — deletion is only ever this run's own
wenshao b4c5b43
Merge remote-tracking branch 'origin/main' into wt-8388-work
wenshao 52de532
fix(review): round-13 suggestions — fail fast, model bash, drop dead …
wenshao 61ae1f8
fix(review): never let a partial artifact outlive its failed write
wenshao 00cbac4
fix(review): round-14 criticals — evidence must be what THIS run rend…
wenshao 3470023
fix(review): round-14 suggestions — pin what the shell runs, not what…
wenshao 3ccefa6
fix(review): drop the banned two-argument expect in the probe-refusal…
wenshao 7056931
fix(review): round-15 criticals — no fabricated bytes, no foreign del…
wenshao 824d64e
fix(review): round-15 suggestions — reachable caps, honest probes, qu…
wenshao e9e4594
fix(review): round-16 criticals — the watchdog must not answer a keyp…
wenshao 71a1537
chore(review): split the CI tooling step and its pin out to #8792
wenshao e7bcfca
fix(review): round-16 production defects — a hang is not a refusal
wenshao d8410d3
fix(review): a symlink is an occupant — writes must not escape the --…
wenshao 544083e
fix(review): a failing stderr must not silence the refusal JSON
wenshao dbdcb81
test(review): restore the probe seams in a hook, not per test
wenshao b56348d
test(review): actually install the probe-restore hook
wenshao f65fd74
fix(review): a partial cleanup, an unbounded read, and a sentinel tha…
wenshao a1b5bed
test(review): make five pins discriminate, and retire one that cannot
wenshao d5e293e
test(review): contain the fd-exhaustion test in a child process
wenshao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,250 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { afterEach, beforeEach, describe, expect, it } from 'vitest'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { probes, runCaptureTui } from './capture-tui.js'; | ||
|
|
||
| const hasTmux = spawnSync('tmux', ['-V']).status === 0; | ||
| const hasFreeze = spawnSync('freeze', ['--version']).status === 0; | ||
|
|
||
| // The no-tmux refusal fires exactly where the real-tmux block below is | ||
| // skipped, so it gets its own suite that runs EVERYWHERE, driving the probe | ||
| // seam instead of the real binary: a refactor that inverts the probe must | ||
| // fail here, not surface as a raw ENOENT on some tmux-less host. | ||
| describe('capture-tui without tmux (probe seam)', () => { | ||
| const realTmux = probes.tmux; | ||
| beforeEach(() => { | ||
| process.exitCode = undefined; | ||
| }); | ||
| afterEach(() => { | ||
| probes.tmux = realTmux; | ||
| process.exitCode = undefined; | ||
| }); | ||
|
|
||
| it('refuses with the contract — exit 3, no artifacts, no throw', () => { | ||
| probes.tmux = () => false; | ||
| const dir = mkdtempSync(join(tmpdir(), 'capture-tui-notmux-')); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| try { | ||
| runCaptureTui({ | ||
| command: 'printf hi', | ||
| cwd: dir, | ||
| cols: 80, | ||
| rows: 24, | ||
| settleMs: 0, | ||
| until: undefined, | ||
| keys: undefined, | ||
| out: join(dir, 'cap'), | ||
| timeoutMs: 1000, | ||
| } as never); | ||
| expect(process.exitCode).toBe(3); | ||
| expect(existsSync(join(dir, 'cap.ans'))).toBe(false); | ||
| expect(existsSync(join(dir, 'cap.json'))).toBe(false); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| } finally { | ||
| rmSync(dir, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| // The command boundary drives REAL tmux — a private-server capture the mocks | ||
| // cannot vouch for (the isolation property IS the exec shape). Skipped where | ||
| // tmux is absent; the pure plan shapes stay pinned in tui-capture.test.ts | ||
| // everywhere. | ||
| describe.skipIf(!hasTmux)('capture-tui (real tmux)', () => { | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| let dir: string; | ||
| beforeEach(() => { | ||
| dir = mkdtempSync(join(tmpdir(), 'capture-tui-')); | ||
| process.exitCode = undefined; | ||
| }); | ||
| afterEach(() => { | ||
| rmSync(dir, { recursive: true, force: true }); | ||
| process.exitCode = undefined; | ||
| }); | ||
|
|
||
| function run(over: Record<string, unknown> = {}): void { | ||
| runCaptureTui({ | ||
| command: 'printf "HELLO-\\033[31mRED\\033[0m-WORLD\\n"; sleep 30', | ||
| cwd: dir, | ||
| cols: 80, | ||
| rows: 24, | ||
| settleMs: 0, | ||
| // Settle on CONTENT, not a fixed delay: under CI load a fixed delay | ||
| // races the shell's startup, captures a blank pane, and the ladder | ||
| // assertions turn flaky (measured once: empty .ans → freeze bounds | ||
| // error → 'png' expectation failed). | ||
| until: 'WORLD', | ||
| keys: undefined, | ||
| out: join(dir, 'cap'), | ||
| timeoutMs: 10_000, | ||
| ...over, | ||
| } as never); | ||
| } | ||
|
|
||
| it('captures the real rendering into .ans and records the ladder honestly', () => { | ||
| run(); | ||
| expect(process.exitCode).toBeUndefined(); | ||
| const ans = readFileSync(join(dir, 'cap.ans'), 'utf8'); | ||
| expect(ans).toContain('HELLO-'); | ||
| expect(ans).toContain('WORLD'); | ||
| // The escapes survived (-e): the red text carries its SGR bytes. | ||
| expect(ans).toContain('[31m'); | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'cap.json'), 'utf8')); | ||
| expect(['png', 'ans-only']).toContain(manifest.evidence); | ||
| if (hasFreeze) { | ||
| expect(manifest.evidence).toBe('png'); | ||
| expect(existsSync(join(dir, 'cap.png'))).toBe(true); | ||
| } else { | ||
| expect(manifest.degradedBecause).toContain('freeze'); | ||
| } | ||
| }); | ||
|
|
||
| it('leaves no tmux server behind — the isolation is also the cleanup', () => { | ||
| run(); | ||
| // Any server this run created is named qwen-review-capture-<ourpid>-…; | ||
| // asking it for sessions must fail because the server is gone. | ||
| const probe = spawnSync('bash', [ | ||
| '-c', | ||
| `for s in $(ls /tmp/tmux-$(id -u)/qwen-review-capture-${process.pid}-* 2>/dev/null); do echo "$s"; done`, | ||
| ]); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| expect((probe.stdout ?? Buffer.from('')).toString().trim()).toBe(''); | ||
| }); | ||
|
|
||
| it('kills the processes the capture started — not just the socket file', () => { | ||
| // The socket probe above can't distinguish "server reaped" from "we | ||
| // unlinked the socket of a live server": the cleanup path removes the | ||
| // socket itself. This probe asks the question that matters — is the | ||
| // process the capture launched actually dead? | ||
| const pidFile = join(dir, 'shell.pid'); | ||
| run({ | ||
| command: `echo $$ > "${pidFile}"; printf "PIDDED\\n"; sleep 30`, | ||
| until: 'PIDDED', | ||
| }); | ||
| const pid = Number(readFileSync(pidFile, 'utf8').trim()); | ||
| expect(Number.isInteger(pid) && pid > 1).toBe(true); | ||
| // kill-server delivers the reap asynchronously; give it a beat. | ||
| let alive = true; | ||
| for (let i = 0; i < 40 && alive; i++) { | ||
| try { | ||
| process.kill(pid, 0); | ||
| spawnSync('sleep', ['0.05']); | ||
| } catch { | ||
| alive = false; | ||
| } | ||
| } | ||
| expect(alive).toBe(false); | ||
| }); | ||
|
|
||
| it('settles by regex when --until matches, and says so', () => { | ||
| run({ until: 'WORLD', settleMs: 0 }); | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'cap.json'), 'utf8')); | ||
| expect(manifest.settledBy).toBe('until-match'); | ||
| }); | ||
|
|
||
| it('captures anyway on --until timeout and records the degraded settle', () => { | ||
| run({ until: 'NEVER-APPEARS', timeoutMs: 1500, settleMs: 0 }); | ||
| expect(process.exitCode).toBeUndefined(); | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'cap.json'), 'utf8')); | ||
| expect(manifest.settledBy).toBe('timeout'); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| // The field whose contract is "why the ladder stopped" carries the late | ||
| // frame too, not just the freeze rung. | ||
| expect(manifest.degradedBecause).toContain('--until never matched'); | ||
| const ans = readFileSync(join(dir, 'cap.ans'), 'utf8'); | ||
| expect(ans).toContain('HELLO-'); | ||
| }); | ||
|
|
||
| it('refuses NaN durations instead of hanging on them', () => { | ||
| // Atomics.wait treats a NaN timeout as INFINITY, and a NaN deadline | ||
| // never expires — `--settle-ms abc` must refuse, not block forever. | ||
| run({ until: undefined, settleMs: Number.NaN }); | ||
| expect(process.exitCode).toBe(3); | ||
| process.exitCode = undefined; | ||
| run({ timeoutMs: Number.NaN }); | ||
| expect(process.exitCode).toBe(3); | ||
| expect(existsSync(join(dir, 'cap.ans'))).toBe(false); | ||
| }); | ||
|
|
||
| it('sends --keys tokens verbatim, one per token', () => { | ||
| runCaptureTui({ | ||
| command: 'cat', | ||
| cwd: dir, | ||
| cols: 80, | ||
| rows: 24, | ||
| settleMs: 800, | ||
| until: 'typed-input', | ||
| keys: ['typed-input', 'Enter'], | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| out: join(dir, 'keys'), | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| timeoutMs: 10_000, | ||
| } as never); | ||
| const ans = readFileSync(join(dir, 'keys.ans'), 'utf8'); | ||
| expect(ans).toContain('typed-input'); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| }); | ||
|
|
||
| it('refuses degenerate geometry with the refusal contract', () => { | ||
| run({ cols: 3 }); | ||
| expect(process.exitCode).toBe(3); | ||
| expect(existsSync(join(dir, 'cap.ans'))).toBe(false); | ||
| }); | ||
|
|
||
| it('refuses an empty command', () => { | ||
| run({ command: ' ' }); | ||
| expect(process.exitCode).toBe(3); | ||
| }); | ||
|
|
||
| it('refuses an invalid --until regex before anything starts', () => { | ||
| run({ until: '[' }); | ||
| expect(process.exitCode).toBe(3); | ||
| // Refused up front: no capture artifacts, and no server was ever started | ||
| // (the socket dir carries no entry for this pid — nothing to race). | ||
| expect(existsSync(join(dir, 'cap.ans'))).toBe(false); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| expect(existsSync(join(dir, 'cap.json'))).toBe(false); | ||
| }); | ||
|
|
||
| it('records a fixed-delay settle honestly when no --until is given', () => { | ||
| run({ until: undefined, settleMs: 600 }); | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'cap.json'), 'utf8')); | ||
| expect(manifest.settledBy).toBe('fixed-delay'); | ||
| }); | ||
|
|
||
| it('degrades to ans-only when freeze is unavailable, and says why', () => { | ||
| // Through the probe seam, so the freeze-less rung is pinned even on | ||
| // hosts that have freeze installed. | ||
| const realFreeze = probes.freeze; | ||
| probes.freeze = () => false; | ||
| try { | ||
| run(); | ||
| } finally { | ||
| probes.freeze = realFreeze; | ||
| } | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'cap.json'), 'utf8')); | ||
| expect(manifest.evidence).toBe('ans-only'); | ||
| expect(manifest.pngPath).toBeNull(); | ||
| expect(manifest.degradedBecause).toContain('freeze is not installed'); | ||
| expect(existsSync(join(dir, 'cap.png'))).toBe(false); | ||
| }); | ||
|
|
||
| it('sends dash-leading keys as keys, not as send-keys flags', () => { | ||
| runCaptureTui({ | ||
| command: 'cat', | ||
| cwd: dir, | ||
| cols: 80, | ||
| rows: 24, | ||
| settleMs: 0, | ||
| until: '-lDONE', | ||
| keys: ['-l', 'DONE', 'Enter'], | ||
| out: join(dir, 'dash'), | ||
| timeoutMs: 10_000, | ||
| } as never); | ||
| // Without `--` in the plan, tmux eats `-l` as its literal flag (exit 0, | ||
| // nothing typed) and the pane would read "DONE" — the corruption is | ||
| // silent, which is exactly why this pins the rendered text. | ||
| const manifest = JSON.parse(readFileSync(join(dir, 'dash.json'), 'utf8')); | ||
| expect(manifest.settledBy).toBe('until-match'); | ||
| expect(readFileSync(join(dir, 'dash.ans'), 'utf8')).toContain('-lDONE'); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.