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(connect): close a cancel→reconnect race in the OAuth UI

Louis Beaumont3f2f18a59295
diff --git a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
index f46b5f643..e66641ce0 100644
--- a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
@@ -1063,10 +1063,13 @@ function OAuthPanel({ integrationId, integrationName }: { integrationId: string;
const handleCancel = async () => {
connectingRef.current = false;
- setStatus("idle");
- // Drop the pending OAuth sender on the backend so the awaiting oauth_connect
- // call returns immediately instead of hanging on the 120s timeout.
+ // Stay in "loading" (cancel button visible, connect button hidden) until the
+ // backend has actually dropped the pending sender. Otherwise a quick
+ // cancel→connect sequence can race: a late-arriving oauth_cancel would
+ // retain-drop the new flow's entry by integration_id. Keeping the connect
+ // button hidden during the cancel IPC eliminates that window.
try { await commands.oauthCancel(integrationId); } catch { /* ignore */ }
+ setStatus("idle");
};
const handleDisconnect = async () => {