Skip to content

fix(tui): drain terminal input before exit#314

Merged
liruifengv merged 2 commits into
mainfrom
liruifeng/fix-tui-exit-input-drain-main
Jun 2, 2026
Merged

fix(tui): drain terminal input before exit#314
liruifengv merged 2 commits into
mainfrom
liruifeng/fix-tui-exit-input-drain-main

Conversation

@liruifengv
Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; this fixes a terminal cleanup bug reported during /exit.

Problem

When Kitty keyboard protocol reports Enter key release events, exiting immediately after /exit can let a late release sequence reach the parent shell, leaving raw CSI-u text in the VS Code terminal.

What changed

The TUI now drains terminal input before stopping the UI and exiting, preserving existing shutdown cleanup while preventing late keyboard release events from leaking. A regression test covers the shutdown order, and a changeset records the CLI patch.

Validation

  • pnpm exec vitest run apps/kimi-code/test/tui/signal-handlers.test.ts apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts apps/kimi-code/test/tui/components/editor/custom-editor.test.ts
  • pnpm exec oxlint --type-aware apps/kimi-code/src/tui/kimi-tui.ts apps/kimi-code/test/tui/signal-handlers.test.ts
  • git diff --check origin/main...HEAD
  • pnpm run typecheck

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. No doc update is needed for this terminal cleanup fix.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: fa3c251

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@fa3c251
npx https://pkg.pr.new/@moonshot-ai/kimi-code@fa3c251

commit: fa3c251

@liruifengv liruifengv merged commit 6de3d97 into main Jun 2, 2026
8 checks passed
@liruifengv liruifengv deleted the liruifeng/fix-tui-exit-input-drain-main branch June 2, 2026 06:04
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant