moi-computer 0.11.1-next.0 → 0.11.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/client/AGENTS.md +2 -2
  2. package/client/components/ui/button.tsx +1 -53
  3. package/client/components/ui/collapsible.tsx +1 -15
  4. package/client/components/ui/dialog.tsx +1 -58
  5. package/client/components/ui/dropdown-menu.tsx +1 -254
  6. package/client/components/ui/hover-card.tsx +1 -44
  7. package/client/components/ui/input.tsx +1 -21
  8. package/client/components/ui/popover.tsx +1 -88
  9. package/client/components/ui/resizable.tsx +1 -40
  10. package/client/components/ui/skeleton.tsx +1 -13
  11. package/client/components/ui/slider.tsx +1 -70
  12. package/client/components/ui/spinner.tsx +1 -18
  13. package/client/components/ui/switch.tsx +1 -23
  14. package/client/components/ui/tabs.tsx +1 -0
  15. package/client/components/ui/textarea.tsx +1 -18
  16. package/client/components/ui/tooltip.tsx +1 -51
  17. package/client/features/chat/ChatPanel.tsx +6 -6
  18. package/client/features/chat/ChatPopup.tsx +3 -4
  19. package/client/features/chat/TurnView.tsx +5 -4
  20. package/client/features/chat/api.ts +5 -14
  21. package/client/features/chat/chat-frames.ts +5 -2
  22. package/client/features/chat/composer/ChatComposer.tsx +5 -1
  23. package/client/features/chat/composer/ModelPicker.tsx +4 -3
  24. package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
  25. package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
  26. package/client/features/chat/group-turns.ts +11 -0
  27. package/client/features/chat/session-view.ts +53 -0
  28. package/client/features/chat/useChat.ts +5 -1
  29. package/client/features/dev/ChatStatesPage.tsx +3 -1
  30. package/client/features/dev/DevIndexPage.tsx +5 -0
  31. package/client/features/dev/DevRoutes.tsx +2 -0
  32. package/client/features/dev/HarnessDebugPage.tsx +1 -1
  33. package/client/features/dev/UiComponentPreviews.tsx +834 -0
  34. package/client/features/dev/UiComponentsPage.tsx +60 -0
  35. package/client/features/home/WorkspacePreview.tsx +1 -1
  36. package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
  37. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
  38. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
  39. package/client/features/settings/SettingsLayout.tsx +1 -1
  40. package/client/features/settings/WorkspaceSettings.tsx +4 -1
  41. package/client/features/views/ViewManager.tsx +14 -9
  42. package/client/features/widgets/WidgetFrame.tsx +1 -1
  43. package/client/features/widgets/Widgets.tsx +1 -3
  44. package/client/features/workspace/WorkspaceScreen.tsx +5 -1
  45. package/client/features/workspace/WorkspaceSplitLayout.tsx +6 -1
  46. package/client/features/workspace/api.ts +2 -4
  47. package/client/index.css +22 -29
  48. package/dist/{chunk-tny85yt2.js → chunk-4s15axjs.js} +2 -2
  49. package/dist/{chunk-c9pjqx9m.js → chunk-53a7pxcz.js} +1 -1
  50. package/dist/chunk-6664vxpk.css +1 -0
  51. package/dist/{chunk-104m57qw.js → chunk-87thzbtw.js} +2 -2
  52. package/dist/chunk-a6jad1a6.js +1 -0
  53. package/dist/chunk-dghwstd2.js +9 -0
  54. package/dist/chunk-eg120aca.js +1 -0
  55. package/dist/{chunk-v7wr1df4.js → chunk-j3wvxjr7.js} +1 -1
  56. package/dist/chunk-vwjeezeb.js +1 -0
  57. package/dist/chunk-w482ew2c.js +546 -0
  58. package/dist/chunk-yc471zah.js +70 -0
  59. package/dist/index.html +1 -1
  60. package/lib/format.ts +49 -1
  61. package/lib/themes.ts +6 -6
  62. package/lib/types.ts +5 -7
  63. package/package.json +12 -5
  64. package/registry.json +643 -0
  65. package/server/agent.ts +1 -1
  66. package/server/api.ts +25 -29
  67. package/server/applets.ts +30 -29
  68. package/server/bundler/applet-css.ts +6 -1
  69. package/server/bundler/build-applet.ts +5 -1
  70. package/server/bundler/build-worker.ts +178 -0
  71. package/server/cli-ui-components.ts +28 -33
  72. package/server/cli.ts +6 -11
  73. package/server/data-dir.ts +1 -1
  74. package/server/harness/README.md +13 -9
  75. package/server/harness/acp/NOTES.md +426 -0
  76. package/server/harness/acp/discovery.ts +27 -30
  77. package/server/harness/acp/model-state.ts +57 -0
  78. package/server/harness/acp/session.ts +18 -6
  79. package/server/harness/claude-code/NOTES.md +47 -12
  80. package/server/harness/claude-code/cli.ts +40 -0
  81. package/server/harness/claude-code/index.ts +11 -5
  82. package/server/harness/claude-code/models.ts +72 -19
  83. package/server/harness/claude-code/session.ts +408 -299
  84. package/server/harness/hermes/NOTES.md +18 -0
  85. package/server/harness/hermes/discovery.ts +20 -0
  86. package/server/harness/hermes/index.ts +9 -0
  87. package/server/harness/hermes/models.ts +28 -8
  88. package/server/harness/types.ts +4 -2
  89. package/server/moi-scaffold.ts +1 -1
  90. package/server/preview.ts +3 -1
  91. package/server/registry.ts +63 -41
  92. package/server/tldraw-package.d.ts +4 -0
  93. package/server/ui-components.ts +101 -434
  94. package/server/view-builders.ts +2 -1
  95. package/server/web.ts +9 -5
  96. package/server/workspace-env.ts +3 -2
  97. package/tsconfig.json +0 -1
  98. package/ui-components/accordion.tsx +71 -0
  99. package/ui-components/alert-dialog.tsx +165 -0
  100. package/ui-components/alert.tsx +68 -0
  101. package/ui-components/attachment.tsx +195 -0
  102. package/ui-components/avatar.tsx +90 -0
  103. package/ui-components/badge.tsx +49 -0
  104. package/ui-components/button-group.tsx +78 -0
  105. package/ui-components/button.tsx +55 -0
  106. package/ui-components/calendar.tsx +180 -0
  107. package/ui-components/card.tsx +84 -0
  108. package/ui-components/carousel.tsx +235 -0
  109. package/ui-components/chart.tsx +338 -0
  110. package/ui-components/checkbox.tsx +27 -0
  111. package/ui-components/collapsible.tsx +15 -0
  112. package/ui-components/combobox.tsx +265 -0
  113. package/ui-components/context-menu.tsx +244 -0
  114. package/ui-components/dialog.tsx +138 -0
  115. package/ui-components/docs/accordion.md +463 -0
  116. package/ui-components/docs/alert-dialog.md +481 -0
  117. package/ui-components/docs/alert.md +301 -0
  118. package/ui-components/docs/attachment.md +689 -0
  119. package/ui-components/docs/avatar.md +495 -0
  120. package/ui-components/docs/badge.md +258 -0
  121. package/ui-components/docs/button-group.md +879 -0
  122. package/ui-components/docs/button.md +26 -0
  123. package/ui-components/docs/calendar.md +862 -0
  124. package/ui-components/docs/card.md +265 -0
  125. package/ui-components/docs/carousel.md +627 -0
  126. package/ui-components/docs/chart.md +1256 -0
  127. package/ui-components/docs/checkbox.md +477 -0
  128. package/ui-components/docs/collapsible.md +446 -0
  129. package/ui-components/docs/combobox.md +1003 -0
  130. package/ui-components/docs/context-menu.md +860 -0
  131. package/ui-components/docs/data-table.md +1580 -0
  132. package/ui-components/docs/date-picker.md +614 -0
  133. package/ui-components/docs/dialog.md +414 -0
  134. package/ui-components/docs/drawer.md +51 -0
  135. package/ui-components/docs/dropdown-menu.md +1000 -0
  136. package/ui-components/docs/field.md +1192 -0
  137. package/ui-components/docs/hover-card.md +275 -0
  138. package/ui-components/docs/input-group.md +866 -0
  139. package/ui-components/docs/input.md +456 -0
  140. package/ui-components/docs/label.md +295 -0
  141. package/ui-components/docs/pagination.md +416 -0
  142. package/ui-components/docs/popover.md +348 -0
  143. package/ui-components/docs/progress.md +214 -0
  144. package/ui-components/docs/radio-group.md +389 -0
  145. package/ui-components/docs/resizable.md +265 -0
  146. package/ui-components/docs/select.md +616 -0
  147. package/ui-components/docs/separator.md +216 -0
  148. package/ui-components/docs/skeleton.md +205 -0
  149. package/ui-components/docs/slider.md +226 -0
  150. package/ui-components/docs/spinner.md +332 -0
  151. package/ui-components/docs/switch.md +236 -0
  152. package/ui-components/docs/table.md +551 -0
  153. package/ui-components/docs/tabs.md +379 -0
  154. package/ui-components/docs/textarea.md +187 -0
  155. package/ui-components/docs/toggle-group.md +370 -0
  156. package/ui-components/docs/toggle.md +91 -0
  157. package/ui-components/docs/tooltip.md +290 -0
  158. package/ui-components/drawer.tsx +213 -0
  159. package/ui-components/dropdown-menu.tsx +263 -0
  160. package/ui-components/field.tsx +224 -0
  161. package/ui-components/hover-card.tsx +46 -0
  162. package/ui-components/input-group.tsx +146 -0
  163. package/ui-components/input.tsx +20 -0
  164. package/ui-components/label.tsx +17 -0
  165. package/ui-components/pagination.tsx +124 -0
  166. package/ui-components/popover.tsx +81 -0
  167. package/ui-components/progress.tsx +63 -0
  168. package/ui-components/radio-group.tsx +37 -0
  169. package/ui-components/resizable.tsx +40 -0
  170. package/ui-components/scoped-portal.tsx +31 -0
  171. package/ui-components/select.tsx +195 -0
  172. package/ui-components/separator.tsx +18 -0
  173. package/ui-components/skeleton.tsx +15 -0
  174. package/ui-components/slider.tsx +75 -0
  175. package/ui-components/spinner.tsx +20 -0
  176. package/ui-components/switch.tsx +26 -0
  177. package/ui-components/table.tsx +86 -0
  178. package/ui-components/tabs.tsx +75 -0
  179. package/ui-components/textarea.tsx +17 -0
  180. package/ui-components/toggle-group.tsx +85 -0
  181. package/ui-components/toggle.tsx +42 -0
  182. package/ui-components/tooltip.tsx +61 -0
  183. package/ui-components/utils.ts +8 -0
  184. package/workspace/.claude/skills/moi-workspace/SKILL.md +11 -20
  185. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +4 -3
  186. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
  187. package/dist/chunk-59zf0m6n.js +0 -1
  188. package/dist/chunk-bj3akjs2.js +0 -1
  189. package/dist/chunk-j2w2vak4.js +0 -546
  190. package/dist/chunk-k2r9c95m.js +0 -10
  191. package/dist/chunk-kmbxhgwv.js +0 -1
  192. package/dist/chunk-p1yqa71k.js +0 -83
  193. package/dist/chunk-r5xrenjy.css +0 -1
@@ -182,6 +182,24 @@ what moi's current backends expose — it already carries `cwd`, `git_branch`,
182
182
  `git_repo_root`, `parent_session_id`, per-session token counts and
183
183
  `estimated_cost_usd`/`actual_cost_usd`.
184
184
 
185
+ #### 3.2.2 The default model rides on `currentModelId`, and the catalog is cached
186
+
187
+ `session/new` also returns `currentModelId` — the model Hermes resolves from
188
+ the profile's `config.yaml` (`model.default` + `model.provider`, rewritten by
189
+ `hermes model`). `./models.ts` maps it onto a synthetic `default` row with
190
+ `resolvedModel`, the same convention the Claude and Codex harnesses use, so
191
+ the picker preselects the model a promptless chat would actually run.
192
+ Verified against v0.20.0 (`xai-oauth:grok-build-0.1`, 67 raw rows).
193
+
194
+ The catalog only ever arrives on `session/new`, and every such call persists a
195
+ zero-message row in `state.db` that `hermes sessions list` shows as a blank
196
+ entry (moi's own list hides them). So the state is cached per workspace
197
+ (`../acp/model-state.ts`): the first picker snapshot opens one throwaway
198
+ session, every real chat start refreshes the cache from its own `session/new`,
199
+ and the cache is stamped with the mtimes of the profile's `config.yaml` and
200
+ `.env` (`hermesConfigFingerprint`) so a default changed outside moi is
201
+ rediscovered on the next snapshot instead of on every one.
202
+
185
203
  ### 3.3 The prompt stream
186
204
 
187
205
  `session/prompt` streams `session/update` notifications and resolves with
@@ -153,3 +153,23 @@ export async function resolveHermesProfile(
153
153
  }
154
154
  return profiles.find(p => p.path === workspacePath) ?? null
155
155
  }
