feat(tui): add multiline paste mode in minimal UI
This commit is contained in:
@@ -37,6 +37,7 @@ function minimalTuiPrivates(value: MinimalTui): {
|
||||
handleVerboseCommand: () => void;
|
||||
handleToolEvent: (event: unknown) => void;
|
||||
handleCommand: (command: unknown) => Promise<void>;
|
||||
handleMessage: (content: string) => Promise<void>;
|
||||
handleEscapeAction: () => boolean;
|
||||
handleCtrlCPress: (nowMs?: number) => boolean;
|
||||
clearSubmittedPromptLine: () => boolean;
|
||||
@@ -60,6 +61,7 @@ function minimalTuiPrivates(value: MinimalTui): {
|
||||
handleVerboseCommand: () => void;
|
||||
handleToolEvent: (event: unknown) => void;
|
||||
handleCommand: (command: unknown) => Promise<void>;
|
||||
handleMessage: (content: string) => Promise<void>;
|
||||
handleEscapeAction: () => boolean;
|
||||
handleCtrlCPress: (nowMs?: number) => boolean;
|
||||
clearSubmittedPromptLine: () => boolean;
|
||||
@@ -401,6 +403,48 @@ describe('MinimalTui backend command', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('collects multiline input from /paste and sends as one message', async () => {
|
||||
const mockSession = {
|
||||
id: 'test',
|
||||
getHistory: () => [],
|
||||
addMessage: vi.fn(),
|
||||
clear: vi.fn(),
|
||||
replaceHistory: vi.fn(),
|
||||
};
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
||||
try {
|
||||
const tui = new MinimalTui({
|
||||
session: asSession(mockSession),
|
||||
modelClient: asModelClient({}),
|
||||
systemPrompt: 'test',
|
||||
});
|
||||
|
||||
const promptSpy = vi.fn()
|
||||
.mockResolvedValueOnce('first line')
|
||||
.mockResolvedValueOnce('second line')
|
||||
.mockResolvedValueOnce('.');
|
||||
minimalTuiPrivates(tui).prompt = promptSpy;
|
||||
|
||||
const handleMessageSpy = vi.fn(async () => {});
|
||||
minimalTuiPrivates(tui).handleMessage = handleMessageSpy;
|
||||
minimalTuiPrivates(tui).running = true;
|
||||
minimalTuiPrivates(tui).rl = {
|
||||
once: vi.fn(),
|
||||
removeListener: vi.fn(),
|
||||
question: vi.fn(),
|
||||
write: vi.fn(),
|
||||
prompt: vi.fn(),
|
||||
};
|
||||
|
||||
await minimalTuiPrivates(tui).handleCommand({ type: 'multiline' });
|
||||
|
||||
expect(handleMessageSpy).toHaveBeenCalledWith('first line\nsecond line');
|
||||
expect(promptSpy).toHaveBeenCalledTimes(3);
|
||||
} finally {
|
||||
logSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('only renders tool activity when verbose mode is enabled', () => {
|
||||
const mockSession = {
|
||||
id: 'test',
|
||||
|
||||
Reference in New Issue
Block a user