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.

Make Assistant startup status feel active

rcourtmanaf78b1431aed
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index f4129e8767..c190560c1a 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -514,6 +514,10 @@ runtime cost control, and shared AI transport surfaces.
turns, and selected-provider startup. These events are runtime progress, not
Assistant-authored analysis, and they must not become keyword routers,
explore pre-passes, or instructions that choose the model's next action.
+ Selected-provider startup copy must describe the provider route as actively
+ starting the response (for example, `<Provider> is starting the response.`)
+ rather than as a passive wait label, while preserving the same
+ `provider_start` phase and concrete model-route payload.
The HTTP chat stream handler also owns visible idle progress for silent
intervals after the stream has opened: if no client-visible Assistant event
reaches the browser for the governed idle interval while execution is still
@@ -550,6 +554,11 @@ runtime cost control, and shared AI transport surfaces.
superseded. Live workflow and pending-tool activity must retain a per-state
start timestamp so the drawer can show elapsed wait/run time for long
provider starts and tool calls instead of repeating a timeless waiting label.
+ If the UI enters a loading turn before the assistant shell or first
+ `workflow_state` exists, the active-turn footer must show the active startup
+ status `Sending prompt` and derive elapsed time from the submitted, non-queued
+ user turn or assistant shell timestamp. Queued follow-up messages must not
+ reset that active-turn startup clock.
The referenced OpenCode source at fetched `origin/dev` commit
`0875203a6c726d7a37b5ffbb770cc433c98e7cd6` mutates typed message parts as
events arrive in `packages/opencode/src/cli/cmd/tui/context/sync.tsx`
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index d31405a272..8da7e0b861 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1062,7 +1062,10 @@ the canonical monitored-system blocked payload.
`provider` and `model`, and provider fallback transitions may additionally
carry `failed_provider`, `failed_model`, `next_provider`, and `next_model` so
diagnostics can identify the exact route change without expanding the visible
- operator message. The generated
+ operator message. The selected-route `provider_start` message is operator
+ progress copy and must be active/in-progress wording such as
+ `<Provider> is starting the response.` while the typed `provider` and `model`
+ fields carry the exact route identity. The generated
`frontend-modern/src/api/generated/aiChatEvents.ts` type must stay derived
from `internal/ai/chat/types.go` through `scripts/generate-types.go`, and
frontend API tests must pin any new generated SSE fields, including live
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.ts
index abc7e93903..0606665188 100644
--- a/frontend-modern/src/api/__tests__/aiChat.test.ts
+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts
@@ -218,7 +218,7 @@ describe('AIChatAPI', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
model: 'openrouter:deepseek/deepseek-chat',
},
});
@@ -365,7 +365,7 @@ describe('AIChatAPI', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
model: 'openrouter:qwen/qwen3.7-plus',
},
});
@@ -525,7 +525,7 @@ describe('AIChatAPI', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: 'openrouter:qwen/qwen3.7-plus',
},
diff --git a/frontend-modern/src/api/__tests__/aiChatEvents.test.ts b/frontend-modern/src/api/__tests__/aiChatEvents.test.ts
index f1fa0f889b..89b1bbc52a 100644
--- a/frontend-modern/src/api/__tests__/aiChatEvents.test.ts
+++ b/frontend-modern/src/api/__tests__/aiChatEvents.test.ts
@@ -45,7 +45,7 @@ describe('AI chat stream event contract', () => {
it('exposes selected provider and model metadata on workflow state events', () => {
const workflow: WorkflowStateData = {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: 'openrouter:qwen/qwen3.7-plus',
};
diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.ts
index 66fa9783e8..5137120665 100644
--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts
+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts
@@ -255,7 +255,7 @@ const buildToolBurstFixtureEvents = (model?: string): AIChatStreamEvent[] => [
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
model: assistantFixtureModel(model),
},
},
@@ -417,7 +417,7 @@ const buildStatusBoundaryFixtureEvents = (model?: string): AIChatStreamEvent[] =
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
model: assistantFixtureModel(model),
},
},
@@ -518,7 +518,7 @@ const buildProviderRetryFixtureEvents = (): AIChatStreamEvent[] => [
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to DeepSeek; waiting for the first token.',
+ message: 'DeepSeek is starting the response.',
provider: 'deepseek',
model: 'deepseek:deepseek-chat',
},
@@ -579,7 +579,7 @@ const buildStreamIdleFixtureEvents = (model?: string): AIChatStreamEvent[] => [
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: assistantFixtureModel(model),
},
@@ -624,7 +624,7 @@ const buildQueueHoldFixtureEvents = (model?: string): AIChatStreamEvent[] => [
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: assistantFixtureModel(model),
},
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index aca561b118..e58e533e48 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -5064,7 +5064,25 @@ describe('AIChat', () => {
mockChat.messages.mockReturnValue([]);
renderChat();
expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
- 'Waiting for assistant',
+ 'Sending prompt',
+ );
+ });
+
+ it('shows startup elapsed time once the submitted prompt timestamp is known', () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(5_000);
+ mockChat.isLoading.mockReturnValue(true);
+ mockChat.messages.mockReturnValue([
+ {
+ id: 'user-1',
+ role: 'user' as const,
+ content: 'Check current resource',
+ timestamp: new Date(1_000),
+ },
+ ]);
+ renderChat();
+ expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
+ 'Sending prompt (4s)',
);
});
@@ -5082,7 +5100,7 @@ describe('AIChat', () => {
]);
renderChat();
expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
- 'Waiting for assistant',
+ 'Sending prompt',
);
expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
});
@@ -5206,7 +5224,7 @@ describe('AIChat', () => {
},
{
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_200,
},
];
@@ -5238,7 +5256,7 @@ describe('AIChat', () => {
const status = screen.getByLabelText('Assistant active turn status');
expect(status).toHaveTextContent('Preparing Pulse context.');
expect(status).not.toHaveTextContent(
- 'Sent request to OpenRouter; waiting for the first token.',
+ 'OpenRouter is starting the response.',
);
await vi.advanceTimersByTimeAsync(650);
@@ -5246,7 +5264,7 @@ describe('AIChat', () => {
expect(status).not.toHaveTextContent('pulse_query');
await vi.advanceTimersByTimeAsync(650);
- expect(status).toHaveTextContent('Sent request to OpenRouter; waiting for the first token.');
+ expect(status).toHaveTextContent('OpenRouter is starting the response.');
expect(status).not.toHaveTextContent('Preparing Pulse context.');
expect(status).not.toHaveTextContent('Reading current Pulse inventory with pulse_query.');
});
@@ -5279,7 +5297,7 @@ describe('AIChat', () => {
isStreaming: true,
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
streamEvents: [
@@ -5287,7 +5305,7 @@ describe('AIChat', () => {
type: 'workflow_status',
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
startedAt: 1_000,
@@ -5314,7 +5332,7 @@ describe('AIChat', () => {
'Completed Inspect devices on current resource',
);
expect(screen.getByLabelText('Assistant active turn status')).not.toHaveTextContent(
- 'Sent request to OpenRouter; waiting for the first token.',
+ 'OpenRouter is starting the response.',
);
});
@@ -5347,14 +5365,14 @@ describe('AIChat', () => {
streamEvents: [{ type: 'content', content: 'I checked the first source.' }],
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: Date.now() - 5_000,
},
},
]);
renderChat();
expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
- 'Sent request to OpenRouter; waiting for the first token.',
+ 'OpenRouter is starting the response.',
);
});
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index 1f6ad9560a..f2ab2ba368 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -755,7 +755,7 @@ describe('MessageItem', () => {
},
{
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_200,
},
];
@@ -785,7 +785,7 @@ describe('MessageItem', () => {
screen.queryByText(/Reading current Pulse inventory with pulse_query\./),
).not.toBeInTheDocument();
expect(
- screen.getByText(/Sent request to OpenRouter; waiting for the first token\./),
+ screen.getByText(/OpenRouter is starting the response\./),
).toBeInTheDocument();
});
@@ -802,7 +802,7 @@ describe('MessageItem', () => {
},
{
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_300,
},
];
@@ -843,7 +843,7 @@ describe('MessageItem', () => {
expect(screen.getByText('Reading current Pulse inventory.')).toBeInTheDocument();
expect(screen.getByText('3 devices found')).toBeInTheDocument();
expect(
- screen.getByText('Sent request to OpenRouter; waiting for the first token.'),
+ screen.getByText('OpenRouter is starting the response.'),
).toBeInTheDocument();
expect(screen.queryByText(/pulse_query/)).not.toBeInTheDocument();
});
@@ -859,7 +859,7 @@ describe('MessageItem', () => {
streamEvents: [{ type: 'content', content: 'Partial answer' }],
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
})}
{...makeHandlers()}
@@ -868,7 +868,7 @@ describe('MessageItem', () => {
expect(screen.getByText('Partial answer')).toBeInTheDocument();
expect(
- screen.queryByText('Sent request to OpenRouter; waiting for the first token.'),
+ screen.queryByText('OpenRouter is starting the response.'),
).not.toBeInTheDocument();
expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
});
@@ -886,7 +886,7 @@ describe('MessageItem', () => {
type: 'workflow_status',
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
},
{ type: 'content', content: 'Partial answer' },
@@ -897,7 +897,7 @@ describe('MessageItem', () => {
));
expect(
- screen.getByText('Sent request to OpenRouter; waiting for the first token.'),
+ screen.getByText('OpenRouter is starting the response.'),
).toBeInTheDocument();
expect(screen.getByText('Partial answer')).toBeInTheDocument();
expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
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 abc1c876c7..409dd0e873 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -10,15 +10,59 @@ const assistantMessage = (overrides: Partial<ChatMessage> = {}): ChatMessage =>
...overrides,
});
+const userMessage = (overrides: Partial<ChatMessage> = {}): ChatMessage => ({
+ id: 'user-1',
+ role: 'user',
+ content: 'Check the current node',
+ timestamp: new Date(),
+ ...overrides,
+});
+
describe('getAssistantActiveTurnStatus', () => {
it('stays quiet when no Assistant turn is active', () => {
expect(getAssistantActiveTurnStatus([], false)).toBeNull();
});
- it('shows a waiting state before the first assistant event arrives', () => {
+ it('shows an active send state before the first assistant event arrives', () => {
expect(getAssistantActiveTurnStatus([], true)).toEqual({
type: 'thinking',
- text: 'Waiting for assistant',
+ text: 'Sending prompt',
+ });
+ });
+
+ it('tracks startup timing from the submitted user turn', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [userMessage({ timestamp: new Date(1_000) })],
+ true,
+ 4_000,
+ ),
+ ).toEqual({
+ type: 'thinking',
+ text: 'Sending prompt',
+ startedAt: 1_000,
+ });
+ });
+
+ it('does not let queued follow-ups reset the active turn startup time', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ userMessage({ id: 'user-1', timestamp: new Date(1_000), delivery: 'sent' }),
+ userMessage({
+ id: 'user-2',
+ content: 'Follow up',
+ timestamp: new Date(5_000),
+ delivery: 'queued',
+ }),
+ ],
+ true,
+ 6_000,
+ ),
+ ).toEqual({
+ type: 'thinking',
+ text: 'Sending prompt',
+ startedAt: 1_000,
});
});
@@ -102,7 +146,7 @@ describe('getAssistantActiveTurnStatus', () => {
assistantMessage({
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt,
},
}),
@@ -111,7 +155,7 @@ describe('getAssistantActiveTurnStatus', () => {
),
).toEqual({
type: 'thinking',
- text: 'Sent request to OpenRouter; waiting for the first token.',
+ text: 'OpenRouter is starting the response.',
startedAt,
});
});
@@ -127,7 +171,7 @@ describe('getAssistantActiveTurnStatus', () => {
type: 'workflow_status',
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
startedAt: 1_000,
@@ -393,7 +437,7 @@ describe('getAssistantActiveTurnStatus', () => {
isStreaming: true,
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
streamEvents: [
@@ -401,7 +445,7 @@ describe('getAssistantActiveTurnStatus', () => {
type: 'workflow_status',
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
startedAt: 1_000,
@@ -454,7 +498,7 @@ describe('getAssistantActiveTurnStatus', () => {
isStreaming: true,
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
streamEvents: [
@@ -462,7 +506,7 @@ describe('getAssistantActiveTurnStatus', () => {
type: 'workflow_status',
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
startedAt: 1_000,
@@ -536,7 +580,7 @@ describe('getAssistantActiveTurnStatus', () => {
assistantMessage({
workflowStatus: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
startedAt: 1_000,
},
streamEvents: [
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 807c4db857..fc51759278 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -1443,20 +1443,20 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.workflowStatus).toEqual(
expect.objectContaining({
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
}),
);
expect(assistant.streamEvents).toEqual([
expect.objectContaining({
type: 'workflow_status',
workflowStatus: expect.objectContaining({
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
}),
}),
]);
@@ -1464,7 +1464,7 @@ describe('useChat', () => {
'Preparing Pulse context.',
'Reading current Pulse inventory with pulse_query.',
'Built compact inventory context for the model.',
- 'Sent request to OpenRouter; waiting for the first token.',
+ 'OpenRouter is starting the response.',
]);
dispose();
@@ -1481,7 +1481,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
fire({
@@ -1524,7 +1524,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: 'openrouter:qwen/qwen3.7-plus',
},
@@ -1533,7 +1533,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
provider: 'openrouter',
model: 'openrouter:qwen/qwen3.7-plus',
},
@@ -1558,7 +1558,7 @@ describe('useChat', () => {
type: 'workflow_status',
workflowStatus: expect.objectContaining({
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
}),
}),
);
@@ -1597,7 +1597,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to DeepSeek; waiting for the first token.',
+ message: 'DeepSeek is starting the response.',
provider: 'deepseek',
model: 'deepseek:deepseek-chat',
},
@@ -1639,7 +1639,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to DeepSeek; waiting for the first token.',
+ message: 'DeepSeek is starting the response.',
provider: 'deepseek',
model: 'deepseek:deepseek-chat',
},
@@ -1714,7 +1714,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
fire({ type: 'content', data: 'Here is the answer.' });
@@ -1731,7 +1731,7 @@ describe('useChat', () => {
type: 'workflow_status',
workflowStatus: expect.objectContaining({
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
}),
}),
);
@@ -1784,7 +1784,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
fire({ type: 'tool_start', data: { id: 'tool-1', name: 'pulse_alerts', input: '{}' } });
@@ -2418,7 +2418,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
fire({ type: 'content', data: 'partial response' });
@@ -2480,7 +2480,7 @@ describe('useChat', () => {
type: 'workflow_state',
data: {
phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
+ message: 'OpenRouter is starting the response.',
},
});
fire({ type: 'content', data: 'partial response' });
diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
index f3d3b452c0..1b6b42f82e 100644
--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
@@ -513,6 +513,41 @@ const hasVisibleAssistantOutput = (message: ChatMessage): boolean => {
});
};
+const messageTimestampMs = (message?: ChatMessage): number | undefined => {
+ const timestamp = message?.timestamp;
+ if (!(timestamp instanceof Date)) return undefined;
+ const value = timestamp.getTime();
+ return Number.isFinite(value) ? value : undefined;
+};
+
+const latestSentUserMessage = (messages: ChatMessage[]): ChatMessage | undefined => {
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
+ const message = messages[index];
+ if (message.role === 'user' && message.delivery !== 'queued') {
+ return message;
+ }
+ }
+ return undefined;
+};
+
+const activeTurnStartedAt = (
+ messages: ChatMessage[],
+ assistantMessage?: ChatMessage,
+): number | undefined =>
+ messageTimestampMs(assistantMessage) ?? messageTimestampMs(latestSentUserMessage(messages));
+
+const initialRequestStatus = (
+ messages: ChatMessage[],
+ assistantMessage?: ChatMessage,
+): AssistantActiveTurnStatus => {
+ const startedAt = activeTurnStartedAt(messages, assistantMessage);
+ return {
+ type: 'thinking',
+ text: 'Sending prompt',
+ ...(startedAt !== undefined ? { startedAt } : {}),
+ };
+};
+
export const getAssistantActiveTurnStatus = (
messages: ChatMessage[],
isLoading: boolean,
@@ -522,7 +557,7 @@ export const getAssistantActiveTurnStatus = (
const assistantMessage = [...messages].reverse().find((message) => message.role === 'assistant');
if (!assistantMessage) {
- return { type: 'thinking', text: 'Waiting for assistant' };
+ return initialRequestStatus(messages);
}
const statusCandidates: AssistantActiveTurnStatusCandidate[] = [];
@@ -573,5 +608,5 @@ export const getAssistantActiveTurnStatus = (
return { type: 'generating', text: 'Generating response' };
}
- return { type: 'thinking', text: 'Waiting for assistant' };
+ return initialRequestStatus(messages, assistantMessage);
};
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index bb36aaa8cb..b8e08eb897 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -878,7 +878,7 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbac
emitWorkflowState(
streamCallback,
"provider_start",
- fmt.Sprintf("Sent request to %s; waiting for the first token.", providerLabelForAttempt(attempt)),
+ fmt.Sprintf("%s is starting the response.", providerLabelForAttempt(attempt)),
sessionFSMState(sessionFSM),
"",
withWorkflowModelRoute(attempt.Model),
diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.go
index 84783a97f6..bfbe088a83 100644
--- a/internal/ai/chat/service_execute_additional_test.go
+++ b/internal/ai/chat/service_execute_additional_test.go
@@ -683,7 +683,7 @@ func TestService_ExecuteStream_EmitsProviderStartupBeforeProviderCall(t *testing
}
if data.Phase == "provider_start" {
providerStartSeen.Store(true)
- if data.Message != "Sent request to OpenRouter; waiting for the first token." {
+ if data.Message != "OpenRouter is starting the response." {
t.Fatalf("provider_start message = %q", data.Message)
}
if data.Provider != config.AIProviderOpenRouter {