mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 19:52:02 +00:00
Merge pull request #2776 from QwenLM/feat/enhance-btw-command
feat(cli): enhance /btw side question with improved prompt and Ctrl+C/D cancel
This commit is contained in:
parent
61bc80fe19
commit
e855229453
16 changed files with 351 additions and 57 deletions
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { render } from 'ink-testing-library';
|
||||
import { renderWithProviders } from '../../../test-utils/render.js';
|
||||
import { BtwMessage } from './BtwMessage.js';
|
||||
|
||||
describe('BtwMessage', () => {
|
||||
|
|
@ -16,7 +16,7 @@ describe('BtwMessage', () => {
|
|||
});
|
||||
|
||||
it('renders the side question and answer', () => {
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame } = renderWithProviders(
|
||||
<BtwMessage
|
||||
btw={{
|
||||
question: 'side question',
|
||||
|
|
@ -31,4 +31,57 @@ describe('BtwMessage', () => {
|
|||
expect(output).toContain('side question');
|
||||
expect(output).toContain('side answer');
|
||||
});
|
||||
|
||||
it('renders pending state with cancel hint', () => {
|
||||
const { lastFrame } = renderWithProviders(
|
||||
<BtwMessage
|
||||
btw={{
|
||||
question: 'pending question',
|
||||
answer: '',
|
||||
isPending: true,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
const output = lastFrame() ?? '';
|
||||
expect(output).toContain('/btw');
|
||||
expect(output).toContain('pending question');
|
||||
expect(output).toContain('Answering...');
|
||||
expect(output).toContain('Ctrl+C');
|
||||
expect(output).toContain('Ctrl+D');
|
||||
});
|
||||
|
||||
it('accepts containerWidth prop for content width calculation', () => {
|
||||
const { lastFrame } = renderWithProviders(
|
||||
<BtwMessage
|
||||
btw={{
|
||||
question: 'q',
|
||||
answer: 'some answer text',
|
||||
isPending: false,
|
||||
}}
|
||||
containerWidth={60}
|
||||
/>,
|
||||
);
|
||||
|
||||
const output = lastFrame() ?? '';
|
||||
expect(output).toContain('some answer text');
|
||||
});
|
||||
|
||||
it('renders dismiss hint when answer is complete', () => {
|
||||
const { lastFrame } = renderWithProviders(
|
||||
<BtwMessage
|
||||
btw={{
|
||||
question: 'q',
|
||||
answer: 'a',
|
||||
isPending: false,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
const output = lastFrame() ?? '';
|
||||
expect(output).toContain('Space');
|
||||
expect(output).toContain('Enter');
|
||||
expect(output).toContain('Escape');
|
||||
expect(output).toContain('dismiss');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue