moi-computer 0.3.1-next.0 → 0.4.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 (99) hide show
  1. package/README.md +49 -12
  2. package/client/api/workspace-keys.ts +2 -2
  3. package/client/app/AppRouter.tsx +0 -2
  4. package/client/app/shell/SidebarLayout.tsx +3 -16
  5. package/client/assets/openai.svg +1 -3
  6. package/client/components/shared/Composer.tsx +53 -2
  7. package/client/components/ui/button.tsx +1 -1
  8. package/client/components/ui/tooltip.tsx +12 -15
  9. package/client/features/chat/ChatComposer.tsx +25 -15
  10. package/client/features/chat/ChatPanel.tsx +5 -2
  11. package/client/features/chat/MarkdownContent.tsx +20 -2
  12. package/client/features/chat/ModelPicker.tsx +5 -3
  13. package/client/features/chat/TurnView.tsx +2 -2
  14. package/client/features/chat/chat-frames.ts +13 -6
  15. package/client/features/chat/chat-send.ts +1 -1
  16. package/client/features/chat/chat-store.ts +22 -17
  17. package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
  18. package/client/features/chat/tool-group/format.ts +22 -7
  19. package/client/features/chat/useChat.ts +11 -2
  20. package/client/features/connectors/McpServerCards.tsx +95 -0
  21. package/client/features/connectors/api.ts +0 -11
  22. package/client/features/dev/HarnessDebugPage.tsx +210 -74
  23. package/client/features/home/HomePage.tsx +33 -28
  24. package/client/features/home/api.ts +24 -12
  25. package/client/features/home/workspace-presentation.tsx +17 -15
  26. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
  27. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
  28. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
  29. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
  30. package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
  31. package/client/features/settings/ConnectorsSettings.tsx +89 -0
  32. package/client/features/settings/SettingsLayout.tsx +2 -2
  33. package/client/features/settings/WorkspaceSettings.tsx +8 -4
  34. package/client/features/views/ViewBuilderTab.tsx +19 -15
  35. package/client/features/views/useViewBuilderActions.ts +1 -1
  36. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
  37. package/client/features/workspace/WorkspaceScreen.tsx +11 -3
  38. package/client/features/workspace/api.ts +19 -1
  39. package/client/features/workspace/moi-context.ts +85 -0
  40. package/client/main.tsx +16 -5
  41. package/dist/chunk-19g80zc9.css +1 -0
  42. package/dist/{chunk-jen6xcm1.js → chunk-2vaafjp4.js} +1 -1
  43. package/dist/{chunk-vkvb3hjm.js → chunk-35fq49qa.js} +1 -1
  44. package/dist/chunk-69nhbjhy.js +50 -0
  45. package/dist/{chunk-axszxe4c.js → chunk-72atbmh3.js} +1 -1
  46. package/dist/{chunk-zpxrb1ce.js → chunk-7mkv2gr0.js} +2 -2
  47. package/dist/{chunk-cs8vbert.js → chunk-fh2mf6v9.js} +3 -3
  48. package/dist/chunk-gt7n06ef.js +1 -0
  49. package/dist/chunk-jwmc32rp.js +63 -0
  50. package/dist/chunk-kh24bstm.js +10 -0
  51. package/dist/chunk-sfa4mbmx.js +15 -0
  52. package/dist/index.html +1 -1
  53. package/dist/openai-ep9ht2pq.svg +1 -0
  54. package/lib/ids.ts +15 -0
  55. package/lib/moi-context.ts +170 -0
  56. package/lib/types.ts +29 -11
  57. package/lib/view-builder-directives.ts +16 -0
  58. package/lib/workspace-types.ts +12 -0
  59. package/package.json +2 -1
  60. package/server/api.ts +92 -30
  61. package/server/harness/README.md +25 -9
  62. package/server/harness/claude-code/NOTES.md +20 -6
  63. package/server/harness/claude-code/adapter.ts +2 -2
  64. package/server/harness/claude-code/git-worktree.ts +32 -0
  65. package/server/harness/claude-code/index.ts +33 -12
  66. package/server/harness/claude-code/mcp.ts +16 -65
  67. package/server/harness/claude-code/models.ts +3 -0
  68. package/server/harness/claude-code/session.ts +196 -61
  69. package/server/harness/codex/NOTES.md +41 -11
  70. package/server/harness/codex/adapter.ts +121 -16
  71. package/server/harness/codex/client.ts +67 -18
  72. package/server/harness/codex/discovery.ts +114 -0
  73. package/server/harness/codex/index.ts +10 -5
  74. package/server/harness/codex/probe.ts +4 -2
  75. package/server/harness/codex/session.ts +89 -13
  76. package/server/harness/executable.ts +82 -0
  77. package/server/harness/openclaw/adapter.ts +8 -1
  78. package/server/harness/openclaw/index.ts +8 -14
  79. package/server/harness/openclaw/session.ts +50 -10
  80. package/server/harness/openclaw/strip.ts +2 -2
  81. package/server/harness/shell-path.ts +79 -0
  82. package/server/harness/types.ts +22 -5
  83. package/server/registry.ts +57 -12
  84. package/server/view-builders.ts +3 -2
  85. package/server/web.ts +24 -8
  86. package/server/workspace-import.ts +45 -0
  87. package/workspace/.claude/skills/moi-workspace/SKILL.md +3 -3
  88. package/client/features/connectors/ConnectorsPage.tsx +0 -92
  89. package/client/features/connectors/McpMenu.tsx +0 -145
  90. package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
  91. package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
  92. package/dist/chunk-4vf1t6v1.js +0 -10
  93. package/dist/chunk-6c8cwpzc.js +0 -1
  94. package/dist/chunk-b3ynfk4g.js +0 -62
  95. package/dist/chunk-b4b276wx.js +0 -15
  96. package/dist/chunk-kxmvv1ax.js +0 -48
  97. package/dist/chunk-npwq6jmr.css +0 -1
  98. package/dist/openai-h13pza4b.svg +0 -3
  99. package/lib/view-builder-meta.ts +0 -35
@@ -1,5 +1,8 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
2
 
3
+ import { IconCheck, IconCopy } from '@tabler/icons-react'
4
+ import { useSearchParams } from 'wouter'
5
+
3
6
  import { Button } from '@/client/components/ui/button'
4
7
  import { cn } from '@/client/lib/cn'
5
8
  import { wsUrl } from '@/client/lib/ws-url'
@@ -110,28 +113,54 @@ function LogRow({ time, badge, badgeClass, label, body }: LogRowProps) {
110
113
  }
111
114
 
112
115
  type PaneProps = {
113
- title: string
116
+ title: React.ReactNode
114
117
  hint?: string
118
+ // Extra header widgets (e.g. a filter input), rendered before the follow toggle.
119
+ controls?: React.ReactNode
120
+ onCopy?: () => void
115
121
  onClear?: () => void
116
122
  children: React.ReactNode
117
123
  }
118
124
 
119
- function Pane({ title, hint, onClear, children }: PaneProps) {
125
+ function Pane({ title, hint, controls, onCopy, onClear, children }: PaneProps) {
120
126
  const scroller = useRef<HTMLDivElement>(null)
121
127
  const [follow, setFollow] = useState(true)
128
+ const [copied, setCopied] = useState(false)
129
+ const handleCopy = useCallback(() => {
130
+ onCopy?.()
131
+ setCopied(true)
132
+ setTimeout(() => setCopied(false), 1500)
133
+ }, [onCopy])
122
134
  useEffect(() => {
123
135
  if (follow && scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight
124
136
  })
125
137
  return (
126
- <div className="flex min-h-0 flex-1 flex-col rounded-lg border border-border bg-background">
138
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col rounded-lg border border-border bg-background">
127
139
  <div className="flex items-center gap-2 border-b border-border px-2 py-1">
128
- <span className="text-xs font-semibold">{title}</span>
140
+ {typeof title === 'string' ? <span className="text-xs font-semibold">{title}</span> : title}
129
141
  {hint && <span className="truncate text-[10px] text-muted-foreground">{hint}</span>}
130
142
  <span className="grow" />
143
+ {controls}
131
144
  <label className="flex items-center gap-1 text-[10px] text-muted-foreground">
132
145
  <input type="checkbox" checked={follow} onChange={e => setFollow(e.target.checked)} />
133
146
  follow
134
147
  </label>
148
+ {onCopy && (
149
+ <Button
150
+ type="button"
151
+ variant="ghost"
152
+ size="icon-sm"
153
+ onClick={handleCopy}
154
+ aria-label="Copy log"
155
+ title="Copy log"
156
+ >
157
+ {copied ? (
158
+ <IconCheck stroke={1.75} className="text-muted-foreground" />
159
+ ) : (
160
+ <IconCopy stroke={1.75} />
161
+ )}
162
+ </Button>
163
+ )}
135
164
  {onClear && (
136
165
  <Button type="button" variant="ghost" size="sm" onClick={onClear}>
137
166
  Clear
@@ -146,8 +175,10 @@ function Pane({ title, hint, onClear, children }: PaneProps) {
146
175
  }
147
176
 
148
177
  export function HarnessDebugPage() {
178
+ const [searchParams, setSearchParams] = useSearchParams()
149
179
  const [workspaces, setWorkspaces] = useState<WorkspaceEntry[]>([])
150
- const [workspaceId, setWorkspaceId] = useState('')
180
+ // Seeded from ?workspace= so the selection survives reloads / can be shared.
181
+ const [workspaceId, setWorkspaceId] = useState(() => searchParams.get('workspace') ?? '')
151
182
  const [models, setModels] = useState<Model[]>([])
152
183
  const [model, setModel] = useState('')
153
184
  const [effort, setEffort] = useState('')
@@ -160,6 +191,12 @@ export function HarnessDebugPage() {
160
191
  const [clientFrames, setClientFrames] = useState<BroadcastFrame[]>([])
161
192
  const [events, setEvents] = useState<unknown[] | null>(null)
162
193
  const [hidePreviews, setHidePreviews] = useState(false)
194
+ const [rightTab, setRightTab] = useState<'frames' | 'events'>('frames')
195
+ // Split position of the wire pane, as % of the row. Wire frames are the
196
+ // denser log, so it gets more room by default; the handle between the panes
197
+ // drags it between 20% and 80%.
198
+ const [leftPct, setLeftPct] = useState(60)
199
+ const rowRef = useRef<HTMLDivElement>(null)
163
200
 
164
201
  const wireCursor = useRef(0)
165
202
  const wsRef = useRef<WebSocket | null>(null)
@@ -173,11 +210,26 @@ export function HarnessDebugPage() {
173
210
  .then(r => r.json())
174
211
  .then((list: WorkspaceEntry[]) => {
175
212
  setWorkspaces(list)
176
- setWorkspaceId(id => id || (list[0]?.id ?? ''))
213
+ // Keep the URL-seeded id only if it's a real workspace.
214
+ setWorkspaceId(id => (id && list.some(w => w.id === id) ? id : (list[0]?.id ?? '')))
177
215
  })
178
216
  .catch(() => {})
179
217
  }, [])
180
218
 
219
+ const selectWorkspace = useCallback(
220
+ (id: string) => {
221
+ setWorkspaceId(id)
222
+ setSearchParams(
223
+ prev => {
224
+ prev.set('workspace', id)
225
+ return prev
226
+ },
227
+ { replace: true }
228
+ )
229
+ },
230
+ [setSearchParams]
231
+ )
232
+
181
233
  const provider = workspaces.find(w => w.id === workspaceId)?.type ?? 'claude-code'
182
234
 
183
235
  // Model list for the selected workspace.
@@ -287,6 +339,12 @@ export function HarnessDebugPage() {
287
339
  [models, model]
288
340
  )
289
341
 
342
+ const [wireFilter, setWireFilter] = useState('')
343
+ const visibleWire = useMemo(() => {
344
+ const q = wireFilter.trim().toLowerCase()
345
+ return q ? wire.filter(f => frameLabel(f.frame).toLowerCase().includes(q)) : wire
346
+ }, [wire, wireFilter])
347
+
290
348
  const visibleClientFrames = useMemo(
291
349
  () =>
292
350
  hidePreviews
@@ -295,6 +353,24 @@ export function HarnessDebugPage() {
295
353
  [clientFrames, hidePreviews]
296
354
  )
297
355
 
356
+ // Copy the displayed frames (respecting any active filter) as timestamped
357
+ // JSONL — the same shape the panes render, so a paste reads like the
358
+ // on-screen log.
359
+ const copyWire = useCallback(() => {
360
+ navigator.clipboard.writeText(
361
+ visibleWire
362
+ .map(f => `${ts(f.ts)} ${f.dir === 'send' ? '→' : '←'} ${JSON.stringify(f.frame)}`)
363
+ .join('\n')
364
+ )
365
+ }, [visibleWire])
366
+ const copyRight = useCallback(() => {
367
+ navigator.clipboard.writeText(
368
+ rightTab === 'frames'
369
+ ? visibleClientFrames.map(f => `${ts(f.ts)} ws ${JSON.stringify(f.frame)}`).join('\n')
370
+ : JSON.stringify(events ?? [], null, 2)
371
+ )
372
+ }, [rightTab, visibleClientFrames, events])
373
+
298
374
  return (
299
375
  <div className="flex h-dvh flex-col gap-2 bg-muted p-2">
300
376
  <div className="flex flex-wrap items-center gap-2 rounded-lg border border-border bg-background px-2 py-1.5 text-xs">
@@ -304,7 +380,7 @@ export function HarnessDebugPage() {
304
380
  <select
305
381
  className="rounded border border-border bg-background px-1 py-0.5"
306
382
  value={workspaceId}
307
- onChange={e => setWorkspaceId(e.target.value)}
383
+ onChange={e => selectWorkspace(e.target.value)}
308
384
  >
309
385
  {workspaces.length === 0 && <option value="">no workspaces</option>}
310
386
  {workspaces.map(w => (
@@ -389,77 +465,137 @@ export function HarnessDebugPage() {
389
465
  />
390
466
  </div>
391
467
 
392
- <div className="flex min-h-0 flex-1 gap-2">
468
+ <div ref={rowRef} className="flex min-h-0 flex-1 gap-1">
469
+ {/* Dynamic drag geometry can't be a static Tailwind class */}
470
+ <div className="flex min-w-0" style={{ width: `${leftPct}%` }}>
471
+ <Pane
472
+ title={provider === 'codex' ? 'App-server wire' : 'Harness wire'}
473
+ hint={
474
+ provider === 'codex'
475
+ ? 'raw JSON-RPC, both directions'
476
+ : provider === 'openclaw'
477
+ ? 'no wire tap for OpenClaw yet'
478
+ : 'raw Agent SDK messages + enqueued inputs'
479
+ }
480
+ controls={
481
+ <input
482
+ className="w-36 rounded border border-border bg-background px-1.5 py-0.5 font-mono text-[10px]"
483
+ placeholder="filter types…"
484
+ value={wireFilter}
485
+ onChange={e => setWireFilter(e.target.value)}
486
+ />
487
+ }
488
+ onCopy={copyWire}
489
+ onClear={() => setWire([])}
490
+ >
491
+ {visibleWire.map(f => (
492
+ <LogRow
493
+ key={f.seq}
494
+ time={f.ts}
495
+ badge={f.dir === 'send' ? '→' : '←'}
496
+ badgeClass={
497
+ f.dir === 'send'
498
+ ? 'bg-blue-500/15 text-blue-600'
499
+ : 'bg-amber-500/15 text-amber-600'
500
+ }
501
+ label={frameLabel(f.frame)}
502
+ body={f.frame}
503
+ />
504
+ ))}
505
+ </Pane>
506
+ </div>
507
+
508
+ <div
509
+ className="w-1.5 shrink-0 cursor-col-resize touch-none rounded-full hover:bg-border active:bg-border"
510
+ onPointerDown={e => {
511
+ e.preventDefault()
512
+ e.currentTarget.setPointerCapture(e.pointerId)
513
+ }}
514
+ onPointerMove={e => {
515
+ if (!e.currentTarget.hasPointerCapture(e.pointerId) || !rowRef.current) return
516
+ const rect = rowRef.current.getBoundingClientRect()
517
+ const pct = ((e.clientX - rect.left) / rect.width) * 100
518
+ setLeftPct(Math.min(80, Math.max(20, pct)))
519
+ }}
520
+ />
521
+
393
522
  <Pane
394
- title={provider === 'codex' ? 'App-server wire' : 'Harness wire'}
523
+ title={
524
+ <span className="flex items-center gap-1">
525
+ <button
526
+ type="button"
527
+ className={cn(
528
+ 'rounded px-1.5 py-0.5 text-xs',
529
+ rightTab === 'frames' ? 'bg-muted font-medium' : 'text-muted-foreground'
530
+ )}
531
+ onClick={() => setRightTab('frames')}
532
+ >
533
+ Client frames
534
+ </button>
535
+ <button
536
+ type="button"
537
+ className={cn(
538
+ 'rounded px-1.5 py-0.5 text-xs',
539
+ rightTab === 'events' ? 'bg-muted font-medium' : 'text-muted-foreground'
540
+ )}
541
+ onClick={() => setRightTab('events')}
542
+ >
543
+ Durable events
544
+ </button>
545
+ </span>
546
+ }
395
547
  hint={
396
- provider === 'codex'
397
- ? 'raw JSON-RPC, both directions'
398
- : provider === 'openclaw'
399
- ? 'no wire tap for OpenClaw yet'
400
- : 'raw Agent SDK messages + enqueued inputs'
548
+ rightTab === 'frames'
549
+ ? 'what the browser receives on /ws'
550
+ : 'GET /sessions/:id/events replay'
401
551
  }
402
- onClear={() => setWire([])}
552
+ onCopy={copyRight}
553
+ onClear={rightTab === 'frames' ? () => setClientFrames([]) : undefined}
403
554
  >
404
- {wire.map(f => (
405
- <LogRow
406
- key={f.seq}
407
- time={f.ts}
408
- badge={f.dir === 'send' ? '→' : '←'}
409
- badgeClass={
410
- f.dir === 'send' ? 'bg-blue-500/15 text-blue-600' : 'bg-amber-500/15 text-amber-600'
411
- }
412
- label={frameLabel(f.frame)}
413
- body={f.frame}
414
- />
415
- ))}
416
- </Pane>
417
-
418
- <Pane
419
- title="Client frames"
420
- hint="what the browser receives on /ws"
421
- onClear={() => setClientFrames([])}
422
- >
423
- <div className="border-b border-border/40 px-2 py-1">
424
- <label className="flex items-center gap-1 text-[10px] text-muted-foreground">
425
- <input
426
- type="checkbox"
427
- checked={hidePreviews}
428
- onChange={e => setHidePreviews(e.target.checked)}
429
- />
430
- hide preview frames
431
- </label>
432
- </div>
433
- {visibleClientFrames.map(f => (
434
- <LogRow
435
- key={f.seq}
436
- time={f.ts}
437
- badge="ws"
438
- badgeClass="bg-purple-500/15 text-purple-600"
439
- label={frameLabel(f.frame)}
440
- body={f.frame}
441
- />
442
- ))}
443
- </Pane>
444
-
445
- <Pane title="Durable events" hint="GET /sessions/:id/events replay">
446
- <div className="border-b border-border/40 px-2 py-1">
447
- <Button type="button" size="sm" variant="secondary" onClick={fetchEvents}>
448
- Fetch events
449
- </Button>
450
- </div>
451
- {events?.map((ev, i) => (
452
- <LogRow
453
- key={i}
454
- time={Date.now()}
455
- badge="ev"
456
- badgeClass="bg-teal-500/15 text-teal-600"
457
- label={frameLabel(ev)}
458
- body={ev}
459
- />
460
- ))}
461
- {events?.length === 0 && (
462
- <div className="p-2 text-[11px] text-muted-foreground">no events</div>
555
+ {rightTab === 'frames' ? (
556
+ <>
557
+ <div className="border-b border-border/40 px-2 py-1">
558
+ <label className="flex items-center gap-1 text-[10px] text-muted-foreground">
559
+ <input
560
+ type="checkbox"
561
+ checked={hidePreviews}
562
+ onChange={e => setHidePreviews(e.target.checked)}
563
+ />
564
+ hide preview frames
565
+ </label>
566
+ </div>
567
+ {visibleClientFrames.map(f => (
568
+ <LogRow
569
+ key={f.seq}
570
+ time={f.ts}
571
+ badge="ws"
572
+ badgeClass="bg-purple-500/15 text-purple-600"
573
+ label={frameLabel(f.frame)}
574
+ body={f.frame}
575
+ />
576
+ ))}
577
+ </>
578
+ ) : (
579
+ <>
580
+ <div className="border-b border-border/40 px-2 py-1">
581
+ <Button type="button" size="sm" variant="secondary" onClick={fetchEvents}>
582
+ Fetch events
583
+ </Button>
584
+ </div>
585
+ {events?.map((ev, i) => (
586
+ <LogRow
587
+ key={i}
588
+ time={Date.now()}
589
+ badge="ev"
590
+ badgeClass="bg-teal-500/15 text-teal-600"
591
+ label={frameLabel(ev)}
592
+ body={ev}
593
+ />
594
+ ))}
595
+ {events?.length === 0 && (
596
+ <div className="p-2 text-[11px] text-muted-foreground">no events</div>
597
+ )}
598
+ </>
463
599
  )}
464
600
  </Pane>
465
601
  </div>
@@ -1,7 +1,15 @@
1
1
  import { IconChevronRight, IconEggCracked, IconLoader2, IconPlus } from '@tabler/icons-react'
2
2
  import { Link, useLocation } from 'wouter'
3
3
 
4
- import { useAddWorkspace, useDiscoveredWorkspaces, useWorkspacePreview, useWorkspaces } from './api'
4
+ import {
5
+ useDiscoveredWorkspaces,
6
+ useWorkspacePreview,
7
+ useWorkspaces,
8
+ useWorkspaceSetupInfo
9
+ } from './api'
10
+ import { CreateWorkspaceDialog } from './workspace-setup/CreateWorkspaceDialog'
11
+ import { ImportWorkspaceDialog } from './workspace-setup/ImportWorkspaceDialog'
12
+ import { useWorkspaceImport } from './workspace-setup/useWorkspaceImport'
5
13
  import { HomeLogo } from './HomeLogo'
6
14
  import { Button } from '@/client/components/ui/button'
7
15
  import {
@@ -12,20 +20,22 @@ import {
12
20
  import { cn } from '@/client/lib/cn'
13
21
  import { useUiStore } from '@/client/store/ui'
14
22
  import {
15
- WorkspaceTypeIcon,
23
+ WorkspaceAgentIcons,
16
24
  workspaceDisplayName,
17
25
  workspaceProviderIcon
18
26
  } from '@/client/features/home/workspace-presentation'
19
27
  import type { DiscoveredWorkspace, WorkspaceEntry } from '@/lib/types'
20
28
 
21
- import { CreateWorkspaceDialog } from './CreateWorkspaceDialog'
22
29
  import { WorkspacePreview } from './WorkspacePreview'
23
30
 
24
31
  export function HomePage() {
25
32
  const [, navigate] = useLocation()
26
33
  const workspacesQuery = useWorkspaces()
27
34
  const discoveredQuery = useDiscoveredWorkspaces()
28
- const importMutation = useAddWorkspace()
35
+ const setupInfo = useWorkspaceSetupInfo()
36
+ const importFlow = useWorkspaceImport({
37
+ onSuccess: entry => navigate(`/workspace/${entry.id}`)
38
+ })
29
39
  const discoveredWorkspacesOpen = useUiStore(state => state.discoveredWorkspacesOpen)
30
40
  const setDiscoveredWorkspacesOpen = useUiStore(state => state.setDiscoveredWorkspacesOpen)
31
41
 
@@ -48,13 +58,9 @@ export function HomePage() {
48
58
  const workspaces = workspacesQuery.data
49
59
  const discovered = discoveredQuery.data
50
60
  const count = workspaces.length
51
- const importingPath =
52
- importMutation.isPending && importMutation.variables ? importMutation.variables.path : null
53
61
 
54
62
  function handleAdd(suggestion: DiscoveredWorkspace) {
55
- importMutation.mutate(suggestion, {
56
- onSuccess: entry => navigate(`/workspace/${entry.id}`)
57
- })
63
+ importFlow.startImport(suggestion)
58
64
  }
59
65
 
60
66
  return (
@@ -122,21 +128,25 @@ export function HomePage() {
122
128
  <CollapsibleContent>
123
129
  <ul className="border-t border-border">
124
130
  {discovered.map(item => (
125
- <SuggestedRow
126
- key={item.path}
127
- suggestion={item}
128
- onAdd={handleAdd}
129
- loading={importingPath === item.path}
130
- />
131
+ <SuggestedRow key={item.path} suggestion={item} onAdd={handleAdd} />
131
132
  ))}
132
133
  </ul>
133
- {importMutation.isError && (
134
- <p className="mt-3 text-xs text-destructive">{importMutation.error.message}</p>
135
- )}
136
134
  </CollapsibleContent>
137
135
  </Collapsible>
138
136
  </section>
139
137
  )}
138
+
139
+ {importFlow.choice && (
140
+ <ImportWorkspaceDialog
141
+ choice={importFlow.choice}
142
+ availability={setupInfo.data?.availability}
143
+ isPending={importFlow.isPending}
144
+ errorMessage={importFlow.error?.message}
145
+ onTypeChange={importFlow.selectType}
146
+ onSubmit={importFlow.submit}
147
+ onReset={importFlow.reset}
148
+ />
149
+ )}
140
150
  </div>
141
151
  )
142
152
  }
@@ -174,25 +184,20 @@ function WorkspaceCard({ workspace }: WorkspaceCardProps) {
174
184
  type SuggestedRowProps = {
175
185
  suggestion: DiscoveredWorkspace
176
186
  onAdd: (suggestion: DiscoveredWorkspace) => void
177
- loading: boolean
178
187
  }
179
188
 
180
- function SuggestedRow({ suggestion, onAdd, loading }: SuggestedRowProps) {
181
- const { path, type } = suggestion
189
+ function SuggestedRow({ suggestion, onAdd }: SuggestedRowProps) {
190
+ const { path, types } = suggestion
182
191
  const name = workspaceDisplayName(suggestion)
183
192
  return (
184
193
  <li className="flex items-center gap-2 border-b border-border px-1 py-3">
185
- <WorkspaceTypeIcon type={type} />
194
+ <WorkspaceAgentIcons types={types} />
186
195
  <span className="shrink-0 text-sm font-medium text-foreground">{name}</span>
187
196
  <span title={path} className="min-w-0 flex-1 truncate text-xs text-muted-foreground">
188
197
  {suggestion.displayPath ?? path}
189
198
  </span>
190
- <Button variant="outline" size="sm" onClick={() => onAdd(suggestion)} disabled={loading}>
191
- {loading ? (
192
- <IconLoader2 stroke={1.75} className="animate-spin" />
193
- ) : (
194
- <IconPlus stroke={1.75} />
195
- )}
199
+ <Button variant="outline" size="sm" onClick={() => onAdd(suggestion)}>
200
+ <IconPlus stroke={1.75} />
196
201
  Add
197
202
  </Button>
198
203
  </li>
@@ -4,6 +4,7 @@ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
4
  import { workspaceKeys } from '@/client/api/workspace-keys'
5
5
  import type {
6
6
  DiscoveredWorkspace,
7
+ HarnessAvailability,
7
8
  WorkspaceEntry,
8
9
  WorkspacePreview,
9
10
  WorkspaceType
@@ -43,37 +44,48 @@ export function useDiscoveredWorkspaces() {
43
44
  })
44
45
  }
45
46
 
46
- export function useAddWorkspace() {
47
+ export function useImportWorkspace() {
47
48
  const queryClient = useQueryClient()
48
- return useMutation<WorkspaceEntry, Error, DiscoveredWorkspace>({
49
- mutationFn: discovered =>
50
- requestJson('/api/workspaces', jsonRequest('POST', discovered), 'Failed to add workspace'),
51
- onSuccess: (entry, suggestion) => {
49
+ return useMutation<WorkspaceEntry, Error, ImportWorkspaceInput>({
50
+ mutationFn: input =>
51
+ requestJson('/api/workspaces', jsonRequest('POST', input), 'Failed to add workspace'),
52
+ onSuccess: (entry, input) => {
52
53
  queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
53
54
  upsertWorkspaceEntry(previous, entry)
54
55
  )
55
56
  queryClient.setQueryData<DiscoveredWorkspace[]>(workspaceKeys.discover, previous =>
56
- (previous ?? []).filter(item => item.path !== suggestion.path)
57
+ (previous ?? []).filter(item => item.path !== input.path)
57
58
  )
58
59
  }
59
60
  })
60
61
  }
61
62
 
62
- export type CreateWorkspaceInfo = {
63
+ export type ImportWorkspaceInput = {
64
+ path: string
65
+ type: WorkspaceType
66
+ }
67
+
68
+ export type WorkspaceSetupInfo = {
63
69
  root: string
64
70
  displayRoot: string
65
71
  canChooseFolder: boolean
72
+ // Per-backend runtime availability (are the Claude/Codex CLIs installed?),
73
+ // keyed by workspace type. Missing entries mean available.
74
+ availability?: Partial<Record<WorkspaceType, HarnessAvailability>>
66
75
  }
67
76
 
68
- export function useCreateWorkspaceInfo() {
69
- return useQuery<CreateWorkspaceInfo>({
70
- queryKey: workspaceKeys.createInfo,
77
+ export function useWorkspaceSetupInfo() {
78
+ return useQuery<WorkspaceSetupInfo>({
79
+ queryKey: workspaceKeys.setupInfo,
80
+ // Availability can change while the app is open (the user installs the
81
+ // agent CLI) — refetch on mount instead of caching forever.
71
82
  queryFn: () => requestJson('/api/workspaces/create'),
72
- staleTime: Infinity
83
+ staleTime: 30_000,
84
+ refetchOnMount: 'always'
73
85
  })
74
86
  }
75
87
 
76
- export type ChooseFolderResult = { path: string } | { canceled: true }
88
+ export type ChooseFolderResult = DiscoveredWorkspace | { canceled: true }
77
89
 
78
90
  export function useChooseFolder() {
79
91
  return useMutation<ChooseFolderResult, Error, void>({
@@ -1,7 +1,6 @@
1
1
  import claudeIcon from '@/client/assets/claude.svg'
2
2
  import openaiIcon from '@/client/assets/openai.svg'
3
3
  import openclawIcon from '@/client/assets/openclaw.svg'
4
- import { cn } from '@/client/lib/cn'
5
4
  import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
6
5
 
7
6
  export const workspaceProviderIcon: Record<WorkspaceType, string> = {
@@ -16,28 +15,31 @@ export const workspaceTypeLabel: Record<WorkspaceType, string> = {
16
15
  codex: 'Codex'
17
16
  }
18
17
 
19
- type WorkspaceTypeIconProps = {
20
- type: WorkspaceType
21
- className?: string
18
+ type WorkspaceAgentIconsProps = {
19
+ types: WorkspaceType[]
22
20
  }
23
21
 
24
- export function WorkspaceTypeIcon({ type, className }: WorkspaceTypeIconProps) {
22
+ export function WorkspaceAgentIcons({ types }: WorkspaceAgentIconsProps) {
23
+ const label = types.map(type => workspaceTypeLabel[type]).join(', ')
24
+
25
25
  return (
26
- <img
27
- src={workspaceProviderIcon[type]}
28
- alt=""
29
- aria-label={workspaceTypeLabel[type]}
30
- className={cn('size-4 shrink-0', className)}
31
- />
26
+ <span role="img" aria-label={label} className="inline-flex shrink-0 items-center -space-x-0.5">
27
+ {types.map(type => (
28
+ <img
29
+ key={type}
30
+ src={workspaceProviderIcon[type]}
31
+ alt=""
32
+ className="size-4 shrink-0 rounded-full bg-muted ring-2 ring-muted"
33
+ />
34
+ ))}
35
+ </span>
32
36
  )
33
37
  }
34
38
 
35
- type WorkspaceDisplaySource = Pick<
36
- WorkspaceEntry | DiscoveredWorkspace,
37
- 'name' | 'path' | 'type' | 'agentId'
38
- >
39
+ type WorkspaceDisplaySource = WorkspaceEntry | DiscoveredWorkspace
39
40
 
40
41
  export function workspaceDisplayName(workspace: WorkspaceDisplaySource): string {
42
+ if ('types' in workspace) return workspace.path.split('/').pop() || workspace.path
41
43
  if (workspace.name) return workspace.name
42
44
  if (workspace.type === 'openclaw') return workspace.agentId ?? 'OpenClaw agent'
43
45
  return workspace.path.split('/').pop() || workspace.path