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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/client/api/app-config.ts +51 -0
  2. package/client/api/workspace-keys.ts +1 -0
  3. package/client/app/routes/WorkspaceRoute.tsx +4 -2
  4. package/client/features/applets/api.ts +38 -0
  5. package/client/features/applets/applet-thumbnail.ts +208 -0
  6. package/client/features/chat/ChatEmptyState.tsx +5 -3
  7. package/client/features/chat/ChatPanel.tsx +2 -8
  8. package/client/features/chat/ChatSelector.tsx +29 -10
  9. package/client/features/chat/MarkdownContent.tsx +2 -2
  10. package/client/features/home/HomePage.tsx +13 -0
  11. package/client/features/home/WorkspacePreview.tsx +10 -5
  12. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
  13. package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
  14. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
  15. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
  16. package/client/features/views/ViewBuilder.tsx +18 -4
  17. package/client/features/views/ViewManager.tsx +18 -2
  18. package/client/features/widgets/WidgetFrame.tsx +1 -1
  19. package/client/features/widgets/WidgetGrid.tsx +1 -1
  20. package/client/features/widgets/Widgets.tsx +16 -15
  21. package/client/features/workspace/CustomizePanel.tsx +29 -8
  22. package/client/features/workspace/WorkspaceScreen.tsx +8 -14
  23. package/client/index.tsx +6 -1
  24. package/client/runtime/useWorkspaceEvents.ts +17 -0
  25. package/client/runtime/workspace-theme.ts +29 -6
  26. package/dist/chunk-5c19v3zr.js +10 -0
  27. package/dist/chunk-6wx91x8j.js +1 -0
  28. package/dist/chunk-8s41nd3g.js +1 -0
  29. package/dist/{chunk-6w6j9g4b.js → chunk-a7fzp0z0.js} +2 -2
  30. package/dist/{chunk-pp62fnxh.js → chunk-b959mdkj.js} +1 -1
  31. package/dist/chunk-cagtq45k.js +1 -0
  32. package/dist/chunk-cva7jpt4.js +82 -0
  33. package/dist/chunk-sapvd7he.css +1 -0
  34. package/dist/{chunk-sxc24vfp.js → chunk-zbeq02yc.js} +1 -1
  35. package/dist/chunk-zbt8emsw.js +2 -0
  36. package/dist/chunk-zfz3b4xg.js +2 -0
  37. package/dist/index.html +1 -1
  38. package/lib/types.ts +60 -41
  39. package/package.json +1 -1
  40. package/server/api.ts +69 -31
  41. package/server/app-config.ts +144 -0
  42. package/server/applets.ts +17 -0
  43. package/server/cli.ts +47 -11
  44. package/server/layout.ts +40 -45
  45. package/server/moi-scaffold.ts +37 -1
  46. package/server/thumbnails.ts +197 -0
  47. package/server/views.ts +10 -1
  48. package/server/widgets.ts +4 -18
  49. package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
  50. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
  51. package/client/features/drawings/annotation-availability.ts +0 -10
  52. package/client/features/widgets/api.ts +0 -47
  53. package/client/features/widgets/useWidgetThumbnails.ts +0 -107
  54. package/client/features/widgets/widget-snapshot.ts +0 -71
  55. package/dist/chunk-3becmq75.js +0 -81
  56. package/dist/chunk-8ew39cvq.js +0 -10
  57. package/dist/chunk-c8gtrjwp.js +0 -1
  58. package/dist/chunk-v964b5g7.js +0 -1
  59. package/dist/chunk-zx33ts9d.css +0 -1
