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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
test(e2e,parallel-chat): wait for foreground bus registration before emitting
Louis Beaumonta306f8a6de24
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex 1bfb52560..0c705575d 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -3893,10 +3893,25 @@ export function StandaloneChat({if (!mountedRef.current) return;handleAgentEventDataRef.current?.(envelope.event);});+ // E2E seam: agent_event delivery to the panel is gated on this+ // foreground registration completing. parallel-chat.spec.ts waits+ // on this signal before emitting events; without it, deltas race+ // the registration window and go to the default router, which+ // early-returns for `store.currentId === sid`, silently dropping+ // them. Cleared in the cleanup below so successive switches don't+ // see a stale id.+ if (typeof window !== "undefined") {+ (window as any).__e2eForegroundReady = conversationId;+ }})();return () => {cancelled = true;try { off?.(); } catch { /* ignore */ }+ if (typeof window !== "undefined") {+ if ((window as any).__e2eForegroundReady === conversationId) {+ (window as any).__e2eForegroundReady = null;+ }+ }};}, [conversationId]);diff --git a/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.tsindex d9b64831c..98740fa99 100644--- a/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/parallel-chat.spec.ts@@ -69,12 +69,34 @@ async function emitAgentEvent(sessionId: string, event: unknown): Promise<void>}/** Switch the chat panel to a given session id. Mirrors what the- * sidebar's row click does. */+ * sidebar's row click does.+ *+ * Waits on `__e2eForegroundReady` (set by the chat panel after it has+ * registered its agent-event foreground handler for `id`). Without this+ * wait, a fixed pause was racy on macOS webkit: the chat-load-conversation+ * handler completes async, then setConversationId triggers a useEffect+ * whose own async work (mountAgentEventBus + registerForeground) lands a+ * few microtasks later. Tests that emitted events immediately after the+ * switch sometimes hit that window — the events fell through to the+ * router's default handler, which early-returns for `store.currentId+ * === sid`, and the panel never saw the deltas. */async function switchToSession(id: string): Promise<void> {await emitFromWebview('chat-load-conversation', { conversationId: id });- // The handler does an async dynamic import + disk lookup before- // calling startNewConversation/loadConversation. 250ms is enough on a- // dev machine; CI gets the multiplier via t().+ await browser.waitUntil(+ async () =>+ (await browser.execute(+ (sid: string) => (window as any).__e2eForegroundReady === sid,+ id,+ )) as boolean,+ {+ timeout: t(10_000),+ interval: 50,+ timeoutMsg: `chat panel did not register foreground for ${id}`,+ },+ );+ // Settle pause for framer-motion exit animations on the outgoing+ // session's messages (200ms exit + buffer). Without this the next read+ // can see the previous session's bubbles mid-fade.await browser.pause(t(400));}