The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): re-read the offer timing only after a backend list read
alt-glitch55474d31e1ea
diff --git a/apps/desktop/src/app/capabilities/connectors/data/queries-rules.test.tsx b/apps/desktop/src/app/capabilities/connectors/data/queries-rules.test.tsxindex f399e9d4b1a..a0cfc224210 100644--- a/apps/desktop/src/app/capabilities/connectors/data/queries-rules.test.tsx+++ b/apps/desktop/src/app/capabilities/connectors/data/queries-rules.test.tsx@@ -7,6 +7,7 @@ import { queryClient } from '@/lib/query-client'import { $freeTierTurnCompleted, noteFreeTierTurnComplete } from '@/store/free-tier-sign-in'import { setPrimaryGateway, setPrimaryGatewayConnectionId } from '@/store/gateway'+import { connectorsListQueryKey } from './keys'import { useHostedConnectors } from './queries'const row = { connected: false, connector: 'notion', enabled: true, gateway_disabled_tools: [] }@@ -93,6 +94,18 @@ describe('a connected app first seen on a list read', () => {await waitFor(() => expect($freeTierTurnCompleted.get()).toBe(before + 1))})+ it('waits for the backend read when the page starts from saved connected rows', async () => {+ const request = gateway([{ ...row, connected: true }])+ queryClient.setQueryData(connectorsListQueryKey('default'), { available: true, connectors: [{ ...row, connected: true }] }, { updatedAt: 1 })+ const before = $freeTierTurnCompleted.get()++ mount()+ expect($freeTierTurnCompleted.get()).toBe(before)++ await waitFor(() => expect(asked(request, 'connectors.list')).toBe(true))+ await waitFor(() => expect($freeTierTurnCompleted.get()).toBe(before + 1))+ })+it('does not when nothing is connected', async () => {const request = gateway([row])const before = $freeTierTurnCompleted.get()diff --git a/apps/desktop/src/app/capabilities/connectors/data/queries.ts b/apps/desktop/src/app/capabilities/connectors/data/queries.tsindex 7e0b694076e..bb71385d4a8 100644--- a/apps/desktop/src/app/capabilities/connectors/data/queries.ts+++ b/apps/desktop/src/app/capabilities/connectors/data/queries.ts@@ -119,13 +119,15 @@ export function useHostedConnectors(scope: ProfileScope): HostedConnectorsView {// A list read is where the backend first sees an app this page never watched connect (an// authorization past the watch, a connect by link) and arms the sign-in offer; re-read when it is due.+ // Only after a read from the backend: saved or cached rows arrive before the read that arms it.const anyConnected = list.data?.connectors.some(connector => connector.connected) ?? false+ const readFromBackend = list.isFetchedAfterMount && !list.isFetchinguseEffect(() => {- if (anyConnected) {+ if (anyConnected && readFromBackend) {noteFreeTierAppConnected()}- }, [anyConnected])+ }, [anyConnected, readFromBackend, list.dataUpdatedAt])const policy = useQuery({...read('policy'),