The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(composio): handle missing connection status in connect flow
Steven Enamakel7bbc7d04c6b4
diff --git a/app/src/components/composio/useComposioConnectFlow.ts b/app/src/components/composio/useComposioConnectFlow.tsindex 51bf2ee91e..c8a94f61c8 100644--- a/app/src/components/composio/useComposioConnectFlow.ts+++ b/app/src/components/composio/useComposioConnectFlow.ts@@ -75,6 +75,12 @@ export function useComposioConnectFlow({const pollDeadlineRef = useRef<number>(0);const pollIntervalRef = useRef<number>(POLL_INTERVAL_START_MS);const isPollingRef = useRef<boolean>(false);+ // Bumped by every `stopPolling`. A `tick` captures it before awaiting and+ // drops its response if the value moved while the request was in flight —+ // clearing the timer alone cannot un-send a request, so without this a poll+ // that resolves after Cancel could still push the modal back to `connected`+ // for an account that has just been deleted.+ const pollEpochRef = useRef<number>(0);const inFlightRef = useRef<boolean>(false);// Set while polling to fire an immediate re-poll (e.g. on window focus).const pokePollRef = useRef<() => void>(() => {});@@ -131,6 +137,7 @@ export function useComposioConnectFlow({const [savingScope, setSavingScope] = useState<keyof ComposioUserScopePref | null>(null);const stopPolling = useCallback(() => {+ pollEpochRef.current += 1;isPollingRef.current = false;pokePollRef.current = () => {};if (pollTimerRef.current != null) {@@ -162,6 +169,7 @@ export function useComposioConnectFlow({// Guard against overlapping executions: if a previous tick is still// in flight or we've already stopped/deadlined, skip this round.if (inFlightRef.current || !isPollingRef.current) return;+ const epoch = pollEpochRef.current;if (Date.now() > pollDeadlineRef.current) {stopPolling();setPhase('error');@@ -171,6 +179,10 @@ export function useComposioConnectFlow({inFlightRef.current = true;try {const resp = await listConnections();+ // Cancelled (or otherwise stopped) while this request was in flight:+ // the answer describes a connection state the user has already moved+ // on from, so applying it would resurrect a dead phase.+ if (epoch !== pollEpochRef.current) return;const allForToolkit = resp.connections.filter(c => c.toolkit.toLowerCase() === toolkit.slug.toLowerCase());