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(ci): isolate desktop E2E state

Louis Beaumont55afca4318ad
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-send-transport.ts b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-send-transport.ts
index d8169e020..89a758457 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-send-transport.ts
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-send-transport.ts
@@ -81,7 +81,7 @@ export function usePiSendTransport(options: PiSendTransportOptions) {
options,
(message, displayLabel, imageDataUrls) => sendPiMessage(message, displayLabel, imageDataUrls),
);
- const { handleStop, openConnectionSetup } = usePiLiveSendControls({
+ const { handleStop: stopLiveSend, openConnectionSetup } = usePiLiveSendControls({
abortControllerRef,
activePipeExecution,
cancelStreamingMessageRender,
@@ -114,6 +114,22 @@ export function usePiSendTransport(options: PiSendTransportOptions) {
setIsStreaming(false);
}
+ async function handleStop() {
+ try {
+ await stopLiveSend();
+ } finally {
+ // The low-level stop control owns the visible streaming state, while
+ // this transport owns the dispatch guards. Leaving forceQueueMode set
+ // after a user stop makes every later send enqueue behind a turn that no
+ // longer exists. Clear the complete transport state together so Stop is
+ // also a reliable boundary for the next message.
+ if (!activePipeExecution) {
+ clearActivePiTurnState();
+ sendDispatchInFlightRef.current = false;
+ }
+ }
+ }
+
async function interruptActivePiTurn() {
const hasActiveTurn = isLoading || isStreaming || !!piMessageIdRef.current;
if (!hasActiveTurn) return;
diff --git a/apps/screenpipe-app-tauri/e2e/specs/chat-sidebar-pipe-inventory.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/chat-sidebar-pipe-inventory.spec.ts
index 93f7e8bda..a7441927d 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/chat-sidebar-pipe-inventory.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/chat-sidebar-pipe-inventory.spec.ts
@@ -28,6 +28,11 @@ import {
t,
waitForAppReady,
} from "../helpers/test-utils.js";
+import {
+ authHeaders,
+ fetchJson,
+ getLocalApiConfig,
+} from "../helpers/api-utils.js";
const PIPE_NAME = "e2e-sidebar-lazy-inventory";
const PIPE_DIR = join(E2E_DATA_DIR, "pipes", PIPE_NAME);
@@ -116,33 +121,49 @@ function writeConversation(
}
async function clickSection(title: string): Promise<void> {
- await browser.execute((wanted: string) => {
+ const clicked = await browser.execute((wanted: string) => {
const sidebar = document.querySelector('[data-testid="chat-sidebar"]');
const buttons = Array.from(sidebar?.querySelectorAll<HTMLButtonElement>("button") ?? []);
- buttons.find((button) => button.textContent?.trim().toLowerCase() === wanted)?.click();
+ const button = buttons.find((candidate) =>
+ candidate.textContent?.trim().toLowerCase() === wanted,
+ );
+ button?.click();
+ return Boolean(button);
}, title.toLowerCase());
+ if (!clicked) throw new Error(`sidebar section '${title}' was not found`);
+
+ await browser.waitUntil(
+ async () => await browser.execute((wanted: string) => {
+ const sidebar = document.querySelector('[data-testid="chat-sidebar"]');
+ const buttons = Array.from(sidebar?.querySelectorAll<HTMLButtonElement>("button") ?? []);
+ const button = buttons.find((candidate) =>
+ candidate.textContent?.trim().toLowerCase() === wanted,
+ );
+ return button?.getAttribute("aria-expanded") === "true";
+ }, title.toLowerCase()),
+ {
+ timeout: t(5_000),
+ interval: 100,
+ timeoutMsg: `sidebar section '${title}' did not expand`,
+ },
+ );
}
-async function mockPipeInventory(): Promise<void> {
- await browser.execute((pipeName: string) => {
- const originalFetch = window.fetch.bind(window);
- window.fetch = (input: RequestInfo | URL, init?: RequestInit) => {
- const url = typeof input === "string" ? input : (input as Request)?.url ?? String(input);
- if (url.includes("/pipes?include_execution_counts=true")) {
- return Promise.resolve(new Response(JSON.stringify({
- data: [{
- config: { name: pipeName },
- execution_count: 12,
- last_run: new Date().toISOString(),
- }],
- }), {
- status: 200,
- headers: { "Content-Type": "application/json" },
- }));
- }
- return originalFetch(input, init);
- };
- }, PIPE_NAME);
+async function waitForBackendPipe(): Promise<void> {
+ const config = await getLocalApiConfig();
+ await browser.waitUntil(async () => {
+ const result = await fetchJson(
+ `http://127.0.0.1:${config.port}/pipes?include_execution_counts=true`,
+ authHeaders(config.key),
+ );
+ if (!result.ok || !result.body || typeof result.body !== "object") return false;
+ const data = (result.body as { data?: Array<{ config?: { name?: string } }> }).data ?? [];
+ return data.some((pipe) => pipe.config?.name === PIPE_NAME);
+ }, {
+ timeout: t(15_000),
+ interval: 250,
+ timeoutMsg: "installed pipe missing from backend inventory",
+ });
}
describe("chat sidebar pipe inventory", function () {
@@ -150,7 +171,6 @@ describe("chat sidebar pipe inventory", function () {
before(async () => {
await waitForAppReady();
- await seedEntitledAccount();
await openHomeWindow();
mkdirSync(PIPE_DIR, { recursive: true });
mkdirSync(CHATS_DIR, { recursive: true });
@@ -174,7 +194,13 @@ describe("chat sidebar pipe inventory", function () {
localStorage.removeItem(`screenpipe:group-expanded:pipe:${pipeName}`);
}, PIPE_NAME);
await reloadAndWaitForHome();
- await mockPipeInventory();
+ // Apply the fake entitlement only after reload. Seeding it before reload
+ // lets the normal account refresh reject the deliberately fake token and
+ // put the entitlement gate back over the sidebar on slower lanes.
+ await seedEntitledAccount();
+ const sidebar = await $('[data-testid="chat-sidebar"]');
+ await sidebar.waitForExist({ timeout: t(10_000) });
+ await waitForBackendPipe();
});
after(() => {
diff --git a/apps/screenpipe-app-tauri/e2e/specs/meeting-apps-picker.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/meeting-apps-picker.spec.ts
index 582945ee9..2b1079820 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/meeting-apps-picker.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/meeting-apps-picker.spec.ts
@@ -45,6 +45,51 @@ const WEBEX_TOGGLE_TESTID = 'meeting-apps-picker-toggle-webex';
const OPEN_BUTTON_TESTID = 'settings-ignore-meeting-apps-button';
const COUNT_BADGE_TESTID = 'settings-ignore-meeting-apps-count';
const DIALOG_TESTID = 'meeting-apps-picker-dialog';
+let restoreAudioDisabled = false;
+let restoreMeetingDetectorDisabled = false;
+
+async function switchEnabled(id: string): Promise<boolean> {
+ const element = await $(`#${id}`);
+ await element.waitForExist({ timeout: t(8_000) });
+ return (await element.getAttribute('aria-checked')) === 'true';
+}
+
+async function ensureMeetingControlsEnabled(): Promise<void> {
+ restoreAudioDisabled = !(await switchEnabled('disableAudio'));
+ if (restoreAudioDisabled) {
+ await (await $('#disableAudio')).click();
+ await browser.waitUntil(() => switchEnabled('disableAudio'), {
+ timeout: t(5_000),
+ timeoutMsg: 'audio settings did not enable for the meeting picker test',
+ });
+ }
+
+ restoreMeetingDetectorDisabled = !(await switchEnabled('disableMeetingDetector'));
+ if (restoreMeetingDetectorDisabled) {
+ await (await $('#disableMeetingDetector')).click();
+ await browser.waitUntil(() => switchEnabled('disableMeetingDetector'), {
+ timeout: t(5_000),
+ timeoutMsg: 'meeting detection did not enable for the picker test',
+ });
+ }
+}
+
+async function restoreRecordingControls(): Promise<void> {
+ if (restoreMeetingDetectorDisabled && await switchEnabled('disableMeetingDetector')) {
+ await (await $('#disableMeetingDetector')).click();
+ await browser.waitUntil(async () => !(await switchEnabled('disableMeetingDetector')), {
+ timeout: t(5_000),
+ timeoutMsg: 'meeting detection setting did not restore after the picker test',
+ });
+ }
+ if (restoreAudioDisabled && await switchEnabled('disableAudio')) {
+ await (await $('#disableAudio')).click();
+ await browser.waitUntil(async () => !(await switchEnabled('disableAudio')), {
+ timeout: t(5_000),
+ timeoutMsg: 'audio setting did not restore after the meeting picker test',
+ });
+ }
+}
async function openRecordingSettings(): Promise<void> {
const navSettings = await $('[data-testid="nav-settings"]');
@@ -87,6 +132,14 @@ describe('Meeting-apps ignore picker', () => {
await waitForAppReady();
await openHomeWindow();
await openRecordingSettings();
+ // The broad E2E job intentionally boots with `no-recording`, which
+ // persists disableAudio=true. This UI spec owns the state it needs instead
+ // of depending on an earlier spec to have enabled recording by chance.
+ await ensureMeetingControlsEnabled();
+ });
+
+ after(async () => {
+ await restoreRecordingControls();
});
// Make the spec self-contained even if a previous run left Webex ignored
diff --git a/apps/screenpipe-app-tauri/e2e/specs/zz-enterprise-license-prompt.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/zz-enterprise-license-prompt.spec.ts
index ef0c4f696..94f44dc16 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/zz-enterprise-license-prompt.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/zz-enterprise-license-prompt.spec.ts
@@ -159,6 +159,13 @@ describe('Enterprise onboarding activation', () => {
});
it('handles invalid key, seat-limit, and retry success without sticking on validating', async () => {
+ // Enterprise onboarding now lets the user choose account sign-in or an
+ // organization key. Enter the key path explicitly before exercising the
+ // activation form so this remains deterministic from a clean install.
+ await waitForBodyText('use enterprise key');
+ const useEnterpriseKey = await $('button*=use enterprise key');
+ await useEnterpriseKey.waitForEnabled({ timeout: t(10_000) });
+ await useEnterpriseKey.click();
await waitForBodyText('activate this device');
const initialText = ((await browser.execute(
() => document.body.innerText.toLowerCase(),