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.

fix: only clear findingId after successful chat send

rcourtmandbf603d7e2b4
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index df8ac6d15f..b2af7dcf35 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -322,8 +322,8 @@ export function useChat(options: UseChatOptions = {}) {
};
// Send a message - allows sending mid-stream (aborts current response like Pulse AI TUI)
- const sendMessage = async (prompt: string, mentions?: Array<{ id: string; name: string; type: string; node?: string }>, findingId?: string) => {
- if (!prompt.trim()) return;
+ const sendMessage = async (prompt: string, mentions?: Array<{ id: string; name: string; type: string; node?: string }>, findingId?: string): Promise<boolean> => {
+ if (!prompt.trim()) return false;
// If already streaming, abort the current request first
if (isLoading() && abortControllerRef) {
@@ -352,7 +352,7 @@ export function useChat(options: UseChatOptions = {}) {
} catch (error) {
logger.error('[useChat] Failed to create session:', error);
notificationStore.error('Failed to create chat session');
- return;
+ return false;
}
}
@@ -394,10 +394,11 @@ export function useChat(options: UseChatOptions = {}) {
mentions,
findingId
);
+ return true;
} catch (error) {
if (error instanceof Error && error.name === 'AbortError') {
logger.debug('[useChat] Request aborted');
- return;
+ return false;
}
logger.error('[useChat] Chat failed:', error);
const errorMessage = error instanceof Error ? error.message : 'Failed to get Pulse Assistant response';
@@ -410,6 +411,7 @@ export function useChat(options: UseChatOptions = {}) {
: msg
)
);
+ return false;
} finally {
abortControllerRef = null;
setIsLoading(false);
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index f6ba466fc7..c43e670c71 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -414,8 +414,8 @@ export const AIChat: Component<AIChatProps> = (props) => {
const ctx = aiChatStore.context;
const findingId = ctx.findingId;
chat.sendMessage(prompt, mentions.length > 0 ? mentions : undefined, findingId)
- .then(() => {
- if (findingId) {
+ .then((ok) => {
+ if (ok && findingId) {
aiChatStore.clearFindingId?.();
}
});