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.

Show Assistant stream idle progress

rcourtmanacae3aae28c4
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 6506a011d6..c220c92290 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -546,6 +546,9 @@ runtime cost control, and shared AI transport surfaces.
the real `provider_retry` workflow state, including attempt metadata and
`retry_after_ms`, so browser proof of retry countdown behavior does not
depend on external provider availability or API spend.
+ The local `stream-idle` fixture must exercise the real `stream_idle`
+ workflow state after selected-provider startup so browser proof of visible
+ idle liveness does not depend on making a real provider pause on demand.
This fixture is a local development primitive, not a product mode: it must
not bypass backend governance in production, persist as a server session, or
introduce any UI-only event shape that real providers cannot emit.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 735bcb3693..8f8126b424 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -580,7 +580,10 @@ payload shape change when the portal presents compact client rows.
Assistant sequence must exercise `provider_retry` with `attempt`,
`max_attempts`, and `retry_after_ms` metadata plus a paced retry window, so
browser proof can verify visible retry countdown behavior without a real
- provider request, VPN dependency, or API spend.
+ provider request, VPN dependency, or API spend. At least one fixture-backed
+ Assistant sequence must exercise `stream_idle` after selected-provider
+ startup, so browser proof can verify visible idle liveness without forcing a
+ real provider to pause on demand.
34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.
Legacy Assistant SSE routes in this handler that still use the older
execute envelope, including `/api/ai/execute/stream` and
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.ts
index 5429a1600f..c43914c8a2 100644
--- a/frontend-modern/src/api/__tests__/aiChat.test.ts
+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts
@@ -332,6 +332,50 @@ describe('AIChatAPI', () => {
});
});
+ it('runs the stream-idle dev stream fixture without opening a provider request', async () => {
+ const onEvent = vi.fn();
+
+ await AIChatAPI.chat(
+ '/fixture stream-idle',
+ 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',
+ 'workflow_state',
+ 'content',
+ 'done',
+ ]);
+ expect(onEvent.mock.calls[2][0]).toMatchObject({
+ type: 'workflow_state',
+ data: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ provider: 'openrouter',
+ model: 'openrouter:qwen/qwen3.7-plus',
+ },
+ });
+ expect(onEvent.mock.calls[3][0]).toMatchObject({
+ type: 'workflow_state',
+ data: {
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
+ },
+ });
+ expect(onEvent.mock.calls[5][0]).toMatchObject({
+ type: 'done',
+ data: {
+ session_id: 'dev-fixture-stream-idle',
+ model: 'openrouter:qwen/qwen3.7-plus',
+ },
+ });
+ });
+
it('runs the compacted-artifact 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 1df7c193b5..cde239f158 100644
--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts
+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts
@@ -6,6 +6,7 @@ export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = [
'/fixture tool-burst',
'/fixture pending-tool',
'/fixture provider-retry',
+ '/fixture stream-idle',
'/fixture compacted-artifact',
'/fixture skipped-tool',
] as const;
@@ -372,6 +373,51 @@ const buildProviderRetryFixtureEvents = (): AIChatStreamEvent[] => [
},
];
+const buildStreamIdleFixtureEvents = (model?: string): AIChatStreamEvent[] => [
+ {
+ type: 'session',
+ data: { id: 'dev-fixture-stream-idle' },
+ },
+ {
+ type: 'workflow_state',
+ data: {
+ phase: 'request_start',
+ message: 'Preparing Pulse context.',
+ },
+ },
+ {
+ type: 'workflow_state',
+ data: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ provider: 'openrouter',
+ model: assistantFixtureModel(model),
+ },
+ },
+ {
+ type: 'workflow_state',
+ data: {
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
+ },
+ },
+ {
+ type: 'content',
+ data: {
+ text: 'The stream-idle fixture kept visible progress alive while the provider stayed quiet.',
+ },
+ },
+ {
+ type: 'done',
+ data: {
+ session_id: 'dev-fixture-stream-idle',
+ model: assistantFixtureModel(model),
+ input_tokens: 41,
+ output_tokens: 19,
+ },
+ },
+];
+
const buildCompactedArtifactFixtureEvents = (model?: string): AIChatStreamEvent[] => [
{
type: 'session',
@@ -448,6 +494,9 @@ const buildFixtureEvents = (prompt: string, model?: string): AIChatStreamEvent[]
if (normalized === '/fixture provider-retry') {
return buildProviderRetryFixtureEvents();
}
+ if (normalized === '/fixture stream-idle') {
+ return buildStreamIdleFixtureEvents(model);
+ }
return buildDeviceCountFixtureEvents(model);
};
@@ -467,6 +516,13 @@ const fixtureStepDelay = (
if (normalizedPrompt === '/fixture pending-tool' && event.type === 'tool_progress') {
return 2200;
}
+ if (
+ normalizedPrompt === '/fixture stream-idle' &&
+ event.type === 'workflow_state' &&
+ event.data.phase === 'stream_idle'
+ ) {
+ return 1800;
+ }
if (normalizedPrompt === '/fixture pending-tool') return defaultDelayMs;
if (normalizedPrompt !== '/fixture tool-burst') return defaultDelayMs;
if (event.type === 'tool_start') return 0;
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
index 996b326af5..08740677ef 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -116,6 +116,45 @@ describe('getAssistantActiveTurnStatus', () => {
});
});
+ it('surfaces stream-idle liveness over stale provider-start progress', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: true,
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ startedAt: 1_000,
+ updatedAt: 1_000,
+ },
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
+ startedAt: 2_000,
+ },
+ startedAt: 2_000,
+ updatedAt: 2_000,
+ },
+ ],
+ }),
+ ],
+ true,
+ ),
+ ).toEqual({
+ type: 'thinking',
+ text: 'Assistant is still working; waiting for the next stream event.',
+ startedAt: 2_000,
+ });
+ });
+
it('prefers workflow progress over selected model route evidence', () => {
const startedAt = Date.now() - 1_000;
expect(
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
index 71e460fec5..23ca705a08 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -1419,7 +1419,7 @@ describe('useChat', () => {
dispose();
});
- it('keeps the provider wait visible when an idle heartbeat arrives', async () => {
+ it('replaces provider wait with visible idle progress when an idle heartbeat arrives', async () => {
const { getFireEvent } = setupWithEventCapture();
const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));
@@ -1444,8 +1444,8 @@ describe('useChat', () => {
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.workflowStatus).toEqual(
expect.objectContaining({
- phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
}),
);
expect(assistant.streamEvents).toHaveLength(1);
@@ -1453,8 +1453,8 @@ describe('useChat', () => {
expect.objectContaining({
type: 'workflow_status',
workflowStatus: expect.objectContaining({
- phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
}),
}),
);
@@ -1617,7 +1617,7 @@ describe('useChat', () => {
dispose();
});
- it('keeps the local request-start status when an early idle heartbeat arrives', async () => {
+ it('replaces local request-start status with visible idle progress', async () => {
const { getFireEvent } = setupWithEventCapture();
const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));
@@ -1635,16 +1635,16 @@ describe('useChat', () => {
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.workflowStatus).toEqual(
expect.objectContaining({
- phase: 'request_start',
- message: 'Preparing Pulse context.',
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
}),
);
expect(assistant.streamEvents).toEqual([
expect.objectContaining({
type: 'workflow_status',
workflowStatus: expect.objectContaining({
- phase: 'request_start',
- message: 'Preparing Pulse context.',
+ phase: 'stream_idle',
+ message: 'Assistant is still working; waiting for the next stream event.',
}),
}),
]);
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index 795dd24b87..36885c90cf 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -151,18 +151,13 @@ export function useChat(options: UseChatOptions = {}) {
const isStreamIdleWorkflowStatus = (status?: WorkflowStatus) => status?.phase === 'stream_idle';
- // stream_idle is transport liveness, not a new Assistant step.
+ // stream_idle is transport liveness, but it must be visible as the latest
+ // active progress state instead of leaving the user on a stale phase label.
const visibleWorkflowStatusForHeartbeat = (
- current: WorkflowStatus | undefined,
+ _current: WorkflowStatus | undefined,
next: WorkflowStatus,
): WorkflowStatus => {
- if (!isStreamIdleWorkflowStatus(next)) return next;
- if (!current || isStreamIdleWorkflowStatus(current)) return next;
-
- return {
- ...current,
- startedAt: current.startedAt || next.startedAt,
- };
+ return next;
};
const setAssistantWorkflowStatus = (