fix: isolate assistant conversation state

This commit is contained in:
ajnart committed 2026-08-02 15:57:05 +02:00
1 parent d7969e1ec1
commit cf6aefa48a
3 files changed
+144 -18

No files matched your search

@@ -0,0 +1,32 @@
export interface AssistantNotificationState {
initialized: boolean;
conversationId: string | null;
notificationKey: string | null;
}
export interface AssistantNotificationUpdate {
state: AssistantNotificationState;
shouldNotify: boolean;
}
export const initialAssistantNotificationState: AssistantNotificationState = {
initialized: false,
conversationId: null,
notificationKey: null,
};
export const updateAssistantNotificationState = (
previous: AssistantNotificationState,
current: Pick<AssistantNotificationState, "conversationId" | "notificationKey">,
): AssistantNotificationUpdate => {
const state = { initialized: true, ...current };
if (!previous.initialized || previous.conversationId !== current.conversationId) {
return { state, shouldNotify: false };
}
return {
state,
shouldNotify: current.notificationKey !== null && current.notificationKey !== previous.notificationKey,
};
};