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

Prepare app v2.4.232

Louis Beaumontd2816f1d107a
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index e6313e574..f32a21ab5 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -111,7 +111,7 @@ interface MentionSuggestion {
const APP_SUGGESTION_LIMIT = 10;
const STREAM_RENDER_THROTTLE_MS = 80;
const FOLLOW_UP_GENERATION_DELAY_MS = 10_000;
-const POST_STREAM_MARKDOWN_DELAY_MS = 1_500;
+const POST_STREAM_SIDE_EFFECT_DELAY_MS = 1_500;
const CHAT_RAIL_CLASS = "max-w-4xl mx-auto w-full";
const CONNECTION_SUGGESTION_LIMIT = 3;
@@ -1648,14 +1648,6 @@ function MarkdownBlock({ text, isUser }: { text: string; isUser: boolean }) {
);
}
-function StreamingTextBlock({ text }: { text: string }) {
- return (
- <div className="prose prose-sm max-w-full overflow-hidden break-words whitespace-pre-wrap leading-relaxed dark:prose-invert [word-break:break-word]">
- {text}
- </div>
- );
-}
-
// Groups consecutive tool blocks into a single group for collapsible rendering
type GroupedBlock =
| { type: "text"; text: string; key: number }
@@ -1800,12 +1792,10 @@ function ToolCallGroup({ toolCalls, defaultExpanded = false }: { toolCalls: Tool
// Renders message content with interleaved text and tool call blocks
function MessageContent({
message,
- isStreamingMessage = false,
onImageClick,
onRetry,
}: {
message: Message;
- isStreamingMessage?: boolean;
onImageClick?: (images: string[], index: number) => void;
onRetry?: (prompt: string) => void;
}) {
@@ -1847,9 +1837,6 @@ function MessageContent({
<div className="space-y-2 min-w-0 w-full overflow-hidden">
{grouped.map((group) => {
if (group.type === "text") {
- if (isStreamingMessage && !isUser) {
- return <StreamingTextBlock key={`text-${group.key}`} text={group.text} />;
- }
return <MarkdownBlock key={`text-${group.key}`} text={group.text} isUser={isUser} />;
}
if (group.type === "thinking") {
@@ -1902,11 +1889,7 @@ function MessageContent({
return (
<div className="space-y-2">
{imageThumbs}
- {isStreamingMessage && !isUser ? (
- <StreamingTextBlock text={message.content} />
- ) : (
- <MarkdownBlock text={message.content} isUser={isUser} />
- )}
+ <MarkdownBlock text={message.content} isUser={isUser} />
{sourceFooter}
{retryCta}
</div>
@@ -2420,8 +2403,6 @@ export function StandaloneChat({
const [followUpSuggestions, setFollowUpSuggestions] = useState<string[]>([]);
const followUpAbortRef = useRef<AbortController | null>(null);
const followUpFiredRef = useRef(false);
- const [deferredMarkdownMessageIds, setDeferredMarkdownMessageIds] = useState<Set<string>>(() => new Set());
- const deferredMarkdownTimersRef = useRef<Map<string, ReturnType<typeof setTimeout>>>(new Map());
const lastUserMessageRef = useRef<string>("");
// Ref to sendMessage so useEffect callbacks can call it without stale closures
@@ -2478,33 +2459,6 @@ export function StandaloneChat({
}, STREAM_RENDER_THROTTLE_MS);
}, [renderStreamingMessageSnapshot]);
- const deferMarkdownRender = useCallback((messageId: string) => {
- const existingTimer = deferredMarkdownTimersRef.current.get(messageId);
- if (existingTimer) {
- clearTimeout(existingTimer);
- }
-
- setDeferredMarkdownMessageIds((prev) => {
- if (prev.has(messageId)) return prev;
- const next = new Set(prev);
- next.add(messageId);
- return next;
- });
-
- const timer = setTimeout(() => {
- deferredMarkdownTimersRef.current.delete(messageId);
- React.startTransition(() => {
- setDeferredMarkdownMessageIds((prev) => {
- if (!prev.has(messageId)) return prev;
- const next = new Set(prev);
- next.delete(messageId);
- return next;
- });
- });
- }, POST_STREAM_MARKDOWN_DELAY_MS);
- deferredMarkdownTimersRef.current.set(messageId, timer);
- }, []);
-
// Process an image file to base64
// Resize image to max 1024px and compress as JPEG to keep base64 payload small
const resizeImage = useCallback((dataUrl: string): Promise<string> => {
@@ -3063,10 +3017,6 @@ export function StandaloneChat({
mountedRef.current = true;
return () => {
mountedRef.current = false;
- for (const timer of deferredMarkdownTimersRef.current.values()) {
- clearTimeout(timer);
- }
- deferredMarkdownTimersRef.current.clear();
};
}, []);
@@ -4342,10 +4292,6 @@ export function StandaloneChat({
? { ...m, content, contentBlocks, ...(emptyResponseRetryPrompt ? { retryPrompt: emptyResponseRetryPrompt } : {}) }
: m);
});
- if (streamedText || content) {
- deferMarkdownRender(msgId);
- }
-
if (!isPipeWatch) {
const analyticsPayload = {
provider: activePreset?.provider,
@@ -4355,7 +4301,7 @@ export function StandaloneChat({
};
setTimeout(() => {
posthog.capture("chat_response_received", analyticsPayload);
- }, POST_STREAM_MARKDOWN_DELAY_MS);
+ }, POST_STREAM_SIDE_EFFECT_DELAY_MS);
const followUpText = streamedText || content || "";
if (followUpText.length > 500 && !followUpFiredRef.current) {
@@ -6243,10 +6189,6 @@ export function StandaloneChat({
) : (
<MessageContent
message={message}
- isStreamingMessage={
- (isStreaming && message.id === piMessageIdRef.current) ||
- deferredMarkdownMessageIds.has(message.id)
- }
onImageClick={(images, index) => setImageViewer({ images, index })}
onRetry={(prompt) => sendMessage(prompt)}
/>
diff --git a/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts
index d0d8ff890..d9b64831c 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts
@@ -28,6 +28,7 @@ import { openHomeWindow, waitForAppReady, t } from '../helpers/test-utils.js';
const SESSION_A = '11111111-1111-1111-1111-111111111111';
const SESSION_B = '22222222-2222-2222-2222-222222222222';
+const SESSION_MARKDOWN = '44444444-4444-4444-4444-444444444444';
/** Emit a Tauri event from the webview. The frontend's `listen()` calls
* pick it up the same as a Rust-emitted event. */
@@ -159,6 +160,14 @@ async function readAssistantMessages(): Promise<string[]> {
return texts;
}
+async function hasLiveMarkdownElements(): Promise<boolean> {
+ return (await browser.execute(() => {
+ const assistant = document.querySelector('[data-testid="chat-message-assistant"]');
+ if (!assistant) return false;
+ return Boolean(assistant.querySelector('h2') && assistant.querySelector('li'));
+ })) as boolean;
+}
+
describe('Parallel chat — Louis repro', function () {
// Switching + faking three turns is fast, but on CI the WebDriver
// round-trip dominates; budget generously.
@@ -249,4 +258,33 @@ describe('Parallel chat — Louis repro', function () {
expect(orderAfter).toEqual(orderBefore);
});
+
+ it('renders markdown while an assistant message is still streaming', async () => {
+ await openHomeWindow();
+ const home = await $('[data-testid="section-home"]');
+ await home.waitForExist({ timeout: t(15_000) });
+
+ await switchToSession(SESSION_MARKDOWN);
+ await seedUserMessage(SESSION_MARKDOWN, '(e2e) prompt for live markdown');
+
+ await emitAgentEvent(SESSION_MARKDOWN, {
+ type: 'message_start',
+ message: { role: 'assistant' },
+ });
+ await emitAgentEvent(SESSION_MARKDOWN, {
+ type: 'message_update',
+ assistantMessageEvent: {
+ type: 'text_delta',
+ delta: '## Summary\n\n- live markdown renders before agent_end\n',
+ },
+ });
+
+ await browser.waitUntil(hasLiveMarkdownElements, {
+ timeout: t(5_000),
+ interval: 100,
+ timeoutMsg: 'streaming assistant markdown did not render before agent_end',
+ });
+
+ await emitAgentEvent(SESSION_MARKDOWN, { type: 'agent_end' });
+ });
});
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index ba6b868bc..6d64e08e6 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -10580,7 +10580,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.4.231"
+version = "2.4.232"
dependencies = [
"aes",
"anyhow",
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index caff6cb30..596da5c9e 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.4.231"
+version = "2.4.232"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/health.rs b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
index 7aab127dd..d71db6395 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/health.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
@@ -338,6 +338,10 @@ fn apply_capture_session_status(
return base_status;
}
+ if capture_running == Some(true) {
+ return base_status;
+ }
+
if start_in_progress {
return RecordingStatus::Starting;
}
@@ -1214,6 +1218,13 @@ mod tests {
assert_eq!(status, RecordingStatus::Recording);
}
+ #[test]
+ fn test_running_capture_wins_over_stale_starting_flag() {
+ let status =
+ apply_capture_session_status(RecordingStatus::Recording, true, Some(true), true);
+ assert_eq!(status, RecordingStatus::Recording);
+ }
+
#[test]
fn test_pool_saturation_scenario() {
// Simulate DB pool saturation: server responds but with unhealthy status