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.

Pause Assistant queued follow-ups on stop

rcourtmane9aa084f6b75
diff --git a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
index 694a6acbe2..a18f79e007 100644
--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
@@ -31,6 +31,7 @@ interface ChatMessagesProps {
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedFollowUps?: QueuedFollowUp[];
+ queuedFollowUpsPaused?: boolean;
onEditQueuedFollowUp?: (id: string) => void;
onCancelQueuedFollowUp?: (id: string) => void;
// Dashboard props
@@ -172,6 +173,7 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {
id: entry.id,
position: index + 1,
count: entries.length,
+ paused: Boolean(props.queuedFollowUpsPaused),
},
]),
);
@@ -271,6 +273,7 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {
onUseModelRoute={props.onUseModelRoute}
queuedPosition={queuedMeta()?.position}
queuedCount={queuedMeta()?.count}
+ queuedPaused={queuedMeta()?.paused}
onEditQueued={
queuedMeta() && props.onEditQueuedFollowUp
? () => {
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 7500d182d5..3bac48d846 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -70,6 +70,7 @@ interface MessageItemProps {
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedPosition?: number;
queuedCount?: number;
+ queuedPaused?: boolean;
onEditQueued?: () => void;
onCancelQueued?: () => void;
}
@@ -426,10 +427,11 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
if (!isQueuedUserMessage()) return '';
const position = props.queuedPosition;
const count = props.queuedCount;
+ const state = props.queuedPaused ? 'Paused' : 'Queued';
if (position && count && count > 1) {
- return `Queued ${position} of ${count}`;
+ return `${state} ${position} of ${count}`;
}
- return 'Queued';
+ return state;
});
// Group stream events into display blocks. Content collapses into a single
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 9d7b06a6a3..fbdd964b10 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -26,6 +26,7 @@ const {
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedFollowUps?: QueuedFollowUp[];
+ queuedFollowUpsPaused?: boolean;
onEditQueuedFollowUp?: (id: string) => void;
onCancelQueuedFollowUp?: (id: string) => void;
}> = [];
@@ -43,6 +44,7 @@ const {
model: vi.fn(() => ''),
setModel: vi.fn(),
queuedFollowUps: vi.fn((): QueuedFollowUp[] => []),
+ queuedFollowUpsPaused: vi.fn(() => false),
queuedFollowUpCount: vi.fn(() => 0),
sendMessage: vi.fn().mockResolvedValue(true),
retryMessage: vi.fn(),
@@ -240,6 +242,7 @@ vi.mock('../ChatMessages', () => ({
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedFollowUps?: QueuedFollowUp[];
+ queuedFollowUpsPaused?: boolean;
onEditQueuedFollowUp?: (id: string) => void;
onCancelQueuedFollowUp?: (id: string) => void;
}) => {
@@ -426,6 +429,7 @@ beforeEach(() => {
mockChat.sessionId.mockReturnValue('');
mockChat.model.mockReturnValue('');
mockChat.queuedFollowUps.mockReturnValue([]);
+ mockChat.queuedFollowUpsPaused.mockReturnValue(false);
mockChat.queuedFollowUpCount.mockReturnValue(0);
mockChat.sendMessage.mockResolvedValue(true);
mockChat.sendQueuedFollowUpNow.mockResolvedValue(true);
@@ -2407,6 +2411,33 @@ describe('AIChat', () => {
expect(mockChat.clearQueuedFollowUps).toHaveBeenCalledTimes(1);
});
+ it('shows paused queued follow-ups and lets the first one resume', () => {
+ mockChat.queuedFollowUpCount.mockReturnValue(1);
+ mockChat.queuedFollowUpsPaused.mockReturnValue(true);
+ mockChat.queuedFollowUps.mockReturnValue([
+ {
+ id: 'queued-paused-1',
+ messageId: 'msg-queued-paused-1',
+ prompt: 'paused queued prompt',
+ timestamp: new Date(),
+ },
+ ]);
+ renderChat();
+
+ expect(screen.getByRole('status', { name: 'Queued follow-up messages' })).toHaveTextContent(
+ '1 follow-up paused',
+ );
+ expect(mockChatMessagesProps.at(-1)?.queuedFollowUpsPaused).toBe(true);
+
+ fireEvent.click(
+ screen.getByRole('button', {
+ name: 'Resume queued follow-up: paused queued prompt',
+ }),
+ );
+
+ expect(mockChat.sendQueuedFollowUpNow).toHaveBeenCalledWith('queued-paused-1');
+ });
+
it('lets a later queued follow-up be promoted to send next', async () => {
mockChat.queuedFollowUpCount.mockReturnValue(2);
mockChat.queuedFollowUps.mockReturnValue([
@@ -2458,6 +2489,7 @@ describe('AIChat', () => {
const chatMessagesProps = mockChatMessagesProps.at(-1);
expect(chatMessagesProps?.queuedFollowUps).toBe(queuedFollowUps);
+ expect(chatMessagesProps?.queuedFollowUpsPaused).toBe(false);
chatMessagesProps?.onEditQueuedFollowUp?.('queued-row-1');
expect(mockChat.takeQueuedFollowUp).toHaveBeenCalledWith('queued-row-1');
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
index 2ff6a05754..5a35c35eef 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
@@ -26,6 +26,7 @@ let capturedMessageItemProps: Array<{
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedPosition?: number;
queuedCount?: number;
+ queuedPaused?: boolean;
onEditQueued?: () => void;
onCancelQueued?: () => void;
}> = [];
@@ -46,6 +47,7 @@ vi.mock('../MessageItem', () => ({
onUseModelRoute?: (modelId: string, messageId?: string) => void;
queuedPosition?: number;
queuedCount?: number;
+ queuedPaused?: boolean;
onEditQueued?: () => void;
onCancelQueued?: () => void;
}) => {
@@ -286,6 +288,8 @@ describe('ChatMessages', () => {
expect(firstQueued).toMatchObject({ queuedPosition: 1, queuedCount: 2 });
expect(secondQueued).toMatchObject({ queuedPosition: 2, queuedCount: 2 });
+ expect(firstQueued?.queuedPaused).toBe(false);
+ expect(secondQueued?.queuedPaused).toBe(false);
firstQueued?.onEditQueued?.();
secondQueued?.onCancelQueued?.();
@@ -294,6 +298,40 @@ describe('ChatMessages', () => {
expect(onCancelQueuedFollowUp).toHaveBeenCalledWith('queue-2');
});
+ it('passes paused queue state to queued message items', () => {
+ const queuedFollowUps: QueuedFollowUp[] = [
+ {
+ id: 'queue-1',
+ messageId: 'queued-user-1',
+ prompt: 'paused queued turn',
+ timestamp: new Date('2026-03-01T12:01:00Z'),
+ },
+ ];
+
+ render(() => (
+ <ChatMessages
+ messages={[
+ makeMessage({
+ id: 'queued-user-1',
+ role: 'user',
+ content: 'paused queued turn',
+ delivery: 'queued',
+ }),
+ ]}
+ {...makeHandlers()}
+ queuedFollowUps={queuedFollowUps}
+ queuedFollowUpsPaused
+ />
+ ));
+
+ const queuedItem = capturedMessageItemProps.find((p) => p.message.id === 'queued-user-1');
+ expect(queuedItem).toMatchObject({
+ queuedPosition: 1,
+ queuedCount: 1,
+ queuedPaused: true,
+ });
+ });
+
it('renders the scroll anchor element', () => {
const { container } = render(() => (
<ChatMessages messages={[makeMessage()]} {...makeHandlers()} />
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 ba6f0fd578..f61525038c 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -187,6 +187,25 @@ describe('MessageItem', () => {
fireEvent.click(screen.getByRole('button', { name: 'Remove queued follow-up' }));
expect(onCancelQueued).toHaveBeenCalledTimes(1);
});
+
+ it('renders paused queued user messages distinctly', () => {
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'user',
+ content: 'follow up after stop',
+ delivery: 'queued',
+ })}
+ {...makeHandlers()}
+ queuedPosition={2}
+ queuedCount={3}
+ queuedPaused
+ />
+ ));
+
+ expect(screen.getByText('follow up after stop')).toBeInTheDocument();
+ expect(screen.getByRole('status')).toHaveTextContent('Paused 2 of 3');
+ });
});
describe('error block', () => {
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 6056e1c293..6d2f99d43c 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -96,6 +96,7 @@ describe('useChat', () => {
expect(chat.sessionId()).toBe('');
expect(chat.model()).toBe('');
expect(chat.queuedFollowUps()).toEqual([]);
+ expect(chat.queuedFollowUpsPaused()).toBe(false);
expect(chat.queuedFollowUpCount()).toBe(0);
expect(typeof chat.sendMessage).toBe('function');
expect(typeof chat.retryMessage).toBe('function');
@@ -104,6 +105,7 @@ describe('useChat', () => {
expect(typeof chat.stop).toBe('function');
expect(typeof chat.cancelQueuedFollowUp).toBe('function');
expect(typeof chat.takeQueuedFollowUp).toBe('function');
+ expect(typeof chat.queuedFollowUpsPaused).toBe('function');
expect(typeof chat.sendQueuedFollowUpNow).toBe('function');
expect(typeof chat.clearQueuedFollowUps).toBe('function');
expect(typeof chat.clearMessages).toBe('function');
@@ -2567,36 +2569,59 @@ describe('useChat', () => {
dispose();
});
- it('clears queued follow-ups when stopping the active response', async () => {
+ it('pauses queued follow-ups when stopping the active response', async () => {
const abortError = new Error('Aborted');
abortError.name = 'AbortError';
- mockChat.mockImplementation(
- (
- _p: string,
- _s: string,
- _m: string | undefined,
- _onEvent: (e: StreamEvent) => void,
- signal?: AbortSignal,
- ) =>
- new Promise<void>((_resolve, reject) => {
- signal?.addEventListener('abort', () => reject(abortError));
- }),
- );
+ mockChat
+ .mockImplementationOnce(
+ (
+ _p: string,
+ _s: string,
+ _m: string | undefined,
+ _onEvent: (e: StreamEvent) => void,
+ signal?: AbortSignal,
+ ) =>
+ new Promise<void>((_resolve, reject) => {
+ signal?.addEventListener('abort', () => reject(abortError));
+ }),
+ )
+ .mockResolvedValueOnce(undefined);
const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));
const send = chat.sendMessage('hello');
await new Promise((r) => setTimeout(r, 0));
await chat.sendMessage('queued follow-up');
+ const queued = chat.queuedFollowUps()[0];
expect(chat.queuedFollowUpCount()).toBe(1);
+ expect(chat.queuedFollowUpsPaused()).toBe(false);
expect(chat.messages().some((message) => message.delivery === 'queued')).toBe(true);
chat.stop();
await expect(send).resolves.toBe(false);
- expect(chat.queuedFollowUpCount()).toBe(0);
- expect(chat.messages().some((message) => message.delivery === 'queued')).toBe(false);
+ expect(mockAbortSession).toHaveBeenCalledWith('s');
+ expect(chat.queuedFollowUpCount()).toBe(1);
+ expect(chat.queuedFollowUpsPaused()).toBe(true);
+ expect(
+ chat.messages().find((message) => message.content === 'queued follow-up'),
+ ).toMatchObject({
+ delivery: 'queued',
+ });
expect(mockChat).toHaveBeenCalledTimes(1);
+
+ await expect(chat.waitForIdle(50)).resolves.toBe(true);
+ await expect(chat.sendQueuedFollowUpNow(queued.id)).resolves.toBe(true);
+
+ expect(chat.queuedFollowUpCount()).toBe(0);
+ expect(chat.queuedFollowUpsPaused()).toBe(false);
+ expect(
+ chat.messages().find((message) => message.content === 'queued follow-up'),
+ ).toMatchObject({
+ delivery: 'sent',
+ });
+ expect(mockChat).toHaveBeenCalledTimes(2);
+ expect(mockChat.mock.calls[1][0]).toBe('queued follow-up');
dispose();
});
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index 89fb90bcaf..ca501f26f0 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -82,6 +82,7 @@ export function useChat(options: UseChatOptions = {}) {
const [sessionId, setSessionId] = createSignal(options.sessionId || '');
const [model, setModel] = createSignal(options.model || '');
const [queuedFollowUps, setQueuedFollowUps] = createSignal<QueuedFollowUp[]>([]);
+ const [queuedFollowUpsPaused, setQueuedFollowUpsPaused] = createSignal(false);
const effectiveModelRoute = (sendOptions?: Pick<SendMessageOptions, 'model'>) => {
const explicitModel = sendOptions?.model?.trim();
@@ -263,14 +264,26 @@ export function useChat(options: UseChatOptions = {}) {
const cancelQueuedFollowUp = (id: string) => {
const item = queuedFollowUps().find((entry) => entry.id === id);
if (!item) return;
- setQueuedFollowUps((prev) => prev.filter((entry) => entry.id !== id));
+ setQueuedFollowUps((prev) => {
+ const next = prev.filter((entry) => entry.id !== id);
+ if (next.length === 0) {
+ setQueuedFollowUpsPaused(false);
+ }
+ return next;
+ });
removeQueuedMessages(new Set([item.messageId]));
};
const takeQueuedFollowUp = (id: string): QueuedFollowUp | undefined => {
const item = queuedFollowUps().find((entry) => entry.id === id);
if (!item) return undefined;
- setQueuedFollowUps((prev) => prev.filter((entry) => entry.id !== id));
+ setQueuedFollowUps((prev) => {
+ const next = prev.filter((entry) => entry.id !== id);
+ if (next.length === 0) {
+ setQueuedFollowUpsPaused(false);
+ }
+ return next;
+ });
removeQueuedMessages(new Set([item.messageId]));
return item;
};
@@ -312,6 +325,7 @@ export function useChat(options: UseChatOptions = {}) {
const clearQueuedFollowUps = () => {
const messageIds = new Set(queuedFollowUps().map((entry) => entry.messageId));
setQueuedFollowUps([]);
+ setQueuedFollowUpsPaused(false);
removeQueuedMessages(messageIds);
};
@@ -322,7 +336,9 @@ export function useChat(options: UseChatOptions = {}) {
// Stop/cancel current request
const stop = () => {
- clearQueuedFollowUps();
+ if (queuedFollowUps().length > 0) {
+ setQueuedFollowUpsPaused(true);
+ }
void cancelActiveRequest('stopped');
};
@@ -1689,6 +1705,7 @@ export function useChat(options: UseChatOptions = {}) {
setMessages((prev) => [...prev, queuedUserMessage]);
setQueuedFollowUps((prev) => [...prev, queuedFollowUp]);
+ setQueuedFollowUpsPaused(false);
logger.debug('[useChat] Queued follow-up while assistant response is streaming', {
queuedFollowUpId: id,
});
@@ -1849,7 +1866,7 @@ export function useChat(options: UseChatOptions = {}) {
};
async function drainQueuedFollowUps() {
- if (isDrainingQueuedFollowUps || isLoading()) return;
+ if (isDrainingQueuedFollowUps || isLoading() || queuedFollowUpsPaused()) return;
isDrainingQueuedFollowUps = true;
try {
@@ -1867,7 +1884,7 @@ export function useChat(options: UseChatOptions = {}) {
isDrainingQueuedFollowUps = false;
}
- if (queuedFollowUps().length > 0 && !isLoading()) {
+ if (queuedFollowUps().length > 0 && !isLoading() && !queuedFollowUpsPaused()) {
queueMicrotask(() => {
void drainQueuedFollowUps();
});
@@ -1897,6 +1914,7 @@ export function useChat(options: UseChatOptions = {}) {
return promoteQueuedFollowUp(id);
}
+ setQueuedFollowUpsPaused(false);
setQueuedFollowUps((prev) => prev.filter((entry) => entry.id !== id));
return startMessageSend(item.prompt, item.mentions, item.findingId, item.sendOptions, {
queuedMessageId: item.messageId,
@@ -1907,6 +1925,7 @@ export function useChat(options: UseChatOptions = {}) {
const clearMessages = () => {
void cancelActiveRequest();
setQueuedFollowUps([]);
+ setQueuedFollowUpsPaused(false);
setMessages([]);
setSessionId(''); // Clear session so next message creates a new one
};
@@ -1915,6 +1934,7 @@ export function useChat(options: UseChatOptions = {}) {
const loadSession = async (id: string): Promise<boolean> => {
void cancelActiveRequest();
setQueuedFollowUps([]);
+ setQueuedFollowUpsPaused(false);
try {
const msgs = await AIChatAPI.getMessages(id);
setMessages(
@@ -1952,6 +1972,7 @@ export function useChat(options: UseChatOptions = {}) {
const newSession = async (): Promise<boolean> => {
void cancelActiveRequest();
setQueuedFollowUps([]);
+ setQueuedFollowUpsPaused(false);
setSessionId('');
setMessages([]);
return true;
@@ -2166,14 +2187,16 @@ export function useChat(options: UseChatOptions = {}) {
// Useful for sending follow-up messages after approvals
const waitForIdle = (timeoutMs = 30000): Promise<boolean> => {
return new Promise((resolve) => {
- if (!isLoading() && queuedFollowUps().length === 0 && !isDrainingQueuedFollowUps) {
+ const hasPendingQueuedDrain = queuedFollowUps().length > 0 && !queuedFollowUpsPaused();
+ if (!isLoading() && !hasPendingQueuedDrain && !isDrainingQueuedFollowUps) {
resolve(true);
return;
}
const startTime = Date.now();
const checkInterval = setInterval(() => {
- if (!isLoading() && queuedFollowUps().length === 0 && !isDrainingQueuedFollowUps) {
+ const hasPendingQueuedDrain = queuedFollowUps().length > 0 && !queuedFollowUpsPaused();
+ if (!isLoading() && !hasPendingQueuedDrain && !isDrainingQueuedFollowUps) {
clearInterval(checkInterval);
resolve(true);
} else if (Date.now() - startTime > timeoutMs) {
@@ -2219,6 +2242,7 @@ export function useChat(options: UseChatOptions = {}) {
model,
setModel,
queuedFollowUps,
+ queuedFollowUpsPaused,
queuedFollowUpCount: () => queuedFollowUps().length,
sendMessage,
sendQueuedFollowUpNow,
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 9e8f96f5e0..1fad3f2c5e 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -4293,6 +4293,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
getModelRouteAlternative={getFailedTurnModelRouteAlternative}
onUseModelRoute={switchToModelRoute}
queuedFollowUps={chat.queuedFollowUps()}
+ queuedFollowUpsPaused={chat.queuedFollowUpsPaused()}
onEditQueuedFollowUp={editQueuedFollowUp}
onCancelQueuedFollowUp={(id) => {
chat.cancelQueuedFollowUp(id);
@@ -4434,7 +4435,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
<ClockIcon class="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
<span class="min-w-0 flex-1 truncate text-xs font-medium">
{pluralizeCount(chat.queuedFollowUpCount(), 'follow-up', 'follow-ups')}{' '}
- queued
+ {chat.queuedFollowUpsPaused() ? 'paused' : 'queued'}
</span>
<button
type="button"
@@ -4467,6 +4468,17 @@ export const AIChat: Component<AIChatProps> = (props) => {
<SendIcon class="h-3.5 w-3.5" aria-hidden="true" />
</button>
</Show>
+ <Show when={chat.queuedFollowUpsPaused() && index() === 0}>
+ <button
+ type="button"
+ onClick={() => sendQueuedFollowUpNext(queued.id)}
+ class="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-blue-700 transition-colors hover:bg-blue-100 hover:text-blue-950 dark:text-blue-200 dark:hover:bg-blue-900/60"
+ title="Resume queued follow-up"
+ aria-label={`Resume queued follow-up: ${preview()}`}
+ >
+ <SendIcon class="h-3.5 w-3.5" aria-hidden="true" />
+ </button>
+ </Show>
<button
type="button"
onClick={() => editQueuedFollowUp(queued.id)}