Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tui-paste-marker-steer-expand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Expand collapsed paste placeholders when steering the draft with Ctrl-S.
2 changes: 1 addition & 1 deletion apps/kimi-code/src/tui/controllers/editor-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class EditorKeyboardController {
host.state.appState.isCompacting
)
return;
const text = editor.getText().trim();
const text = (editor.getExpandedText?.() ?? editor.getText()).trim();
const editorIsBash = editor.inputMode === 'bash';

// Bash commands (`! …`) are not steerable: they stay queued so they run
Expand Down
32 changes: 28 additions & 4 deletions apps/kimi-code/test/tui/controllers/editor-keyboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ describe('EditorKeyboardController Shift-Tab plan toggle', () => {
describe('EditorKeyboardController Ctrl-S steering', () => {
function createCtrlSHarness(options: {
editorText: string;
editorExpandedText?: string;
queued: Array<Record<string, unknown>>;
engineV2?: boolean;
skillCommandMap?: Map<string, string>;
Expand All @@ -488,6 +489,12 @@ describe('EditorKeyboardController Ctrl-S steering', () => {
setText: setText as unknown as (...args: never[]) => unknown,
inputMode: 'prompt' as unknown as (...args: never[]) => unknown,
};
if (options.editorExpandedText !== undefined) {
const expanded = options.editorExpandedText;
editor['getExpandedText'] = vi.fn(() => expanded) as unknown as (
...args: never[]
) => unknown;
}
const host = {
state: {
editor,
Expand All @@ -511,10 +518,11 @@ describe('EditorKeyboardController Ctrl-S steering', () => {
closeOrCancel: vi.fn(() => false),
},
} as unknown as EditorKeyboardHost;
const controller = new EditorKeyboardController(
host,
undefined as unknown as ImageAttachmentStore,
);
const imageStore = {
get: vi.fn(() => undefined),
retainFileIds: vi.fn(),
} as unknown as ImageAttachmentStore;
const controller = new EditorKeyboardController(host, imageStore);
controller.install();
const onCtrlS = editor['onCtrlS'];
if (onCtrlS === undefined) throw new Error('onCtrlS handler not installed');
Expand Down Expand Up @@ -648,4 +656,20 @@ describe('EditorKeyboardController Ctrl-S steering', () => {
expect(setText).not.toHaveBeenCalled();
expect(host.state.queuedMessages).toEqual([]);
});

it('expands paste markers in the editor draft before steering', () => {
const longText = 'line\n'.repeat(15).trimEnd();
const { host, setText, steerMessage, onCtrlS } = createCtrlSHarness({
editorText: '[paste #1 +15 lines]',
editorExpandedText: longText,
queued: [],
});

onCtrlS();

expect(steerMessage).toHaveBeenCalledWith(host.session, [
{ text: longText, parts: undefined, imageAttachmentIds: undefined },
]);
expect(setText).toHaveBeenCalledWith('');
});
});
Loading