From 4b7231be68fb5ac9bf25657f8f39c7e349a63a5d Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 9 Nov 2025 01:41:49 -0500 Subject: [PATCH] fix race condition --- .../opencode/src/cli/cmd/tui/context/sync.tsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/context/sync.tsx b/packages/opencode/src/cli/cmd/tui/context/sync.tsx index 0dc04af2..e53cd60b 100644 --- a/packages/opencode/src/cli/cmd/tui/context/sync.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/sync.tsx @@ -221,23 +221,22 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ sdk.client.app.agents().then((x) => setStore("agent", x.data ?? [])), sdk.client.config.get().then((x) => setStore("config", x.data!)), ]).then(() => { - if (store.status === "loading") setStore("status", "partial") - }) - - // non-blocking - Promise.all([ - sdk.client.session.list().then((x) => - setStore( - "session", - (x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)), + setStore("status", "partial") + // non-blocking + Promise.all([ + sdk.client.session.list().then((x) => + setStore( + "session", + (x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)), + ), ), - ), - sdk.client.command.list().then((x) => setStore("command", x.data ?? [])), - sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)), - sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)), - sdk.client.formatter.status().then((x) => setStore("formatter", x.data!)), - ]).then(() => { - setStore("status", "complete") + sdk.client.command.list().then((x) => setStore("command", x.data ?? [])), + sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)), + sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)), + sdk.client.formatter.status().then((x) => setStore("formatter", x.data!)), + ]).then(() => { + setStore("status", "complete") + }) }) const result = {