fix(cli): make alt+t expand thinking on macOS Option-compose terminals - #5872
Conversation
On macOS, terminals in the default "Option as compose character" mode (iTerm2 "Normal", VS Code without macOptionIsMeta) turn Option+t into the dagger glyph "†" (U+2020) with no modifier metadata, so the app cannot tell Option was held — the "expand thinking" shortcut silently typed "†" into the prompt instead of toggling. Terminals that speak the Kitty keyboard protocol (e.g. Ghostty) report a real Alt+t event, which is why it already worked there. Rewrite a lone "†" to a synthetic Alt+t in the keypress pipeline. This both fires TOGGLE_THINKING_EXPANDED and, via the meta flag, stops the glyph from being inserted into the input buffer, so it behaves exactly like Alt+t. Scoped to darwin to avoid affecting legitimate "†" input on other platforms. Generated with AI Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Thanks for the PR! The technical approach looks solid — rewriting the † compose glyph to a synthetic Alt+t in the keypress pipeline is a clean, minimal fix for a real macOS terminal pain point.
However, the PR body doesn't follow the PR template. A few required sections are missing:
- Reviewer Test Plan (with
How to verify,Evidence (Before & After), andTested ontable) — this is the most important missing piece. Maintainers use it to confirm the fix works before merging. - Risk & Scope — what are the tradeoffs, what's out of scope, any breaking changes?
- Linked Issues — is there an open issue this closes?
Could you restructure the PR body to match the template? The technical content you've already written (root cause analysis, the fix, the test results) maps naturally onto the template sections.
中文说明
感谢贡献!技术方案本身很棒——在按键处理管道中将 † 组合字符改写为合成的 Alt+t,是解决 macOS 终端 Option 键编码问题的简洁方案。
但 PR 正文没有按照 PR 模板 来写,缺少几个必填部分:
- Reviewer Test Plan(包含
How to verify、Evidence (Before & After)和Tested on表格)——这是最重要的缺失部分,维护者需要通过它来确认修复有效后再合并。 - Risk & Scope——有哪些取舍?哪些不在范围内?是否有破坏性变更?
- Linked Issues——是否有关联的 issue?
能否按模板重新组织 PR 正文?你已经写好的技术内容(根因分析、修复方案、测试结果)可以很自然地映射到模板的各个部分。
— Qwen Code · qwen3.7-max
chiga0
left a comment
There was a problem hiding this comment.
Overview
Final Verdict: LGTM — Clean, surgical fix for a real macOS terminal pain point. The root cause analysis is thorough (Option-as-compose encoding difference, not a key-parsing bug), and the fix follows the existing alt+return normalization pattern already in the codebase.
Findings Summary
- Critical/Major: 0 items
- Minor: 0 items
- Nit: 0 items
Key Observations
The fix is minimal and well-scoped: one glyph rewrite († → Alt+t) in the keypress pipeline, guarded by process.platform === 'darwin' and !isPaste. Setting meta: true achieves both goals simultaneously — fires TOGGLE_THINKING_EXPANDED and prevents glyph insertion into the input buffer. Terminals that already work (Ghostty via Kitty protocol, Option-as-Meta via ESC t) never hit this branch.
Additional Audit Coverage
- Paste mode guard:
!isPastecorrectly prevents†in pasted content from being rewritten on macOS. Pasted dagger glyphs pass through unchanged. - Platform scoping:
process.platform === 'darwin'is the correct check. Linux/Windows users typing†(e.g., via compose key or character picker) are unaffected. - False positive risk: A macOS user deliberately typing
†into the prompt would have it intercepted. Extremely unlikely edge case, and the trade-off is well-justified — the(alt+t to expand)hint is now accurate on every terminal. - Precedent: Follows the exact same pattern as the existing
alt+returnnormalization (key.name === 'return' && key.sequence === '\x1b\r' → key.meta = true) two lines above. Consistent with codebase conventions. - Test quality: Tests mock
process.platformwithObject.defineProperty+finallycleanup. Both positive (darwin rewrite) and negative (linux passthrough) paths covered. Test structure mirrors existing Kitty protocol tests.
This review was generated by QoderWork AI
|
@qwen-code-ci-bot /triage |
yiliang114
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
|
@qwen-code /triage |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No review findings at blocker level. The † → Alt+t rewrite is correctly placed and well-tested.
A few minor defensive suggestions for consideration (not blockers):
- Modifier guard: Consider adding
!key.ctrl && !key.shift && !key.metato the rewrite condition. Compose-mode terminals deliver†with all modifiers false, so this is consistent today, but the defensive check is cheap. - Name guard: Consider adding
key.name === ''to assert the compose-character assumption explicitly. - Follow-up: The same compose-character problem affects Alt+m (Option+m → µ). Consider tracking this in a follow-up issue.
— qwen3.7-max via Qwen Code /review
|
Thanks for the PR, @chiga0! Template looks good ✓ — all required sections present. Direction: This fixes a real pain point. The Approach: The scope is tight — one constant, one conditional block, two tests. The rewrite sits right next to the existing The acknowledged tradeoff (a legitimate Moving on to code review. 🔍 中文说明感谢贡献,@chiga0! 模板完整 ✓ 方向: 这修复了一个真实的痛点。UI 中展示了 方案: 范围控制得很好——一个常量、一个条件块、两个测试。改写逻辑放在 已知的权衡(在 macOS 上合法输入的 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewIndependent proposal (before reading the diff): To fix the macOS Option-as-compose-character issue for Comparison: The PR's approach matches this exactly. Two files, +115/-0, focused entirely on the one fix:
No critical bugs, no security concerns, no AGENTS.md violations. Every edit serves the stated goal — no drive-by refactors, no scope creep. Reuse CheckThe Unit Test ResultsApplied the PR patch on top of
TypeScript typecheck: clean, no errors. Real-Scenario Testing (tmux)Note: This fix is macOS-specific ( Baseline: interactive mode with thinking promptAfter pressing Alt+t (thinking block expanded)The Verdict: Code is clean, tests pass, the fix is minimal and well-placed. The only thing this environment can't verify is the actual macOS terminal behavior — that requires a macOS reviewer to confirm. 中文说明代码审查独立方案(阅读 diff 前): 修复 macOS Option 组合字符模式下 对比: PR 的方案与此完全一致。两个文件,+115/-0,完全聚焦于这一个修复:
无关键 bug、无安全问题、无 AGENTS.md 违规。 每个编辑都服务于目标。 单测结果将 PR 补丁应用到 真实场景测试(tmux)注意: 此修复仅限 macOS。测试环境为 Linux,无法触发 基线: 交互模式下思考摘要正常显示 "(alt+t to expand)"。 结论: 代码整洁、测试通过、修复最小且位置合理。唯一无法验证的是 macOS 终端的实际行为,需要 macOS 审阅者确认。 — Qwen Code · qwen3.7-max |
|
Stepping back: this is exactly the kind of PR you want to see from a community contributor. The root cause analysis is spot-on — macOS terminals in default "Option as compose character" mode silently convert The implementation matches my independent proposal exactly. One constant, one conditional block, two tests — 9 lines of production code that solve the problem without touching anything else. The 95 unit tests pass (93 existing + 2 new), typecheck is clean, and the tmux baseline on Linux confirms the The prior If I had to maintain this in six months, I'd thank the author — the constant name and block comment tell the whole story of why this exists, so no one has to rediscover the terminal encoding rabbit hole. Approving. ✅ 中文说明退一步看:这正是社区贡献者应该提交的 PR 类型。根因分析准确——macOS 终端在默认"Option 作为组合字符"模式下会将 实现与我的独立方案完全一致。一个常量、一个条件块、两个测试——9 行生产代码解决问题,没有触及其他任何东西。 95 个单测通过(93 已有 + 2 新增),类型检查通过,Linux 上的 tmux 基线测试确认 之前的 如果六个月后需要维护这个代码,我会感谢作者——常量名和注释块完整解释了为什么需要这个改动,不需要重新发现终端编码的问题。 批准 ✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: CI still running.
The † → Alt+t rewrite is correctly placed after all early-return paths, well-guarded with process.platform === 'darwin' and !isPaste, and the key object mutation follows the existing pattern (e.g. the return-key meta rewrite above). Tests cover both the darwin positive case and the linux negative case with proper platform restoration. The !key.meta insert guard in text-buffer.ts correctly prevents the stale key.sequence from leaking into the input buffer.
LGTM ✅
— qwen3.7-max via Qwen Code /review
| ); | ||
| }); | ||
|
|
||
| it('rewrites macOS composed Option+t glyph "†" to Alt+t', () => { |
There was a problem hiding this comment.
[Suggestion] These two compose-glyph rewrite tests are placed inside describe('Enter key handling') but test macOS Option+t glyph rewriting, which is unrelated to Enter key handling. Moving them to their own describe('macOS compose-glyph rewrite') block would improve discoverability and match the file's convention of grouping tests by concern area (Escape, Tab/Backspace, paste mode, etc.).
— qwen3.7-max via Qwen Code /review
| if ( | ||
| process.platform === 'darwin' && | ||
| !isPaste && | ||
| key.sequence === OPTION_T_COMPOSED_GLYPH |
There was a problem hiding this comment.
[Suggestion] Consider adding a key.name === '' guard to the condition, matching the pattern already used for the backslash handler (~line 869: key.sequence === '\\' && !key.name). This ensures the rewrite only fires when the terminal did not recognize the keypress (empty name), preventing edge cases where a kitty-protocol fall-through or buffer overflow path delivers a pre-decoded † character with name: '†'.
| key.sequence === OPTION_T_COMPOSED_GLYPH | |
| process.platform === 'darwin' && | |
| !isPaste && | |
| key.name === '' && | |
| key.sequence === OPTION_T_COMPOSED_GLYPH |
— qwen3.7-max via Qwen Code /review
Both the triage job and the PR-review job run the qwen agent directly on the persistent self-hosted ECS pool with no per-run isolation. $HOME, /tmp and the workspace are reused between runs, so a prior run's agent session/memory (default ~/.qwen) or leftover draft comments (/tmp/stage-*.md, which survive git clean) can bleed into the next run. This surfaced on QwenLM#5874: its triage posted QwenLM#5872's review verbatim (wrong author, wrong approver, wrong diff), while the same run's internal stage actually exercised QwenLM#5874 — the PR id was correct, the agent state was stale. Point QWEN_HOME at a per-run $RUNNER_TEMP/qwen-home on the Qwen step and reset it (plus /tmp/stage-*.md) in the pre-run cleanup, for both jobs. QWEN_HOME relocates the entire global qwen dir (storage.ts), so this isolates sessions/memory/temp without touching $HOME and disturbing git/npm. The tmux-testing job is already container-isolated and unchanged. Refs QwenLM#5882
What this PR does
Fixes the "expand thinking" shortcut (
Alt+t) on macOS terminals that use the default "Option as compose character" mode — specifically iTerm2 (Normal mode) and VS Code's integrated terminal (withoutmacOptionIsMeta). These terminals deliverOption+tas the dagger glyph†(U+2020) with no modifier metadata, so the app can't tell Option was held — the shortcut silently typed†into the prompt instead of toggling the thinking summary. The fix rewrites a lone†to a syntheticAlt+tin the keypress pipeline, scoped todarwinonly. Terminals that speak the Kitty keyboard protocol (e.g. Ghostty) already report a realAlt+tevent and are unaffected.Why it's needed
The thinking summary UI shows
(alt+t to expand)but the shortcut only worked in Ghostty and terminals configured with "Option as Meta". Most macOS users on iTerm2 or VS Code — the two most popular terminals — would pressAlt+tand get a†inserted into their prompt instead. This makes the shortcut work everywhere without requiring users to reconfigure their terminal's Option key behavior.Reviewer Test Plan
How to verify
qwenand trigger a response that shows the thinking summary (∴ Thought for Xs (alt+t to expand)).Option+t— the thinking block should expand/collapse. Previously it typed†into the prompt.Evidence (Before & After)
Before:
Option+tin iTerm2/VS Code inserts†into the prompt; thinking summary does not expand.After:
Option+tin iTerm2/VS Code toggles the thinking summary, matching Ghostty behavior.Tested on
Environment (optional)
iTerm2 (default Option=Normal), VS Code integrated terminal, Ghostty — all on macOS.
Risk & Scope
†character typed via other means on macOS would also be rewritten toAlt+t. This is extremely unlikely in practice since†is rarely typed in a terminal coding context.darwin).Linked Issues
中文说明
本 PR 做了什么
修复了 macOS 终端在默认"Option 作为组合字符"模式下(iTerm2 的 Normal 模式和 VS Code 集成终端未开启
macOptionIsMeta时),Alt+t展开思考摘要快捷键无效的问题。这些终端将Option+t转换为匕首符号†(U+2020),且不携带修饰键信息,导致应用无法识别 Option 键被按下——快捷键会静默地将†输入到提示符中,而非展开思考摘要。修复方案是在按键管道中将单独的†重写为合成的Alt+t,仅在darwin平台生效。使用 Kitty 键盘协议的终端(如 Ghostty)已经上报真实的Alt+t事件,不受影响。为什么需要这个改动
思考摘要 UI 显示了
(alt+t to expand)提示,但该快捷键只在 Ghostty 和配置了"Option as Meta"的终端中有效。大多数 macOS 用户使用 iTerm2 或 VS Code——这两个最流行的终端——按下Alt+t后只会在提示符中插入†。此修复让快捷键在所有终端中都能正常工作,无需用户修改终端的 Option 键配置。审阅者测试计划
qwen,触发一个包含思考摘要的响应(∴ Thought for Xs (alt+t to expand))。Option+t——思考块应展开/折叠。此前会输入†到提示符中。测试环境
风险与范围
†字符也会被重写为Alt+t。实际风险极低,因为终端编码场景中几乎不会输入†。darwin)。