test(documents): e2e for the document chat panel; clear tail on settle

Add an e2e suite mocking the capability probe, the chat history GET, and the
streaming chat POST so the panel renders (v1.27.31 lesson): the entry opens an
empty safety-noted surface, a turn streams a reply that settles to one assistant
bubble, a non-indexed document shows the calm hint, and no provider leaves no
chat surface. Clear the streamed tail + optimistic bubble once the persisted
twin lands so the reply never double-renders.
This commit is contained in:
Marc-André Bombeck committed 2026-07-09 03:24:03 +02:00
1 parent 2ede0886c3
commit 8cead5ccdb
2 files changed
+299 -1

No files matched your search

@@ -275,10 +275,14 @@ export function useSendDocumentChatMessage(documentId: string) {
if (resolvedConversationId) {
// Reload the encrypted-on-disk thread (canonical ids + any outbound
// editorialisation). The persisted twin replaces the optimistic bubble.
// editorialisation), then clear the live tail + optimistic bubble so the
// persisted turns are the single source — the refetch is awaited, so the
// canonical messages are in cache before the streamed copy is dropped
// (no gap, no duplicate assistant bubble).
await queryClient.invalidateQueries({
queryKey: queryKeys.inboundDocumentChat(documentId),
});
setStreaming(EMPTY_STREAMING);
setOptimisticUser(null);
}
return resolvedConversationId;