Skip to content

fix(tui): keep input anchored after slash command menu closes - #1413

Merged
liruifengv merged 4 commits into
mainfrom
fix/slash-menu-input-shift
Jul 6, 2026
Merged

fix(tui): keep input anchored after slash command menu closes#1413
liruifengv merged 4 commits into
mainfrom
fix/slash-menu-input-shift

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue.

Problem

After opening the slash command menu and closing it, the input box shifts upward instead of staying anchored at the bottom of the screen. Closing the menu by deleting the leading / with Backspace did not trigger any re-render at all, so the stale position lingered.

What changed

Force a full re-render when the slash command menu closes, so the editor snaps back to the bottom instead of sitting where the taller dropdown left it. The full re-render is gated on two conditions to avoid worse side effects:

  • Only when the session content already overflows one screen. Below one screen a full clear + home would yank the editor to the top and leave a blank tail, so the normal differential render is kept there.
  • Never inside tmux, whose own reflow handles the shrink and where a full clear is disruptive.

The close edge is detected from a render frame rather than from key handling, so asynchronous closes are covered too — for example Backspace deleting the leading /, where the menu only disappears once the completion re-query resolves. The same overflow/tmux gating is applied when restoring the editor from selector panels such as /help and /sessions.

Added tests covering Escape close, Backspace asynchronous close, content-fits-one-screen, and tmux cases.

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. (N/A — bug fix, no user-facing surface change beyond restoring correct behavior.)

Force a full re-render when the slash command menu closes, but only when the session content already overflows one screen; skipped under tmux. Detect the close edge from a render frame so asynchronous closes (Backspace deleting the leading slash) are covered too. Apply the same overflow/tmux gating when restoring the editor from selector panels.
@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 29cae68

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

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@29cae68
npx https://pkg.pr.new/@moonshot-ai/kimi-code@29cae68

commit: 29cae68

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55575aa924

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Outdated
Address Codex review: the overflow probe ran before the editor container was swapped back, so it counted the tall replacement panel and forced a full clear/home even when the restored content fit on one screen, yanking the editor to the top. Measure after the editor is mounted instead.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e050c1904b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/components/editor/custom-editor.ts Outdated
Address Codex review: the guard skipped the forced redraw when the post-close layout is exactly one screen, leaving the editor shifted up because the differential renderer keeps the old viewport offset after a shrink. An exact fill is safe to clear (no blank tail), so redraw when content fills or overflows the viewport, and cover it with a test.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a196f4e33d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@liruifengv
liruifengv merged commit 913d042 into main Jul 6, 2026
10 checks passed
@liruifengv
liruifengv deleted the fix/slash-menu-input-shift branch July 6, 2026 07:18
This was referenced Jul 6, 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