fix(cli): gate mintty OSC 8 detection on TERM_PROGRAM_VERSION ≥ 3.3 (#4420)#4451
Conversation
…4420) mintty added OSC 8 in 3.1 and hardened it in 3.3. Older builds — still bundled with some Git-for-Windows distros and developer environments like Laragon — print the raw `\x1b]8;;url\x07` bytes as visible garbage instead of silently ignoring them. The previous unconditional `case 'mintty': return true` deviated from the upstream `supports-hyperlinks` library (which rejects all of win32 outside WT_SESSION) and let those old mintty users see escape bytes in their UI. Gate on TERM_PROGRAM_VERSION (set by mintty since 2.7 in 2017 — a missing value implies an ancient build, so we refuse rather than guess). Users on mintty 3.1–3.2.x who know their build works can still opt in with FORCE_HYPERLINK=1. This fixes the OSC 8 component of #4420 (the "garbled UI on Windows + Git Bash" report). The Ink 7 render interaction and terminalRedrawOptimizer angles flagged in the same triage need separate Windows-environment testing; `QWEN_CODE_LEGACY_ERASE_LINES=1` remains the documented escape hatch for those.
📋 Review SummaryThis PR addresses issue #4420 by fixing OSC 8 hyperlink detection for mintty terminals on Windows. The change gates OSC 8 support on 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
case 'mintty':
return isMinttyVersionSupported(env['TERM_PROGRAM_VERSION']);This would match the pattern used elsewhere and make the version logic self-documenting. 🔵 Low
✅ Highlights
|
wenshao
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: self-PR; CI still running. LGTM! ✅ — qwen-latest-series-invite-beta-v34 via Qwen Code /review
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
Mirrors the Warp/Hyper pattern: after asserting auto-detection rejects an older mintty build, set FORCE_HYPERLINK=1 and verify it opts back in. The PR description for #4451 documents this contract for users on mintty 3.1–3.2 who know their build's OSC 8 implementation works; pinning it as a test guards against a future refactor reordering the early-exit checks. Addresses review feedback on #4451.
wenshao
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: self-PR.
Terminal-only notes (not blocking):
parseVersionparseInt(n,10)||0can produceInfinityfor ~341-digit inputs (pre-existing;Number.isFiniteguard recommended)- Redundant
!TERM_PROGRAM_VERSIONguard in mintty case —parseVersionzero-value fallback already covers this - VTE packed-integer heuristic in
parseVersionapplies globally; consider scoping to VTE-only
— DeepSeek/deepseek-v4-pro via Qwen Code /review
wenshao
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: self-PR. — qwen-latest-series-invite-beta-v38 via Qwen Code /review
ReviewVerdict: ship it, but don't close #4420 on merge. Why this is the right move
Important caveat — don't close #4420 on mergeThe PR description already says this, but worth making it loud:
The #4420 triage flagged three causes (Ink 6→7 render pipeline / OSC 8 / terminalRedrawOptimizer). This PR addresses only one, and probably not the dominant one. The Ink 7 rendering interaction with MinTTY is still the primary suspect and untouched. Please keep #4420 open after merge until someone with a Windows + Git Bash environment confirms the rest. On the bot's "extract
|
Local maintainer validation — all gates green ✅Reviewed at head Environment
Results
All CI checks green
Fix analysisBefore (broken): case 'mintty':
// mintty ≥ 3.3 supports OSC 8; older installs are extremely rare
// and still degrade safely (terminal just prints the visible bytes).
return true;The comment was wrong: older mintty builds (still shipping in some Git-for-Windows distros and developer environments like Laragon) print raw After (fixed): Gates on case 'mintty':
if (!env['TERM_PROGRAM_VERSION']) return false;
return version.major > 3 || (version.major === 3 && version.minor >= 3);
8 exact version cases tested (the single new
E2E limitationAttempted an e2e that drives the compiled Reviewer recommendationSafe to merge.
— Maintainer local validation, run on |
Summary
Fixes the OSC 8 component of #4420 — garbled UI on Windows + Git Bash after upgrading to v0.16.0.
osc8.tswas unconditionally returningtrueforTERM_PROGRAM=mintty, deviating from upstreamsupports-hyperlinks(which rejects all of win32 outsideWT_SESSION).\x1b]8;;url\x07bytes as visible garbage instead of silently ignoring them.TERM_PROGRAM_VERSIONto be present (mintty has set it since 2.7 in 2017 — missing implies an ancient build) and version ≥ 3.3. Users on mintty 3.1–3.2.x who know their build works can still opt in viaFORCE_HYPERLINK=1.Scope note
The #4420 triage flagged three potential causes:
This PR addresses only (2). The screenshots in the issue look more like Ink 7's previous-frame-not-erased behavior than OSC 8 escape garbage, so this fix alone may not fully resolve the user's report — but it's clearly the right move regardless (matches upstream behavior, removes a Windows-specific hazard).
QWEN_CODE_LEGACY_ERASE_LINES=1remains the documented escape hatch for (1) and (3) until they get separate Windows-environment testing.Test plan
npx vitest run packages/cli/src/ui/utils/osc8.test.ts— 79 tests passnpx vitest run packages/cli/src/ui/utils/— 670 tests pass (32 files)