Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 4b7231b

Browse files
committed
fix race condition
1 parent 70a6fe9 commit 4b7231b

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/context

packages/opencode/src/cli/cmd/tui/context/sync.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,22 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
221221
sdk.client.app.agents().then((x) => setStore("agent", x.data ?? [])),
222222
sdk.client.config.get().then((x) => setStore("config", x.data!)),
223223
]).then(() => {
224-
if (store.status === "loading") setStore("status", "partial")
225-
})
226-
227-
// non-blocking
228-
Promise.all([
229-
sdk.client.session.list().then((x) =>
230-
setStore(
231-
"session",
232-
(x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)),
224+
setStore("status", "partial")
225+
// non-blocking
226+
Promise.all([
227+
sdk.client.session.list().then((x) =>
228+
setStore(
229+
"session",
230+
(x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)),
231+
),
233232
),
234-
),
235-
sdk.client.command.list().then((x) => setStore("command", x.data ?? [])),
236-
sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)),
237-
sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)),
238-
sdk.client.formatter.status().then((x) => setStore("formatter", x.data!)),
239-
]).then(() => {
240-
setStore("status", "complete")
233+
sdk.client.command.list().then((x) => setStore("command", x.data ?? [])),
234+
sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)),
235+
sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)),
236+
sdk.client.formatter.status().then((x) => setStore("formatter", x.data!)),
237+
]).then(() => {
238+
setStore("status", "complete")
239+
})
241240
})
242241

243242
const result = {

0 commit comments

Comments
 (0)