moi-computer 0.4.0 → 0.5.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 (123) hide show
  1. package/README.md +41 -5
  2. package/bin/moi.mjs +11 -0
  3. package/client/api/workspace-keys.ts +1 -0
  4. package/client/app/AppRouter.tsx +5 -1
  5. package/client/app/routes/WorkspaceRoute.tsx +9 -5
  6. package/client/app/shell/SidebarLayout.tsx +9 -7
  7. package/client/components/shared/BottomPanel.tsx +24 -5
  8. package/client/components/shared/Composer.tsx +1 -1
  9. package/client/components/shared/PanelHeader.tsx +1 -1
  10. package/client/components/ui/button.tsx +5 -5
  11. package/client/components/ui/dropdown-menu.tsx +6 -6
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/input.tsx +1 -1
  14. package/client/components/ui/popover.tsx +1 -1
  15. package/client/components/ui/skeleton.tsx +1 -1
  16. package/client/components/ui/textarea.tsx +1 -1
  17. package/client/components/ui/tooltip.tsx +1 -1
  18. package/client/features/applets/applet-cache.ts +20 -1
  19. package/client/features/applets/applet-log.ts +10 -30
  20. package/client/features/applets/applet-runtime.ts +272 -0
  21. package/client/features/applets/useApplet.ts +36 -10
  22. package/client/features/chat/ChatComposer.tsx +1 -1
  23. package/client/features/chat/ChatEmptyState.tsx +186 -0
  24. package/client/features/chat/ChatPanel.tsx +95 -54
  25. package/client/features/chat/ChatPopup.tsx +3 -13
  26. package/client/features/chat/ChatPromptBubbles.tsx +74 -0
  27. package/client/features/chat/MarkdownContent.tsx +15 -3
  28. package/client/features/chat/ModelPicker.tsx +1 -1
  29. package/client/features/chat/TurnView.tsx +6 -17
  30. package/client/features/chat/chat-send.ts +26 -1
  31. package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
  32. package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
  33. package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
  34. package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
  35. package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
  36. package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
  37. package/client/features/chat/tool-group/format.ts +3 -3
  38. package/client/features/chat/useAppletChatMessage.ts +69 -0
  39. package/client/features/chat/useChat.ts +49 -14
  40. package/client/features/chat/useStickToBottom.ts +11 -1
  41. package/client/features/connectors/McpServerCards.tsx +3 -3
  42. package/client/features/dev/HarnessDebugPage.tsx +4 -4
  43. package/client/features/dev/PixelPainter.tsx +1 -1
  44. package/client/features/dev/PlaygroundPage.tsx +1 -1
  45. package/client/features/dev/ToolCallsPage.tsx +2 -2
  46. package/client/features/home/HomePage.tsx +17 -14
  47. package/client/features/home/WorkspacePreview.tsx +12 -13
  48. package/client/features/home/api.ts +8 -5
  49. package/client/features/home/workspace-presentation.tsx +1 -1
  50. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
  51. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
  52. package/client/features/scratchpad/Scratchpad.tsx +41 -2
  53. package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
  54. package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
  55. package/client/features/settings/EnvironmentSettings.tsx +1 -1
  56. package/client/features/settings/IconPicker.tsx +11 -11
  57. package/client/features/settings/SettingsLayout.tsx +1 -1
  58. package/client/features/settings/WorkspaceSettings.tsx +2 -2
  59. package/client/features/settings/api.ts +33 -1
  60. package/client/features/widgets/HiddenPanel.tsx +4 -3
  61. package/client/features/widgets/Widgets.tsx +1 -0
  62. package/client/features/workspace/CustomizePanel.tsx +96 -82
  63. package/client/features/workspace/WorkspaceScreen.tsx +129 -107
  64. package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
  65. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  66. package/client/features/workspace/api.ts +52 -0
  67. package/client/features/workspace/moi-context.ts +63 -17
  68. package/client/features/workspace/tab-resolution.ts +75 -0
  69. package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
  70. package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
  71. package/client/index.css +10 -15
  72. package/client/lib/app-icon-registry.ts +77 -70
  73. package/client/lib/rate-limit.ts +77 -0
  74. package/client/runtime/useWorkspaceEvents.ts +15 -2
  75. package/client/runtime/workspace-theme.ts +115 -0
  76. package/client/store/ui.ts +42 -17
  77. package/client/theme.css +20 -15
  78. package/dist/{chunk-fh2mf6v9.js → chunk-3m1xe1j3.js} +94 -94
  79. package/dist/chunk-5vaevt8z.js +2 -0
  80. package/dist/{chunk-69nhbjhy.js → chunk-7bzpmtxp.js} +4 -4
  81. package/dist/chunk-h0hk61pm.js +9 -0
  82. package/dist/{chunk-35fq49qa.js → chunk-h3evrtyp.js} +1 -1
  83. package/dist/chunk-k5sjx9s5.js +1 -0
  84. package/dist/{chunk-2vaafjp4.js → chunk-m9qja0nx.js} +1 -1
  85. package/dist/chunk-s7za1qsv.css +1 -0
  86. package/dist/{chunk-72atbmh3.js → chunk-tcfa3vt3.js} +1 -1
  87. package/dist/chunk-v797g6ap.js +51 -0
  88. package/dist/chunk-xyrw8318.js +27 -0
  89. package/dist/index.html +1 -1
  90. package/lib/app-icons.ts +73 -0
  91. package/lib/moi-context.ts +104 -3
  92. package/lib/themes.ts +83 -45
  93. package/lib/types.ts +44 -9
  94. package/lib/workspace-tabs.ts +48 -0
  95. package/package.json +4 -1
  96. package/server/api.ts +57 -5
  97. package/server/app-settings.ts +65 -0
  98. package/server/applets.ts +132 -22
  99. package/server/bundler/build-applet.ts +74 -16
  100. package/server/cli.ts +144 -17
  101. package/server/control.ts +53 -7
  102. package/server/data-dir.ts +1 -1
  103. package/server/events.ts +1 -1
  104. package/server/functions-worker.ts +15 -1
  105. package/server/functions.ts +51 -6
  106. package/server/layout.ts +9 -14
  107. package/server/moi-scaffold.ts +37 -3
  108. package/server/registry.ts +1 -1
  109. package/server/skill-update.ts +47 -0
  110. package/server/skill-version.ts +2 -11
  111. package/server/tabs.ts +59 -0
  112. package/server/theme.ts +8 -14
  113. package/server/view-builders.ts +6 -2
  114. package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
  115. package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
  116. package/client/features/workspace/useWorkspaceTheme.ts +0 -82
  117. package/dist/chunk-19g80zc9.css +0 -1
  118. package/dist/chunk-7mkv2gr0.js +0 -2
  119. package/dist/chunk-gt7n06ef.js +0 -1
  120. package/dist/chunk-jwmc32rp.js +0 -63
  121. package/dist/chunk-kh24bstm.js +0 -10
  122. package/dist/chunk-sfa4mbmx.js +0 -15
  123. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