@@ -0,0 +1,51 @@
1
+ import { useSyncExternalStore } from 'react'
2
+
3
+ import type { ClientAppConfig } from '@/lib/types'
4
+
5
+ import { onWorkspaceEventsReconnect } from '@/client/runtime/useWorkspaceEvents'
6
+
7
+ import { requestJson } from './http'
8
+
9
+ // Startup config (GET /api/config): frozen for the server process lifetime,
10
+ // so it is fetched once before the app mounts (see init() in index.tsx) and
11
+ // read synchronously everywhere after that — no query, no loading states.
12
+ // The one thing that can change it is a server restart; the events socket
13
+ // reconnecting is that signal, so the store re-fetches there.
14
+
15
+ const DEFAULTS: ClientAppConfig = {
16
+ cloudDemo: false,
17
+ experiments: [],
18
+ demoInstallUrl: 'https://moi.computer'
19
+ }
20
+
21
+ let current: ClientAppConfig = DEFAULTS
22
+ const listeners = new Set<() => void>()
23
+
24
+ function subscribe(listener: () => void): () => void {
25
+ listeners.add(listener)
26
+ return () => {
27
+ listeners.delete(listener)
28
+ }
29
+ }
30
+
31
+ // Failures keep the last known value (defaults on the very first fetch):
32
+ // non-demo is the safe presentation, and the server still enforces its gates.
33
+ async function fetchAppConfig(): Promise<void> {
34
+ try {
35
+ current = await requestJson<ClientAppConfig>('/api/config')
36
+ for (const listener of listeners) listener()
37
+ } catch {}
38
+ }
39
+
40
+ // Called once from init() before the app mounts; never rejects, so a config
41
+ // hiccup cannot block the app from starting.
42
+ export async function loadAppConfig(): Promise<void> {
43
+ await fetchAppConfig()
44
+ onWorkspaceEventsReconnect(() => {
45
+ void fetchAppConfig()
46
+ })
47
+ }
48
+
49
+ export function useAppConfig(): ClientAppConfig {
50
+ return useSyncExternalStore(subscribe, () => current)
51
+ }
@@ -5,6 +5,7 @@ export const workspaceKeys = {
5
5
  preview: (id: string) => ['workspaces', 'preview', id] as const,
6
6
  layout: (id: string) => ['workspaces', 'layout', id] as const,
7
7
  widgets: (id: string) => ['workspaces', 'widgets', id] as const,
8
+ appletThumbnails: (id: string) => ['workspaces', 'applet-thumbnails', id] as const,
8
9
  views: (id: string) => ['workspaces', 'views', id] as const,
9
10
  viewBuilders: (id: string) => ['workspaces', 'view-builders', id] as const,
10
11
  sessions: (id: string) => ['workspaces', 'sessions', id] as const,
@@ -46,10 +46,12 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
46
46
  if (event.type === 'theme:updated' || event.type === 'workspace:updated') {
47
47
  queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
48
48
  } else if (event.type === 'widget-layout:updated' || event.type === 'widget:updated') {
49
- // widget:updated too: a rebundle bumps the widget's content `tag`, and
49
+ // widget:updated too: a rebundle bumps the widget's content revision, and
50
50
  // the thumbnail invalidation hook reads it off this query.
51
51
  queryClient.invalidateQueries({ queryKey: workspaceKeys.widgets(id) })
52
- } else if (event.type === 'view-layout:updated') {
52
+ } else if (event.type === 'view-layout:updated' || event.type === 'view:updated') {
53
+ // view:updated also bumps the built bundle revision used by thumbnail
54
+ // freshness checks.
53
55
  queryClient.invalidateQueries({ queryKey: workspaceKeys.views(id) })
54
56
  }
55
57
  })
