Skip to content

fix: flush pending IME commit text on terminal dispose#796

Merged
xiaolai merged 1 commit intomainfrom
fix/audit-793
Apr 18, 2026
Merged

fix: flush pending IME commit text on terminal dispose#796
xiaolai merged 1 commit intomainfrom
fix/audit-793

Conversation

@xiaolai
Copy link
Copy Markdown
Owner

@xiaolai xiaolai commented Apr 18, 2026

Closes #793

Summary

  • createTerminalInstance.dispose() previously cleared the 80ms IME grace timer without flushing pendingCommitText, silently dropping committed CJK input if the user closed the terminal inside the grace window.
  • Mirror the existing onCompositionStart flush pattern: if a pending commit exists when dispose() runs, invoke onCompositionCommit(pendingCommitText) (wrapped in try/catch since the PTY may already be closing) before nulling the state.

Test plan

  • New unit test: dispose during grace window invokes onCompositionCommit with the pending text exactly once and the timer firing later is a no-op.
  • New unit test: errors thrown from onCompositionCommit during dispose flush do not propagate.
  • pnpm test src/components/Terminal/ — 291/291 passing.
  • pnpm check:all — passes.

🤖 Generated with Claude Code

Mirror the pattern from onCompositionStart: if the terminal is disposed
while the 80ms IME grace timer is still pending, flush the queued
commit text via onCompositionCommit before clearing the timer. This
prevents silent loss of committed CJK input when the user closes the
terminal panel or switches tabs immediately after confirming a
pinyin candidate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@xiaolai xiaolai added the audit Codebase audit finding label Apr 18, 2026
@xiaolai
Copy link
Copy Markdown
Owner Author

xiaolai commented Apr 18, 2026

VERIFIED — The audit finding is resolved. dispose() now flushes pendingCommitText via onCompositionCommit (with try/catch) before nulling the timer, exactly as suggested in #793, and two new tests cover both the flush path and the error-swallow path — no scope creep.

@xiaolai xiaolai enabled auto-merge (squash) April 18, 2026 10:01
@xiaolai xiaolai merged commit 99fff28 into main Apr 18, 2026
8 checks passed
@xiaolai xiaolai deleted the fix/audit-793 branch April 18, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit Codebase audit finding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[audit] terminal: dispose() drops pending IME commit text instead of flushing

1 participant