MCPcopy
hub / github.com/anomalyco/opencode / syncWorkspace

Function syncWorkspace

packages/tui/src/context/project.tsx:55–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53 }
54
55 async function syncWorkspace() {
56 const listed = await sdk.client.experimental.workspace.list().catch(() => undefined)
57 if (!listed?.data) return
58 const status = await sdk.client.experimental.workspace.status().catch(() => undefined)
59 const next = Object.fromEntries((status?.data ?? []).map((item) => [item.workspaceID, item.status]))
60
61 batch(() => {
62 setStore("workspace", "list", reconcile(listed.data))
63 setStore("workspace", "status", reconcile(next))
64 if (!listed.data.some((item) => item.id === store.workspace.current)) {
65 setStore("workspace", "current", undefined)
66 }
67 })
68 }
69
70 sdk.event.on("event", (event) => {
71 if (event.payload.type === "workspace.status") {

Callers

nothing calls this directly

Calls 5

batchFunction · 0.85
setStoreFunction · 0.85
listMethod · 0.65
reconcileFunction · 0.50
statusMethod · 0.45

Tested by

no test coverage detected