@@ -0,0 +1,38 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
2
+
3
+ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
+ import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
5
+ import { workspaceKeys } from '@/client/api/workspace-keys'
6
+ import type { AppletThumbnail, AppletThumbnailBatch } from '@/lib/types'
7
+
8
+ // Freshness records only — image bytes stay server-side (`.moi/.cache`) and
9
+ // reach the UI as plain <img> URLs.
10
+ export function useAppletThumbnailRecords(workspaceId: string) {
11
+ return useQuery<AppletThumbnail[]>({
12
+ queryKey: workspaceKeys.appletThumbnails(workspaceId),
13
+ queryFn: async () =>
14
+ (
15
+ await requestJson<{ thumbnails: AppletThumbnail[] }>(
16
+ `/api/workspaces/${workspaceId}/applet-thumbnails`
17
+ )
18
+ ).thumbnails,
19
+ ...WORKSPACE_RESOURCE_OPTIONS
20
+ })
21
+ }
22
+
23
+ export function useSaveAppletThumbnails(workspaceId: string) {
24
+ const queryClient = useQueryClient()
25
+
26
+ return useMutation<void, Error, AppletThumbnailBatch>({
27
+ mutationFn: input =>
28
+ requestVoid(
29
+ `/api/workspaces/${workspaceId}/applet-thumbnails`,
30
+ jsonRequest('PUT', input),
31
+ 'Failed to save applet thumbnails'
32
+ ),
33
+ onSuccess: () => {
34
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.appletThumbnails(workspaceId) })
35
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.preview(workspaceId) })
36
+ }
37
+ })
38
+ }
@@ -0,0 +1,208 @@
1
+ import { useEffect, useRef } from 'react'
2
+
3
+ import { useAppletThumbnailRecords, useSaveAppletThumbnails } from '@/client/features/applets/api'
4
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
5
+ import type { AppletKind, AppletThumbnail, AppletThumbnailUpdate } from '@/lib/types'
6
+
7
+ export const THUMBNAIL_MAX_EDGE = 1_000
8
+ export const THUMBNAIL_PIXEL_RATIO = 3
9
+ export const THUMBNAIL_FRESH_MS = 3 * 60 * 60 * 1_000
10
+ // A capture that took this long janked the main thread (the DOM clone +
11
+ // style-inline walk is synchronous). Routine age-based re-captures of such a
12
+ // target are skipped; only a rebuilt bundle earns another attempt.
13
+ export const SLOW_CAPTURE_MS = 1_000
14
+
15
+ const THUMBNAIL_FORMAT_REVISION = '1000px-3x-webp-q80-v1'
16
+ const SETTLE_MS = 5_000
17
+ const ASSET_TIMEOUT_MS = 1_000
18
+ const CAPTURE_TIMEOUT_MS = 10_000
19
+
20
+ export type AppletThumbnailTarget = {
21
+ id: string
22
+ revision?: string
23
+ }
24
+
25
+ type AppletThumbnailCaptureTarget = AppletThumbnailTarget & {
26
+ element: HTMLElement | null
27
+ }
28
+
29
+ type UseAppletThumbnailsArgs = {
30
+ kind: AppletKind
31
+ enabled: boolean
32
+ targets: readonly AppletThumbnailTarget[]
33
+ }
34
+
35
+ type CaptureThumbnail = (element: HTMLElement, stripHostChrome: boolean) => Promise<string | null>
36
+
37
+ export function thumbnailScale(element: HTMLElement): number {
38
+ return Math.min(
39
+ THUMBNAIL_PIXEL_RATIO,
40
+ THUMBNAIL_MAX_EDGE / Math.max(element.offsetWidth, element.offsetHeight)
41
+ )
42
+ }
43
+
44
+ export function appletThumbnailRevision(bundleRevision?: string): string {
45
+ return `${THUMBNAIL_FORMAT_REVISION}:${bundleRevision ?? ''}`
46
+ }
47
+
48
+ export function isAppletThumbnailStale(
49
+ record: AppletThumbnail | undefined,
50
+ revision: string,
51
+ now = Date.now()
52
+ ): boolean {
53
+ if (!record || record.revision !== revision) return true
54
+ const capturedAt = Date.parse(record.capturedAt)
55
+ return !Number.isFinite(capturedAt) || now - capturedAt >= THUMBNAIL_FRESH_MS
56
+ }
57
+
58
+ // A slow target is only worth re-capturing when its bundle changed: the new
59
+ // code deserves one measured attempt. A routine age-based refresh of the same
60
+ // bundle is not worth a >1s main-thread stall for a slightly fresher image.
61
+ export function shouldSkipSlowCapture(
62
+ record: AppletThumbnail | undefined,
63
+ revision: string
64
+ ): boolean {
65
+ return (
66
+ record !== undefined &&
67
+ record.revision === revision &&
68
+ record.captureMs !== undefined &&
69
+ record.captureMs >= SLOW_CAPTURE_MS
70
+ )
71
+ }
72
+
73
+ const timeoutNull = (ms: number) =>
74
+ new Promise<null>(resolve => {
75
+ setTimeout(() => resolve(null), ms)
76
+ })
77
+
78
+ async function captureThumbnail(
79
+ element: HTMLElement,
80
+ stripHostChrome: boolean
81
+ ): Promise<string | null> {
82
+ const { createContext, destroyContext, domToDataUrl } = await import('modern-screenshot')
83
+
84
+ const run = async () => {
85
+ const context = await createContext(element, {
86
+ scale: thumbnailScale(element),
87
+ type: 'image/webp',
88
+ quality: 0.8,
89
+ backgroundColor: '#ffffff',
90
+ timeout: ASSET_TIMEOUT_MS,
91
+ ...(stripHostChrome && {
92
+ onCreateForeignObjectSvg: (svg: SVGSVGElement) => {
93
+ const style = document.createElement('style')
94
+ style.textContent =
95
+ '[data-widget-chrome] { border-radius: 0 !important; box-shadow: none !important; }' +
96
+ '[data-widget-chrome]::after { display: none !important; }'
97
+ svg.append(style)
98
+ }
99
+ })
100
+ })
101
+ try {
102
+ return await domToDataUrl(context)
103
+ } finally {
104
+ destroyContext(context)
105
+ }
106
+ }
107
+
108
+ return Promise.race([run(), timeoutNull(CAPTURE_TIMEOUT_MS)])
109
+ }
110
+
111
+ export async function collectAppletThumbnailUpdates(
112
+ kind: AppletKind,
113
+ records: readonly AppletThumbnail[],
114
+ targets: readonly AppletThumbnailCaptureTarget[],
115
+ isCancelled: () => boolean,
116
+ capture: CaptureThumbnail = captureThumbnail,
117
+ now = Date.now()
118
+ ): Promise<AppletThumbnailUpdate[] | null> {
119
+ const updates: AppletThumbnailUpdate[] = []
120
+
121
+ for (const target of targets) {
122
+ if (isCancelled()) return null
123
+ const revision = appletThumbnailRevision(target.revision)
124
+ const record = records.find(item => item.kind === kind && item.id === target.id)
125
+
126
+ if (!isAppletThumbnailStale(record, revision, now)) {
127
+ updates.push({ id: target.id, revision })
128
+ continue
129
+ }
130
+ if (shouldSkipSlowCapture(record, revision)) {
131
+ updates.push({ id: target.id, revision })
132
+ continue
133
+ }
134
+
135
+ if (!target.element) {
136
+ updates.push({ id: target.id, revision, image: null })
137
+ continue
138
+ }
139
+ const started = performance.now()
140
+ const image = await capture(target.element, kind === 'widget').catch(() => null)
141
+ const captureMs = Math.round(performance.now() - started)
142
+ if (isCancelled()) return null
143
+ updates.push({ id: target.id, revision, image, captureMs })
144
+ }
145
+
146
+ return updates
147
+ }
148
+
149
+ // Widgets provide every visible grid cell; a view provides only its active
150
+ // frame. The lifecycle and persistence stay identical for both kinds.
151
+ export function useAppletThumbnails({ kind, enabled, targets }: UseAppletThumbnailsArgs): void {
152
+ const workspaceId = useWorkspaceId()
153
+ const records = useAppletThumbnailRecords(workspaceId).data
154
+ const save = useSaveAppletThumbnails(workspaceId)
155
+ const targetsRef = useRef(targets)
156
+ targetsRef.current = targets
157
+ const recordsRef = useRef(records ?? [])
158
+ recordsRef.current = records ?? []
159
+ const saveRef = useRef(save.mutate)
160
+ saveRef.current = save.mutate
161
+ const targetKey = targets.map(target => `${target.id}@${target.revision ?? ''}`).join('\n')
162
+ // Hold the first pass until the stored records arrive — capturing against an
163
+ // unloaded store would re-screenshot everything on every page load.
164
+ const ready = records !== undefined
165
+
166
+ useEffect(() => {
167
+ if (!enabled || !ready || targetKey === '') return
168
+
169
+ let cancelled = false
170
+ let generation = 0
171
+ let timer: ReturnType<typeof setTimeout> | undefined
172
+
173
+ const schedule = () => {
174
+ generation += 1
175
+ const scheduledGeneration = generation
176
+ if (timer !== undefined) clearTimeout(timer)
177
+ if (document.visibilityState !== 'visible') return
178
+
179
+ timer = setTimeout(async () => {
180
+ timer = undefined
181
+ const thumbnails = await collectAppletThumbnailUpdates(
182
+ kind,
183
+ recordsRef.current,
184
+ targetsRef.current.map(target => ({
185
+ ...target,
186
+ element: document.querySelector<HTMLElement>(
187
+ `[data-applet-thumbnail="${CSS.escape(`${kind}:${target.id}`)}"]`
188
+ )
189
+ })),
190
+ () =>
191
+ cancelled ||
192
+ generation !== scheduledGeneration ||
193
+ document.visibilityState !== 'visible'
194
+ )
195
+ if (!thumbnails || cancelled || document.visibilityState !== 'visible') return
196
+ saveRef.current({ kind, thumbnails })
197
+ }, SETTLE_MS)
198
+ }
199
+
200
+ document.addEventListener('visibilitychange', schedule)
201
+ schedule()
202
+ return () => {
203
+ cancelled = true
204
+ if (timer !== undefined) clearTimeout(timer)
205
+ document.removeEventListener('visibilitychange', schedule)
206
+ }
207
+ }, [enabled, kind, ready, targetKey])
208
+ }
@@ -4,6 +4,7 @@ import {
4
4
  IconFileSearch,
5
5
  IconGhost,
6
6
  IconLayout2,
7
+ IconMessages,
7
8
  IconPiano,
8
9
  IconSketching,
9
10
  IconTableSpark,
@@ -99,7 +100,7 @@ export function resolveChatEmptyState({
99
100
  return 'empty'
100
101
  }
101
102
 
102
- const EMPTY_STATE_STYLES = cn('flex flex-1 flex-col items-center justify-center')
103
+ const EMPTY_STATE_STYLES = cn('flex flex-1 flex-col items-center justify-center self-center')
103
104
 
104
105
  type ChatEmptyStateProps = {
105
106
  kind: ChatEmptyStateKind
@@ -179,8 +180,9 @@ export function ChatWorkspaceWelcome({ disabled = false, onSelectPrompt }: Welco
179
180
 
180
181
  function EmptyState() {
181
182
  return (
182
- <div className={cn(EMPTY_STATE_STYLES, 'gap-1 text-center')}>
183
- <p className="mx-auto max-w-sm px-8 text-sm text-muted-foreground">
183
+ <div className={cn(EMPTY_STATE_STYLES, 'gap-2 text-center text-muted-foreground')}>
184
+ <IconMessages size={56} stroke={0.5} aria-hidden />
185
+ <p className="mx-auto max-w-sm px-8 text-sm">
184
186
  Chat with your agent, create widgets and views, and manage your workspace context from here
185
187
  </p>
186
188
  </div>
@@ -57,7 +57,6 @@ type ChatPanelProps = {
57
57
  annotation?: ComposerAnnotationControls
58
58
  send: (text: string, options?: ChatSendOptions) => void
59
59
  stop: () => void
60
- onSelectSession: (sessionId: string | null) => void
61
60
  // Chat on a separate tab doesn't have a close button
62
61
  onClose?: () => void
63
62
  builderDraft?: ViewBuilderChatDraft
@@ -80,7 +79,6 @@ export function ChatPanel({
80
79
  annotation,
81
80
  send,
82
81
  stop,
83
- onSelectSession,
84
82
  onClose,
85
83
  builderDraft
86
84
  }: ChatPanelProps) {
@@ -161,11 +159,7 @@ export function ChatPanel({
161
159
  return (
162
160
  <div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
163
161
  <header className="mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] items-center justify-between pr-2 pb-2 pl-2">
164
- {builderDraft ? (
165
- <div className="flex h-7 items-center px-2.5 text-sm font-medium">Build a new view</div>
166
- ) : (
167
- <ChatSelector selectedSessionId={sessionId ?? null} onSelectSession={onSelectSession} />
168
- )}
162
+ <ChatSelector isViewBuilder={!!builderDraft} />
169
163
  {onClose && docked && (
170
164
  <Tooltip>
171
165
  <TooltipTrigger
@@ -190,7 +184,7 @@ export function ChatPanel({
190
184
  ref={scrollRef}
191
185
  className="flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-8 [--scroll-fade-reveal:8px]"
192
186
  >
193
- <div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col items-center gap-6">
187
+ <div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6">
194
188
  {showEmptyState && (
195
189
  <ChatEmptyState
196
190
  kind={emptyStateKind}
@@ -4,6 +4,7 @@ import { IconArchive, IconChevronDown, IconEdit } from '@tabler/icons-react'
4
4
  import { useArchiveWorkspaceSession, useWorkspaceSessions } from './api'
5
5
  import { useWorkspaceAgent } from '@/client/features/workspace/api'
6
6
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
7
+ import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
7
8
  import { cn } from '@/client/lib/cn'
8
9
  import {
9
10
  hasRunningBackgroundSession,
@@ -28,8 +29,11 @@ import {
28
29
  import { Spinner } from '@/client/components/ui/spinner'
29
30
 
30
31
  type ChatSelectorProps = {
31
- onSelectSession: (sessionId: string | null) => void
32
- selectedSessionId: string | null
32
+ isViewBuilder?: boolean
33
+ }
34
+
35
+ type ChatHeaderLabelProps = {
36
+ label: string
33
37
  }
34
38
 
35
39
  type ChatSessionGroup = {
@@ -38,6 +42,10 @@ type ChatSessionGroup = {
38
42
  sessions: SessionInfo[]
39
43
  }
40
44
 
45
+ function ChatHeaderLabel({ label }: ChatHeaderLabelProps) {
46
+ return <div className="flex h-7 items-center px-2.5 text-sm font-medium">{label}</div>
47
+ }
48
+
41
49
  // One tiny text badge per row at most: a cron/subagent flavor wins; otherwise
42
50
  // an external origin shows its provider lowercase (e.g. "irc", "telegram").
43
51
  // Plain app chats get none.
@@ -231,8 +239,18 @@ export function groupSessionsByDate(sessions: SessionInfo[], now = new Date()):
231
239
  return [...groups.values()]
232
240
  }
233
241
 
234
- export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelectorProps) {
242
+ export function ChatSelector({ isViewBuilder = false }: ChatSelectorProps) {
243
+ if (isViewBuilder) {
244
+ return <ChatHeaderLabel label="Build a new view" />
245
+ }
246
+
247
+ return <SessionSelector />
248
+ }
249
+
250
+ function SessionSelector() {
235
251
  const workspaceId = useWorkspaceId()
252
+ const [selectedSession, selectSession] = useSelectedSession()
253
+ const selectedSessionId = selectedSession ?? null
236
254
  const [confirmingSessionId, setConfirmingSessionId] = useState<string | null>(null)
237
255
  const { data: sessions = [] } = useWorkspaceSessions(workspaceId)
238
256
  const canArchive = useWorkspaceAgent(workspaceId).data?.supportsArchiving === true
@@ -240,14 +258,15 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
240
258
  const hasRunningBackgroundChat = useLive(state =>
241
259
  hasRunningBackgroundSession(state.activity, workspaceId, selectedSessionId)
242
260
  )
261
+
262
+ if (sessions.length === 0) {
263
+ return <ChatHeaderLabel label="New chat" />
264
+ }
265
+
243
266
  const active = sessions.find(s => s.sessionId === selectedSessionId)
244
267
  const label = active?.summary ?? 'New chat'
245
268
  const sessionGroups = groupSessionsByDate(sessions)
246
269
 
247
- function handleSelect(sessionId: string | null) {
248
- onSelectSession(sessionId)
249
- }
250
-
251
270
  function handleMenuOpenChange(open: boolean) {
252
271
  if (!open) setConfirmingSessionId(null)
253
272
  }
@@ -259,7 +278,7 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
259
278
  store.clearAttachments(workspaceId, sessionId)
260
279
  store.clearPreviewsForSession(workspaceId, sessionId)
261
280
  if (selectedSessionId === sessionId) {
262
- onSelectSession(null)
281
+ selectSession(null)
263
282
  }
264
283
  }
265
284
 
@@ -286,7 +305,7 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
286
305
  >
287
306
  <DropdownMenuItem
288
307
  className="shrink-0 gap-1 font-medium text-muted-foreground! **:text-muted-foreground!"
289
- onClick={() => handleSelect(null)}
308
+ onClick={() => selectSession(null)}
290
309
  >
291
310
  <IconEdit size={16} stroke={1.75} />
292
311
  New chat
@@ -305,7 +324,7 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
305
324
  active={selectedSessionId === session.sessionId}
306
325
  canArchive={canArchive}
307
326
  confirmingArchive={confirmingSessionId === session.sessionId}
308
- onSelect={handleSelect}
327
+ onSelect={selectSession}
309
328
  onArchive={handleArchive}
310
329
  onRequestArchive={setConfirmingSessionId}
311
330
  workspaceId={workspaceId}
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from 'react'
2
2
 
3
- import ReactMarkdown from 'react-markdown'
3
+ import ReactMarkdown, { type ExtraProps } from 'react-markdown'
4
4
  import rehypeHighlight from 'rehype-highlight'
5
5
  import remarkGfm from 'remark-gfm'
6
6
 
@@ -10,7 +10,7 @@ const remarkPlugins = [remarkGfm]
10
10
  const rehypePlugins = [rehypeHighlight]
11
11
 
12
12
  const components = {
13
- code({ className, children, ...props }: ComponentProps<'code'>) {
13
+ code({ node: _node, className, children, ...props }: ComponentProps<'code'> & ExtraProps) {
14
14
  return (
15
15
  <code
16
16
  className={cn(
@@ -1,3 +1,5 @@
1
+ import { useState } from 'react'
2
+
1
3
  import { IconChevronRight, IconEggCracked, IconLoader2, IconPlus } from '@tabler/icons-react'
2
4
  import { Link, useLocation } from 'wouter'
3
5
 
@@ -9,8 +11,10 @@ import {
9
11
  } from './api'
10
12
  import { CreateWorkspaceDialog } from './workspace-setup/CreateWorkspaceDialog'
11
13
  import { ImportWorkspaceDialog } from './workspace-setup/ImportWorkspaceDialog'
14
+ import { InstallMoiDialog } from './workspace-setup/InstallMoiDialog'
12
15
  import { useWorkspaceImport } from './workspace-setup/useWorkspaceImport'
13
16
  import { HomeLogo } from './HomeLogo'
17
+ import { useAppConfig } from '@/client/api/app-config'
14
18
  import { Button } from '@/client/components/ui/button'
15
19
  import {
16
20
  Collapsible,
@@ -38,6 +42,8 @@ export function HomePage() {
38
42
  const importFlow = useWorkspaceImport({
39
43
  onSuccess: entry => navigate(`/workspace/${entry.id}`)
40
44
  })
45
+ const appConfig = useAppConfig()
46
+ const [installDialogOpen, setInstallDialogOpen] = useState(false)
41
47
  const discoveredWorkspacesOpen = useUiStore(state => state.discoveredWorkspacesOpen)
42
48
  const setDiscoveredWorkspacesOpen = useUiStore(state => state.setDiscoveredWorkspacesOpen)
43
49
 
@@ -62,6 +68,11 @@ export function HomePage() {
62
68
  const count = workspaces.length
63
69
 
64
70
  function handleAdd(suggestion: DiscoveredWorkspace) {
71
+ // Cloud demo: adding workspaces is off — offer the install dialog instead.
72
+ if (appConfig.cloudDemo) {
73
+ setInstallDialogOpen(true)
74
+ return
75
+ }
65
76
  importFlow.startImport(suggestion)
66
77
  }
67
78
 
@@ -149,6 +160,8 @@ export function HomePage() {
149
160
  onReset={importFlow.reset}
150
161
  />
151
162
  )}
163
+
164
+ <InstallMoiDialog open={installDialogOpen} onOpenChange={setInstallDialogOpen} />
152
165
  </div>
153
166
  )
154
167
  }
@@ -1,7 +1,10 @@
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
+ import {
5
+ getWorkspaceThemeColorStyle,
6
+ getWorkspaceThemeStyle
7
+ } from '@/client/runtime/workspace-theme'
5
8
 
6
9
  import { useWorkspacePreview } from './api'
7
10
 
@@ -85,7 +88,7 @@ function useFolderRadiusScale() {
85
88
  return { ref, horizontalRadiusScale }
86
89
  }
87
90
 
88
- // Bottom-to-top placement for up to three widget screenshots. Each card peeks
91
+ // Bottom-to-top placement for up to three applet thumbnails. Each card peeks
89
92
  // out of the folder at a slightly different angle and lifts on card hover.
90
93
  const STACK = [
91
94
  cn(
@@ -115,9 +118,10 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
115
118
  const backdropPath = folderBackdropPath(horizontalRadiusScale)
116
119
  const noiseFilterId = `folder-noise-${workspaceId}`
117
120
  const themeStyle = getWorkspaceThemeStyle(theme)
121
+ const folderThemeStyle = getWorkspaceThemeColorStyle(theme)
118
122
 
119
123
  return (
120
- <div ref={ref} style={themeStyle} className="relative h-45 w-full font-sans">
124
+ <div ref={ref} style={folderThemeStyle} className="relative h-45 w-full">
121
125
  <svg
122
126
  viewBox={`0 0 ${FOLDER.width} ${FOLDER.height}`}
123
127
  preserveAspectRatio="none"
@@ -158,7 +162,7 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
158
162
  alt=""
159
163
  loading="lazy"
160
164
  className={cn(
161
- 'absolute top-[12%] left-[14%] aspect-4/3 w-[72%] rounded-lg object-cover object-top shadow-xs',
165
+ 'absolute top-[12%] left-[14%] h-auto max-h-[72%] w-auto max-w-[72%] rounded-[calc(var(--radius-2xl)*0.4)] bg-background object-contain shadow-xs [corner-shape:superellipse(1.2)]',
162
166
  'animate-in transition-transform duration-300 ease-out fade-in',
163
167
  slots[index]
164
168
  )}
@@ -169,8 +173,9 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
169
173
  <div className="absolute inset-x-[12%] top-[22%] flex justify-end">
170
174
  <div
171
175
  aria-hidden="true"
176
+ style={themeStyle}
172
177
  className={cn(
173
- 'w-max max-w-40 origin-center rounded-lg bg-card px-3 py-2 shadow-xs',
178
+ 'w-max max-w-40 origin-center rounded-lg bg-card px-3 py-2 font-sans shadow-xs',
174
179
  'animate-in transition-transform duration-300 ease-out fade-in',
175
180
  STACK[STACK.length - 1],
176
181
  'group-hover:translate-y-0.5 group-focus-visible:translate-y-0.5'
@@ -3,6 +3,7 @@ import { type FormEvent, type ReactElement, useState } from 'react'
3
3
  import { useLocation } from 'wouter'
4
4
 
5
5
  import { useCreateWorkspace, useWorkspaceSetupInfo } from '../api'
6
+ import { useAppConfig } from '@/client/api/app-config'
6
7
  import { Button } from '@/client/components/ui/button'
7
8
  import {
8
9
  Dialog,
@@ -16,6 +17,7 @@ import { validateWorkspaceFolderName } from '@/lib/workspace-name'
16
17
  import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
17
18
  import type { WorkspaceType } from '@/lib/types'
18
19
 
20
+ import { InstallMoiDialog } from './InstallMoiDialog'
19
21
  import { WorkspaceAgentStep } from './WorkspaceAgentStep'
20
22
  import { WorkspaceDialogContent } from './WorkspaceDialogContent'
21
23
 
@@ -29,6 +31,7 @@ const DEFAULT_WORKSPACE_TYPE = WORKSPACE_TYPE_ORDER[0]
29
31
 
30
32
  export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
31
33
  const [, navigate] = useLocation()
34
+ const appConfig = useAppConfig()
32
35
  const info = useWorkspaceSetupInfo()
33
36
  const createMutation = useCreateWorkspace()
34
37
 
@@ -41,6 +44,12 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
41
44
  const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
42
45
  const isCreating = createMutation.isPending
43
46
 
47
+ // Cloud demo: creating workspaces is off — the same trigger opens the
48
+ // install-moi dialog instead. After every hook so the hook order is stable.
49
+ if (appConfig.cloudDemo) {
50
+ return <InstallMoiDialog trigger={trigger} />
51
+ }
52
+
44
53
  function finish(workspaceId: string) {
45
54
  setOpen(false)
46
55
  navigate(`/workspace/${workspaceId}`)