Fixes #212 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Add concurrent chat support with per-chat state, chat activity UI, IPC per-chat handling, and accompanying tests. > > - **Frontend (Chat concurrency)** > - Replace global chat atoms with per-chat maps: `chatMessagesByIdAtom`, `isStreamingByIdAtom`, `chatErrorByIdAtom`, `chatStreamCountByIdAtom`, `recentStreamChatIdsAtom`. > - Update `ChatPanel`, `ChatInput`, `MessagesList`, `DyadMarkdownParser`, and `useVersions` to read/write per-chat state. > - Add `useSelectChat` to centralize selecting/navigating chats; wire into `ChatList`. > - **UI** > - Add chat activity popover: `ChatActivityButton` and list; integrate into `preview_panel/ActionHeader` (renamed from `PreviewHeader`) and swap in `TitleBar`. > - **IPC/Main** > - Send error payloads with `chatId` on `chat:response:error`; update `ipc_client` to route errors per chat. > - Persist streaming partial assistant content periodically; improve cancellation/end handling. > - Make `FileUploadsState` per-chat (`addFileUpload({chatId,fileId}, ...)`, `clear(chatId)`, `getFileUploadsForChat(chatId)`); update handlers/processors accordingly. > - **Testing** > - Add e2e `concurrent_chat.spec.ts` and snapshots; extend helpers (`snapshotMessages` timeout, chat activity helpers). > - Fake LLM server: support `tc=` with options, optional sleep delay to simulate concurrency. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9035f30b73a1f2e5a366a0cac1c63411742b16f3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
23 lines
994 B
TypeScript
23 lines
994 B
TypeScript
import type { Message } from "@/ipc/ipc_types";
|
|
import { atom } from "jotai";
|
|
import type { ChatSummary } from "@/lib/schemas";
|
|
|
|
// Per-chat atoms implemented with maps keyed by chatId
|
|
export const chatMessagesByIdAtom = atom<Map<number, Message[]>>(new Map());
|
|
export const chatErrorByIdAtom = atom<Map<number, string | null>>(new Map());
|
|
|
|
// Atom to hold the currently selected chat ID
|
|
export const selectedChatIdAtom = atom<number | null>(null);
|
|
|
|
export const isStreamingByIdAtom = atom<Map<number, boolean>>(new Map());
|
|
export const chatInputValueAtom = atom<string>("");
|
|
export const homeChatInputValueAtom = atom<string>("");
|
|
|
|
// Atoms for chat list management
|
|
export const chatsAtom = atom<ChatSummary[]>([]);
|
|
export const chatsLoadingAtom = atom<boolean>(false);
|
|
|
|
// Used for scrolling to the bottom of the chat messages (per chat)
|
|
export const chatStreamCountByIdAtom = atom<Map<number, number>>(new Map());
|
|
export const recentStreamChatIdsAtom = atom<Set<number>>(new Set<number>());
|