@@ -0,0 +1,69 @@
1
+ // Chat's half of the applet `sendChatMessage` API: turn a validated runtime
2
+ // event into a real send on the active chat.
3
+ //
4
+ // The runtime already did the untrusted work — narrowed the args, stamped the
5
+ // applet's `<kind>:<name>` as `source`, and rate-limited repeats
6
+ // (applet-runtime.ts). What's left is chat policy: reveal the chat, then send
7
+ // the text as an ordinary user message with the applet attribution riding the
8
+ // `<moi-context>` envelope.
9
+ //
10
+ // Sending while a turn is running is fine and deliberate — the composer offers
11
+ // the same ("Queue a follow-up"), and the harness queues the message into the
12
+ // live session rather than rejecting it.
13
+ import { reportAppletError } from '@/client/features/applets/applet-log'
14
+ import { type AppletChatMessage, useAppletEvent } from '@/client/features/applets/applet-runtime'
15
+ import type { ChatSendOptions } from '@/client/features/chat/chat-send'
16
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
17
+
18
+ type UseAppletChatMessageOptions = {
19
+ send: (draft: string, options?: ChatSendOptions) => void
20
+ // Bring the chat on screen before the run starts. On a view tab in
21
+ // full-screen mode the chat is a popover that is closed by default, so
22
+ // without this the agent would start working somewhere the user can't see.
23
+ revealChat: () => void
24
+ // Same gate the composer's send button uses: `null` means the agent is
25
+ // ready, a string names why it isn't, and `undefined` means the availability
26
+ // query hasn't answered yet. Only `null` may send.
27
+ unavailableReason: string | null | undefined
28
+ }
29
+
30
+ // Why an applet message can't go out right now, or null when it can. The gate
31
+ // is exactly the composer's — `canSubmitComposerAction` requires `null`, so
32
+ // `undefined` (availability still loading) blocks there too. Starting a run the
33
+ // visible UI would have refused is worse than dropping a click the user can
34
+ // repeat a moment later.
35
+ export function appletSendBlockedReason(
36
+ unavailableReason: string | null | undefined
37
+ ): string | null {
38
+ if (unavailableReason === null) return null
39
+ if (unavailableReason === undefined) {
40
+ return "this workspace's agent availability has not resolved yet"
41
+ }
42
+ return `this workspace's agent is unavailable (${unavailableReason})`
43
+ }
44
+
45
+ export function useAppletChatMessage({
46
+ send,
47
+ revealChat,
48
+ unavailableReason
49
+ }: UseAppletChatMessageOptions): void {
50
+ const workspaceId = useWorkspaceId()
51
+
52
+ useAppletEvent(workspaceId, 'sendChatMessage', (event: AppletChatMessage) => {
53
+ const blocked = appletSendBlockedReason(unavailableReason)
54
+ if (blocked) {
55
+ // Journaled rather than dropped quietly: from the applet's side the
56
+ // button did nothing, and this is the only place that says why.
57
+ reportAppletError(workspaceId, {
58
+ source: 'runtime',
59
+ message: `sendChatMessage("${event.message}") was dropped: ${blocked}.`
60
+ })
61
+ return
62
+ }
63
+ // `message` is the visible chat text; everything else in the event IS the
64
+ // envelope's applet attribution.
65
+ const { message, ...applet } = event
66
+ revealChat()
67
+ send(message, { applet })
68
+ })
69
+ }
@@ -3,14 +3,29 @@ import { useCallback, useMemo } from 'react'
3
3
  import { useQueryClient } from '@tanstack/react-query'
4
4
 
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
- import { useSessionView, useThreadConfig, useWorkspaceModels } from '@/client/features/chat/api'
7
- import { useMoiUserMessageContext } from '@/client/features/workspace/moi-context'
6
+ import {
7
+ useSessionView,
8
+ useThreadConfig,
9
+ useWorkspaceModels,
10
+ useWorkspaceSessions
11
+ } from '@/client/features/chat/api'
12
+ import {
13
+ type WorkspaceTabAddress,
14
+ useMoiUserMessageContext
15
+ } from '@/client/features/workspace/moi-context'
8
16
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
9
17
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
10
18
  import { sendMessage } from '@/client/features/chat/chat-connection'
11
- import { resolveChatRunOptions, startOptimisticTurn } from '@/client/features/chat/chat-send'
19
+ import {
20
+ type ChatSendOptions,
21
+ attachmentsForSend,
22
+ ownsComposerAttachments,
23
+ resolveChatRunOptions,
24
+ startOptimisticTurn
25
+ } from '@/client/features/chat/chat-send'
12
26
  import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
13
- import { draftKey, liveStore, selectPreviews, useLive } from '@/client/features/chat/chat-store'
27
+ import { liveStore, selectPreviews, useLive } from '@/client/features/chat/chat-store'
28
+ import { useUiStore } from '@/client/store/ui'
14
29
  import { emptyViewState } from '@/lib/format'
15
30
  import type { Part, ViewState } from '@/lib/types'
16
31
 
@@ -19,16 +34,24 @@ const EMPTY: ViewState = emptyViewState()
19
34
  // Thin projection over app-level state: the active thread + spinner/error come
20
35
  // from the live store; the transcript comes from the React Query cache (kept
21
36
  // current by the connection manager's WS deltas). No socket lifecycle here.
22
- export function useChat() {
37
+ //
38
+ // Takes the workspace's tab address because every message carries it: the
39
+ // envelope tells the agent which tab the user is on and what the active view
40
+ // is rendering with. Call this BELOW `useWorkspaceNavigation`, which owns it.
41
+ export function useChat(address: WorkspaceTabAddress) {
23
42
  const workspaceId = useWorkspaceId()
24
43
  const qc = useQueryClient()
25
44
  const { layout } = useWorkspaceLayoutCtx()
26
45
  const modelsData = useWorkspaceModels(workspaceId).data
46
+ const sessions = useWorkspaceSessions(workspaceId).data
27
47
  // Snapshot of the workspace's ambient UI state + queued one-shot
28
48
  // directives, taken when the message actually goes out.
29
- const buildMoiContext = useMoiUserMessageContext()
49
+ const buildMoiContext = useMoiUserMessageContext(address)
30
50
 
31
51
  const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
52
+ const sessionSelectionInitialized = useLive(s =>
53
+ Object.prototype.hasOwnProperty.call(s.activeByWorkspace, workspaceId)
54
+ )
32
55
  const activity = useLive(s =>
33
56
  activeSessionId ? (s.activity[`${workspaceId}:${activeSessionId}`] ?? 'idle') : 'idle'
34
57
  )
@@ -39,7 +62,14 @@ export function useChat() {
39
62
  activeSessionId ? (s.errors[`${workspaceId}:${activeSessionId}`] ?? null) : null
40
63
  )
41
64
 
42
- const view = useSessionView(workspaceId, activeSessionId).data ?? EMPTY
65
+ const viewQuery = useSessionView(workspaceId, activeSessionId)
66
+ const view = viewQuery.data ?? EMPTY
67
+ const chatLoaded =
68
+ sessionSelectionInitialized &&
69
+ sessions !== undefined &&
70
+ (activeSessionId === null ||
71
+ (sessions.some(session => session.sessionId === activeSessionId) &&
72
+ viewQuery.data !== undefined))
43
73
 
44
74
  // The live streaming preview as a synthetic assistant turn, so the ChatPanel
45
75
  // can run it through the SAME groupTurns pipeline as finalized turns — a
@@ -60,13 +90,13 @@ export function useChat() {
60
90
  // keystroke re-renders only the composer — not this hook's host (WorkspaceView)
61
91
  // and its whole subtree. See `ChatInput`.
62
92
  const send = useCallback(
63
- (draft: string) => {
93
+ (draft: string, options?: ChatSendOptions) => {
64
94
  const text = draft.trim()
65
95
  // Attachments for the active thread, keyed exactly like the draft. Only
66
96
  // fully-uploaded ones are sent; the composer disables send while any are
67
- // still uploading, so in practice they're all ready here.
68
- const pending = liveStore.getState().attachments[draftKey(workspaceId, activeSessionId)] ?? []
69
- const ready = pending.filter(a => a.status === 'ready' && a.upload)
97
+ // still uploading, so in practice they're all ready here. An applet send
98
+ // gets none — the staged files are the user's, not the widget's.
99
+ const ready = attachmentsForSend(workspaceId, activeSessionId, options)
70
100
  // No `processing` guard: sending while a turn is in flight QUEUES the
71
101
  // message into the same live server session (streaming-input mode).
72
102
  if (!text && ready.length === 0) return
@@ -118,16 +148,20 @@ export function useChat() {
118
148
  model,
119
149
  effort,
120
150
  stream,
121
- context: buildMoiContext(),
151
+ context: buildMoiContext(options),
122
152
  ...(ready.length > 0 ? { attachments: ready.map(a => a.upload!.id) } : {})
123
153
  })
154
+ useUiStore.getState().markMessageSentFromMoi(workspaceId)
124
155
  if (isNew) {
125
156
  qc.invalidateQueries({ queryKey: workspaceKeys.preview(workspaceId) })
126
157
  }
127
158
  // Drop the thread's attachments now that they've been sent (revokes the
128
159
  // preview object URLs). Keyed by the pre-mint id, matching where they were
129
- // stored by the composer.
130
- liveStore.getState().clearAttachments(workspaceId, activeSessionId)
160
+ // stored by the composer. Skipped for an applet send, which carried none:
161
+ // clearing here would discard the user's staged (and in-flight) files.
162
+ if (ownsComposerAttachments(options)) {
163
+ liveStore.getState().clearAttachments(workspaceId, activeSessionId)
164
+ }
131
165
  },
132
166
  [
133
167
  activeSessionId,
@@ -161,6 +195,7 @@ export function useChat() {
161
195
 
162
196
  return {
163
197
  view,
198
+ chatLoaded,
164
199
  previewTurn,
165
200
  sessionId: activeSessionId,
166
201
  processing,
@@ -22,6 +22,9 @@ type StickToBottom = {
22
22
  atBottom: boolean
23
23
  // Scroll to the bottom and re-pin. `smooth` for user-initiated jumps.
24
24
  scrollToBottom: (behavior?: ScrollBehavior) => void
25
+ // Show top-anchored content such as the initial Chat welcome without the
26
+ // resize observer pulling it back to the bottom.
27
+ scrollToTop: () => void
25
28
  }
26
29
 
27
30
  export function useStickToBottom(
@@ -48,6 +51,13 @@ export function useStickToBottom(
48
51
  [scrollRef, setPinned]
49
52
  )
50
53
 
54
+ const scrollToTop = useCallback(() => {
55
+ const el = scrollRef.current
56
+ if (!el) return
57
+ setPinned(false)
58
+ el.scrollTo({ top: 0, behavior: 'auto' })
59
+ }, [scrollRef, setPinned])
60
+
51
61
  // Track whether the user is at the bottom. A programmatic scroll-to-bottom
52
62
  // also fires this with distance ≈ 0, so pinned stays true — no fight.
53
63
  useEffect(() => {
@@ -82,5 +92,5 @@ export function useStickToBottom(
82
92
  scrollToBottom('auto')
83
93
  }, [resetKey, scrollToBottom])
84
94
 
85
- return { atBottom, scrollToBottom }
95
+ return { atBottom, scrollToBottom, scrollToTop }
86
96
  }
@@ -19,14 +19,14 @@ type McpServerIconProps = {
19
19
 
20
20
  function McpServerIcon({ name, status }: McpServerIconProps) {
21
21
  const icon = getMcpIcon(name)
22
- const className = 'size-full rounded-sm ring-2 ring-background'
22
+ const className = 'size-full rounded-lg ring-2 ring-background'
23
23
 
24
24
  return (
25
25
  <span className="relative size-10 shrink-0">
26
26
  {icon ? (
27
27
  <img src={icon} alt="" className={className} />
28
28
  ) : (
29
- <span className="flex size-full items-center justify-center rounded-sm bg-muted text-muted-foreground ring-2 ring-background">
29
+ <span className="flex size-full items-center justify-center rounded-lg bg-muted text-muted-foreground ring-2 ring-background">
30
30
  <IconMcp className="size-5" />
31
31
  </span>
32
32
  )}
@@ -79,7 +79,7 @@ export function McpServerCard({ server }: McpServerCardProps) {
79
79
 
80
80
  export function McpServerCardSkeleton() {
81
81
  return (
82
- <McpServerCardLayout icon={<Skeleton className="size-10 shrink-0 rounded-sm" />}>
82
+ <McpServerCardLayout icon={<Skeleton className="size-10 shrink-0 rounded-lg" />}>
83
83
  <Skeleton className="h-4 w-36 max-w-full" />
84
84
  <Skeleton className="h-4 w-20" />
85
85
  </McpServerCardLayout>
@@ -105,7 +105,7 @@ function LogRow({ time, badge, badgeClass, label, body }: LogRowProps) {
105
105
  <span className="shrink-0 font-semibold">{label}</span>
106
106
  <span className="truncate text-muted-foreground">{shortJson(body)}</span>
107
107
  </summary>
108
- <pre className="mt-1 max-h-80 overflow-auto rounded bg-muted p-2 text-[10px] whitespace-pre-wrap">
108
+ <pre className="mt-1 max-h-80 overflow-auto rounded bg-muted p-2 font-mono text-[10px] whitespace-pre-wrap">
109
109
  {JSON.stringify(body, null, 2)}
110
110
  </pre>
111
111
  </details>
@@ -135,7 +135,7 @@ function Pane({ title, hint, controls, onCopy, onClear, children }: PaneProps) {
135
135
  if (follow && scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight
136
136
  })
137
137
  return (
138
- <div className="flex min-h-0 min-w-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-xl border border-border bg-background">
139
139
  <div className="flex items-center gap-2 border-b border-border px-2 py-1">
140
140
  {typeof title === 'string' ? <span className="text-xs font-semibold">{title}</span> : title}
141
141
  {hint && <span className="truncate text-[10px] text-muted-foreground">{hint}</span>}
@@ -373,7 +373,7 @@ export function HarnessDebugPage() {
373
373
 
374
374
  return (
375
375
  <div className="flex h-dvh flex-col gap-2 bg-muted p-2">
376
- <div className="flex flex-wrap items-center gap-2 rounded-lg border border-border bg-background px-2 py-1.5 text-xs">
376
+ <div className="flex flex-wrap items-center gap-2 rounded-xl border border-border bg-background px-2 py-1.5 text-xs">
377
377
  <span className="font-semibold tracking-widest text-muted-foreground uppercase">
378
378
  Harness debug
379
379
  </span>
@@ -439,7 +439,7 @@ export function HarnessDebugPage() {
439
439
  </Button>
440
440
  </div>
441
441
 
442
- <div className="flex flex-wrap items-center gap-1.5 rounded-lg border border-border bg-background px-2 py-1.5">
442
+ <div className="flex flex-wrap items-center gap-1.5 rounded-xl border border-border bg-background px-2 py-1.5">
443
443
  {SCENARIOS.map(s => (
444
444
  <Button
445
445
  key={s.label}
@@ -74,7 +74,7 @@ export function PixelPainter() {
74
74
  )}
75
75
  </div>
76
76
 
77
- <pre className="rounded-md border border-border bg-card px-3 py-2 text-center font-mono text-sm leading-snug text-card-foreground">
77
+ <pre className="rounded-lg border border-border bg-card px-3 py-2 text-center font-mono text-sm leading-snug text-card-foreground">
78
78
  {ascii}
79
79
  </pre>
80
80
 
@@ -24,7 +24,7 @@ type SegmentedProps<T extends string | number> = {
24
24
 
25
25
  function Segmented<T extends string | number>({ options, value, onChange }: SegmentedProps<T>) {
26
26
  return (
27
- <div className="flex gap-1 rounded-lg bg-accent p-1">
27
+ <div className="flex gap-1 rounded-xl bg-accent p-1">
28
28
  {options.map(o => (
29
29
  <Button
30
30
  key={String(o.value)}
@@ -28,7 +28,7 @@ type SegmentedProps = {
28
28
 
29
29
  function Segmented({ value, onChange }: SegmentedProps) {
30
30
  return (
31
- <div className="flex gap-1 rounded-lg bg-accent p-1">
31
+ <div className="flex gap-1 rounded-xl bg-accent p-1">
32
32
  {VARIANTS.map(o => (
33
33
  <Button
34
34
  key={o.value}
@@ -65,7 +65,7 @@ export function ToolCallsPage() {
65
65
 
66
66
  <Segmented value={variant} onChange={setVariant} />
67
67
 
68
- <div className="w-full max-w-[var(--column-w)] rounded-xl border border-border bg-background p-5 font-sans text-foreground shadow-sm">
68
+ <div className="w-full max-w-(--column-w) rounded-xl border border-border bg-background p-5 font-sans text-foreground shadow-sm">
69
69
  {/* `processing` only matters for the live variant — it turns the trailing
70
70
  reasoning into "Thinking" and shows the live running tool spinning. */}
71
71
  <ToolCallGroup
@@ -18,6 +18,7 @@ import {
18
18
  CollapsibleTrigger
19
19
  } from '@/client/components/ui/collapsible'
20
20
  import { cn } from '@/client/lib/cn'
21
+ import { getWorkspaceThemeStyle, usePreloadWorkspaceFonts } from '@/client/runtime/workspace-theme'
21
22
  import { useUiStore } from '@/client/store/ui'
22
23
  import {
23
24
  WorkspaceAgentIcons,
@@ -29,6 +30,7 @@ import type { DiscoveredWorkspace, WorkspaceEntry } from '@/lib/types'
29
30
  import { WorkspacePreview } from './WorkspacePreview'
30
31
 
31
32
  export function HomePage() {
33
+ usePreloadWorkspaceFonts()
32
34
  const [, navigate] = useLocation()
33
35
  const workspacesQuery = useWorkspaces()
34
36
  const discoveredQuery = useDiscoveredWorkspaces()
@@ -65,11 +67,11 @@ export function HomePage() {
65
67
 
66
68
  return (
67
69
  <div className="mx-auto w-full max-w-3xl px-8 pt-14 pb-16">
68
- <HomeLogo className="mb-8" />
70
+ <HomeLogo className="mb-10" />
69
71
 
70
72
  {count > 0 ? (
71
- <section className="mb-10">
72
- <div className="mb-2 flex items-center justify-between gap-2">
73
+ <section className="mb-12">
74
+ <div className="mb-4 flex items-center justify-between gap-2">
73
75
  <h1 className="text-sm font-medium text-foreground">My workspaces</h1>
74
76
  <CreateWorkspaceDialog
75
77
  trigger={
@@ -81,14 +83,14 @@ export function HomePage() {
81
83
  />
82
84
  </div>
83
85
 
84
- <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3">
85
- {workspaces.map(ws => (
86
- <WorkspaceCard key={ws.id} workspace={ws} />
86
+ <div className="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2 md:grid-cols-3">
87
+ {workspaces.map(workspace => (
88
+ <WorkspaceCard key={workspace.id} workspace={workspace} />
87
89
  ))}
88
90
  </div>
89
91
  </section>
90
92
  ) : (
91
- <div className="mb-10 flex flex-col items-center gap-4 px-8 pt-6 pb-12 text-center">
93
+ <div className="mb-10 flex flex-col items-center gap-4 px-8 pt-8 pb-16 text-center">
92
94
  <IconEggCracked size={32} stroke={1.5} className="text-muted-foreground" />
93
95
  <div className="flex flex-col gap-1.5">
94
96
  <h2 className="font-medium">Let’s start with creating your first workspace</h2>
@@ -158,20 +160,21 @@ type WorkspaceCardProps = {
158
160
  function WorkspaceCard({ workspace }: WorkspaceCardProps) {
159
161
  const name = workspaceDisplayName(workspace)
160
162
  const previewQuery = useWorkspacePreview(workspace.id)
163
+ const theme = previewQuery.data?.theme
161
164
  const updatedAt = previewQuery.data?.updatedAt ?? new Date(workspace.addedAt).getTime()
162
165
 
163
166
  return (
164
- <Link
165
- href={`/workspace/${workspace.id}`}
166
- className="group flex min-w-0 flex-col gap-4 rounded-xl bg-card p-2 shadow-xs transition-shadow hover:shadow-sm"
167
- >
167
+ <Link href={`/workspace/${workspace.id}`} className="group flex min-w-0 flex-col gap-3">
168
168
  <WorkspacePreview workspaceId={workspace.id} />
169
- <div className="flex min-w-0 flex-col gap-2 px-2 pb-2">
170
- <div className="flex min-w-0 items-center gap-1.5">
169
+ <div className="flex min-w-0 flex-col gap-2 px-2">
170
+ <div
171
+ className="flex min-w-0 items-center gap-1.5 font-sans"
172
+ style={getWorkspaceThemeStyle(theme)}
173
+ >
171
174
  <img
172
175
  src={workspace.icon ?? workspaceProviderIcon[workspace.type ?? 'claude-code']}
173
176
  alt=""
174
- className="size-4 shrink-0 rounded-[4px]"
177
+ className="size-4 shrink-0 rounded-xs"
175
178
  />
176
179
  <span className="truncate text-sm font-medium text-foreground">{name}</span>
177
180
  </div>
@@ -1,6 +1,7 @@
1
1
  import { useLayoutEffect, useRef, useState } from 'react'
2
2
 
3
3
  import { cn } from '@/client/lib/cn'
4
+ import { getWorkspaceThemeStyle } from '@/client/runtime/workspace-theme'
4
5
 
5
6
  import { useWorkspacePreview } from './api'
6
7
 
@@ -10,9 +11,9 @@ type WorkspacePreviewProps = {
10
11
 
11
12
  const FOLDER = {
12
13
  width: 320,
13
- height: 160,
14
- radius: 24,
15
- topLeftRadius: 12,
14
+ height: 180,
15
+ radius: 32,
16
+ topLeftRadius: 18,
16
17
  bodyTop: 24,
17
18
  tabEnd: 124,
18
19
  shoulder: {
@@ -109,12 +110,14 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
109
110
  const thumbnails = query.data ? [...query.data.thumbnails].reverse() : []
110
111
  const slots = STACK.slice(STACK.length - thumbnails.length)
111
112
  const firstUserMessage = query.data?.firstUserMessage
113
+ const theme = query.data?.theme
112
114
  const { ref, horizontalRadiusScale } = useFolderRadiusScale()
113
115
  const backdropPath = folderBackdropPath(horizontalRadiusScale)
114
116
  const noiseFilterId = `folder-noise-${workspaceId}`
117
+ const themeStyle = getWorkspaceThemeStyle(theme)
115
118
 
116
119
  return (
117
- <div ref={ref} className="relative h-40 w-full">
120
+ <div ref={ref} style={themeStyle} className="relative h-45 w-full font-sans">
118
121
  <svg
119
122
  viewBox={`0 0 ${FOLDER.width} ${FOLDER.height}`}
120
123
  preserveAspectRatio="none"
@@ -145,11 +148,7 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
145
148
  <feBlend in="SourceGraphic" in2="clippedNoise" mode="soft-light" />
146
149
  </filter>
147
150
  </defs>
148
- <path
149
- d={backdropPath}
150
- filter={`url(#${noiseFilterId})`}
151
- className="mask-[linear-gradient(to_bottom,rgba(0,0,0,0.5),black_40%)] fill-accent"
152
- />
151
+ <path d={backdropPath} filter={`url(#${noiseFilterId})`} className="fill-accent" />
153
152
  </svg>
154
153
 
155
154
  {thumbnails.map((src, index) => (
@@ -159,7 +158,7 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
159
158
  alt=""
160
159
  loading="lazy"
161
160
  className={cn(
162
- 'absolute top-[12%] left-[14%] aspect-4/3 w-[72%] rounded-sm object-cover object-top shadow-xs',
161
+ 'absolute top-[12%] left-[14%] aspect-4/3 w-[72%] rounded-lg object-cover object-top shadow-xs',
163
162
  'animate-in transition-transform duration-300 ease-out fade-in',
164
163
  slots[index]
165
164
  )}
@@ -167,11 +166,11 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
167
166
  ))}
168
167
 
169
168
  {thumbnails.length === 0 && firstUserMessage && (
170
- <div className="absolute inset-x-[12%] top-[20%] flex justify-end">
169
+ <div className="absolute inset-x-[12%] top-[22%] flex justify-end">
171
170
  <div
172
171
  aria-hidden="true"
173
172
  className={cn(
174
- 'w-max max-w-40 origin-center rounded-sm bg-card px-3 py-2 shadow-xs',
173
+ 'w-max max-w-40 origin-center rounded-lg bg-card px-3 py-2 shadow-xs',
175
174
  'animate-in transition-transform duration-300 ease-out fade-in',
176
175
  STACK[STACK.length - 1],
177
176
  'group-hover:translate-y-0.5 group-focus-visible:translate-y-0.5'
@@ -186,7 +185,7 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
186
185
 
187
186
  <div
188
187
  className={cn(
189
- 'absolute inset-x-2 top-[40%] bottom-2 rounded-lg bg-accent',
188
+ 'absolute inset-x-2 top-[40%] bottom-2 rounded-2xl bg-[color-mix(in_oklch,var(--accent),var(--foreground)_5%)]',
190
189
  'mask-[linear-gradient(to_bottom,rgba(0,0,0,0.9)_0%,black_50%)] backdrop-blur-lg',
191
190
  'inset-shadow-[0_0_12px_color-mix(in_oklab,var(--background)_20%,transparent)]'
192
191
  )}
@@ -2,6 +2,8 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
2
2
 
3
3
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
4
  import { workspaceKeys } from '@/client/api/workspace-keys'
5
+ import { liveStore } from '@/client/features/chat/chat-store'
6
+ import { useUiStore } from '@/client/store/ui'
5
7
  import type {
6
8
  DiscoveredWorkspace,
7
9
  HarnessAvailability,
@@ -16,7 +18,7 @@ export function upsertWorkspaceEntry(
16
18
  ): WorkspaceEntry[] {
17
19
  const current = entries ?? []
18
20
  const existing = current.findIndex(item => item.id === entry.id || item.path === entry.path)
19
- if (existing === -1) return [...current, entry]
21
+ if (existing === -1) return [entry, ...current]
20
22
  return current.map((item, index) => (index === existing ? { ...item, ...entry } : item))
21
23
  }
22
24
 
@@ -50,6 +52,8 @@ export function useImportWorkspace() {
50
52
  mutationFn: input =>
51
53
  requestJson('/api/workspaces', jsonRequest('POST', input), 'Failed to add workspace'),
52
54
  onSuccess: (entry, input) => {
55
+ liveStore.getState().setActive(entry.id, null)
56
+ useUiStore.getState().markWorkspacePendingAnalysis(entry.id)
53
57
  queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
54
58
  upsertWorkspaceEntry(previous, entry)
55
59
  )
@@ -109,10 +113,9 @@ export function useCreateWorkspace() {
109
113
  'Failed to create workspace'
110
114
  ),
111
115
  onSuccess: entry => {
112
- queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous => [
113
- ...(previous ?? []),
114
- entry
115
- ])
116
+ queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
117
+ upsertWorkspaceEntry(previous, entry)
118
+ )
116
119
  }
117
120
  })
118
121
  }
@@ -10,7 +10,7 @@ export const workspaceProviderIcon: Record<WorkspaceType, string> = {
10
10
  }
11
11
 
12
12
  export const workspaceTypeLabel: Record<WorkspaceType, string> = {
13
- 'claude-code': 'Claude',
13
+ 'claude-code': 'Claude Code',
14
14
  openclaw: 'OpenClaw',
15
15
  codex: 'Codex'
16
16
  }
@@ -235,7 +235,7 @@ function ExistingFolderButton({ available, disabled, onClick }: ExistingFolderBu
235
235
  <Tooltip>
236
236
  <TooltipTrigger render={button} />
237
237
  <TooltipContent>
238
- Run <code className="rounded-[4px] bg-accent px-1 py-0.5 font-mono">moi init</code> in the
238
+ Run <code className="rounded-xs bg-accent px-1 py-0.5 font-mono">moi init</code> in the
239
239
  folder to add it manually
240
240
  </TooltipContent>
241
241
  </Tooltip>
@@ -10,6 +10,7 @@ import {
10
10
  workspaceTypeLabel
11
11
  } from '@/client/features/home/workspace-presentation'
12
12
  import { cn } from '@/client/lib/cn'
13
+ import { useUiStore } from '@/client/store/ui'
13
14
  import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
14
15
  import type { HarnessAvailability, WorkspaceType } from '@/lib/types'
15
16
 
@@ -18,8 +19,8 @@ const OPENCLAW_LOCKED_DESCRIPTION =
18
19
  'Initialize OpenClaw in the folder\nmanually, then import it to moi'
19
20
 
20
21
  const workspaceAgentDescription: Record<WorkspaceType, string> = {
21
- 'claude-code': 'By Anthropic',
22
- codex: 'By OpenAI',
22
+ 'claude-code': 'Anthropic',
23
+ codex: 'OpenAI',
23
24
  openclaw: 'Open-source'
24
25
  }
25
26
 
@@ -91,9 +92,16 @@ export function WorkspaceAgentStep({
91
92
  onTypeChange,
92
93
  onSubmit
93
94
  }: WorkspaceAgentStepProps) {
95
+ const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
94
96
  const options = getWorkspaceAgentOptions({ availability, detectedTypes })
95
97
  const selectableType = resolveWorkspaceAgentSelection(options, selectedType)
96
98
  const selectedUnavailable = selectableType !== selectedType
99
+ const subscriptionTip =
100
+ selectableType === 'claude-code'
101
+ ? 'Tip: you can use your existing Claude subscription in moi'
102
+ : selectableType === 'codex'
103
+ ? 'Tip: you can use your existing ChatGPT subscription in moi'
104
+ : undefined
97
105
 
98
106
  useEffect(() => {
99
107
  if (selectableType && selectedUnavailable) onTypeChange(selectableType)
@@ -106,11 +114,16 @@ export function WorkspaceAgentStep({
106
114
  <DialogDescription>{WORKSPACE_AGENT_DESCRIPTION}</DialogDescription>
107
115
  </div>
108
116
 
109
- <WorkspaceAgentSelector
110
- options={options}
111
- selectedType={selectedUnavailable ? undefined : selectedType}
112
- onTypeChange={onTypeChange}
113
- />
117
+ <div className="flex flex-col gap-4">
118
+ <WorkspaceAgentSelector
119
+ options={options}
120
+ selectedType={selectedUnavailable ? undefined : selectedType}
121
+ onTypeChange={onTypeChange}
122
+ />
123
+ {!hasSentMessageFromMoi && subscriptionTip && (
124
+ <p className="text-sm text-muted-foreground">{subscriptionTip}</p>
125
+ )}
126
+ </div>
114
127
 
115
128
  {errorMessage && (
116
129
  <p role="alert" className="text-xs text-destructive">
@@ -183,7 +196,7 @@ function WorkspaceAgentOptionButton({
183
196
  onSelect(option.type)
184
197
  }}
185
198
  className={cn(
186
- 'relative flex w-full flex-col items-start justify-between gap-6 rounded-lg bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
199
+ 'relative flex w-full 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',
187
200
  !selected && 'opacity-70',
188
201
  !selected && !option.disabled && 'cursor-pointer hover:opacity-100',
189
202
  option.disabled && 'cursor-not-allowed'