Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): keep pending follow-up below history (#6753)

Ezra Ellette65e668a90344
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.test.tsx
index 474a30895..6f3318908 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.test.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.test.tsx
@@ -140,4 +140,29 @@ describe("ChatMainPane", () => {
render(<ChatMainPane {...paneProps("chat", [])} />);
expect(screen.queryByTestId("first-run-banner")).not.toBeInTheDocument();
});
+
+ it("renders a pending follow-up after durable chat history", () => {
+ const existingMessage: Message = {
+ id: "existing-message",
+ role: "user",
+ content: "existing durable message",
+ timestamp: Date.now(),
+ };
+
+ render(
+ <ChatMainPane
+ {...paneProps("chat", [existingMessage])}
+ pendingSend={{ text: "follow-up message" }}
+ />,
+ );
+
+ const messageList = screen.getByTestId("message-list");
+ const pendingBubble = screen.getByTestId("chat-pending-user-message");
+ expect(messageList).toHaveTextContent("1");
+ expect(pendingBubble).toHaveTextContent("follow-up message");
+ expect(
+ messageList.compareDocumentPosition(pendingBubble) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).not.toBe(0);
+ });
});
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.tsx
index 611157317..f3d4b4425 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-main-pane.tsx
@@ -251,6 +251,13 @@ export function ChatMainPane({
<FirstRunLearningBanner fallback={homeStarter} />
)}
{!firstRunLearningEnabled && homeStarter}
+ {/* A conversation switch is a hard visual boundary. Remounting the
+ list prevents AnimatePresence from carrying an outgoing chat's
+ exit nodes into the new chat's empty state. */}
+ <ChatMessageList
+ key={conversationId ?? "blank-chat"}
+ {...messageListProps}
+ />
{/* The message the user just sent, shown from the send frame until
the durable row replaces it. Same geometry as a real user row so
nothing moves when the swap happens. */}
@@ -268,13 +275,6 @@ export function ChatMainPane({
</div>
</div>
)}
- {/* A conversation switch is a hard visual boundary. Remounting the
- list prevents AnimatePresence from carrying an outgoing chat's
- exit nodes into the new chat's empty state. */}
- <ChatMessageList
- key={conversationId ?? "blank-chat"}
- {...messageListProps}
- />
<div ref={messagesEndRef} />
</div>