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: clear cloud token on logout

Louis Beaumont435ae68589ca
diff --git a/apps/screenpipe-app-tauri/components/settings/account-section.tsx b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
index c182bb675..fccb15553 100644
--- a/apps/screenpipe-app-tauri/components/settings/account-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
@@ -249,7 +249,12 @@ export function AccountSection() {
size="sm"
data-testid="account-logout-button"
onClick={async () => {
- updateSettings({ user: null as any });
+ await updateSettings({ user: null as any });
+ try {
+ await commands.setCloudToken(null);
+ } catch (e) {
+ console.warn("failed to clear cloud token on logout:", e);
+ }
// Restart Pi with null token so it stops using the old
// account's quota. Next message will auto-start as anonymous.
try {
diff --git a/apps/screenpipe-app-tauri/e2e/specs/zz-owned-browser-background-nav.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/zz-owned-browser-background-nav.spec.ts
index e0296aea4..0eed6e0ad 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/zz-owned-browser-background-nav.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/zz-owned-browser-background-nav.spec.ts
@@ -259,6 +259,21 @@ async function waitForActiveConversation(id: string): Promise<void> {
);
}
+async function waitForForegroundReady(id: string): Promise<void> {
+ await browser.waitUntil(
+ async () =>
+ (await browser.execute(
+ (cid: string) => (window as any).__e2eForegroundReady === cid,
+ id,
+ )) as boolean,
+ {
+ timeout: t(15_000),
+ interval: 150,
+ timeoutMsg: `home foreground bus never registered conversation ${id}`,
+ },
+ );
+}
+
/** POST the owned-browser navigate endpoint the way a background agent/pipe
* does — with the `x-screenpipe-session` owner header the agent's curl shim
* injects. Returns the HTTP status so the caller can assert reachability. */
@@ -336,6 +351,7 @@ describe("Owned browser — per-chat navigation ownership", function () {
writeSeedChatFile(OWN_CHAT, "(e2e) owned-browser ownership probe");
await loadChatIntoHome(OWN_CHAT);
await waitForActiveConversation(OWN_CHAT);
+ await waitForForegroundReady(OWN_CHAT);
// 2. Drive owned-browser commands from a SECOND window: a regression
// attaches the native child to `home`, destroying home's WebDriver
@@ -395,6 +411,7 @@ describe("Owned browser — per-chat navigation ownership", function () {
writeSeedChatFile(OWN_CHAT, "(e2e) owned-browser reveal probe");
await loadChatIntoHome(OWN_CHAT);
await waitForActiveConversation(OWN_CHAT);
+ await waitForForegroundReady(OWN_CHAT);
await showWindow({ Search: { query: null } });
await waitForWindowHandle("search", t(10_000));
@@ -479,6 +496,7 @@ describe("Owned browser — fast chat switching keeps pipe state out of other ch
await loadChatIntoHome(BROWSER_CHAT_A);
await waitForActiveConversation(BROWSER_CHAT_A);
+ await waitForForegroundReady(BROWSER_CHAT_A);
await browser.pause(t(800));
await invokeOrThrow("owned_browser_hide");
expect(await invokeOrThrow<boolean>("e2e_owned_browser_visible")).toBe(
@@ -489,6 +507,7 @@ describe("Owned browser — fast chat switching keeps pipe state out of other ch
await loadChatIntoHome(PLAIN_CHAT);
await waitForActiveConversation(PLAIN_CHAT);
+ await waitForForegroundReady(PLAIN_CHAT);
const navigateStatus = await postNavigateAs(
port,
key,
@@ -503,8 +522,10 @@ describe("Owned browser — fast chat switching keeps pipe state out of other ch
await loadChatIntoHome(BROWSER_CHAT_B);
await waitForActiveConversation(BROWSER_CHAT_B);
+ await waitForForegroundReady(BROWSER_CHAT_B);
await loadChatIntoHome(PLAIN_CHAT);
await waitForActiveConversation(PLAIN_CHAT);
+ await waitForForegroundReady(PLAIN_CHAT);
await postEvalWithUrlAs(port, key, FOREIGN_URL, FOREIGN_OWNER);
await browser.pause(t(1_200));
expect(await invokeOrThrow<boolean>("e2e_owned_browser_visible")).toBe(
@@ -512,8 +533,10 @@ describe("Owned browser — fast chat switching keeps pipe state out of other ch
);
await loadChatIntoHome(BROWSER_CHAT_A);
await waitForActiveConversation(BROWSER_CHAT_A);
+ await waitForForegroundReady(BROWSER_CHAT_A);
await loadChatIntoHome(BROWSER_CHAT_B);
await waitForActiveConversation(BROWSER_CHAT_B);
+ await waitForForegroundReady(BROWSER_CHAT_B);
await browser.pause(t(1_000));
const chatA = loadChatFile(BROWSER_CHAT_A);