moi-computer 0.12.1-next.2 → 0.12.1-next.4

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 (243) hide show
  1. package/bunfig.toml +1 -5
  2. package/client/api/app-config.ts +1 -2
  3. package/client/api/app-ui-keys.ts +3 -1
  4. package/client/api/http.ts +4 -1
  5. package/client/api/workspace-keys.ts +3 -3
  6. package/client/app/app-provider.tsx +22 -2
  7. package/client/app/app-router.tsx +6 -0
  8. package/client/app/routes/home-route.tsx +14 -0
  9. package/client/app/routes/onboarding-route.tsx +11 -0
  10. package/client/app/routes/settings-route.tsx +10 -0
  11. package/client/app/routes/workspace-route.tsx +21 -19
  12. package/client/app/shell/sidebar-layout.tsx +34 -53
  13. package/client/components/shared/screen-shell.tsx +23 -0
  14. package/client/components/shared/ultrafast-icon.tsx +61 -0
  15. package/client/components/shared/workspace-icon.tsx +2 -2
  16. package/client/features/account/account-menu.tsx +96 -0
  17. package/client/features/account/account-provider.tsx +142 -0
  18. package/client/features/account/account-test-utils.tsx +294 -0
  19. package/client/features/account/api.ts +142 -0
  20. package/client/features/account/identity.ts +23 -0
  21. package/client/features/app-settings/api.ts +33 -0
  22. package/client/features/app-settings/general-settings.tsx +39 -0
  23. package/client/features/app-settings/profile-settings.tsx +95 -0
  24. package/client/features/app-settings/settings-page.tsx +48 -0
  25. package/client/features/app-settings/settings-section.tsx +26 -0
  26. package/client/features/app-settings/users-settings.tsx +195 -0
  27. package/client/features/chat/applet-chat-intents.ts +4 -20
  28. package/client/features/chat/chat-send.ts +17 -13
  29. package/client/features/chat/composer/model-order.ts +8 -4
  30. package/client/features/chat/composer/model-picker.tsx +88 -34
  31. package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
  32. package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
  33. package/client/features/chat/connection/chat-frames.ts +3 -15
  34. package/client/features/chat/messages/chat-empty-state.tsx +1 -4
  35. package/client/features/chat/messages/fork-history.ts +5 -5
  36. package/client/features/chat/messages/turn-view.tsx +3 -12
  37. package/client/features/chat/messages/user-message-bubble.tsx +63 -0
  38. package/client/features/chat/sessions/api.ts +121 -80
  39. package/client/features/chat/sessions/browser-tab-state.ts +14 -12
  40. package/client/features/chat/sessions/chat-selector.tsx +5 -6
  41. package/client/features/chat/sessions/use-selected-session.ts +172 -257
  42. package/client/features/chat/use-chat.ts +14 -19
  43. package/client/features/collab/applet-api.ts +15 -14
  44. package/client/features/collab/components/cursors.tsx +61 -24
  45. package/client/features/collab/components/presence-avatars.tsx +25 -12
  46. package/client/features/collab/components/presence-frame.tsx +20 -24
  47. package/client/features/collab/components/presence-group.tsx +15 -7
  48. package/client/features/collab/components/user-avatar-group.tsx +21 -8
  49. package/client/features/collab/components/user-avatar.tsx +38 -7
  50. package/client/features/collab/components/user.tsx +31 -12
  51. package/client/features/collab/users.ts +0 -5
  52. package/client/features/collab/workspace-users-menu.tsx +4 -4
  53. package/client/features/demo/demo-dialog.tsx +11 -3
  54. package/client/features/dev/collab/collab-playground.tsx +7 -7
  55. package/client/features/dev/collab/local-user-settings.tsx +7 -53
  56. package/client/features/dev/dev-index-page.tsx +5 -0
  57. package/client/features/dev/dev-routes.tsx +2 -0
  58. package/client/features/dev/harness-debug-page.tsx +3 -3
  59. package/client/features/dev/onboarding-preview-page.tsx +76 -0
  60. package/client/features/dev/workspace-setup-mocks.ts +16 -14
  61. package/client/features/dev/workspace-setup-preview.tsx +11 -17
  62. package/client/features/harness/api.ts +45 -15
  63. package/client/features/harness/device-login-steps.tsx +9 -3
  64. package/client/features/harness/harness-login-panel.tsx +228 -0
  65. package/client/features/harness/harness-presentation.ts +15 -0
  66. package/client/features/harness/harness-selector.tsx +119 -0
  67. package/client/features/harness/use-harness-login.ts +77 -0
  68. package/client/features/home/home-page.tsx +7 -7
  69. package/client/features/onboarding/agent-setup-step.tsx +57 -0
  70. package/client/features/onboarding/api.ts +42 -0
  71. package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
  72. package/client/features/onboarding/onboarding-page.tsx +32 -0
  73. package/client/features/onboarding/onboarding-screen.tsx +20 -0
  74. package/client/features/onboarding/onboarding-status.tsx +24 -0
  75. package/client/features/onboarding/workspace-setup-step.tsx +239 -0
  76. package/client/features/overview/default/registry.tsx +2 -2
  77. package/client/features/overview/default/views-widget.tsx +6 -5
  78. package/client/features/overview/overview.tsx +9 -11
  79. package/client/features/overview/widget-canvas.tsx +1 -1
  80. package/client/features/overview/workspace-name.tsx +2 -2
  81. package/client/features/update/update-control.tsx +1 -1
  82. package/client/features/views/api.ts +69 -16
  83. package/client/features/views/pending-view-screen.tsx +30 -9
  84. package/client/features/views/use-view-actions.ts +19 -20
  85. package/client/features/views/view-presentation.ts +2 -2
  86. package/client/features/views/view-submission.ts +28 -41
  87. package/client/features/workspace/add/api.ts +3 -23
  88. package/client/features/workspace/add/create-workspace-dialog.tsx +11 -7
  89. package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
  90. package/client/features/workspace/add/workspace-agent-options.ts +11 -12
  91. package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
  92. package/client/features/workspace/api.ts +32 -36
  93. package/client/features/workspace/harness-transition.ts +88 -0
  94. package/client/features/{settings → workspace/settings}/api.ts +1 -34
  95. package/client/features/{settings → workspace/settings}/connectors-settings.tsx +3 -3
  96. package/client/features/{settings → workspace/settings}/environment-settings.tsx +3 -3
  97. package/client/features/{settings → workspace/settings}/general-settings.tsx +77 -3
  98. package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
  99. package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
  100. package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
  101. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
  102. package/client/features/workspace/setup/workspace-setup.tsx +34 -14
  103. package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
  104. package/client/features/workspace/use-workspace-navigation.ts +25 -9
  105. package/client/features/workspace/workspace-content.tsx +11 -8
  106. package/client/features/workspace/workspace-frame.tsx +2 -1
  107. package/client/features/workspace/workspace-layout-context.tsx +5 -2
  108. package/client/features/workspace/workspace-menu.tsx +12 -8
  109. package/client/features/workspace/workspace-pending-screen.tsx +10 -10
  110. package/client/features/workspace/workspace-presentation.tsx +5 -13
  111. package/client/features/workspace/workspace-state.ts +169 -0
  112. package/client/features/workspace/workspace-tabs.tsx +22 -2
  113. package/client/index.css +2 -0
  114. package/client/index.tsx +3 -3
  115. package/client/lib/flags.ts +1 -1
  116. package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
  117. package/client/lib/user-display-name.ts +6 -0
  118. package/client/main.tsx +4 -1
  119. package/client/runtime/workspace-events.ts +21 -4
  120. package/client/runtime/workspace-theme.ts +9 -0
  121. package/client/tailwind-config.ts +43 -0
  122. package/dist/chunk-0mjzg20x.js +2 -0
  123. package/dist/chunk-2y59vrxg.js +5 -0
  124. package/dist/chunk-58dyt9bk.js +2 -0
  125. package/dist/chunk-5aj040e5.css +1 -0
  126. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  127. package/dist/chunk-71fn6rmj.js +546 -0
  128. package/dist/chunk-7yg1m8hx.js +2 -0
  129. package/dist/chunk-825hys3h.js +1 -0
  130. package/dist/chunk-9bb8m9rx.js +2 -0
  131. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  132. package/dist/chunk-g0tcwqxc.js +1 -0
  133. package/dist/chunk-n0nab26d.js +1 -0
  134. package/dist/chunk-nf2wkvf9.js +14 -0
  135. package/dist/chunk-v88n1bay.js +74 -0
  136. package/dist/index.html +1 -1
  137. package/lib/harness-instructions.ts +1 -1
  138. package/lib/{app-icons.ts → identity-icons.ts} +6 -7
  139. package/lib/onboarding.ts +41 -0
  140. package/lib/speed-mode.ts +5 -0
  141. package/lib/types.ts +72 -63
  142. package/lib/view-build-directives.ts +1 -2
  143. package/lib/workspace-icon.ts +2 -2
  144. package/lib/workspace-layout.ts +1 -1
  145. package/lib/workspace-name.ts +15 -12
  146. package/package.json +9 -8
  147. package/server/README.md +27 -25
  148. package/server/api/harnesses.ts +31 -8
  149. package/server/api/index.ts +164 -131
  150. package/server/api/onboarding.ts +46 -0
  151. package/server/app-config.ts +23 -24
  152. package/server/app-settings.ts +6 -2
  153. package/server/applets/config.ts +5 -5
  154. package/server/applets/views.ts +19 -17
  155. package/server/cli/commands/init.ts +3 -3
  156. package/server/cli/commands/skill.ts +16 -17
  157. package/server/cli/commands/start.ts +8 -34
  158. package/server/cli/server.ts +18 -6
  159. package/server/collab/config.ts +1 -2
  160. package/server/collab/manager.ts +4 -1
  161. package/server/collab/skill/index.ts +1 -1
  162. package/server/control.ts +3 -3
  163. package/server/data-dir.ts +1 -1
  164. package/server/harness/README.md +24 -8
  165. package/server/harness/acp/session.ts +8 -4
  166. package/server/harness/auth.ts +14 -17
  167. package/server/harness/claude-code/NOTES.md +4 -3
  168. package/server/harness/claude-code/index.ts +2 -0
  169. package/server/harness/claude-code/models.ts +2 -20
  170. package/server/harness/claude-code/run-action.ts +123 -0
  171. package/server/harness/claude-code/session-title.ts +5 -7
  172. package/server/harness/claude-code/session.ts +24 -16
  173. package/server/harness/codex/NOTES.md +14 -9
  174. package/server/harness/codex/adapter.ts +14 -17
  175. package/server/harness/codex/index.ts +2 -0
  176. package/server/harness/codex/run-action.ts +93 -0
  177. package/server/harness/codex/session-title.ts +6 -8
  178. package/server/harness/codex/session.ts +11 -11
  179. package/server/harness/command.ts +45 -0
  180. package/server/harness/executable.ts +5 -0
  181. package/server/harness/fork.ts +6 -4
  182. package/server/harness/install.ts +49 -0
  183. package/server/harness/openclaw/session.ts +1 -2
  184. package/server/harness/run-action.ts +85 -0
  185. package/server/harness/session-title.ts +0 -46
  186. package/server/harness/types.ts +26 -2
  187. package/server/onboarding/brief.ts +29 -0
  188. package/server/onboarding/ideas.ts +48 -0
  189. package/server/onboarding/jobs.ts +291 -0
  190. package/server/onboarding/prompt.md +49 -0
  191. package/server/sessions/archive.ts +5 -14
  192. package/server/sessions/config.ts +17 -16
  193. package/server/sessions/lifecycle.ts +15 -13
  194. package/server/sessions/pending-views.ts +79 -108
  195. package/server/sessions/selected.ts +75 -161
  196. package/server/sessions/store.ts +40 -113
  197. package/server/sessions/view-sessions.ts +128 -111
  198. package/server/skills/locations.ts +82 -0
  199. package/server/skills/lock.ts +29 -0
  200. package/server/skills/template.ts +36 -25
  201. package/server/skills/update.ts +52 -5
  202. package/server/skills/version.ts +17 -22
  203. package/server/skills/workspace.ts +121 -0
  204. package/server/web.ts +23 -8
  205. package/server/workspace-state/file.ts +177 -0
  206. package/server/workspace-state/index.ts +162 -0
  207. package/server/workspace-state/legacy-migration.ts +79 -0
  208. package/server/workspace-state/lock.ts +42 -0
  209. package/server/workspace-state/types.ts +16 -0
  210. package/server/workspaces/change-harness.ts +88 -0
  211. package/server/workspaces/harness-transition.ts +29 -0
  212. package/server/workspaces/init.ts +29 -16
  213. package/server/workspaces/layout.ts +3 -0
  214. package/server/workspaces/registry.ts +58 -10
  215. package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
  216. package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
  217. package/skill/references/DESIGN.md +148 -0
  218. package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
  219. package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
  220. package/ui-components/badge.tsx +1 -1
  221. package/client/accept-hmr-dependencies.ts +0 -22
  222. package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
  223. package/dist/chunk-00rh9df4.js +0 -2
  224. package/dist/chunk-4nh7y1hq.css +0 -1
  225. package/dist/chunk-am4agx6v.js +0 -2
  226. package/dist/chunk-d7cbm65e.js +0 -2
  227. package/dist/chunk-hbpdv7vd.js +0 -1
  228. package/dist/chunk-hmka9rt5.js +0 -2
  229. package/dist/chunk-hvh9f5h0.js +0 -14
  230. package/dist/chunk-mjjregkn.js +0 -10
  231. package/dist/chunk-pcnahct1.js +0 -5
  232. package/dist/chunk-rt30jbcm.js +0 -1
  233. package/dist/chunk-vt6zybej.js +0 -2
  234. package/dist/chunk-wbkwf6cc.js +0 -68
  235. package/dist/chunk-xjyfyz64.js +0 -1
  236. package/dist/chunk-y8nbwp21.js +0 -546
  237. package/dist/chunk-ysfdcew7.js +0 -1
  238. package/lib/experimental.ts +0 -14
  239. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
  240. /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
  241. /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
  242. /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
  243. /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
@@ -1,15 +1,9 @@
1
+ import { HarnessSelector } from '@/client/features/harness/harness-selector'
1
2
  import { type ReactNode, useEffect } from 'react'
2
3
 
3
- import { IconCircleCheckFilled } from '@tabler/icons-react'
4
-
5
4
  import { Button } from '@/client/components/ui/button'
6
- import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
7
5
  import { DialogDescription, DialogTitle } from '@/client/components/ui/dialog'
8
6
  import { Skeleton } from '@/client/components/ui/skeleton'
9
- import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
10
- import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
11
- import { cn } from '@/client/lib/cn'
12
- import { useUiStore } from '@/client/store/ui'
13
7
  import type { WorkspaceType } from '@/lib/types'
14
8
 
15
9
  import {
@@ -17,7 +11,7 @@ import {
17
11
  type WorkspaceAgentOption
18
12
  } from './workspace-agent-options'
19
13
 
20
- const WORKSPACE_AGENT_DESCRIPTION = 'Choose which agent Moi will use to build your workspace'
14
+ const WORKSPACE_AGENT_DESCRIPTION = 'Choose the agent to build the workspace'
21
15
  type WorkspaceAgentSelectorProps = {
22
16
  title: string
23
17
  selectedType: WorkspaceType
@@ -47,15 +41,8 @@ export function WorkspaceAgentSelector({
47
41
  onTypeChange,
48
42
  onSubmit
49
43
  }: WorkspaceAgentSelectorProps) {
50
- const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
51
44
  const selectableType = resolveWorkspaceAgentSelection(options, selectedType)
52
45
  const selectedUnavailable = selectableType !== selectedType
53
- const subscriptionTip =
54
- selectableType === 'claude-code'
55
- ? 'Tip: you can use your existing Claude subscription in Moi'
56
- : selectableType === 'codex'
57
- ? 'Tip: you can use your existing ChatGPT subscription in Moi'
58
- : undefined
59
46
 
60
47
  useEffect(() => {
61
48
  if (!isPending && selectableType && selectedUnavailable) onTypeChange(selectableType)
@@ -79,16 +66,13 @@ export function WorkspaceAgentSelector({
79
66
  <Skeleton className="h-32 min-w-32 flex-1" />
80
67
  </div>
81
68
  ) : (
82
- <WorkspaceAgentCards
69
+ <HarnessSelector
83
70
  disabled={isPending}
84
71
  options={options}
85
72
  selectedType={selectedUnavailable ? undefined : selectedType}
86
73
  onTypeChange={onTypeChange}
87
74
  />
88
75
  )}
89
- {!hasSentMessageFromMoi && subscriptionTip && (
90
- <p className="w-0 min-w-full text-sm text-muted-foreground">{subscriptionTip}</p>
91
- )}
92
76
  </div>
93
77
 
94
78
  {errorMessage && (
@@ -110,116 +94,3 @@ export function WorkspaceAgentSelector({
110
94
  </div>
111
95
  )
112
96
  }
113
-
114
- type WorkspaceAgentCardsProps = {
115
- disabled: boolean
116
- options: WorkspaceAgentOption[]
117
- selectedType?: WorkspaceType
118
- onTypeChange: (type: WorkspaceType) => void
119
- }
120
-
121
- function WorkspaceAgentCards({
122
- disabled,
123
- options,
124
- selectedType,
125
- onTypeChange
126
- }: WorkspaceAgentCardsProps) {
127
- return (
128
- <fieldset
129
- disabled={disabled}
130
- aria-label="Agent"
131
- className="flex min-w-0 flex-wrap justify-center gap-2"
132
- >
133
- {options.map(option => (
134
- <WorkspaceAgentOptionButton
135
- key={option.type}
136
- option={option}
137
- selected={selectedType === option.type}
138
- onSelect={onTypeChange}
139
- />
140
- ))}
141
- </fieldset>
142
- )
143
- }
144
-
145
- type WorkspaceAgentOptionButtonProps = {
146
- option: WorkspaceAgentOption
147
- selected: boolean
148
- onSelect: (type: WorkspaceType) => void
149
- }
150
-
151
- function WorkspaceAgentOptionButton({
152
- option,
153
- selected,
154
- onSelect
155
- }: WorkspaceAgentOptionButtonProps) {
156
- const showDisabledTooltip = Boolean(option.disabledReason)
157
- const button = (
158
- <button
159
- type="button"
160
- disabled={option.disabled && !showDisabledTooltip}
161
- aria-disabled={option.disabled || undefined}
162
- aria-pressed={selected}
163
- onClick={event => {
164
- if (option.disabled) {
165
- event.preventDefault()
166
- return
167
- }
168
- onSelect(option.type)
169
- }}
170
- className={cn(
171
- 'relative flex h-32 min-w-32 flex-1 flex-col items-start justify-between gap-6 rounded-xl bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
172
- !selected && 'opacity-70',
173
- !selected && !option.disabled && 'cursor-pointer hover:opacity-100',
174
- option.disabled && 'cursor-not-allowed'
175
- )}
176
- >
177
- <span className="relative inline-flex">
178
- <WorkspaceAgentIcon type={option.type} />
179
- {selected && (
180
- <IconCircleCheckFilled
181
- size={16}
182
- stroke={1.75}
183
- aria-hidden="true"
184
- className="absolute -top-1.5 -right-1.5"
185
- />
186
- )}
187
- </span>
188
- <span className="flex min-w-0 flex-col gap-0.5">
189
- <span className="text-sm font-medium text-foreground">
190
- {workspaceTypeLabel[option.type]}
191
- </span>
192
- <span className="text-xs leading-4 text-muted-foreground">{option.description}</span>
193
- </span>
194
- </button>
195
- )
196
-
197
- if (!showDisabledTooltip) return button
198
-
199
- return (
200
- <Tooltip>
201
- <TooltipTrigger render={button} />
202
- <TooltipContent className="max-w-[calc(100vw-2rem)] leading-5 sm:max-w-96">
203
- <span className="text-center">
204
- {option.disabledReason}
205
- {option.disabledCommand && (
206
- <>
207
- <br />
208
- <code className="rounded-xs bg-accent px-1 py-0.5 font-mono wrap-anywhere">
209
- {option.disabledCommand}
210
- </code>
211
- </>
212
- )}
213
- </span>
214
- </TooltipContent>
215
- </Tooltip>
216
- )
217
- }
218
-
219
- type WorkspaceAgentIconProps = {
220
- type: WorkspaceType
221
- }
222
-
223
- function WorkspaceAgentIcon({ type }: WorkspaceAgentIconProps) {
224
- return <img src={workspaceProviderIcon[type]} alt="" className="size-8 shrink-0" />
225
- }
@@ -1,3 +1,4 @@
1
+ import { receiveWorkspaceHarness } from './harness-transition'
1
2
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
2
3
 
3
4
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
@@ -6,20 +7,16 @@ import { workspaceKeys } from '@/client/api/workspace-keys'
6
7
  import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
7
8
  import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
8
9
  import type {
9
- WorkspaceAgent,
10
- WorkspaceLayout,
10
+ WorkspaceHarness,
11
+ WorkspaceEntry,
12
+ WorkspaceLayoutResponse,
11
13
  WorkspaceLayoutSave,
12
14
  WorkspaceSkillsStatus,
13
15
  WorkspaceSkillsUpdateFailure,
14
16
  WorkspaceType
15
17
  } from '@/lib/types'
16
18
 
17
- export type WorkspaceLayoutResponse = WorkspaceLayout & {
18
- cwd: string
19
- name: string
20
- provider?: WorkspaceType
21
- agentId?: string
22
- }
19
+ export type { WorkspaceLayoutResponse } from '@/lib/types'
23
20
 
24
21
  export function useWorkspaceLayout(workspaceId: string) {
25
22
  return useQuery<WorkspaceLayoutResponse>({
@@ -29,49 +26,34 @@ export function useWorkspaceLayout(workspaceId: string) {
29
26
  })
30
27
  }
31
28
 
32
- // The workspace's agent backend in one snapshot: availability (runtime
33
- // presence + auth), the model catalog, and capabilities.
34
- // `harness:updated` events refresh availability;
35
- // focus refetches pick up model changes after a CLI update.
36
- export function useWorkspaceAgent(workspaceId: string) {
29
+ // Workspace models, capabilities, and readiness for credential overrides or gateways.
30
+ export function useWorkspaceHarness(workspaceId: string) {
37
31
  const queryClient = useQueryClient()
38
32
  useWorkspaceEvent(event => {
39
33
  if (event.type === 'harness:updated' && event.workspaceId === workspaceId) {
40
- queryClient.setQueryData<WorkspaceAgent>(workspaceKeys.agent(workspaceId), prev =>
34
+ void queryClient.cancelQueries({ queryKey: workspaceKeys.harness(workspaceId) })
35
+ queryClient.setQueryData<WorkspaceHarness>(workspaceKeys.harness(workspaceId), prev =>
41
36
  prev ? { ...prev, availability: event.availability } : prev
42
37
  )
43
38
  }
44
39
  // Env can swap credentials; the server dropped its cache — refetch.
45
40
  if (event.type === 'env:updated' && event.workspaceId === workspaceId) {
46
- queryClient.invalidateQueries({ queryKey: workspaceKeys.agent(workspaceId) })
41
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.harness(workspaceId) })
47
42
  }
48
43
  })
49
- return useQuery<WorkspaceAgent>({
50
- queryKey: workspaceKeys.agent(workspaceId),
44
+ return useQuery<WorkspaceHarness>({
45
+ queryKey: workspaceKeys.harness(workspaceId),
51
46
  queryFn: async ({ signal }) => {
52
- const key = workspaceKeys.agent(workspaceId)
53
- const previous = queryClient.getQueryData<WorkspaceAgent>(key)
54
- // `refresh=true` makes the server re-probe the CLI (three child
55
- // processes, seconds) instead of answering from its 30s cache. Only
56
- // worth it when the last snapshot was a failure: the user may have
57
- // signed in or installed the agent since, and that is also the only
58
- // state with a "check again" button. A working agent is reconfirmed
59
- // from the cache.
60
- const refresh = previous !== undefined && previous.availability.status !== 'available'
61
- const result = await requestJson<WorkspaceAgent>(
62
- `/api/workspaces/${workspaceId}/agent${refresh ? '?refresh=true' : ''}`,
47
+ const previous = queryClient.getQueryData<WorkspaceHarness>(
48
+ workspaceKeys.harness(workspaceId)
49
+ )
50
+ const refresh = previous?.hasAuthOverrides && previous.availability.status !== 'available'
51
+ return requestJson<WorkspaceHarness>(
52
+ `/api/workspaces/${workspaceId}/harness${refresh ? '?refresh=true' : ''}`,
63
53
  { signal }
64
54
  )
65
- // A live auth event received during this request is newer than its snapshot.
66
- const current = queryClient.getQueryData<WorkspaceAgent>(key)
67
- return current && current !== previous
68
- ? { ...result, availability: current.availability }
69
- : result
70
55
  },
71
56
  staleTime: 30_000,
72
- // Reconfirm cached failures on entry; a recent successful check can be reused.
73
- refetchOnMount: query =>
74
- query.state.data?.availability.status === 'available' ? true : 'always',
75
57
  refetchOnWindowFocus: true
76
58
  })
77
59
  }
@@ -140,3 +122,17 @@ export function useSaveLayout(workspaceId: string) {
140
122
  }
141
123
  })
142
124
  }
125
+
126
+ export function useChangeWorkspaceHarness(workspaceId: string) {
127
+ const queryClient = useQueryClient()
128
+ return useMutation({
129
+ mutationFn: (type: WorkspaceType) =>
130
+ requestJson<WorkspaceEntry>(
131
+ `/api/workspaces/${workspaceId}/harness`,
132
+ jsonRequest('PATCH', { type })
133
+ ),
134
+ onSuccess: entry => {
135
+ void receiveWorkspaceHarness(queryClient, workspaceId, entry.type ?? 'claude-code')
136
+ }
137
+ })
138
+ }
@@ -0,0 +1,88 @@
1
+ import { useEffect } from 'react'
2
+ import { matchQuery, useQueryClient, type QueryClient, type Query } from '@tanstack/react-query'
3
+ import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
4
+ import type { WorkspaceLayoutResponse, WorkspaceType } from '@/lib/types'
5
+ import { workspaceKeys } from '@/client/api/workspace-keys'
6
+ import { liveStore } from '@/client/features/chat/chat-store'
7
+ import { writeSelectedSession } from '@/client/features/chat/sessions/browser-tab-state'
8
+ import { browserTabSelectionKey } from '@/client/features/chat/sessions/use-selected-session'
9
+ import { changeWorkspaceStateCache } from './workspace-state'
10
+
11
+ export async function receiveWorkspaceHarness(
12
+ queryClient: QueryClient,
13
+ id: string,
14
+ harness: WorkspaceType
15
+ ) {
16
+ const cached = queryClient.getQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id))
17
+ let previous = cached ? (cached.provider ?? 'claude-code') : undefined
18
+ try {
19
+ const key = `moi:workspace-harness:${id}`
20
+ previous = (sessionStorage.getItem(key) as WorkspaceType | null) ?? previous
21
+ sessionStorage.setItem(key, harness)
22
+ } catch {
23
+ /* Cached layout still detects live changes when storage is unavailable. */
24
+ }
25
+ if (!previous || previous === harness) return
26
+
27
+ const keys = [
28
+ workspaceKeys.layout(id),
29
+ workspaceKeys.state(id),
30
+ workspaceKeys.sessions(id),
31
+ workspaceKeys.mcp(id),
32
+ workspaceKeys.skills(id),
33
+ workspaceKeys.views(id),
34
+ ['workspaces', 'events', id]
35
+ ]
36
+ const affected = {
37
+ predicate: (query: Query) => keys.some(queryKey => matchQuery({ queryKey }, query))
38
+ }
39
+ await queryClient.cancelQueries(affected)
40
+ // Discard the old provider snapshot before rendering the new harness status.
41
+ void queryClient.resetQueries({ queryKey: workspaceKeys.harness(id), exact: true })
42
+ queryClient.setQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id), previous =>
43
+ previous
44
+ ? {
45
+ ...previous,
46
+ provider: harness,
47
+ selectedModel: undefined,
48
+ selectedEffort: undefined,
49
+ selectedSpeedMode: undefined
50
+ }
51
+ : previous
52
+ )
53
+ writeSelectedSession(id, { selected: {} })
54
+ queryClient.setQueryData(browserTabSelectionKey(id), { selected: {} })
55
+ changeWorkspaceStateCache(queryClient, id, state => {
56
+ state.selected = {}
57
+ delete state.pinnedSessionId
58
+ })
59
+ const clean = <T>(entries: Record<string, T>) =>
60
+ Object.fromEntries(Object.entries(entries).filter(([key]) => !key.startsWith(`${id}:`)))
61
+ liveStore.setState(state => ({
62
+ activity: clean(state.activity),
63
+ errors: clean(state.errors),
64
+ previews: Object.fromEntries(
65
+ Object.entries(state.previews).filter(([, preview]) => preview.workspaceId !== id)
66
+ )
67
+ }))
68
+ queryClient.removeQueries({ queryKey: ['workspaces', 'events', id] })
69
+ await Promise.all([
70
+ queryClient.invalidateQueries(affected),
71
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true }),
72
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.previews })
73
+ ])
74
+ }
75
+
76
+ export function useWorkspaceHarnessChanges(id: string, harness: WorkspaceType | null) {
77
+ const queryClient = useQueryClient()
78
+ useEffect(() => {
79
+ if (harness) void receiveWorkspaceHarness(queryClient, id, harness)
80
+ }, [harness, id, queryClient])
81
+ useWorkspaceEvent(event => {
82
+ if (event.type === 'connection:opened') {
83
+ void queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
84
+ } else if (event.type === 'workspace-harness:switched' && event.workspaceId === id) {
85
+ void receiveWorkspaceHarness(queryClient, id, event.harness)
86
+ }
87
+ })
88
+ }
@@ -1,43 +1,10 @@
1
1
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
2
-
3
2
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
3
  import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
5
4
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
5
  import type { WorkspaceLayoutResponse } from '@/client/features/workspace/api'
7
6
  import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
8
- import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
9
- import type { AppSettings, WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
10
-
11
- // App-wide settings (server-side settings.json, GET/PATCH /api/settings) —
12
- // shared by every workspace, unlike the per-workspace queries below.
13
- export const appSettingsKey = ['app-settings'] as const
14
-
15
- export function useAppSettings() {
16
- const queryClient = useQueryClient()
17
- // Another client can change settings; the server broadcasts the new value
18
- // over the live-events socket so every open client stays in sync.
19
- useWorkspaceEvent(event => {
20
- if (event.type === 'settings:updated') {
21
- queryClient.setQueryData<AppSettings>(appSettingsKey, event.settings)
22
- }
23
- })
24
- return useQuery<AppSettings>({
25
- queryKey: appSettingsKey,
26
- queryFn: () => requestJson('/api/settings'),
27
- staleTime: 30_000
28
- })
29
- }
30
-
31
- export function useSaveAppSettings() {
32
- const queryClient = useQueryClient()
33
- return useMutation<AppSettings, Error, Partial<AppSettings>>({
34
- mutationFn: patch =>
35
- requestJson('/api/settings', jsonRequest('PATCH', patch), 'Failed to save settings'),
36
- onSuccess: next => {
37
- queryClient.setQueryData<AppSettings>(appSettingsKey, next)
38
- }
39
- })
40
- }
7
+ import type { WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
41
8
 
42
9
  export function useWorkspaceEnv(workspaceId: string) {
43
10
  return useQuery<WorkspaceEnvView>({
@@ -36,7 +36,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
36
36
  if (connectors.isError) {
37
37
  return (
38
38
  <ConnectorsState>
39
- <p className="text-sm text-muted-foreground">Could not load connectors.</p>
39
+ <p className="text-sm text-muted-foreground">Could not load connectors</p>
40
40
  <Button variant="outline" size="sm" onClick={() => connectors.refetch()}>
41
41
  Retry
42
42
  </Button>
@@ -48,7 +48,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
48
48
  return (
49
49
  <ConnectorsState>
50
50
  <IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
51
- <p className="text-sm text-foreground">No connectors configured.</p>
51
+ <p className="text-sm text-foreground">No connectors configured</p>
52
52
  </ConnectorsState>
53
53
  )
54
54
  }
@@ -81,7 +81,7 @@ export function ConnectorsSettings() {
81
81
  return (
82
82
  <SettingsPage
83
83
  title="Connectors"
84
- description="Connectors available to the agent in this workspace."
84
+ description="Connectors available to the agent in this workspace"
85
85
  >
86
86
  <ConnectorsContent connectors={connectors} />
87
87
  </SettingsPage>
@@ -57,7 +57,7 @@ export function EnvironmentSettings() {
57
57
  <IconLoader2 className="size-4 animate-spin" stroke={1.75} />
58
58
  </div>
59
59
  ) : variables.length === 0 ? (
60
- <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet.</p>
60
+ <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet</p>
61
61
  ) : (
62
62
  variables.map(variable => {
63
63
  const editable = variable.source !== 'dotenv'
@@ -132,8 +132,8 @@ export function EnvironmentSettings() {
132
132
  title="Inherit .env files"
133
133
  description={
134
134
  dotenvFiles > 0
135
- ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space.`
136
- : 'No .env files found in this space.'
135
+ ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space`
136
+ : 'No .env files found in this space'
137
137
  }
138
138
  control={
139
139
  <Switch
@@ -1,4 +1,4 @@
1
- import { IconLoader2 } from '@tabler/icons-react'
1
+ import { IconChevronDown, IconLoader2 } from '@tabler/icons-react'
2
2
  import { useLocation } from 'wouter'
3
3
 
4
4
  import { useAppConfig } from '@/client/api/app-config'
@@ -17,7 +17,18 @@ import { Button } from '@/client/components/ui/button'
17
17
  import { Input } from '@/client/components/ui/input'
18
18
  import { useRemoveWorkspace } from '@/client/features/home/api'
19
19
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
20
+ import { harnessIcon, harnessLabel } from '@/client/features/harness/harness-presentation'
21
+ import {
22
+ DropdownMenu,
23
+ DropdownMenuTrigger,
24
+ DropdownMenuContent,
25
+ DropdownMenuRadioGroup,
26
+ DropdownMenuRadioItem
27
+ } from '@/client/components/ui/dropdown-menu'
28
+ import { Tooltip, TooltipTrigger, TooltipContent } from '@/client/components/ui/tooltip'
29
+ import { useLive } from '@/client/features/chat/chat-store'
20
30
 
31
+ import { useChangeWorkspaceHarness } from '@/client/features/workspace/api'
21
32
  import { SettingsPage, SettingsRow, SettingsSection } from './settings-layout'
22
33
 
23
34
  export function GeneralSettings() {
@@ -32,7 +43,7 @@ export function GeneralSettings() {
32
43
  }
33
44
 
34
45
  return (
35
- <SettingsPage title="General" description="Basic details for this space.">
46
+ <SettingsPage title="General" description="Basic details for this space">
36
47
  <SettingsSection>
37
48
  <SettingsRow
38
49
  title="Path"
@@ -46,6 +57,7 @@ export function GeneralSettings() {
46
57
  />
47
58
  }
48
59
  />
60
+ <WorkspaceHarnessSetting />
49
61
  </SettingsSection>
50
62
 
51
63
  {!demo && (
@@ -56,7 +68,7 @@ export function GeneralSettings() {
56
68
  control={
57
69
  <AlertDialog>
58
70
  <AlertDialogTrigger
59
- render={<Button type="button" variant="destructive" size="sm" />}
71
+ render={<Button type="button" variant="destructive" />}
60
72
  disabled={removeWorkspace.isPending}
61
73
  >
62
74
  Remove
@@ -101,3 +113,65 @@ export function GeneralSettings() {
101
113
  </SettingsPage>
102
114
  )
103
115
  }
116
+
117
+ function WorkspaceHarnessSetting() {
118
+ const { demo } = useAppConfig()
119
+ const { workspaceId, provider } = useWorkspaceLayoutCtx()
120
+ const type = provider ?? 'claude-code'
121
+ const change = useChangeWorkspaceHarness(workspaceId)
122
+ const active = useLive(state =>
123
+ Object.entries(state.activity).some(
124
+ ([key, activity]) => key.startsWith(`${workspaceId}:`) && activity !== 'idle'
125
+ )
126
+ )
127
+ const reason = demo
128
+ ? 'Changing agents is unavailable in the demo'
129
+ : type === 'hermes' || type === 'openclaw'
130
+ ? 'This workspace belongs to its agent and cannot use another agent'
131
+ : active
132
+ ? 'Wait for the agent to finish before changing it'
133
+ : undefined
134
+ return (
135
+ <>
136
+ <SettingsRow
137
+ title="Agent"
138
+ control={
139
+ <Tooltip disabled={!reason}>
140
+ <TooltipTrigger render={<span tabIndex={reason ? 0 : undefined} aria-label={reason} />}>
141
+ <DropdownMenu>
142
+ <DropdownMenuTrigger
143
+ render={<Button variant="outline" />}
144
+ disabled={Boolean(reason) || change.isPending}
145
+ aria-label="Agent"
146
+ >
147
+ <img src={harnessIcon[type]} alt="" className="size-4 shrink-0" />
148
+ {harnessLabel[type]}
149
+ <IconChevronDown stroke={1.5} />
150
+ </DropdownMenuTrigger>
151
+ <DropdownMenuContent align="end" className="min-w-44">
152
+ <DropdownMenuRadioGroup
153
+ value={type}
154
+ onValueChange={value => change.mutate(value)}
155
+ >
156
+ {(['claude-code', 'codex'] as const).map(option => (
157
+ <DropdownMenuRadioItem key={option} value={option}>
158
+ <img src={harnessIcon[option]} alt="" className="size-4 shrink-0" />
159
+ {harnessLabel[option]}
160
+ </DropdownMenuRadioItem>
161
+ ))}
162
+ </DropdownMenuRadioGroup>
163
+ </DropdownMenuContent>
164
+ </DropdownMenu>
165
+ </TooltipTrigger>
166
+ <TooltipContent>{reason}</TooltipContent>
167
+ </Tooltip>
168
+ }
169
+ />
170
+ {change.error && (
171
+ <p role="alert" className="text-sm text-destructive">
172
+ {change.error.message}
173
+ </p>
174
+ )}
175
+ </>
176
+ )
177
+ }
@@ -1,7 +1,7 @@
1
1
  import { useQueryClient } from '@tanstack/react-query'
2
2
 
3
3
  import { workspaceKeys } from '@/client/api/workspace-keys'
4
- import { useUpdateEnv, useWorkspaceEnv } from '@/client/features/settings/api'
4
+ import { useUpdateEnv, useWorkspaceEnv } from '@/client/features/workspace/settings/api'
5
5
  import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
6
6
 
7
7
  // Workspace env state in one hook: the masked env view (query), the patch
@@ -11,9 +11,9 @@ import {
11
11
  import { Button } from '@/client/components/ui/button'
12
12
  import { Checkbox } from '@/client/components/ui/checkbox'
13
13
  import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/client/components/ui/tabs'
14
- import { useUpdateWorkspaceIcon } from '@/client/features/settings/api'
14
+ import { useUpdateWorkspaceIcon } from '@/client/features/workspace/settings/api'
15
15
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
16
- import { APP_ICON_CHOICES } from '@/client/lib/app-icon-registry'
16
+ import { IDENTITY_ICON_CHOICES } from '@/client/lib/identity-icon-registry'
17
17
  import { cn } from '@/client/lib/cn'
18
18
  import type { WorkspaceIcon } from '@/lib/types'
19
19
  import { EMOJI_FONT, FAVORITE_EMOJI } from './icon-picker-options'
@@ -241,7 +241,7 @@ export function WorkspaceIconPicker() {
241
241
  className="scrollbar-thin h-72 overflow-y-auto rounded-xl border border-border bg-background p-1.5"
242
242
  >
243
243
  <PickerItems>
244
- {APP_ICON_CHOICES.map(({ id, Icon }) => (
244
+ {IDENTITY_ICON_CHOICES.map(({ id, Icon }) => (
245
245
  <PickerItem
246
246
  key={id}
247
247
  aria-label={id}