The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): send the agent back into wait when the user keeps waiting after a timeout
brooklyn!821d86ab248c
diff --git a/apps/desktop/src/store/connector-flow.test.ts b/apps/desktop/src/store/connector-flow.test.tsindex f27f0a0b094..d65ba3739b3 100644--- a/apps/desktop/src/store/connector-flow.test.ts+++ b/apps/desktop/src/store/connector-flow.test.ts@@ -80,4 +80,50 @@ describe('the moment the browser has the sign-in', () => {expect(onWaiting).not.toHaveBeenCalled()})++ it('sends the agent back in when the user keeps waiting after a timeout', async () => {+ let clock = 0+ const open = vi.fn(async () => {})+ const onWaiting = vi.fn()+ const request = vi.fn(async (method: string) =>+ method === 'connectors.list'+ ? listed(false)+ : { results: [{ connector: 'gmail', status: 'initiated', connect_url: 'https://auth.test/x' }] }+ )+ const flow = createConnectorFlow('session', [{ connector: 'gmail' }], {+ request: request as never,+ open,+ onWaiting,+ // Each poll tick burns the whole window so the first wait times out.+ delay: async () => {+ clock += 120001+ },+ now: () => clock+ })++ await flow.refresh()+ await flow.connect('gmail')++ expect(flow.state.get().rows[0].phase).toBe('timeout')+ expect(onWaiting).toHaveBeenCalledTimes(1)++ await flow.keepWaiting('gmail')++ expect(onWaiting).toHaveBeenCalledTimes(2)+ })++ it('asks the gateway to reconnect, not connect, when the grant is expired or revoked', async () => {+ const { flow, request } = flowWith({+ list: () => ({+ available: true,+ connectors: [{ connector: 'gmail', connected: false, enabled: true, connectionStatus: 'expired' }]+ }),+ connect: () => ({ results: [{ connector: 'gmail', status: 'active' }] })+ })++ await flow.refresh()+ await flow.connect('gmail')++ expect(request).toHaveBeenCalledWith('connectors.connect', expect.objectContaining({ reconnect: true }))+ })})diff --git a/apps/desktop/src/store/connector-flow.ts b/apps/desktop/src/store/connector-flow.tsindex fcc00c1df7f..1e7752a7c5b 100644--- a/apps/desktop/src/store/connector-flow.ts+++ b/apps/desktop/src/store/connector-flow.ts@@ -16,7 +16,8 @@ export interface ConnectorFlowState {export interface ConnectorFlowDeps {request: <T>(method: string, params: { session_id: string; connectors?: string[]; reconnect?: boolean }) => Promise<T>open: (url: string) => Promise<void>- /** The browser has the sign-in and the card is now waiting on the user. */+ /** The browser has the sign-in and the card is now waiting on the user.+ * Also fired when the user asks to keep waiting after a timeout. */onWaiting?: (slug: string) => voiddelay?: () => Promise<void>now?: () => number@@ -238,6 +239,8 @@ export function createConnectorFlow(sessionId: string, seeds: ConnectorRow[], deconst token = (attempts.get(slug) ?? 0) + 1attempts.set(slug, token)update(slug, { phase: 'waiting', error: undefined })+ // The agent's own wait timed out alongside ours; send it back in.+ deps.onWaiting?.(slug)await wait(slug, token)},skip: (slug: string) => {