Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep Assistant dev fixtures local

rcourtman50c0b68adcad
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.ts
index c43914c8a2..06d0931b3b 100644
--- a/frontend-modern/src/api/__tests__/aiChat.test.ts
+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts
@@ -241,6 +241,59 @@ describe('AIChatAPI', () => {
});
});
+ it('accepts the burst-tool alias for the tool-burst dev stream fixture', async () => {
+ const onEvent = vi.fn();
+
+ await AIChatAPI.chat('/fixture burst-tool', undefined, 'openrouter:qwen/qwen3.7-plus', onEvent);
+
+ expect(apiFetchMock).not.toHaveBeenCalled();
+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([
+ 'session',
+ 'workflow_state',
+ 'workflow_state',
+ 'tool_start',
+ 'tool_end',
+ 'content',
+ 'done',
+ ]);
+ expect(onEvent.mock.calls[0][0]).toMatchObject({
+ type: 'session',
+ data: { id: 'dev-fixture-tool-burst' },
+ });
+ expect(onEvent.mock.calls[6][0]).toMatchObject({
+ type: 'done',
+ data: {
+ session_id: 'dev-fixture-tool-burst',
+ model: 'openrouter:qwen/qwen3.7-plus',
+ },
+ });
+ });
+
+ it('fails unknown dev fixture prompts locally instead of sending them to a provider', async () => {
+ const onEvent = vi.fn();
+
+ await AIChatAPI.chat('/fixture typo-check', undefined, 'openrouter:qwen/qwen3.7-plus', onEvent);
+
+ expect(apiFetchMock).not.toHaveBeenCalled();
+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([
+ 'session',
+ 'workflow_state',
+ 'error',
+ ]);
+ expect(onEvent.mock.calls[2][0]).toMatchObject({
+ type: 'error',
+ data: {
+ message: expect.stringContaining('Unknown Assistant fixture "/fixture typo-check"'),
+ },
+ });
+ expect(onEvent.mock.calls[2][0]).toMatchObject({
+ type: 'error',
+ data: {
+ message: expect.stringContaining('tool-burst'),
+ },
+ });
+ });
+
it('runs the pending-tool dev stream fixture without opening a provider request', async () => {
const onEvent = vi.fn();
diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.ts
index cde239f158..9f87bb050a 100644
--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts
+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts
@@ -11,6 +11,17 @@ export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = [
'/fixture skipped-tool',
] as const;
+const AI_CHAT_DEV_STREAM_FIXTURE_ALIASES: Record<
+ string,
+ (typeof AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS)[number]
+> = {
+ '/fixture burst-tool': '/fixture tool-burst',
+};
+
+const availableFixtureNames = AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS.map((prompt) =>
+ prompt.replace('/fixture ', ''),
+);
+
const DEFAULT_DEV_FIXTURE_STEP_DELAY_MS = 140;
const TEST_FIXTURE_STEP_DELAY_MS = 0;
@@ -24,8 +35,18 @@ export interface AIChatDevStreamFixtureOptions {
const normalizeFixturePrompt = (prompt: string) => prompt.trim().toLowerCase().replace(/\s+/g, ' ');
-export const isAIChatDevStreamFixturePrompt = (prompt: string): boolean => {
+const canonicalizeFixturePrompt = (prompt: string) => {
+ const normalized = normalizeFixturePrompt(prompt);
+ return AI_CHAT_DEV_STREAM_FIXTURE_ALIASES[normalized] || normalized;
+};
+
+const isAIChatDevStreamFixtureCommand = (prompt: string): boolean => {
const normalized = normalizeFixturePrompt(prompt);
+ return normalized === '/fixture' || normalized.startsWith('/fixture ');
+};
+
+export const isAIChatDevStreamFixturePrompt = (prompt: string): boolean => {
+ const normalized = canonicalizeFixturePrompt(prompt);
return AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS.some((fixturePrompt) => fixturePrompt === normalized);
};
@@ -71,6 +92,26 @@ const waitForFixtureStep = (delayMs: number, signal?: AbortSignal) => {
const assistantFixtureModel = (model?: string) => model?.trim() || 'dev:assistant-stream-fixture';
+const buildUnknownFixtureEvents = (prompt: string): AIChatStreamEvent[] => [
+ {
+ type: 'session',
+ data: { id: 'dev-fixture-unknown' },
+ },
+ {
+ type: 'workflow_state',
+ data: {
+ phase: 'request_start',
+ message: 'Checking local Assistant fixture.',
+ },
+ },
+ {
+ type: 'error',
+ data: {
+ message: `Unknown Assistant fixture "${prompt}". Available fixtures: ${availableFixtureNames.join(', ')}.`,
+ },
+ },
+];
+
const buildDeviceCountFixtureEvents = (model?: string): AIChatStreamEvent[] => [
{
type: 'session',
@@ -532,8 +573,8 @@ const fixtureStepDelay = (
export const maybeRunAIChatDevStreamFixture = async (
options: AIChatDevStreamFixtureOptions,
): Promise<boolean> => {
- const normalizedPrompt = normalizeFixturePrompt(options.prompt);
- if (!isAIChatDevStreamFixtureAvailable() || !isAIChatDevStreamFixturePrompt(normalizedPrompt)) {
+ const normalizedPrompt = canonicalizeFixturePrompt(options.prompt);
+ if (!isAIChatDevStreamFixtureAvailable() || !isAIChatDevStreamFixtureCommand(options.prompt)) {
return false;
}
@@ -542,7 +583,9 @@ export const maybeRunAIChatDevStreamFixture = async (
(import.meta.env.MODE === 'test'
? TEST_FIXTURE_STEP_DELAY_MS
: DEFAULT_DEV_FIXTURE_STEP_DELAY_MS);
- const events = buildFixtureEvents(normalizedPrompt, options.model);
+ const events = isAIChatDevStreamFixturePrompt(normalizedPrompt)
+ ? buildFixtureEvents(normalizedPrompt, options.model)
+ : buildUnknownFixtureEvents(normalizeFixturePrompt(options.prompt));
for (let index = 0; index < events.length; index += 1) {
const event = events[index];