Repository navigation
Conversation
|
Caution Review failedFailed to post review comments. We encountered an issue with GitHub. Use ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 206b2c81b93c8be8e6610a01993b9419b971a66c and 2d50cdb. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout. (14)
🧰 Additional context used📓 Path-based instructions (5)**/*📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/renderer/src/**/*.{css,scss,tsx,ts}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,sh,ps1}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (7)📚 Learning: 2026-06-16T15:35:16.815ZApplied to files:
📚 Learning: 2026-07-21T20:38:08.166ZApplied to files:
📚 Learning: 2026-06-24T11:33:31.894ZApplied to files:
📚 Learning: 2026-07-08T00:01:30.534ZApplied to files:
📚 Learning: 2026-07-22T10:22:46.721ZApplied to files:
📚 Learning: 2026-07-22T18:28:59.997ZApplied to files:
📚 Learning: 2026-07-28T01:28:17.192ZApplied to files:
🪛 Betterleaks (1.7.0)config/patches/@[email protected][high] 6-6: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) [high] 7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 📝 WalkthroughWalkthroughAdds IME-aware deferred newline handling for terminal keyboard shortcuts, including redispatched Enter absorption and lifecycle cleanup. Captured terminal input now verifies pane mounting and PTY ownership before dispatch, with reconfirmation guarded by binding identity. Composition sessions are routed only while captured PTY ownership remains valid and are disposed with the connection. Unit tests and a Playwright suite validate Hangul composition, Enter chord timing, PTY bytes, submitted lines, and stale-state behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
09eadb3 to
206b2c8
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.test.ts (1)
16-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
it.eachhere runs the same test twice with no route-specific difference.Both iterations construct an identical mock transport and ignore the parameter, so the titles claim local-IPC vs SSH coverage the assertions don't provide. Either drop the
it.eachor thread the route into the fixture so it actually varies.♻️ Collapse to a single test
- it.each(['local IPC', 'SSH remote runtime'])( - 'sends on the captured %s route while its PTY still owns the mounted pane', - () => { - const transport = createTransport('pty-original') + it('sends on the captured route while its PTY still owns the mounted pane', () => { + const transport = createTransport('pty-original') - expect( - sendCapturedTerminalInput({ - targetPaneMounted: true, - currentTransport: transport, - capturedTransport: transport, - capturedPtyId: 'pty-original', - data: '\r' - }) - ).toBe(true) - expect(transport.sendInput).toHaveBeenCalledWith('\r') - } - ) + expect( + sendCapturedTerminalInput({ + targetPaneMounted: true, + currentTransport: transport, + capturedTransport: transport, + capturedPtyId: 'pty-original', + data: '\r' + }) + ).toBe(true) + expect(transport.sendInput).toHaveBeenCalledWith('\r') + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d6a3710c-69fd-491d-b373-70de72253fbb
📥 Commits
Reviewing files that changed from the base of the PR and between badf911 and 206b2c81b93c8be8e6610a01993b9419b971a66c.
📒 Files selected for processing (6)
src/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.test.tssrc/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.tssrc/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.tssrc/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.tstests/e2e/korean-ime-terminal-shift-enter-commit.spec.ts
206b2c8 to
2d50cdb
Compare
| const onSessionEnd = (event: Event): void => { | ||
| const detail = getCompositionDetail(event) | ||
| if (!detail) { | ||
| return | ||
| } | ||
| event.preventDefault() | ||
| const captured = | ||
| session?.id === detail.id | ||
| ? session | ||
| : previousSession?.id === detail.id | ||
| ? previousSession | ||
| : null | ||
| if (!captured) { | ||
| return | ||
| } | ||
| if (session === captured) { | ||
| session = null | ||
| } | ||
| if (previousSession === captured) { | ||
| previousSession = null | ||
| } | ||
| if ( | ||
| disposed || | ||
| !detail.data || | ||
| captured.ptyId === null || | ||
| args.getCurrentTransport() !== args.capturedTransport || | ||
| args.capturedTransport.getPtyId() !== captured.ptyId | ||
| ) { | ||
| return | ||
| } | ||
| args.terminal.input(detail.data) | ||
| } |
There was a problem hiding this comment.
preventDefault called before captured is resolved
event.preventDefault() fires at line 67 regardless of whether captured resolves to a non-null session. When getCompositionDetail returns a valid detail but the session ID does not match either tracked slot (e.g., a duplicate end event or a session that was already cleared), the event is cancelled unconditionally. If the xterm patch ever checks defaultPrevented on the dispatched event to skip its own fallback, an orphaned end event would silently suppress that path. Moving the preventDefault() call to after the if (!captured) { return } guard would make the contract explicit — the event is only consumed when this route is actually handling it.
| absorbRedispatchedEnter: (enter) => { | ||
| const state = statesByEnterCode.get(enter.code)?.get(enter.timeStamp) | ||
| if (!state || state.absorbCredits <= 0) { | ||
| clearCreditsForCode(enter.code) | ||
| return false | ||
| } | ||
| state.absorbCredits -= 1 | ||
| cleanUpIfSettled(enter, state) | ||
| return true |
There was a problem hiding this comment.
clearCreditsForCode invalidates credits for all concurrent Enter cycles
When absorbRedispatchedEnter is called with a timestamp that has no credit (either !state or state.absorbCredits <= 0), it calls clearCreditsForCode which zeroes credits for every timestamp tracked under the same key code. In the unlikely-but-possible case of two overlapping IME compositions (e.g., fast Korean chord entry on a slow host), the second arrival of a spent credit for timestamp A would also clear the unspent credit for a still-in-flight timestamp B, causing B's subsequent macOS re-dispatch to pass through un-absorbed and produce a duplicate newline. The existing tests cover the intended semantics, but this cross-timestamp side-effect of the "stale credit" retirement path is not covered by an explicit multi-cycle overlap + spent-credit test.
Greptile SummaryThis PR fixes a Korean IME race on macOS where pressing Shift+Enter or Ctrl+Enter during an active composition would either submit an empty line or produce duplicate encoded Enter sequences. The root cause was that macOS delivers the committing Enter chord twice — first as an IME Process keydown (
Confidence Score: 4/5Safe to merge; the core IME race is correctly fixed and well-tested across unit, integration, and E2E layers The deferred-newline state machine and composition-route logic are sound and backed by thorough tests. Two minor defensive concerns exist: Files Needing Attention:
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.ts | New module implementing the deferred-newline state machine; logic is sound and thoroughly tested, but clearCreditsForCode in absorbRedispatchedEnter has a cross-timestamp side-effect in overlapping Enter cycles |
| src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts | New module routing xterm custom composition events to the PTY transport; event.preventDefault() is called before the !captured null-guard, which could silently cancel events the route does not intend to handle |
| src/renderer/src/components/terminal-pane/keyboard-handlers.ts | Integrates deferred-newline sender and absorb-redispatch logic cleanly; absorb check correctly positioned after scope guard and before shortcut resolution; e.keyCode === 13 guard reliably distinguishes real from Process-key Enter |
| src/renderer/src/components/terminal-pane/pty-connection.ts | Minimal surgical addition of installTerminalImeCompositionRoute with proper disposal on pane teardown |
| src/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.ts | Extracted staleness guard for deferred input delivery; straightforward and correctly tested |
| tests/e2e/korean-ime-terminal-shift-enter-commit.spec.ts | Comprehensive E2E harness using CDP to replay the exact macOS Hangul commit sequence; covers both redispatch orderings and a modifier-lost variant; proper cleanup in finally |
| src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.ts | 12 unit tests covering fallback timer, double-send guards, cross-cycle credit isolation, blur cleanup, and null-element path |
| src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts | Validates xterm patch behavior with real Terminal instances including IBus Hangul de-duplication, blur/focus ordering, and Escape cancellation |
| src/renderer/src/components/terminal-pane/pty-connection.test.ts | Single test assertion update — filters by event type rather than counting all addEventListener calls, correctly accommodating the new composition route listeners |
Sequence Diagram
sequenceDiagram
participant OS as macOS IME
participant KB as keyboard-handlers
participant DNS as DeferredNewlineSender
participant SATC as sendAfterComposition
participant xterm as xterm element
participant PTY as PTY Transport
OS->>KB: "keydown isComposing=true keyCode=229 Enter t=100"
KB->>DNS: "defer enter t=100 element sendResolvedInput"
DNS->>SATC: register compositionend listener and 200ms fallback
KB->>KB: preventDefault stopImmediatePropagation
OS->>xterm: compositionend glyph committed
xterm->>SATC: compositionend fires
SATC->>SATC: clearTimeout fallback then setTimeout send 0
OS->>KB: "keydown isComposing=false keyCode=13 Enter t=100 re-dispatch"
KB->>DNS: "absorbRedispatchedEnter enter t=100"
DNS-->>KB: true credit consumed
KB->>KB: preventDefault stopImmediatePropagation re-dispatch absorbed
Note over SATC: macrotask fires
SATC->>PTY: sendResolvedInput one newline after glyph flush
DNS->>DNS: cleanUpIfSettled state deleted
Reviews (1): Last reviewed commit: "fix(terminal): complete IME composition ..." | Re-trigger Greptile
|
Closing as superseded by #11293, which incorporated this PRs IME Enter/newline ordering work while preserving contributor authorship and reconciling it with the broader xterm composition fixes. The merged implementation passes the complete #11052 regression matrix (50/50), combined IME coverage, native Linux IBus coverage, and platform CI. Thank you @nwparker for the original fix. |
Summary
compositionendcommits the trailing IME textReproduction
The unchanged CDP scenario reproduced two failures before the fix: Shift+Enter submitted an empty line instead of the completed Korean text, while Ctrl+Enter split the text around duplicate encoded Enter sequences. The terminal now commits the final syllable before emitting one modified newline chord.
Validation
pnpm typecheck:webpnpm check:max-lines-ratchetgit diff origin/main...HEAD --checkCloses #10842