feat(FN-1975): stream chat session updates through SSE
- Emit chat:session:updated from ChatStore when message deletion mutates a session and cover deleteMessage false returns - Pass ChatStore into SSE setup and forward chat session update events to connected clients - Update useChat to consume SSE updates in real time with safer EnrichedChatSession typing - Add core and dashboard tests for chat-store emissions, SSE forwarding, route wiring, and hook behavior
This commit is contained in:
@@ -387,9 +387,23 @@ export class ChatStore extends EventEmitter<ChatStoreEvents> {
|
||||
const existing = this.getMessage(id);
|
||||
if (!existing) return false;
|
||||
|
||||
const sessionId = existing.sessionId;
|
||||
const now = new Date().toISOString();
|
||||
|
||||
this.db.prepare("DELETE FROM chat_messages WHERE id = ?").run(id);
|
||||
|
||||
// Update the parent session's updatedAt timestamp
|
||||
this.db.prepare("UPDATE chat_sessions SET updatedAt = ? WHERE id = ?").run(now, sessionId);
|
||||
|
||||
this.db.bumpLastModified();
|
||||
this.emit("chat:message:deleted", id);
|
||||
|
||||
// Emit session:updated for the parent session
|
||||
const updatedSession = this.getSession(sessionId);
|
||||
if (updatedSession) {
|
||||
this.emit("chat:session:updated", updatedSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user