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.

Remove duplicate Assistant streaming status

rcourtman9e05efaf8e0e
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 6770713937..64d1f8a575 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -109,6 +109,10 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
!props.message.content.trim() &&
!hasRenderableStreamEvents() &&
!props.message.error;
+ const inlineStreamingStatusText = createMemo(() => {
+ const workflowMessage = props.message.workflowStatus?.message?.trim();
+ return workflowMessage || 'Thinking...';
+ });
const interruptionLabel = createMemo(() => {
switch (props.message.interruption) {
case 'replaced':
@@ -210,7 +214,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
style="animation-delay: 240ms"
/>
</span>
- <span>Thinking...</span>
+ <span>{inlineStreamingStatusText()}</span>
</div>
</Show>
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 82f7a9b8fd..73c3211771 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -2869,7 +2869,7 @@ describe('AIChat', () => {
expect(screen.getByText('Thinking...')).toBeInTheDocument();
});
- it('shows "Thinking..." while the assistant turn waits for the first token', () => {
+ it('does not duplicate first-token status in the footer once an assistant turn exists', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
{
@@ -2882,11 +2882,11 @@ describe('AIChat', () => {
},
]);
renderChat();
- expect(screen.getByText('Thinking...')).toBeInTheDocument();
+ expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
});
- it('shows workflow progress while the assistant turn waits for the first token', () => {
+ it('does not duplicate workflow progress in the footer once an assistant turn exists', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
{
@@ -2906,13 +2906,13 @@ describe('AIChat', () => {
]);
renderChat();
expect(
- screen.getByText('Planning governed action and safety checks before execution.'),
- ).toBeInTheDocument();
+ screen.queryByText('Planning governed action and safety checks before execution.'),
+ ).not.toBeInTheDocument();
expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
});
- it('shows tool status when assistant has pending tools', () => {
+ it('does not duplicate pending tool status in the footer once an assistant turn exists', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
{
@@ -2924,10 +2924,10 @@ describe('AIChat', () => {
},
]);
renderChat();
- expect(screen.getByText('Running get nodes...')).toBeInTheDocument();
+ expect(screen.queryByText('Running get nodes...')).not.toBeInTheDocument();
});
- it('shows "Generating response..." when assistant is streaming', () => {
+ it('does not duplicate status in the footer when assistant content is streaming', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
{
@@ -2939,10 +2939,11 @@ describe('AIChat', () => {
},
]);
renderChat();
- expect(screen.getByText('Generating response...')).toBeInTheDocument();
+ expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
+ expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
});
- it('tracks the active assistant status when a queued user turn is the last message', () => {
+ it('keeps queued follow-up status without duplicating active assistant streaming status', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.queuedFollowUpCount.mockReturnValue(1);
mockChat.messages.mockReturnValue([
@@ -2962,7 +2963,7 @@ describe('AIChat', () => {
},
]);
renderChat();
- expect(screen.getByText('Generating response...')).toBeInTheDocument();
+ expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
expect(screen.getByText('1 follow-up queued')).toBeInTheDocument();
});
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 13e47cd1d3..72353555cc 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -506,6 +506,32 @@ describe('MessageItem', () => {
expect(container.querySelector('.animate-pulse')).not.toBeInTheDocument();
});
+ it('shows workflow progress inline before content arrives', () => {
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content: '',
+ isStreaming: true,
+ pendingTools: [],
+ streamEvents: [],
+ workflowStatus: {
+ phase: 'plan',
+ message: 'Planning governed action and safety checks before execution.',
+ state: 'READING',
+ tool: 'pulse_exec',
+ },
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(
+ screen.getByText('Planning governed action and safety checks before execution.'),
+ ).toBeInTheDocument();
+ expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
+ });
+
it('does not show cursor when streaming but there are pending tools', () => {
const { container } = render(() => (
<MessageItem
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index cbd15623ca..006f05e671 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -1064,40 +1064,19 @@ export const AIChat: Component<AIChatProps> = (props) => {
if (!chat.isLoading()) return null;
const messages = chat.messages();
- const lastMessage =
- [...messages]
- .reverse()
- .find((message) => message.role === 'assistant' && message.isStreaming) ||
- messages[messages.length - 1];
-
- if (!lastMessage || lastMessage.role !== 'assistant') {
- return { type: 'thinking', text: 'Thinking...' };
- }
-
- if (lastMessage.pendingTools && lastMessage.pendingTools.length > 0) {
- const tool = lastMessage.pendingTools[0];
- const toolName = formatIdentifierLabel(tool.name, { stripPrefix: 'pulse_' });
- return { type: 'tool', text: `Running ${toolName}...` };
- }
-
- const workflowMessage = lastMessage.workflowStatus?.message.trim();
- if (lastMessage.isStreaming && !lastMessage.content.trim() && workflowMessage) {
- return { type: 'thinking', text: workflowMessage };
+ const activeAssistant = [...messages]
+ .reverse()
+ .find((message) => message.role === 'assistant' && message.isStreaming);
+ if (activeAssistant) {
+ return null;
}
- const isWaitingForFirstToken =
- lastMessage.isStreaming &&
- !lastMessage.content.trim() &&
- (!lastMessage.streamEvents || lastMessage.streamEvents.length === 0);
+ const lastMessage = messages[messages.length - 1];
- if (isWaitingForFirstToken) {
+ if (!lastMessage || lastMessage.role !== 'assistant') {
return { type: 'thinking', text: 'Thinking...' };
}
- if (lastMessage.isStreaming) {
- return { type: 'generating', text: 'Generating response...' };
- }
-
return { type: 'thinking', text: 'Thinking...' };
});