mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-09-12 14:46:02 +00:00
* feat(opentui): add the build, CI and parity tooling for the renderer migration Batch 7 of the ink→OpenTUI migration (#8662): everything the renderer needs to be built, verified and shipped — ink stays the default. Bundled builds silently lose code-block syntax highlighting because @opentui/core resolves its tree-sitter assets package-relatively, which misses inside the esbuild bundle. Relocate the runtime assets (parser worker, grammar wasms/scm, web-tree-sitter, native render library) next to the bundle, and gate OTUI_ASSET_ROOT on the tree being complete for the running platform — @opentui/core throws on any missing key, so an incomplete relocation must fall back instead of half-configuring. Standalone archives gain a Bun runtime (the renderer needs bun:ffi) and per-target @opentui platform packages via the existing release packaging, with --runtime=node restoring classic packaging. The renderer matrix drives interactive E2E under node+ink and bun+opentui, but Batch 6's renderer gate silently falls back to ink on an unsupported runtime, so a green opentui leg could be a false green. QWEN_TUI_RENDERER_STRICT turns that fallback into a loud startup failure for the matrix legs only; user-facing default behavior is unchanged. Parity tooling: a tui-parity workflow with component snapshots and a no-flicker gate (zero full-screen clears, balanced DEC 2026) that runs offline without model credentials, an ink→opentui codemod with a self-test, the PTY/tmux comparison harnesses, and the cli scripts/ tree is now covered by the package typecheck. * fix(ci): build all packages in the tui-parity jobs With prepare skipped, npm ci leaves the CLI's workspace dependencies unbuilt, and a workspace-scoped build of the CLI alone resolves their types from a dist that does not exist yet. The parity jobs must run the repository-root build like the other E2E legs. * fix(build): enforce renderer strict mode and drop musl from standalone packages Address yiliang114's review on the Batch 7 build/CI work: - propagate QWEN_TUI_RENDERER_STRICT into RendererSelection so the dispatcher also fails loudly when the OpenTUI entry returns false or throws, closing the false-green path in the E2E renderer matrix - stage the OpenTUI platform packages only for the bun runtime and drop the -musl variants: the bundled Bun binaries are glibc-linked and cannot start on musl hosts, so the musl render packages claimed support the archives cannot deliver - wipe dist/opentui-assets before re-copying so a stale tree from an earlier bundle cannot satisfy the key-existence runtime gate - route the script-PTY capture branch through spawnScriptPty so the argv form follows the platform, and give it the destroy() that finish() expects from the node-pty-like interface - harden pty-e2e.sh (set -euo pipefail, mktemp+trap, full TCL escaping of the prompt) and tmux-compare.sh (missing-binary check, mktemp+trap) - pin the CI Bun setups to 1.3.14 = DEFAULT_BUN_VERSION so an upstream Bun release cannot flip the gating legs on its own * fix(build): keep classic Node packaging as the standalone default The temporary OpenTUI preview flavor (--runtime=bun) stays available but no longer replaces the default release archives, keeping Batch 7 additive for existing standalone users. * fix(scripts): compare prettier-normalized output in the codemod self-test Address F1 and F3 from the deep verification report: - The self-test compared the codemod's raw output against the prettier-formatted fixtures/after.tsx, so 2 of 17 tests failed as committed. Normalize both sides through the repo prettier config before comparing (tests 1 and 6); the harness awaits because prettier 3's format() is async-only. - Refresh the tui-parity.yml baseline entry from 2190 to the measured 2508 bytes so the ratchet tracks real growth. * fix(build): gate standalone opentui assets by runtime flavor Node archives carry no opentui-assets tree at all: the renderer needs bun:ffi, and cross-built archives would only hold another platform's native library that the all-or-nothing asset gate could never activate. Bun archives now prune every @opentui/core-* directory that does not belong to the build target, dropping the build host's library from the archive. The npm-package allowlist comment is corrected to match the observed fallback behavior. * test(cli): cover the OpenTUI strict-mode dispatch and e2e renderer matrix main() now has coverage for the four dispatch outcomes: strict mode throws both when the OpenTUI entry declines to start and when it boots with an error, and non-strict mode falls through to startInteractiveUI. resolveE2eCliCommand gains coverage for the opentui leg — bun on PATH resolves to bun, and a missing bun fails with the actionable error.
33 lines
1.4 KiB
Bash
Executable file
33 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
||
# tmux 前后对比 harness:左 pane 跑原版 qwen(ink),右 pane 跑 qwen2(opentui),
|
||
# 发送相同输入,抓取两 pane 输出做对比(渲染/闪屏/鼠标/显示 parity 自测)。
|
||
# 用法: ./tmux-compare.sh [prompt] (需本机 qwen-code 凭据跑真实任务;无凭据时用 qwen2-demo)
|
||
set -euo pipefail
|
||
PROMPT="${1:-hi}"
|
||
SESS=qwcmp
|
||
S=$(command -v qwen || true)
|
||
S2=$(command -v qwen2 || true)
|
||
if [ -z "$S" ] || [ -z "$S2" ]; then
|
||
echo "需要 qwen 和 qwen2 都在 PATH 中(当前: qwen=${S:-缺失}, qwen2=${S2:-缺失})" >&2
|
||
exit 1
|
||
fi
|
||
INK_OUT=$(mktemp /tmp/qwen-ink.XXXXXX.txt)
|
||
OTUI_OUT=$(mktemp /tmp/qwen-opentui.XXXXXX.txt)
|
||
trap 'rm -f "$INK_OUT" "$OTUI_OUT"' EXIT
|
||
tmux kill-session -t $SESS 2>/dev/null || true
|
||
tmux new-session -d -s $SESS -x 120 -y 40 \; \
|
||
split-window -h \; \
|
||
select-layout tiled >/dev/null
|
||
tmux send-keys -t $SESS:0.0 "$S" Enter
|
||
tmux send-keys -t $SESS:0.1 "$S2" Enter
|
||
sleep 6
|
||
# 发送相同 prompt
|
||
tmux send-keys -t $SESS:0.0 "$PROMPT" Enter
|
||
tmux send-keys -t $SESS:0.1 "$PROMPT" Enter
|
||
sleep 12
|
||
tmux capture-pane -p -t $SESS:0.0 > "$INK_OUT"
|
||
tmux capture-pane -p -t $SESS:0.1 > "$OTUI_OUT"
|
||
tmux kill-session -t $SESS 2>/dev/null || true
|
||
echo "=== ink (original) ==="; tail -20 "$INK_OUT"
|
||
echo "=== opentui (qwen2) ==="; tail -20 "$OTUI_OUT"
|
||
echo "=== diff (behavior) ==="; diff "$INK_OUT" "$OTUI_OUT" | head -40 || true
|