From 74048ece2d06dd8c3b6f9be46a10ae0c927e13db Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 24 Oct 2025 15:35:53 -0400 Subject: [PATCH] ignore: fix new session message loading with retry logic to handle server processing delays --- packages/desktop/src/context/sync.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/desktop/src/context/sync.tsx b/packages/desktop/src/context/sync.tsx index 0fea4a42..12aa9587 100644 --- a/packages/desktop/src/context/sync.tsx +++ b/packages/desktop/src/context/sync.tsx @@ -134,11 +134,18 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ if (match.found) return store.session[match.index] return undefined }, - async sync(sessionID: string) { + async sync(sessionID: string, isRetry = false) { const [session, messages] = await Promise.all([ sdk.client.session.get({ path: { id: sessionID } }), sdk.client.session.messages({ path: { id: sessionID } }), ]) + + // If no messages and this might be a new session, retry after a delay + if (!isRetry && messages.data!.length === 0) { + setTimeout(() => this.sync(sessionID, true), 500) + return + } + setStore( produce((draft) => { const match = Binary.search(draft.session, sessionID, (s) => s.id)