Skip to content

fix(terminal): keep ime tab from accepting completions - #7203

Merged
NicholasRBowers merged 2 commits into
kirodotdev:mainfrom
leonlaiyc:fix/terminal-completion-ime-tab
Sep 11, 2026
Merged

NicholasRBowers merged 2 commits into
kirodotdev:mainfrom
leonlaiyc:fix/terminal-completion-ime-tab

Conversation

@leonlaiyc

@leonlaiyc leonlaiyc commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Terminal completion already leaves Enter alone during the short window after an
IME composition ends, but Tab did not have the full choose-key contract. Accepting
Tab in that window rewrote the command with a menu suggestion; merely returning it
to xterm instead sent Tab to the PTY and triggered shell completion.

Why it matters

People typing with a Chinese, Japanese, or Korean IME can have their terminal
command line rewritten by either UI completion layer when they are only committing
or navigating an IME candidate.

What changed (motivation → approach → change)

The terminal tracks compositionend because browser native composition flags may
already be clear on the committing keydown. A Tab with live native composition
flags is still left to the browser/IME. During the post-composition grace window,
after those flags clear, Tab is now claimed and consumed: the completion menu does
not accept it, xterm does not pass it to the PTY, and the browser default is
prevented. Existing Enter behavior is unchanged, and ordinary Tab completion still
works after the grace window expires.

Tests

  • Added a decisive regression proving grace-window Tab is not accepted by the
    menu, is not passed to xterm/PTY, has its default action prevented, and sends no
    completion bytes.
  • Kept the positive control proving Tab still completes after the grace window.
  • npm exec -- vitest run src/test/TerminalCompletion.test.tsx --coverage.enabled=false
    — 65 passed.
  • Directly relevant IME siblings (useImeGuard.documentLatch and
    ImeEnterGuardSites) — 37 passed.
  • npm exec -- tsc -b --pretty false — passed.
  • Exact-file ESLint — passed.

Red-before on PR head 22ca20622441ef84706b988303466d2ef903aaeb:
1 failed / 64 passed; the regression observed that post-composition Tab returned
true to xterm. Green-after on current head: 65 / 65 passed.

Manual verification

N/A — the focused component harness deterministically drives xterm's custom key
handler, composition-end event, fake clock, DOM cancellation state, and PTY-write
seam.

Screenshots / video

Why no screenshot: This changes keyboard-event ownership during IME composition;
the rendered terminal completion UI is unchanged.

Related Issues

no linked issue: this is the exact unfixed sibling named by merged PR #7000's
first-principles review.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Pattern harvest

Rule candidate: any keydown handler that routes committing keys (Enter/Tab) must honor the IME composition boundary — check e.isComposing || e.keyCode === 229 AND the post-compositionend grace window before treating the key as a UI command; a handler reading e.key alone misroutes a just-committed IME candidate.

@leonlaiyc
leonlaiyc requested review from a team and buluoray August 31, 2026 04:28
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 31, 2026
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 4a5ea83d2bb9794794deef028d96172e129e89c1 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

The diff is small and I've read the surrounding handler. The change extends the established IME grace-window pattern (merged for Enter in #7000) to Tab at the single key-ownership choke point, with the asymmetry (Enter passes through, Tab is fully consumed) explicitly justified: a leaked Tab reaches the PTY as shell completion and rewrites the line, which is the harm. The grace check deliberately precedes the menu-open check so Tab can't escape to xterm even with no menu — matching the stated problem. Tests pin both the negative (grace-window Tab consumed, no bytes sent) and the positive control (Tab completes after the window), with red-before evidence. The "Manual verification: N/A" rests on a browser premise (compositionend before flags clear) already established by the merged Enter sibling, and the harness drives the real handler deterministically — no unverified platform branch. Proportionate, right layer, reversible.

Design-Verdict: PASS

A real CJK-IME harm, fixed at the one key-ownership choke point by extending the already-merged Enter grace-window contract, with bidirectional regression pins.

[DESIGN-REVIEWED] 4a5ea83

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed 4a5ea83d2bb9794794deef028d96172e129e89c1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

The sole candidate requires a modifier-held Tab (Ctrl/Alt/Meta+Tab) arriving within the 60ms IME_GRACE_MS window after a compositionend. Its concrete-input leg is not something that occurs in practice — a human cannot deliberately chain a composition commit and a modifier-Tab chord inside 60ms — and its observable-outcome leg depends on the browser honoring preventDefault for chords (Ctrl+Tab, Alt+Tab, Meta+Tab) that are OS/browser-reserved and generally not cancelable. Both legs resolve to "might," so the candidate fails the (a)/(c) bar and is dropped. No grounded defect surfaced during falsification.

[OPUS-REVIEWED] 4a5ea83

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 4a5ea83d2bb9794794deef028d96172e129e89c1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4a5ea83

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — ✅ PASS

UX-level review of 4a5ea83d2bb9794794deef028d96172e129e89c1 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

No attachments and no recordings exist for this PR — consistent with its declared <!-- no-visual-delta -->. The diff confirms: it only changes keyboard-event ownership (Tab consumed during the 60 ms post-IME grace window) plus comments and tests. No user-visible control, label, string, state, or rendered element is added or changed, so there are no evidence gaps and nothing for a blind reader to see.

