mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-10 17:49:06 +00:00
* feat(web-shell): queue prompts while turns are running * fix(web-shell): address pending prompt review feedback * fix(web-shell): tighten queued prompt event handling * fix(web-shell): avoid showing active prompt as queued * fix(web-shell): address queued prompt review follow-ups * fix(web-shell): address pending prompt review issues * fix(web-shell): reconcile queued prompt actions from server * fix(daemon): address pending prompt critical review * test(webui): expect submit abort signal forwarding * fix(web-shell): avoid duplicate queued prompt sync * fix(web-shell): keep local slash commands out of queue * fix(webui): avoid aborting prompt admission * fix(daemon): avoid queued prompt cancel cascades * fix(webui): avoid stale client id for queue cleanup * test(webui): update stale session queue cleanup expectation * fix(web-shell): preserve queue reconciliation identity * fix(web-shell): guard queue clear session writes --------- Co-authored-by: ytahdn <ytahdn@gmail.com> Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import {
|
|
appendOrDeferLocalUserMessage,
|
|
isCommandPrompt,
|
|
} from './localCommandQueue';
|
|
|
|
describe('appendOrDeferLocalUserMessage', () => {
|
|
it('appends and returns false when no turn is streaming', () => {
|
|
const append = vi.fn();
|
|
const enqueue = vi.fn();
|
|
|
|
const deferred = appendOrDeferLocalUserMessage(
|
|
false,
|
|
'/context',
|
|
undefined,
|
|
{
|
|
append,
|
|
},
|
|
);
|
|
|
|
expect(deferred).toBe(false);
|
|
expect(append).toHaveBeenCalledExactlyOnceWith('/context');
|
|
expect(enqueue).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('suppresses local commands and returns true while a turn is streaming', () => {
|
|
const append = vi.fn();
|
|
const enqueue = vi.fn();
|
|
|
|
const deferred = appendOrDeferLocalUserMessage(
|
|
true,
|
|
'/context',
|
|
undefined,
|
|
{
|
|
append,
|
|
},
|
|
);
|
|
|
|
expect(deferred).toBe(true);
|
|
expect(enqueue).not.toHaveBeenCalled();
|
|
expect(append).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('does not enqueue images when suppressing', () => {
|
|
const append = vi.fn();
|
|
const enqueue = vi.fn();
|
|
const images = [{ data: 'base64xx', media_type: 'image/png' }];
|
|
|
|
appendOrDeferLocalUserMessage(true, '/stats', images, { append });
|
|
|
|
expect(enqueue).not.toHaveBeenCalled();
|
|
expect(append).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('isCommandPrompt', () => {
|
|
it('treats slash and shell prefixes as commands', () => {
|
|
expect(isCommandPrompt('/context detail')).toBe(true);
|
|
expect(isCommandPrompt('/stats')).toBe(true);
|
|
expect(isCommandPrompt('!ls -la')).toBe(true);
|
|
expect(isCommandPrompt(' /context')).toBe(true); // leading whitespace
|
|
});
|
|
|
|
it('treats prose as not a command', () => {
|
|
expect(isCommandPrompt('summarize the project structure')).toBe(false);
|
|
expect(isCommandPrompt('what does this do?')).toBe(false);
|
|
expect(isCommandPrompt('')).toBe(false);
|
|
});
|
|
});
|