Repository navigation
feat(terminal): Korean Won (₩) → backquote key mapping for Korean keyboards - #13104
Conversation
📝 WalkthroughWalkthroughAdds the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ebbc445f-a684-4430-ad6c-2fb08c9f5670
📥 Commits
Reviewing files that changed from the base of the PR and between 38275c2 and eda76a740fe032890719768021141827e8ce3001.
📒 Files selected for processing (12)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/renderer/src/components/settings/TerminalMacKeyboardSection.tsxsrc/renderer/src/components/settings/terminal-advanced-platform-search.tssrc/renderer/src/components/settings/terminal-search.test.tssrc/renderer/src/components/settings/terminal-search.tssrc/renderer/src/components/terminal-pane/terminal-korean-won-input.test.tssrc/renderer/src/components/terminal-pane/terminal-korean-won-input.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/constants.tssrc/shared/types.ts
|
Thanks! I'm working on a larger IME change but I let me look into this one and ensure it gets resolved! |
|
Heads-up on a merge-order conflict, from the IME remediation branch (#12560) — plus a note that I think this PR is worth landing. The conflict. #12560 removes the first-party terminal IME layer entirely (first-party terminal-IME source files go to zero; composition moves back to a patched xterm). Two things this PR depends on are deleted there:
Both PRs also modify #12560 is expected to merge first, so the live input-source gate here will need rebasing onto whatever replaces it. Flagging early so it isn't a surprise at merge time — the feature itself is unaffected, only the mechanism it queries. On the merits, from the IME work: this is measured, not speculative. Sealed hardware evidence on macOS shows the grave key emitting Worth adding to the motivation: native terminals don't need this setting because they honour a user's own One consequence worth stating explicitly in the PR: with this on, ₩ becomes untypable in the terminal. That seems right for a currency symbol versus a shell metacharacter, but it should be a documented trade rather than a surprise. Two small things from adjacent work that may be useful here:
|
|
Thanks for the detailed review! Quick alignment notes on the two implementation points:
Also addressed in the PR description:
The settings copy was also updated to state the Korean-input-source precondition (per the CodeRabbit Minor finding). Thanks for shepherding this one! |
Korean keyboard users type markdown code fences and shell backquotes on the key that US layouts reserve for ` — 두벌식 and 세벌식 390 put ₩ there, 세벌식 최종 puts *, so there was no way to type a backquote without switching layouts. Add a Mac-only terminal setting, "Korean Won (₩) to Backquote (`)", that rewrites the plain backquote-position keystroke to backquote while a Korean input source is active. It sits in Terminal → Advanced, right below the existing JIS Yen (¥) to Backslash (\) mapping. The rewrite keys on the keystroke position alone — no character or layout-variant knowledge — and follows the live input source through the existing MacNativeTextInputSourceTracker, which refreshes on focus and keyboard activity (Caps Lock / 한영 input switches never blur the window). Modified chords and IME-composed events pass through untouched. Covered by resolver and input-source tracker unit tests; verified manually in the GUI.
State in the setting copy that the backquote rewrite applies only while a Korean input source is active, and add JSDoc to the Korean Won resolver exports (addresses CodeRabbit pre-merge docstring coverage and copy-clarity findings).
1c94b50 to
e658fac
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Rebase complete — #12560 landed and this PR is now MERGEABLE against the new main. What changed to survive the IME remediation:
Verified: resolver + gate tests pass, typecheck and lint green. One pre-existing note: 5 IME/xterm composition test files fail on plain |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/lib/keyboard-layout/korean-input-source.ts (1)
1-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce the module header comment.
Keep the physical-key rationale. Remove the layout inventory and macOS preference implementation details. Move long operational details to documentation if needed.
As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3454e6c3-98ce-40c5-ab44-dc2ba39705cb
📒 Files selected for processing (15)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/renderer/src/components/settings/TerminalMacKeyboardSection.tsxsrc/renderer/src/components/settings/terminal-advanced-platform-search.tssrc/renderer/src/components/settings/terminal-search.test.tssrc/renderer/src/components/settings/terminal-search.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-korean-won-input.test.tssrc/renderer/src/components/terminal-pane/terminal-korean-won-input.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/keyboard-layout/korean-input-source.test.tssrc/renderer/src/lib/keyboard-layout/korean-input-source.tssrc/shared/constants.tssrc/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (12)
- src/main/codex-accounts/service.test.ts
- src/main/codex-accounts/runtime-home-service.test.ts
- src/renderer/src/i18n/locales/en.json
- src/shared/constants.ts
- src/renderer/src/components/settings/terminal-search.test.ts
- src/shared/types.ts
- src/renderer/src/components/terminal-pane/terminal-korean-won-input.test.ts
- src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
- src/renderer/src/components/settings/terminal-advanced-platform-search.ts
- src/renderer/src/components/settings/TerminalMacKeyboardSection.tsx
- src/renderer/src/components/settings/terminal-search.ts
- src/renderer/src/components/terminal-pane/terminal-korean-won-input.ts
| try { | ||
| return await reader() | ||
| } catch { | ||
| // Why: the IPC can transiently reject during main-process teardown; treat | ||
| // as no signal so the rewrite stays off instead of guessing. | ||
| return null | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve the cached classification when IPC fails.
This catch converts a rejected IPC request to null. Line 104 then clears a previously known Korean state. This bypasses the failure-preservation path in refreshInputSourceId and disables the mapping after a transient IPC failure.
Proposed fix
- try {
- return await reader()
- } catch {
- // Why: the IPC can transiently reject during main-process teardown; treat
- // as no signal so the rewrite stays off instead of guessing.
- return null
- }
+ return reader()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| try { | |
| return await reader() | |
| } catch { | |
| // Why: the IPC can transiently reject during main-process teardown; treat | |
| // as no signal so the rewrite stays off instead of guessing. | |
| return null | |
| } | |
| return reader() |
|
Following up on my earlier heads-up about the deleted composition layer — you got there first. I can confirm this is fully rebased: I also confirmed this is not made redundant by 17b3dff. That commit changed composition ownership, not what the Korean layout maps onto the physical key. There is no ₩→backquote rewrite anywhere on main, and main's Gates are green on the head with Two non-blocking findings. 1. 2. One integration path is untested. Ordering is safe — the Korean block at Minor: |
* Revert "fix(terminal): detach the Korean input-source probe when its setting goes off (#13283)" This reverts commit 5a84dbb. * Revert "fix(terminal): stop the Korean gate caching an unknown input source as negative (#13182)" This reverts commit 4349599. * Revert "perf(terminal): gate the Korean input-source probe on its setting (#13181)" This reverts commit 42fc537. * Revert "feat(terminal): Korean Won (₩) → backquote key mapping for Korean keyboards (#13104)" This reverts commit 2400393.
…boards (stablyai#13104) * feat(terminal): map Korean Won (₩) key to backquote on macOS Korean keyboard users type markdown code fences and shell backquotes on the key that US layouts reserve for ` — 두벌식 and 세벌식 390 put ₩ there, 세벌식 최종 puts *, so there was no way to type a backquote without switching layouts. Add a Mac-only terminal setting, "Korean Won (₩) to Backquote (`)", that rewrites the plain backquote-position keystroke to backquote while a Korean input source is active. It sits in Terminal → Advanced, right below the existing JIS Yen (¥) to Backslash (\) mapping. The rewrite keys on the keystroke position alone — no character or layout-variant knowledge — and follows the live input source through the existing MacNativeTextInputSourceTracker, which refreshes on focus and keyboard activity (Caps Lock / 한영 input switches never blur the window). Modified chords and IME-composed events pass through untouched. Covered by resolver and input-source tracker unit tests; verified manually in the GUI. * docs(terminal): clarify Korean Won mapping scope and add docstrings State in the setting copy that the backquote rewrite applies only while a Korean input source is active, and add JSDoc to the Korean Won resolver exports (addresses CodeRabbit pre-merge docstring coverage and copy-clarity findings).
* Revert "fix(terminal): detach the Korean input-source probe when its setting goes off (stablyai#13283)" This reverts commit 4b8d3e9. * Revert "fix(terminal): stop the Korean gate caching an unknown input source as negative (stablyai#13182)" This reverts commit d7061e0. * Revert "perf(terminal): gate the Korean input-source probe on its setting (stablyai#13181)" This reverts commit 0712e9a. * Revert "feat(terminal): Korean Won (₩) → backquote key mapping for Korean keyboards (stablyai#13104)" This reverts commit eee48f8.
Summary
Korean keyboard layouts put a different character on the key that US layouts reserve for the backquote (
`):*So Korean terminal users cannot type a backquote — markdown code fences and shell backquotes require switching layouts or copy-paste. This adds a Mac-only terminal setting, "Korean Won (₩) to Backquote (`)" (Terminal → Advanced, right below the existing JIS Yen mapping), that rewrites the plain backquote-position keystroke to backquote while a Korean input source is active.
Screenshots
A new settings toggle row appears in Settings → Terminal → Advanced. No other visual change; the toggle looks identical to the JIS Yen row above it.
Testing
pnpm lintpnpm typecheckpnpm test(resolver + settings + i18n suites; full renderer suites green)pnpm buildUnit tests cover the rewrite resolver (position-based rule, modifier exclusion, IME
keyCode 229guard, all gates), the settings search index, and the i18n catalog. Manual GUI verification on macOS with 한국어 - 두벌식 input source, including Caps Lock / 한영 switching.AI Review Report
CodeRabbit review (CLI,
--base-commit HEAD) flagged 4 findings in the first input-source module — all resolved by deleting that module and reusing the existingMacNativeTextInputSourceTracker(which already refreshes on focus and keyboard activity). A follow-up PR review found no findings. One Minor copy finding (setting precondition not stated) is fixed in this revision.Cross-platform check: the feature is Mac-only by design (UI gated on
isMac, mirroring JIS Yen; the input-source IPC returns null off-Darwin). Windows/Linux behavior is untouched — the rewrite cannot fire because the gate requires macOS + a Korean input source. No shortcuts, labels, paths, or shell behavior change on any platform; the rewrite injects via xterm's existingonDatapath so PTY input guards still run.Security Audit
No new input handling beyond a keydown rewrite that already exists for JIS Yen; no command execution, path handling, auth, secrets, or dependency changes. The only IPC touched is the pre-existing read-only
app:getKeyboardInputSourceId(HIToolbox prefs read). No follow-up needed.Notes
event.code(Backquote, the physical key) rather thanevent.key, and excludeskeyCode 229(IME-owned presses) — matching the guidance from the IME remediation work.terminal-ime-input-source.tsandforwardHangulJamo, which this PR's live input-source gate queries. refactor(terminal): remove the IME composition handler, with recorded-trace regression tests #12560 is expected to merge first; this PR will be rebased onto its replacement mechanism. The feature itself is unaffected, only the mechanism it queries.