Skip to content

Fix keyboard shortcuts not working with non-Latin IME (#1790) - #1791

Open
Jaehui-Lee wants to merge 2 commits into
manaflow-ai:mainfrom
Jaehui-Lee:fix-1790
Open

Jaehui-Lee wants to merge 2 commits into
manaflow-ai:mainfrom
Jaehui-Lee:fix-1790

Conversation

@Jaehui-Lee

@Jaehui-Lee Jaehui-Lee commented Mar 19, 2026 •

Copy link
Copy Markdown

Summary

  • Fix Cmd+letter shortcuts (Cmd+T, Cmd+Shift+L, Cmd+Shift+M, etc.) not
    firing when a non-Latin IME (Korean, Japanese, Chinese) is active
  • Use TISCopyCurrentKeyboardLayoutInputSource() to resolve the
    underlying keyboard layout through the IME
  • Treat non-Basic-Latin charactersIgnoringModifiers as absent to allow
    layout translation fallback

Closes #1790

Test plan

  • Manual: Korean IME active → Cmd+T, Cmd+Shift+L, Cmd+Shift+M work
  • CI: 3 new unit tests for IME shortcut routing
  • Regression: English/Dvorak shortcuts still work

Summary by cubic

Fixes Cmd+letter shortcuts not firing with non‑Latin IMEs by resolving the ASCII‑capable layout and ignoring non‑Latin event characters. Shortcuts like Cmd+P, Cmd+T, and Cmd+Shift+L/M now work without regressing English/Dvorak.

  • Bug Fixes
    • Use TISCopyCurrentKeyboardLayoutInputSource() to resolve the ASCII‑capable layout through IMEs.
    • Only trust charactersIgnoringModifiers when all chars are Basic Latin (U+0020–U+007E); add a helper to enforce this so CJK/jamo are treated as absent for Command shortcuts.
    • Add 3 tests (Korean jamo fallback Cmd+P; respect underlying layout over raw keyCode; trust Latin chars when present) and explicitly assert non‑consumption in the negative case.

Written for commit 40f9280. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Improved shortcut recognition for non-Latin input so shortcuts use typed Latin characters when present and correctly fall back to keyboard layout when IME produces non-Basic-Latin characters.
  • Tests

    • Added tests verifying shortcut routing with Korean IME, layout-fallback behavior, and precedence of Latin event characters for shortcuts.

@vercel

vercel Bot commented Mar 19, 2026

Copy link
Copy Markdown

@kakao-jacky-lee is attempting to deploy a commit to the Manaflow Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5faeb223-c4c9-4b12-bfe8-b6075f7deb37

📥 Commits

Reviewing files that changed from the base of the PR and between 33a7263 and 40f9280.

📒 Files selected for processing (1)
  • cmuxTests/AppDelegateShortcutRoutingTests.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmuxTests/AppDelegateShortcutRoutingTests.swift

📝 Walkthrough

Walkthrough

Treat non-Basic-Latin charactersIgnoringModifiers as absent so shortcut matching falls back to layout/KeyCode translation, and use the underlying keyboard layout (via TISCopyCurrentKeyboardLayoutInputSource) for character translation; includes tests covering Korean IME cases.

Changes

Cohort / File(s) Summary
IME Shortcut Matching
Sources/AppDelegate.swift
Added isBasicLatinCharacters(_:) and updated matchShortcut so hasEventChars requires non-empty Basic Latin charactersIgnoringModifiers, enabling fallback to layout/keyCode when IME emits non-Latin chars.
Keyboard Layout Lookup
Sources/KeyboardLayout.swift
Switched to TISCopyCurrentKeyboardLayoutInputSource() when translating keyCode→character so the underlying layout (not the IME) is used for UCKeyTranslate.
Unit Tests — Korean IME
cmuxTests/AppDelegateShortcutRoutingTests.swift
Added three tests validating Cmd+P routing across scenarios: IME jamo falling back to layout, layout-respecting rejection, and Latin characters taking precedence.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IME as Input Method
    participant App as AppDelegate
    participant Layout as KeyboardLayout
    participant System

    User->>System: press Cmd+P key
    System->>IME: generate event.charactersIgnoringModifiers (maybe non‑Latin)
    System->>App: deliver NSEvent
    App->>App: check charactersIgnoringModifiers
    alt charactersIgnoringModifiers is non-empty Basic Latin
        App->>App: use event characters to match shortcut
    else non-Basic-Latin or empty
        App->>Layout: request character(forKeyCode, modifierFlags)
        Layout->>Layout: TISCopyCurrentKeyboardLayoutInputSource()
        Layout->>App: return translated character
        App->>App: use layout/keyCode result to match shortcut
    end
    App->>System: post commandPaletteSwitcherRequested (if matched)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped on keys both wide and sly,
When jamo danced and Latin shy,
I nudged the layout through the mist —
Shortcuts found where they exist.
A carrot-toast to fixes nigh! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing keyboard shortcuts that don't work with non-Latin IMEs.
Description check ✅ Passed The description includes a Summary section explaining the fix and why, and a Test plan detailing manual testing and new unit tests. It largely follows the required template structure.
Linked Issues check ✅ Passed The code changes directly address all requirements from issue #1790: using TISCopyCurrentKeyboardLayoutInputSource() [KeyboardLayout.swift], treating non-Basic-Latin characters as absent [AppDelegate.swift], and adding test coverage for IME shortcut routing [AppDelegateShortcutRoutingTests.swift].
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the non-Latin IME keyboard shortcut issue: modifications to shortcut matching, keyboard layout resolution, and comprehensive test coverage for the specific fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

When a non-Latin IME (Korean, Japanese, Chinese, etc.) is active,
Cmd+letter shortcuts handled through the custom matchShortcut() path
fail because charactersIgnoringModifiers returns non-Latin characters
(e.g. Korean jamo) and KeyboardLayout.character() queries the wrong
TIS input source.

- KeyboardLayout.swift: Use TISCopyCurrentKeyboardLayoutInputSource()
  to resolve the underlying ASCII-capable layout through the IME
- AppDelegate.swift: Treat non-Basic-Latin charactersIgnoringModifiers
  as absent so the layout translation and keyCode fallback paths are
  reached
- Add 3 tests for IME shortcut routing (layout fallback, layout
  respected over keyCode, Latin characters still trusted)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmuxTests/AppDelegateShortcutRoutingTests.swift`:
- Around line 3260-3261: The test currently calls
appDelegate.handleBrowserSurfaceKeyEquivalent(event) and ignores its Bool return
value, which can hide unexpected consumption; capture the returned Bool from
handleBrowserSurfaceKeyEquivalent(event) and add an explicit XCTAssertFalse on
that result to ensure the event was not consumed while still waiting for
switcherExpectation to validate that .commandPaletteSwitcherRequested was not
posted (reference appDelegate.handleBrowserSurfaceKeyEquivalent and
switcherExpectation).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3838a37a-1e5b-4486-abe4-21c5f339b2bb

📥 Commits

Reviewing files that changed from the base of the PR and between 5391091 and 33a7263.

📒 Files selected for processing (3)
  • Sources/AppDelegate.swift
  • Sources/KeyboardLayout.swift
  • cmuxTests/AppDelegateShortcutRoutingTests.swift

Comment thread cmuxTests/AppDelegateShortcutRoutingTests.swift Outdated
Address CodeRabbit review: explicitly assert that handleBrowserSurfaceKeyEquivalent
returns false when the underlying layout maps to a different letter, instead of
discarding the return value.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@teamleaderleo teamleaderleo added S2: major A crash, hang, lost state, broken connection, or a regression on a path people use area: input Keyboard, shortcuts, IME, mouse, clipboard and paste labels Sep 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: input Keyboard, shortcuts, IME, mouse, clipboard and paste S2: major A crash, hang, lost state, broken connection, or a regression on a path people use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts not working with non-Latin IME (Korean, Japanese, Chinese, etc.)

2 participants