156
+
157
+ // Version stamp for the profile inputs that decide its default model:
158
+ // config.yaml (`model.default`, rewritten by `hermes model`) and .env
159
+ // (provider keys, which gate which entries the catalog lists at all). Mtimes,
160
+ // not contents — the ACP session reports the real resolved state, this only
161
+ // says when to ask again. A missing file stamps as such, so creating it later
162
+ // still counts as a change.
163
+ export async function hermesConfigFingerprint(home: string | null): Promise<string | undefined> {
164
+ if (!home) return undefined
165
+ const stamps = await Promise.all(
166
+ ['config.yaml', '.env'].map(async file => {
167
+ try {
168
+ return String((await stat(join(home, file))).mtimeMs)
169
+ } catch {
170
+ return 'missing'
171
+ }
172
+ })
173
+ )
174
+ return stamps.join(' ')
175
+ }
@@ -26,6 +26,7 @@ import { getAcpProcessInfo, killAcpWorkspace, killAllAcpClients } from '../acp/c
26
26
  import {
27
27
  DEFAULT_PROFILE,
28
28
  discoverHermesProfiles,
29
+ hermesConfigFingerprint,
29
30
  profileHomeFromWorkspace,
30
31
  resolveHermesProfile
31
32
  } from './discovery'
@@ -42,6 +43,14 @@ const config: AcpProviderConfig = {
42
43
  provider: 'hermes',
43
44
  noPromptModeId: NO_PROMPT_MODE,
44
45
  mapModels: hermesModels,
46
+ // The profile's default model (`currentModelId` on `session/new`) follows
47
+ // config.yaml, which `hermes model` and hand edits change while moi runs.
48
+ // Stamp the cache with the config mtimes so such a change is picked up on
49
+ // the next snapshot without opening a throwaway session every time.
50
+ modelStateFingerprint: async ctx => {
51
+ const profile = await resolveHermesProfile(ctx.workspacePath, ctx.agentId)
52
+ return hermesConfigFingerprint(profile?.home ?? profileHomeFromWorkspace(ctx.workspacePath))
53
+ },
45
54
  supportsImages: true,
46
55
  async spawn(ctx) {
47
56
  const bin = findHarnessExecutable('hermes')
@@ -15,10 +15,11 @@
15
15
  // in `description` alone, which is why the group comes from that field.
16
16
  import type { Model } from '@/lib/types'
17
17
 
18
- import type { AcpModelInfo } from '../acp/wire'
18
+ import type { AcpModelInfo, AcpModelState } from '../acp/wire'
19
19
 
20
20
  const PROVIDER_PREFIX = /^Provider:\s*/
21
- // Hermes marks the model it would pick itself; moi tracks its own selection.
21
+ // This is display cleanup only. The default comes from structured
22
+ // `currentModelId`, never by inferring it from this suffix.
22
23
  const CURRENT_SUFFIX = /\s*•\s*current$/
23
24
 
24
25
  function providerOf(description: string | undefined): string | undefined {
@@ -65,15 +66,34 @@ function hermesModel(info: AcpModelInfo): Model {
65
66
  // — for the same endpoint and model. Both spellings work, so keep the first
66
67
  // and drop rows the picker would render as an exact duplicate. Keyed on
67
68
  // `providerId` where there is one, since both spellings normalize to it.
68
- export function hermesModels(infos: AcpModelInfo[]): Model[] {
69
- const seen = new Set<string>()
69
+ export function hermesModels(state: AcpModelState): Model[] {
70
+ const seen = new Map<string, number>()
70
71
  const out: Model[] = []
71
- for (const info of infos) {
72
+ for (const info of state.availableModels ?? []) {
72
73
  const model = hermesModel(info)
73
74
  const key = `${model.providerId ?? model.group ?? ''} ${model.displayName}`
74
- if (seen.has(key)) continue
75
- seen.add(key)
75
+ const existingIndex = seen.get(key)
76
+ if (existingIndex !== undefined) {
77
+ // If Hermes names a duplicate spelling as current, retain that exact id
78
+ // so the structured default can resolve to a visible picker row.
79
+ if (info.modelId === state.currentModelId) out[existingIndex] = model
80
+ continue
81
+ }
82
+ seen.set(key, out.length)
76
83
  out.push(model)
77
84
  }
78
- return out
85
+
86
+ if (!state.currentModelId) return out
87
+ const currentIndex = out.findIndex(model => model.value === state.currentModelId)
88
+ if (currentIndex === -1) return out
89
+
90
+ out[currentIndex] = { ...out[currentIndex], resolvedModel: state.currentModelId }
91
+ return [
92
+ {
93
+ value: 'default',
94
+ resolvedModel: state.currentModelId,
95
+ displayName: 'Default (from Hermes)'
96
+ },
97
+ ...out
98
+ ]
79
99
  }
@@ -72,6 +72,8 @@ export type DiscoveredWorkspaceCandidate = {
72
72
  type: WorkspaceType
73
73
  }
74
74
 
75
+ export type HarnessWorkspace = Pick<WorkspaceEntry, 'id' | 'path' | 'type' | 'agentId'>
76
+
75
77
  export type Harness = {
76
78
  id: WorkspaceType
77
79
  capabilities: HarnessCapabilities
@@ -104,9 +106,9 @@ export type Harness = {
104
106
  discoverWorkspaces?(registeredPaths: Set<string>): Promise<DiscoveredWorkspaceCandidate[]>
105
107
  // Without a workspace, only check whether the runtime is installed. With a
106
108
  // workspace, also check provider state such as authentication.
107
- availability?(ws?: WorkspaceEntry): Promise<HarnessAvailability>
109
+ availability?(ws?: HarnessWorkspace): Promise<HarnessAvailability>
108
110
  // Optional recovery flow the host can start without a terminal.
109
- startLogin?(ws: WorkspaceEntry): Promise<HarnessLogin>
111
+ startLogin?(ws: HarnessWorkspace): Promise<HarnessLogin>
110
112
 
111
113
  // -- host integration hooks -------------------------------------------------
112
114
  // Env is frozen at spawn everywhere; this reaps idle sessions/processes so
@@ -20,7 +20,7 @@ export const MOI_PACKAGE_JSON = {
20
20
  // Base UI primitives and the cn() stack, so one install at workspace
21
21
  // creation covers the common path. Component-specific deps (recharts,
22
22
  // embla, …) stay agent-installed on demand — `add` prints them.
23
- '@base-ui/react': '^1.2.0',
23
+ '@base-ui/react': '^1.8.0',
24
24
  'class-variance-authority': '^0.7.1',
25
25
  clsx: '^2.1.1',
26
26
  'tailwind-merge': '^3.3.1'
package/server/preview.ts CHANGED
@@ -61,7 +61,9 @@ export async function serveWorkspaceImagePreview(
61
61
  .resize(PREVIEW_MAX_EDGE, PREVIEW_MAX_EDGE, { fit: 'inside', withoutEnlargement: true })
62
62
  .webp({ quality: 80 })
63
63
  .toBuffer()
64
- return new Response(data, { headers: { ...headers, 'Content-Type': 'image/webp' } })
64
+ return new Response(new Uint8Array(data), {
65
+ headers: { ...headers, 'Content-Type': 'image/webp' }
66
+ })
65
67
  } catch {
66
68
  // Undecodable (corrupt, or an unsupported codec despite the extension) —
67
69
  // there's no preview to show; the client hides the <img> on error.
@@ -1,4 +1,4 @@
1
- import { mkdir } from 'node:fs/promises'
1
+ import { rename, rm } from 'node:fs/promises'
2
2
  import { homedir } from 'node:os'
3
3
  import { join, resolve, sep } from 'path'
4
4
 
@@ -43,8 +43,23 @@ async function readRegistry(): Promise<WorkspaceEntry[]> {
43
43
  }
44
44
 
45
45
  async function writeRegistry(entries: WorkspaceEntry[]): Promise<void> {
46
- await mkdir(join(_registryPath, '..'), { recursive: true })
47
- await Bun.write(_registryPath, JSON.stringify(entries, null, 2))
46
+ const temporaryPath = `${_registryPath}.${crypto.randomUUID()}.tmp`
47
+ try {
48
+ await Bun.write(temporaryPath, JSON.stringify(entries, null, 2))
49
+ await rename(temporaryPath, _registryPath)
50
+ } finally {
51
+ await rm(temporaryPath, { force: true })
52
+ }
53
+ }
54
+
55
+ // Lock the whole read-modify-write operation, including validation. Atomic
56
+ // replacement keeps readers safe; the queue keeps concurrent writers safe.
57
+ let writeChain: Promise<unknown> = Promise.resolve()
58
+
59
+ function locked<T>(operation: () => Promise<T>): Promise<T> {
60
+ const run = writeChain.then(operation)
61
+ writeChain = run.catch(() => {})
62
+ return run
48
63
  }
49
64
 
50
65
  export type RegisterOptions = {
@@ -90,26 +105,28 @@ export async function registerWorkspace(
90
105
  absPath: string,
91
106
  opts: RegisterOptions = {}
92
107
  ): Promise<WorkspaceEntry> {
93
- const normalPath = resolve(absPath)
94
- const entries = await readRegistry()
95
- if (opts.id) {
96
- const error = workspaceIdError(entries, normalPath, opts.id)
97
- if (error) throw new Error(error)
98
- }
99
- const existing = entries.find(e => e.path === normalPath)
100
- if (existing) return existing
101
- const entry: WorkspaceEntry = {
102
- id: opts.id ?? newWorkspaceId(),
103
- path: normalPath,
104
- addedAt: new Date().toISOString(),
105
- ...(opts.type ? { type: opts.type } : {}),
106
- ...(opts.name ? { name: opts.name } : {}),
107
- ...(opts.agentId ? { agentId: opts.agentId } : {}),
108
- ...(opts.isDefault ? { isDefault: opts.isDefault } : {}),
109
- ...(opts.lastRunAt ? { lastRunAt: opts.lastRunAt } : {})
110
- }
111
- await writeRegistry([entry, ...entries])
112
- return withDisplayPath(entry)
108
+ return locked(async () => {
109
+ const normalPath = resolve(absPath)
110
+ const entries = await readRegistry()
111
+ if (opts.id) {
112
+ const error = workspaceIdError(entries, normalPath, opts.id)
113
+ if (error) throw new Error(error)
114
+ }
115
+ const existing = entries.find(e => e.path === normalPath)
116
+ if (existing) return existing
117
+ const entry: WorkspaceEntry = {
118
+ id: opts.id ?? newWorkspaceId(),
119
+ path: normalPath,
120
+ addedAt: new Date().toISOString(),
121
+ ...(opts.type ? { type: opts.type } : {}),
122
+ ...(opts.name ? { name: opts.name } : {}),
123
+ ...(opts.agentId ? { agentId: opts.agentId } : {}),
124
+ ...(opts.isDefault ? { isDefault: opts.isDefault } : {}),
125
+ ...(opts.lastRunAt ? { lastRunAt: opts.lastRunAt } : {})
126
+ }
127
+ await writeRegistry([entry, ...entries])
128
+ return withDisplayPath(entry)
129
+ })
113
130
  }
114
131
 
115
132
  export async function getWorkspace(id: string): Promise<WorkspaceEntry | null> {
@@ -118,11 +135,13 @@ export async function getWorkspace(id: string): Promise<WorkspaceEntry | null> {
118
135
  }
119
136
 
120
137
  export async function removeWorkspace(id: string): Promise<boolean> {
121
- const entries = await readRegistry()
122
- const next = entries.filter(e => e.id !== id)
123
- if (next.length === entries.length) return false
124
- await writeRegistry(next)
125
- return true
138
+ return locked(async () => {
139
+ const entries = await readRegistry()
140
+ const next = entries.filter(e => e.id !== id)
141
+ if (next.length === entries.length) return false
142
+ await writeRegistry(next)
143
+ return true
144
+ })
126
145
  }
127
146
 
128
147
  export async function listWorkspaces(): Promise<WorkspaceEntry[]> {
@@ -131,19 +150,22 @@ export async function listWorkspaces(): Promise<WorkspaceEntry[]> {
131
150
  }
132
151
 
133
152
  export async function reorderWorkspaces(ids: string[]): Promise<WorkspaceEntry[]> {
134
- const entries = await readRegistry()
135
- if (ids.length !== entries.length) throw new Error('Workspace order must include every workspace')
136
-
137
- const unique = new Set(ids)
138
- if (unique.size !== ids.length) throw new Error('Workspace order contains duplicate ids')
139
-
140
- const byId = new Map(entries.map(e => [e.id, e]))
141
- const next = ids.map(id => byId.get(id))
142
- if (next.some(e => !e)) throw new Error('Workspace order contains unknown ids')
143
-
144
- const ordered = next as WorkspaceEntry[]
145
- await writeRegistry(ordered)
146
- return ordered.map(withDisplayPath)
153
+ return locked(async () => {
154
+ const entries = await readRegistry()
155
+ if (ids.length !== entries.length)
156
+ throw new Error('Workspace order must include every workspace')
157
+
158
+ const unique = new Set(ids)
159
+ if (unique.size !== ids.length) throw new Error('Workspace order contains duplicate ids')
160
+
161
+ const byId = new Map(entries.map(e => [e.id, e]))
162
+ const next = ids.map(id => byId.get(id))
163
+ if (next.some(e => !e)) throw new Error('Workspace order contains unknown ids')
164
+
165
+ const ordered = next as WorkspaceEntry[]
166
+ await writeRegistry(ordered)
167
+ return ordered.map(withDisplayPath)
168
+ })
147
169
  }
148
170
 
149
171
  // Resolve a path to the registered workspace that *contains* it: the entry
@@ -0,0 +1,4 @@
1
+ declare module 'tldraw/package.json' {
2
+ const packageJson: { version: string }
3
+ export default packageJson
4
+ }