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:
Shaojin Wen 2026-04-03 19:17:12 +08:00 committed by GitHub
parent 61bc80fe19
commit e855229453
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 351 additions and 57 deletions

View file

@ -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');
});
});