Skip to content

fix(tui): enter prompt history with Up only when the input is empty - #3111

Open
kimi-agent-bot wants to merge 2 commits into
MoonshotAI:mainfrom
kimi-agent-bot:fix/up-history-empty-only
Open

fix(tui): enter prompt history with Up only when the input is empty#3111
kimi-agent-bot wants to merge 2 commits into
MoonshotAI:mainfrom
kimi-agent-bot:fix/up-history-empty-only

Conversation

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator

What

Up-arrow prompt-history recall is now only entered when the input box is completely empty (or while already browsing history). With a draft in progress, stays pure cursor movement: on the first visual line it just jumps to the line start, and never swaps the draft for a history entry.

Why

Previously the entry condition was first visual line && (empty || browsing || cursorCol === 0). The cursorCol === 0 clause meant that any draft could be swept into history browsing just by pressing at the start of the line — the root cause of draft-loss complaints (e.g. a held key racing the cursor to column 0 and beyond). Narrowing the entry condition eliminates that whole class of accidents by construction: history is only reachable from an empty input, so a draft in progress can never be carried into (or lost through) history browsing.

Changes (all in vendored packages/pi-tui)

  • src/components/editor.tscursorUp branch: drop the cursorCol === 0 entry condition; entry now requires isEditorEmpty() || historyIndex > -1. Continued / navigation while browsing is unchanged.
  • src/components/editor.ts — dedicated tui.editor.historyPrevious action (no default binding; user-configurable): same empty-draft guard, so both recall entry points behave consistently. historyNext needs no guard (already a no-op outside browsing).
  • A whitespace-only draft counts as content and does not trigger recall.
  • Tests: rewrote the three cases that asserted the old enter-with-draft semantics; added coverage for non-empty draft at line start (single- and multi-line), whitespace-only drafts, and the dedicated-key guard.
  • packages/pi-tui/AGENTS.md — registered as local divergence feat: add Ctrl-J newline shortcut in TUI prompt #9.

Notes

@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6dfd807

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

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

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

commit: 6dfd807

@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: 0863e0520a

ℹ️ 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 packages/pi-tui/src/components/editor.ts Outdated
@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 6dfd807695

ℹ️ 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".

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