diff options
| author | Dax Raad <[email protected]> | 2025-10-24 15:35:53 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-10-24 15:35:53 -0400 |
| commit | 74048ece2d06dd8c3b6f9be46a10ae0c927e13db (patch) | |
| tree | 76dbbc427da922e3c7306f9fc08bfe783f48a9b4 | |
| parent | 6646f7264aa04a656722c3f9c57920f162ead0f7 (diff) | |
| download | opencode-74048ece2d06dd8c3b6f9be46a10ae0c927e13db.tar.gz opencode-74048ece2d06dd8c3b6f9be46a10ae0c927e13db.zip | |
ignore: fix new session message loading with retry logic to handle server processing delays
| -rw-r--r-- | packages/desktop/src/context/sync.tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/desktop/src/context/sync.tsx b/packages/desktop/src/context/sync.tsx index 0fea4a421..12aa95878 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) |
