MoonshotAI / MoonshotAI/kimi-code

TUI: Ctrl-S steer sends collapsed [paste #N] placeholder instead of the pasted text

Open
#3,396 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Summary

In the TUI, a large paste (>10 lines or >1000 chars) is collapsed into a [paste #N +M lines] placeholder. The original text lives only in the editor's in-memory paste registry and is expanded back on a normal submit (Enter). Two adjacent gaps in that mechanism lose user content:

  1. Ctrl-S steer drops the pasted content. While the agent is running, pressing Ctrl-S steers the editor draft into the active turn — but the steer path reads editor.getText() (the raw text containing the placeholders) instead of getExpandedText(), then clears the editor, which also clears the paste registry. The model receives only the literal [paste #1 +41 lines], and the original text is gone for good. (The sibling media path on the same shortcut was fixed in 0.24.0 via #1588; the text-marker path was missed.)

  2. Pasting while the cursor sits on a marker silently swallows the new paste. custom-editor.ts intercepts any bracketed paste that arrives while the cursor is on an existing marker, expands the old marker, and discards the incoming content. The intent was the explicit "paste key on a marker = expand it" gesture (which lives on the keystroke path), but ordinary terminal pastes also arrive as bracketed paste and get intercepted the same way.

Repro (bug 1)

  1. Paste a long text (>10 lines) into the TUI prompt — it collapses to [paste #1 +N lines].
  2. While the agent is working, press Ctrl-S.
  3. The steered message the model receives is just [paste #1 +N lines]; the pasted text is lost.

Root cause

  • apps/kimi-code/src/tui/controllers/editor-keyboard.ts — the onCtrlS handler reads editor.getText() rather than getExpandedText() (the external-editor seed in the same file does it correctly), and the editor.setText('') afterwards clears the paste registry.
  • apps/kimi-code/src/tui/components/editor/custom-editor.ts — the bracketed-paste branch expands the marker under the cursor and drops the incoming paste data.

Environment

0.39.1, still present on current main.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/kimi-code/src/tui/controllers/editor-keyboard.ts by comparing the onCtrlS handler with the external-editor seed, then inspect the bracketed-paste branch in apps/kimi-code/src/tui/components/editor/custom-editor.ts. Reproduce both long-paste scenarios in the TUI. Done means Ctrl-S preserves expanded text and pasting on a marker no longer swallows the incoming paste.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.