UX-Verdict: PASS

Invisible keyboard-ownership fix: no rendered UI, string, or control changes; it stops IME candidate keys from rewriting the user's command line.

[UX-REVIEWED] 4a5ea83

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 4a5ea83d2bb9794794deef028d96172e129e89c1 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

The change checks out against the base: Enter-only grace handling at TerminalCompletion.tsx:507 is visibly asymmetric, the private timestamp mechanism it extends is explicitly recorded as out-of-ratchet-scope by ImeEnterClaimRatchet.test.ts ("a structural distinction, not a pardoned file"), no new public surface is added, and the fix reuses the existing local claim helper. Final review:

First-Principles-Verdict: PASS

Only manual check left: on a real IME, a wanted shell-completion Tab typed within 60ms of a commit is swallowed — confirm that trade is acceptable.

What this change ships

Inventory (4 items) — 4 justified

Intent: stop either completion layer from rewriting an IME user's command line when Tab commits or navigates a candidate — a FIX.

  1. In the ~60ms after an IME commit, Tab no longer accepts a completion-menu suggestion — justified
  2. In that window, Tab no longer reaches the shell as shell completion, even with no menu open — justified
  3. Grace-window comments now describe Tab alongside Enter — justified
  4. Tests pin grace-window Tab consumption and post-window Tab completion — justified

The defect is readable on base (TerminalCompletion.tsx:507 guards Enter only; case 'Tab' at 532 accepts during the window), and the added regression with a stated red-before run gives it checkable provenance. The private timestamp latch this extends is a decision ImeEnterClaimRatchet.test.ts:155-157 already records; the shared createImeLatch is not a duplicate here. Remaining claimed keys (ArrowUp/ArrowDown/Escape, counted from the switch) arrive flag-marked mid-composition, so no unfixed siblings.

[FIRST-PRINCIPLES-REVIEWED] 4a5ea83

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 31, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • This PR is PARTIALLY_COVERED with PR #548. Coverage is explicitly incomplete; this finding is not a completion or closure claim. Recommended action for PR #7203: KEEP. Only the mechanism and the Enter half landed in PR #548; the Tab half this PR adds has no coverage anywhere, so nothing here justifies closure. Files: website/src/components/TerminalCompletion.tsx.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@chenmingwei23 chenmingwei23 added the needs-pr-triage PR scanner: awaiting automated triage label Sep 11, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 11, 2026
@NicholasRBowers NicholasRBowers added drive-to-green PR claimed by drive-to-green pipeline and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 11, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with PR Readiness stuck pending. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: CI is fully green on head 633e870de, which already implements exactly the fix GPT's blocking finding demanded on the prior head 22ca20622 (claim-and-consume grace-window Tab, with a red-before regression). The five fork Stage-2 review lanes skipped and never stamped the current head, so readiness pends indefinitely. A rebase-only push onto current main mints a new head and re-fires CI plus the review lanes so GPT can re-judge the fixed code (same shape as #7265/#7267/#7615).

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

@NicholasRBowers
NicholasRBowers force-pushed the fix/terminal-completion-ime-tab branch from 633e870 to 4a5ea83 Compare September 11, 2026 11:43
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]

Rebase-only push: 633e870 → 4a5ea83d2. The code diff is unchanged.

Why: all CI was green on 633e870, but the five Stage-2 review lanes (GPT/Opus/Design/First Principles/UX) completed skipped for that head and never stamped it, so PR Readiness pended forever. A rerun cannot re-fire them (no workflow_run event on rerun), so minting a new head via a rebase onto current main is the established fix (precedent: #7265, #7267, #7615). This also lets GPT re-judge the current code — its 🔴 BLOCKING comment stamps the prior head 22ca206, and the current code is the author's fix for exactly that finding (red-before regression test documented in the PR body).

Verified locally on the rebased head: tsc -b clean, TerminalCompletion.test.tsx 69/69, full frontend suite 2018 files / 32,095 tests passed. Both commits keep @leonlaiyc's authorship.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 11, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]

Body-only edit: added the ## Pattern harvest section. The PR Hygiene gate now requires it on fix PRs (it tightened after this PR's previous head passed). No code change — the harvest states the rule candidate this fix implies (keydown handlers must honor the IME composition boundary before routing Enter/Tab). The edited event re-fires the gate against the updated body.

Status otherwise: all five Stage-2 review lanes stamped the new head 4a5ea83d2 — GPT re-judged the fixed code clean (its prior 🔴 was against the old head 22ca206), Opus/Design/First Principles/UX all pass.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 11, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) September 11, 2026 13:23

@iamwhatever iamwhatever 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.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: IME grace window let Tab reach both the completion menu and xterm; the handler now consumes Tab inside the window while Enter keeps its pass-through, with two regression tests. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.

@NicholasRBowers
NicholasRBowers merged commit aeca7df into kirodotdev:main Sep 11, 2026
102 of 106 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 11, 2026
@chenmingwei23 chenmingwei23 removed the drive-to-green PR claimed by drive-to-green pipeline label Sep 11, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
* fix(terminal): keep ime tab from accepting completions

* fix(terminal): consume IME tab after composition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants