moi-computer 0.12.1-next.3 → 0.13.0

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 (236) 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 +4 -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 +1 -1
  11. package/client/app/routes/workspace-route.tsx +21 -19
  12. package/client/components/shared/screen-shell.tsx +23 -0
  13. package/client/components/shared/ultrafast-icon.tsx +61 -0
  14. package/client/components/shared/workspace-icon.tsx +2 -2
  15. package/client/features/account/account-test-utils.tsx +4 -3
  16. package/client/features/app-settings/api.ts +33 -0
  17. package/client/features/app-settings/general-settings.tsx +39 -0
  18. package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
  19. package/client/features/chat/applet-chat-intents.ts +4 -20
  20. package/client/features/chat/chat-send.ts +17 -13
  21. package/client/features/chat/composer/model-order.ts +8 -4
  22. package/client/features/chat/composer/model-picker.tsx +88 -34
  23. package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
  24. package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
  25. package/client/features/chat/connection/chat-frames.ts +3 -15
  26. package/client/features/chat/messages/chat-empty-state.tsx +1 -4
  27. package/client/features/chat/messages/fork-history.ts +5 -5
  28. package/client/features/chat/messages/tool-group/subagent-card.tsx +1 -0
  29. package/client/features/chat/messages/turn-view.tsx +3 -12
  30. package/client/features/chat/messages/user-message-bubble.tsx +63 -0
  31. package/client/features/chat/sessions/api.ts +121 -80
  32. package/client/features/chat/sessions/browser-tab-state.ts +14 -12
  33. package/client/features/chat/sessions/chat-selector.tsx +5 -6
  34. package/client/features/chat/sessions/use-selected-session.ts +172 -257
  35. package/client/features/chat/use-chat.ts +14 -19
  36. package/client/features/collab/components/user-avatar.tsx +4 -10
  37. package/client/features/collab/workspace-users-menu.tsx +1 -1
  38. package/client/features/connectors/api.ts +12 -4
  39. package/client/features/connectors/mcp-server-cards.tsx +17 -7
  40. package/client/features/connectors/read-connectors.ts +35 -0
  41. package/client/features/demo/demo-dialog.tsx +11 -3
  42. package/client/features/dev/collab/local-user-settings.tsx +1 -1
  43. package/client/features/dev/dev-index-page.tsx +5 -0
  44. package/client/features/dev/dev-routes.tsx +2 -0
  45. package/client/features/dev/harness-debug-page.tsx +3 -3
  46. package/client/features/dev/onboarding-preview-page.tsx +76 -0
  47. package/client/features/dev/workspace-setup-mocks.ts +16 -14
  48. package/client/features/dev/workspace-setup-preview.tsx +11 -17
  49. package/client/features/harness/api.ts +45 -15
  50. package/client/features/harness/device-login-steps.tsx +9 -3
  51. package/client/features/harness/harness-login-panel.tsx +228 -0
  52. package/client/features/harness/harness-presentation.ts +15 -0
  53. package/client/features/harness/harness-selector.tsx +119 -0
  54. package/client/features/harness/use-harness-login.ts +77 -0
  55. package/client/features/home/home-page.tsx +7 -7
  56. package/client/features/onboarding/agent-setup-step.tsx +57 -0
  57. package/client/features/onboarding/api.ts +42 -0
  58. package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
  59. package/client/features/onboarding/onboarding-page.tsx +32 -0
  60. package/client/features/onboarding/onboarding-screen.tsx +20 -0
  61. package/client/features/onboarding/onboarding-status.tsx +24 -0
  62. package/client/features/onboarding/workspace-setup-step.tsx +239 -0
  63. package/client/features/overview/default/registry.tsx +2 -2
  64. package/client/features/overview/default/views-widget.tsx +6 -5
  65. package/client/features/overview/overview.tsx +9 -11
  66. package/client/features/overview/widget-canvas.tsx +1 -1
  67. package/client/features/overview/workspace-name.tsx +2 -2
  68. package/client/features/views/api.ts +69 -16
  69. package/client/features/views/pending-view-screen.tsx +30 -9
  70. package/client/features/views/use-view-actions.ts +19 -20
  71. package/client/features/views/view-presentation.ts +2 -2
  72. package/client/features/views/view-submission.ts +28 -41
  73. package/client/features/workspace/add/api.ts +3 -23
  74. package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
  75. package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
  76. package/client/features/workspace/add/workspace-agent-options.ts +11 -12
  77. package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
  78. package/client/features/workspace/api.ts +32 -36
  79. package/client/features/workspace/harness-transition.ts +89 -0
  80. package/client/features/{settings → workspace/settings}/api.ts +1 -34
  81. package/client/features/{settings → workspace/settings}/connectors-settings.tsx +31 -10
  82. package/client/features/workspace/settings/general-settings.tsx +180 -0
  83. package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
  84. package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
  85. package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
  86. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
  87. package/client/features/workspace/setup/workspace-setup.tsx +34 -14
  88. package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
  89. package/client/features/workspace/use-workspace-navigation.ts +25 -9
  90. package/client/features/workspace/workspace-content.tsx +11 -8
  91. package/client/features/workspace/workspace-frame.tsx +2 -1
  92. package/client/features/workspace/workspace-layout-context.tsx +5 -2
  93. package/client/features/workspace/workspace-menu.tsx +12 -8
  94. package/client/features/workspace/workspace-pending-screen.tsx +10 -10
  95. package/client/features/workspace/workspace-presentation.tsx +5 -13
  96. package/client/features/workspace/workspace-state.ts +169 -0
  97. package/client/features/workspace/workspace-tabs.tsx +22 -2
  98. package/client/index.css +2 -0
  99. package/client/index.tsx +3 -3
  100. package/client/lib/flags.ts +1 -1
  101. package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
  102. package/client/runtime/workspace-events.ts +21 -4
  103. package/client/runtime/workspace-theme.ts +9 -0
  104. package/client/tailwind-config.ts +43 -0
  105. package/dist/chunk-2y59vrxg.js +5 -0
  106. package/dist/chunk-58dyt9bk.js +2 -0
  107. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  108. package/dist/chunk-bncc7heg.js +1 -0
  109. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  110. package/dist/chunk-cqt3s31j.js +546 -0
  111. package/dist/chunk-dcmks9sm.js +75 -0
  112. package/dist/chunk-md45evr2.css +1 -0
  113. package/dist/chunk-n0nab26d.js +1 -0
  114. package/dist/chunk-nf2wkvf9.js +14 -0
  115. package/dist/chunk-nmzhgyp9.js +2 -0
  116. package/dist/chunk-q37knr3m.js +2 -0
  117. package/dist/chunk-s90m4qkz.js +1 -0
  118. package/dist/chunk-wjvd4byz.js +2 -0
  119. package/dist/index.html +1 -1
  120. package/lib/harness-instructions.ts +1 -1
  121. package/lib/{app-icons.ts → identity-icons.ts} +6 -7
  122. package/lib/onboarding.ts +41 -0
  123. package/lib/speed-mode.ts +5 -0
  124. package/lib/types.ts +75 -64
  125. package/lib/view-build-directives.ts +1 -2
  126. package/lib/workspace-icon.ts +2 -2
  127. package/lib/workspace-layout.ts +1 -1
  128. package/lib/workspace-name.ts +15 -12
  129. package/package.json +11 -8
  130. package/server/README.md +27 -25
  131. package/server/api/harnesses.ts +31 -8
  132. package/server/api/index.ts +189 -127
  133. package/server/api/onboarding.ts +46 -0
  134. package/server/app-config.ts +16 -24
  135. package/server/app-settings.ts +6 -2
  136. package/server/applets/config.ts +5 -5
  137. package/server/applets/views.ts +19 -17
  138. package/server/cli/commands/init.ts +3 -3
  139. package/server/cli/commands/skill.ts +16 -17
  140. package/server/cli/commands/start.ts +8 -34
  141. package/server/cli/server.ts +18 -6
  142. package/server/collab/config.ts +1 -2
  143. package/server/collab/manager.ts +4 -1
  144. package/server/collab/skill/index.ts +1 -1
  145. package/server/control.ts +3 -3
  146. package/server/data-dir.ts +1 -1
  147. package/server/harness/README.md +24 -8
  148. package/server/harness/acp/session.ts +8 -4
  149. package/server/harness/auth.ts +14 -17
  150. package/server/harness/claude-code/NOTES.md +4 -3
  151. package/server/harness/claude-code/index.ts +5 -6
  152. package/server/harness/claude-code/mcp.ts +17 -0
  153. package/server/harness/claude-code/models.ts +2 -20
  154. package/server/harness/claude-code/run-action.ts +123 -0
  155. package/server/harness/claude-code/session-title.ts +5 -7
  156. package/server/harness/claude-code/session.ts +24 -16
  157. package/server/harness/codex/NOTES.md +22 -10
  158. package/server/harness/codex/adapter.ts +14 -17
  159. package/server/harness/codex/client.ts +8 -5
  160. package/server/harness/codex/connectors.ts +92 -0
  161. package/server/harness/codex/index.ts +4 -1
  162. package/server/harness/codex/pagination.ts +8 -5
  163. package/server/harness/codex/run-action.ts +93 -0
  164. package/server/harness/codex/session-title.ts +6 -8
  165. package/server/harness/codex/session.ts +11 -11
  166. package/server/harness/codex/transport.ts +13 -6
  167. package/server/harness/command.ts +45 -0
  168. package/server/harness/executable.ts +5 -0
  169. package/server/harness/fork.ts +6 -4
  170. package/server/harness/install.ts +49 -0
  171. package/server/harness/openclaw/session.ts +1 -2
  172. package/server/harness/run-action.ts +85 -0
  173. package/server/harness/session-title.ts +0 -46
  174. package/server/harness/types.ts +30 -3
  175. package/server/onboarding/brief.ts +29 -0
  176. package/server/onboarding/ideas.ts +48 -0
  177. package/server/onboarding/jobs.ts +291 -0
  178. package/server/onboarding/prompt.md +49 -0
  179. package/server/sessions/archive.ts +5 -14
  180. package/server/sessions/config.ts +17 -16
  181. package/server/sessions/lifecycle.ts +15 -13
  182. package/server/sessions/pending-views.ts +79 -108
  183. package/server/sessions/selected.ts +75 -161
  184. package/server/sessions/store.ts +40 -113
  185. package/server/sessions/view-sessions.ts +128 -111
  186. package/server/skills/locations.ts +82 -0
  187. package/server/skills/lock.ts +29 -0
  188. package/server/skills/template.ts +36 -25
  189. package/server/skills/update.ts +52 -5
  190. package/server/skills/version.ts +17 -22
  191. package/server/skills/workspace.ts +121 -0
  192. package/server/web.ts +22 -8
  193. package/server/workspace-state/file.ts +177 -0
  194. package/server/workspace-state/index.ts +162 -0
  195. package/server/workspace-state/legacy-migration.ts +79 -0
  196. package/server/workspace-state/lock.ts +42 -0
  197. package/server/workspace-state/types.ts +16 -0
  198. package/server/workspaces/change-harness.ts +88 -0
  199. package/server/workspaces/harness-transition.ts +29 -0
  200. package/server/workspaces/init.ts +29 -6
  201. package/server/workspaces/layout.ts +3 -0
  202. package/server/workspaces/registry.ts +27 -1
  203. package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
  204. package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
  205. package/skill/references/DESIGN.md +167 -0
  206. package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
  207. package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
  208. package/ui-components/badge.tsx +1 -1
  209. package/client/accept-hmr-dependencies.ts +0 -22
  210. package/client/features/settings/general-settings.tsx +0 -103
  211. package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
  212. package/dist/chunk-20ynagd4.js +0 -2
  213. package/dist/chunk-42tde9a6.js +0 -1
  214. package/dist/chunk-9w543s0r.js +0 -2
  215. package/dist/chunk-a5372n61.js +0 -546
  216. package/dist/chunk-aja9y1vn.js +0 -68
  217. package/dist/chunk-fvcvrh3d.css +0 -1
  218. package/dist/chunk-gtfjw3nx.js +0 -1
  219. package/dist/chunk-j39y2aky.js +0 -14
  220. package/dist/chunk-pcnahct1.js +0 -5
  221. package/dist/chunk-pja30km3.js +0 -1
  222. package/dist/chunk-rm894bc2.js +0 -2
  223. package/dist/chunk-tevvtfbk.js +0 -10
  224. package/dist/chunk-tgt9zd0r.js +0 -2
  225. package/dist/chunk-tv5k5z00.js +0 -1
  226. package/dist/chunk-zq2ae5dx.js +0 -2
  227. package/lib/experimental.ts +0 -14
  228. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
  229. /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
  230. /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
  231. /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
  232. /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
  233. /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
  234. /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
  235. /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
  236. /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,89 @@
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
+ void queryClient.resetQueries({ queryKey: workspaceKeys.mcp(id), exact: true })
43
+ queryClient.setQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id), previous =>
44
+ previous
45
+ ? {
46
+ ...previous,
47
+ provider: harness,
48
+ selectedModel: undefined,
49
+ selectedEffort: undefined,
50
+ selectedSpeedMode: undefined
51
+ }
52
+ : previous
53
+ )
54
+ writeSelectedSession(id, { selected: {} })
55
+ queryClient.setQueryData(browserTabSelectionKey(id), { selected: {} })
56
+ changeWorkspaceStateCache(queryClient, id, state => {
57
+ state.selected = {}
58
+ delete state.pinnedSessionId
59
+ })
60
+ const clean = <T>(entries: Record<string, T>) =>
61
+ Object.fromEntries(Object.entries(entries).filter(([key]) => !key.startsWith(`${id}:`)))
62
+ liveStore.setState(state => ({
63
+ activity: clean(state.activity),
64
+ errors: clean(state.errors),
65
+ previews: Object.fromEntries(
66
+ Object.entries(state.previews).filter(([, preview]) => preview.workspaceId !== id)
67
+ )
68
+ }))
69
+ queryClient.removeQueries({ queryKey: ['workspaces', 'events', id] })
70
+ await Promise.all([
71
+ queryClient.invalidateQueries(affected),
72
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true }),
73
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.previews })
74
+ ])
75
+ }
76
+
77
+ export function useWorkspaceHarnessChanges(id: string, harness: WorkspaceType | null) {
78
+ const queryClient = useQueryClient()
79
+ useEffect(() => {
80
+ if (harness) void receiveWorkspaceHarness(queryClient, id, harness)
81
+ }, [harness, id, queryClient])
82
+ useWorkspaceEvent(event => {
83
+ if (event.type === 'connection:opened') {
84
+ void queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
85
+ } else if (event.type === 'workspace-harness:switched' && event.workspaceId === id) {
86
+ void receiveWorkspaceHarness(queryClient, id, event.harness)
87
+ }
88
+ })
89
+ }
@@ -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>({
@@ -33,7 +33,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
33
33
  )
34
34
  }
35
35
 
36
- if (connectors.isError) {
36
+ if (connectors.isError && !connectors.data?.length) {
37
37
  return (
38
38
  <ConnectorsState>
39
39
  <p className="text-sm text-muted-foreground">Could not load connectors</p>
@@ -44,7 +44,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
44
44
  )
45
45
  }
46
46
 
47
- if (connectors.data.length === 0) {
47
+ if (connectors.data.length === 0 && !connectors.isFetching) {
48
48
  return (
49
49
  <ConnectorsState>
50
50
  <IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
@@ -54,11 +54,26 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
54
54
  }
55
55
 
56
56
  return (
57
- <McpServerGrid>
58
- {sortMcpServers(connectors.data).map(connector => (
59
- <McpServerCard key={connector.name} server={connector} />
60
- ))}
61
- </McpServerGrid>
57
+ <>
58
+ <McpServerGrid>
59
+ {sortMcpServers(connectors.data).map(connector => (
60
+ <McpServerCard key={connector.name} server={connector} />
61
+ ))}
62
+ </McpServerGrid>
63
+ {connectors.isFetching && (
64
+ <p role="status" className="text-sm text-muted-foreground">
65
+ Loading connectors…
66
+ </p>
67
+ )}
68
+ {connectors.isError && (
69
+ <ConnectorsState>
70
+ <p className="text-sm text-muted-foreground">Couldn’t load all connectors</p>
71
+ <Button variant="outline" size="sm" onClick={() => connectors.refetch()}>
72
+ Retry
73
+ </Button>
74
+ </ConnectorsState>
75
+ )}
76
+ </>
62
77
  )
63
78
  }
64
79
 
@@ -68,20 +83,26 @@ type ConnectorsStateProps = {
68
83
 
69
84
  function ConnectorsState({ children }: ConnectorsStateProps) {
70
85
  return (
71
- <div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
86
+ <div className="flex min-h-48 flex-col items-center justify-center gap-3 px-8 py-12 text-center">
72
87
  {children}
73
88
  </div>
74
89
  )
75
90
  }
76
91
 
77
92
  export function ConnectorsSettings() {
78
- const { workspaceId } = useWorkspaceLayoutCtx()
93
+ const { workspaceId, provider } = useWorkspaceLayoutCtx()
79
94
  const connectors = useWorkspaceMcp(workspaceId, true)
80
95
 
81
96
  return (
82
97
  <SettingsPage
83
98
  title="Connectors"
84
- description="Connectors available to the agent in this workspace"
99
+ description={
100
+ provider === 'codex'
101
+ ? 'Manage your connectors in the ChatGPT app'
102
+ : provider === 'claude-code'
103
+ ? 'Manage your connectors in the Claude app'
104
+ : 'Manage your connectors in your agent’s settings'
105
+ }
85
106
  >
86
107
  <ConnectorsContent connectors={connectors} />
87
108
  </SettingsPage>
@@ -0,0 +1,180 @@
1
+ import { IconChevronDown, IconLoader2 } from '@tabler/icons-react'
2
+ import { useLocation } from 'wouter'
3
+
4
+ import { useAppConfig } from '@/client/api/app-config'
5
+ import {
6
+ AlertDialog,
7
+ AlertDialogAction,
8
+ AlertDialogCancel,
9
+ AlertDialogContent,
10
+ AlertDialogDescription,
11
+ AlertDialogFooter,
12
+ AlertDialogHeader,
13
+ AlertDialogTitle,
14
+ AlertDialogTrigger
15
+ } from '@/client/components/ui/alert-dialog'
16
+ import { Button } from '@/client/components/ui/button'
17
+ import { Input } from '@/client/components/ui/input'
18
+ import { useRemoveWorkspace } from '@/client/features/home/api'
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'
30
+
31
+ import { useChangeWorkspaceHarness } from '@/client/features/workspace/api'
32
+ import { SettingsPage, SettingsRow, SettingsSection } from './settings-layout'
33
+
34
+ export function GeneralSettings() {
35
+ const { demo, environment } = useAppConfig()
36
+ const { name, cwd, workspaceId } = useWorkspaceLayoutCtx()
37
+ const [, navigate] = useLocation()
38
+ const removeWorkspace = useRemoveWorkspace()
39
+ const label = name ?? cwd ?? 'this space'
40
+
41
+ const remove = () => {
42
+ removeWorkspace.mutate(workspaceId, { onSuccess: () => navigate('/') })
43
+ }
44
+
45
+ return (
46
+ <SettingsPage title="General" description="Basic details for this space">
47
+ <SettingsSection>
48
+ {environment === 'local' && (
49
+ <SettingsRow
50
+ title="Path"
51
+ control={
52
+ <Input
53
+ value={cwd ?? ''}
54
+ aria-label="Workspace path"
55
+ title={cwd ?? undefined}
56
+ className="w-56"
57
+ readOnly
58
+ />
59
+ }
60
+ />
61
+ )}
62
+ <WorkspaceHarnessSetting />
63
+ </SettingsSection>
64
+
65
+ {!demo && (
66
+ <SettingsSection label="Danger zone">
67
+ <SettingsRow
68
+ title="Remove space"
69
+ description="Removes this space from Moi, its folder and chats stay on disk"
70
+ control={
71
+ <AlertDialog>
72
+ <AlertDialogTrigger
73
+ render={<Button type="button" variant="destructive" />}
74
+ disabled={removeWorkspace.isPending}
75
+ >
76
+ Remove
77
+ </AlertDialogTrigger>
78
+ <AlertDialogContent>
79
+ <AlertDialogHeader>
80
+ <AlertDialogTitle>Remove “{label}” from your workspaces?</AlertDialogTitle>
81
+ <AlertDialogDescription>
82
+ This only removes it from your list. The folder and its sessions stay on disk.
83
+ You can add it back any time.
84
+ </AlertDialogDescription>
85
+ </AlertDialogHeader>
86
+ {removeWorkspace.isError && (
87
+ <p className="text-xs text-destructive">{removeWorkspace.error.message}</p>
88
+ )}
89
+ <AlertDialogFooter>
90
+ <AlertDialogCancel disabled={removeWorkspace.isPending}>
91
+ Cancel
92
+ </AlertDialogCancel>
93
+ <AlertDialogAction
94
+ type="button"
95
+ variant="destructive"
96
+ onClick={remove}
97
+ disabled={removeWorkspace.isPending}
98
+ >
99
+ {removeWorkspace.isPending && (
100
+ <IconLoader2
101
+ data-icon="inline-start"
102
+ stroke={1.75}
103
+ className="animate-spin"
104
+ />
105
+ )}
106
+ Remove
107
+ </AlertDialogAction>
108
+ </AlertDialogFooter>
109
+ </AlertDialogContent>
110
+ </AlertDialog>
111
+ }
112
+ />
113
+ </SettingsSection>
114
+ )}
115
+ </SettingsPage>
116
+ )
117
+ }
118
+
119
+ function WorkspaceHarnessSetting() {
120
+ const { demo } = useAppConfig()
121
+ const { workspaceId, provider } = useWorkspaceLayoutCtx()
122
+ const type = provider ?? 'claude-code'
123
+ const change = useChangeWorkspaceHarness(workspaceId)
124
+ const active = useLive(state =>
125
+ Object.entries(state.activity).some(
126
+ ([key, activity]) => key.startsWith(`${workspaceId}:`) && activity !== 'idle'
127
+ )
128
+ )
129
+ const reason = demo
130
+ ? 'Changing agents is unavailable in the demo'
131
+ : type === 'hermes' || type === 'openclaw'
132
+ ? 'This workspace belongs to its agent and cannot use another agent'
133
+ : active
134
+ ? 'Wait for the agent to finish before changing it'
135
+ : undefined
136
+ return (
137
+ <>
138
+ <SettingsRow
139
+ title="Agent"
140
+ description="Changing the agent changes which chats you see in this space"
141
+ control={
142
+ <Tooltip disabled={!reason}>
143
+ <TooltipTrigger render={<span tabIndex={reason ? 0 : undefined} aria-label={reason} />}>
144
+ <DropdownMenu>
145
+ <DropdownMenuTrigger
146
+ render={<Button variant="outline" />}
147
+ disabled={Boolean(reason) || change.isPending}
148
+ aria-label="Agent"
149
+ >
150
+ <img src={harnessIcon[type]} alt="" className="size-4 shrink-0" />
151
+ {harnessLabel[type]}
152
+ <IconChevronDown stroke={1.5} />
153
+ </DropdownMenuTrigger>
154
+ <DropdownMenuContent align="end" className="min-w-44">
155
+ <DropdownMenuRadioGroup
156
+ value={type}
157
+ onValueChange={value => change.mutate(value)}
158
+ >
159
+ {(['claude-code', 'codex'] as const).map(option => (
160
+ <DropdownMenuRadioItem key={option} value={option}>
161
+ <img src={harnessIcon[option]} alt="" className="size-4 shrink-0" />
162
+ {harnessLabel[option]}
163
+ </DropdownMenuRadioItem>
164
+ ))}
165
+ </DropdownMenuRadioGroup>
166
+ </DropdownMenuContent>
167
+ </DropdownMenu>
168
+ </TooltipTrigger>
169
+ <TooltipContent>{reason}</TooltipContent>
170
+ </Tooltip>
171
+ }
172
+ />
173
+ {change.error && (
174
+ <p role="alert" className="text-sm text-destructive">
175
+ {change.error.message}
176
+ </p>
177
+ )}
178
+ </>
179
+ )
180
+ }