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,245 @@
1
+ import { type ReactElement, useEffect, useState } from 'react'
2
+
3
+ import {
4
+ IconArrowUpRight,
5
+ IconCheck,
6
+ IconCopy,
7
+ IconFolders,
8
+ IconTerminal2,
9
+ IconX
10
+ } from '@tabler/icons-react'
11
+
12
+ import claudeIcon from '@/client/assets/claude.svg'
13
+ import hermesIcon from '@/client/assets/hermes.png'
14
+ import openaiIcon from '@/client/assets/openai.svg'
15
+ import openclawIcon from '@/client/assets/openclaw.svg'
16
+ import { Button } from '@/client/components/ui/button'
17
+ import {
18
+ Dialog,
19
+ DialogClose,
20
+ DialogContent,
21
+ DialogDescription,
22
+ DialogTitle,
23
+ DialogTrigger
24
+ } from '@/client/components/ui/dialog'
25
+ import { useAppConfig } from '@/client/api/app-config'
26
+
27
+ // The canonical setup prompt from moi.computer — pasted into any agent, it
28
+ // fetches INSTALL.md and walks itself through the install.
29
+ const AGENT_COMMAND =
30
+ 'Set up the moi workspace for this project. Fetch https://moi.computer/INSTALL.md, and follow the steps.'
31
+
32
+ type InstallMoiDialogProps = {
33
+ // Trigger-owned (uncontrolled) or controlled via open/onOpenChange — the
34
+ // create-workspace buttons use the former, programmatic opens the latter.
35
+ trigger?: ReactElement
36
+ open?: boolean
37
+ onOpenChange?: (open: boolean) => void
38
+ }
39
+
40
+ // Shown in the cloud demo wherever a workspace would be created: the demo is
41
+ // limited to its built-in workspaces, and the way out is installing moi.
42
+ export function InstallMoiDialog({ trigger, open, onOpenChange }: InstallMoiDialogProps) {
43
+ return (
44
+ <Dialog open={open} onOpenChange={onOpenChange}>
45
+ {trigger && <DialogTrigger render={trigger} />}
46
+ <InstallMoiDialogContent />
47
+ </Dialog>
48
+ )
49
+ }
50
+
51
+ // Hero artwork: a floppy disk cropped by the band, on a soft gradient. The
52
+ // gradient's raw colors are a deliberate owner-approved exception to the
53
+ // semantic-token rule — this block is an illustration (constant across
54
+ // themes), not a UI surface.
55
+ function FloppyHero() {
56
+ return (
57
+ <div className="relative h-44 overflow-hidden rounded-lg bg-[#e6dcc4] bg-[image:radial-gradient(75%_110%_at_0%_0%,#e0742f_0%,rgba(224,116,47,0)_48%),radial-gradient(110%_160%_at_100%_0%,#16352a_0%,rgba(22,53,42,0)_60%),radial-gradient(70%_90%_at_90%_100%,#8fb492_0%,rgba(143,180,146,0)_55%),radial-gradient(60%_80%_at_8%_100%,#dcc294_0%,rgba(220,194,148,0)_52%)]">
58
+ <FloppyDisk className="absolute top-9 left-1/2 w-52 -translate-x-1/2 -rotate-6 drop-shadow-xl" />
59
+ {/* film grain, keeps the flat gradients from banding */}
60
+ <svg
61
+ className="absolute inset-0 size-full opacity-30 mix-blend-soft-light"
62
+ aria-hidden="true"
63
+ >
64
+ <filter id="floppy-grain">
65
+ <feTurbulence
66
+ type="fractalNoise"
67
+ baseFrequency="0.8"
68
+ numOctaves="2"
69
+ stitchTiles="stitch"
70
+ />
71
+ </filter>
72
+ <rect width="100%" height="100%" filter="url(#floppy-grain)" />
73
+ </svg>
74
+ </div>
75
+ )
76
+ }
77
+
78
+ type FloppyDiskProps = {
79
+ className?: string
80
+ }
81
+
82
+ // Front view of a 3.5" floppy: shutter with window, insert arrow, label
83
+ // area, write-protect holes. Drawn inline so it stays crisp and asset-free.
84
+ function FloppyDisk({ className }: FloppyDiskProps) {
85
+ return (
86
+ <svg viewBox="0 0 200 200" aria-hidden="true" className={className}>
87
+ <defs>
88
+ <linearGradient id="floppy-shutter" x1="0" y1="0" x2="0" y2="1">
89
+ <stop offset="0" stopColor="#e3e3e1" />
90
+ <stop offset="0.5" stopColor="#c8c8c6" />
91
+ <stop offset="1" stopColor="#aeaeac" />
92
+ </linearGradient>
93
+ </defs>
94
+ {/* body with clipped top-right corner */}
95
+ <path
96
+ d="M14 2h146l26 26v160a10 10 0 0 1-10 10H14A10 10 0 0 1 4 188V12A10 10 0 0 1 14 2Z"
97
+ fill="#1a1b1d"
98
+ />
99
+ <path
100
+ d="M14 2h146l26 26v160a10 10 0 0 1-10 10H14A10 10 0 0 1 4 188V12A10 10 0 0 1 14 2Z"
101
+ fill="none"
102
+ stroke="#ffffff"
103
+ strokeOpacity="0.08"
104
+ strokeWidth="1.5"
105
+ />
106
+ {/* shutter */}
107
+ <path d="M64 2h96v66a6 6 0 0 1-6 6H70a6 6 0 0 1-6-6V2Z" fill="url(#floppy-shutter)" />
108
+ <rect x="116" y="12" width="28" height="52" rx="3" fill="#191a1c" />
109
+ {/* insert arrow */}
110
+ <path d="M26 30 34 16l8 14h-5v14h-6V30Z" fill="#0e0f10" />
111
+ {/* label area */}
112
+ <rect
113
+ x="22"
114
+ y="92"
115
+ width="156"
116
+ height="106"
117
+ rx="8"
118
+ fill="#202124"
119
+ stroke="#ffffff"
120
+ strokeOpacity="0.05"
121
+ />
122
+ {/* write-protect holes */}
123
+ <rect x="14" y="168" width="13" height="13" rx="2" fill="#0c0d0e" />
124
+ <rect x="172" y="168" width="13" height="13" rx="2" fill="#0c0d0e" />
125
+ <rect x="175" y="171" width="7" height="7" rx="1" fill="#e6e6e4" />
126
+ </svg>
127
+ )
128
+ }
129
+
130
+ function useCopyCommand() {
131
+ const [copied, setCopied] = useState(false)
132
+
133
+ useEffect(() => {
134
+ if (!copied) return
135
+ const t = setTimeout(() => setCopied(false), 1500)
136
+ return () => clearTimeout(t)
137
+ }, [copied])
138
+
139
+ const copy = () => {
140
+ navigator.clipboard
141
+ ?.writeText(AGENT_COMMAND)
142
+ .then(() => setCopied(true))
143
+ .catch(() => {})
144
+ }
145
+
146
+ return { copied, copy }
147
+ }
148
+
149
+ function InstallMoiDialogContent() {
150
+ const { demoInstallUrl } = useAppConfig()
151
+ const { copied, copy } = useCopyCommand()
152
+
153
+ return (
154
+ <DialogContent className="w-[calc(100%-2rem)] max-w-md">
155
+ <div className="p-2">
156
+ <FloppyHero />
157
+ </div>
158
+ <DialogClose
159
+ render={
160
+ <Button
161
+ variant="ghost"
162
+ size="icon-sm"
163
+ aria-label="Close"
164
+ className="absolute top-4 right-4 text-white hover:bg-white/20 hover:text-white"
165
+ >
166
+ <IconX stroke={1.75} />
167
+ </Button>
168
+ }
169
+ />
170
+
171
+ <div className="flex flex-col gap-5 p-6 pt-3">
172
+ <div className="flex flex-col gap-0.5">
173
+ <DialogTitle>Use moi with your projects</DialogTitle>
174
+ <DialogDescription>
175
+ This demo comes with sample workspaces. Connect moi to your agent to unlock all
176
+ features.
177
+ </DialogDescription>
178
+ </div>
179
+
180
+ <ul className="flex flex-col gap-3">
181
+ <li className="flex items-center gap-3">
182
+ <span className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted">
183
+ <IconFolders size={20} stroke={1.5} />
184
+ </span>
185
+ <span className="text-sm text-foreground">
186
+ Connect your own data and import existing projects
187
+ </span>
188
+ </li>
189
+ <li className="flex items-center gap-3">
190
+ <span className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted">
191
+ <IconTerminal2 size={20} stroke={1.5} />
192
+ </span>
193
+ <span className="flex flex-wrap items-center gap-x-1 gap-y-0.5 text-sm text-foreground">
194
+ <span>Works with</span>
195
+ <span className="inline-flex items-center gap-1 font-medium">
196
+ <img src={claudeIcon} alt="" className="size-4 object-contain" />
197
+ Claude Code,
198
+ </span>
199
+ <span className="inline-flex items-center gap-1 font-medium">
200
+ <img src={openaiIcon} alt="" className="size-4 object-contain" />
201
+ Codex,
202
+ </span>
203
+ <span className="inline-flex items-center gap-1 font-medium">
204
+ <img src={hermesIcon} alt="" className="size-4 object-contain" />
205
+ Hermes,
206
+ </span>
207
+ <span className="inline-flex items-center gap-1 font-medium">
208
+ <img src={openclawIcon} alt="" className="size-4 object-contain" />
209
+ OpenClaw,
210
+ </span>
211
+ <span>and more.</span>
212
+ </span>
213
+ </li>
214
+ </ul>
215
+
216
+ <div className="flex flex-col gap-2">
217
+ <p className="text-sm text-muted-foreground">Paste this prompt into your agent:</p>
218
+ <div className="rounded-lg bg-muted p-3">
219
+ <code className="block font-mono text-sm leading-relaxed text-foreground">
220
+ {AGENT_COMMAND}
221
+ </code>
222
+ <div className="mt-5 flex flex-wrap items-center gap-2">
223
+ <Button type="button" onClick={copy}>
224
+ {copied ? (
225
+ <IconCheck data-icon="inline-start" stroke={1.5} />
226
+ ) : (
227
+ <IconCopy data-icon="inline-start" stroke={1.5} />
228
+ )}
229
+ {copied ? 'Copied' : 'Copy installation prompt'}
230
+ </Button>
231
+ <Button
232
+ variant="secondary"
233
+ nativeButton={false}
234
+ render={<a href={demoInstallUrl} target="_blank" rel="noreferrer" />}
235
+ >
236
+ Learn more
237
+ <IconArrowUpRight data-icon="inline-end" stroke={1.5} />
238
+ </Button>
239
+ </div>
240
+ </div>
241
+ </div>
242
+ </div>
243
+ </DialogContent>
244
+ )
245
+ }
@@ -162,7 +162,7 @@ function WorkspaceAgentSelector({
162
162
  <div
163
163
  role="group"
164
164
  aria-label="Agent"
165
- className={cn('grid gap-2', options.length > 2 ? 'grid-cols-3' : 'grid-cols-2')}
165
+ className={cn('grid gap-2', options.length > 2 ? 'grid-cols-4' : 'grid-cols-2')}
166
166
  >
167
167
  {options.map(option => (
168
168
  <WorkspaceAgentOptionButton
@@ -15,7 +15,7 @@ export function WorkspaceDialogContent({
15
15
  closeDisabled = false
16
16
  }: WorkspaceDialogContentProps) {
17
17
  return (
18
- <DialogContent className="w-[calc(100%-2rem)] max-w-md p-6">
18
+ <DialogContent className="w-[calc(100%-2rem)] max-w-xl p-6">
19
19
  <DialogClose
20
20
  render={
21
21
  <Button
@@ -2,9 +2,13 @@ import type { ReactNode, Ref } from 'react'
2
2
  import { useImperativeHandle } from 'react'
3
3
 
4
4
  import { Button } from '@/client/components/ui/button'
5
+ import { Spinner } from '@/client/components/ui/spinner'
5
6
  import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
6
7
  import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
7
- import { useDrawingHistoryState } from '@/client/features/drawings/useDrawingLayer'
8
+ import {
9
+ type DrawingControls,
10
+ useDrawingHistoryState
11
+ } from '@/client/features/drawings/useDrawingLayer'
8
12
  import {
9
13
  type ViewBuilderSketchController,
10
14
  useViewBuilderSketch
@@ -137,7 +141,7 @@ function ViewBuilderSketchSurface({
137
141
  'animate-glow texture-inset-shadow-50% motion-reduce:animate-none'
138
142
  )}
139
143
  />
140
- {status === 'building' && <ViewBuilderBuildingState />}
144
+ {status === 'building' && <ViewBuilderBuildingState controls={sketch.controls} />}
141
145
  {status === 'waiting' && (
142
146
  <ViewBuilderWaitingState error={error} onDiscard={onDiscard} onOpenChat={onOpenChat} />
143
147
  )}
@@ -201,8 +205,18 @@ function ViewBuilderWaitingState({ error, onDiscard, onOpenChat }: ViewBuilderWa
201
205
  )
202
206
  }
203
207
 
204
- function ViewBuilderBuildingState() {
205
- return <ViewBuilderStatusLayout />
208
+ type ViewBuilderBuildingStateProps = {
209
+ controls: DrawingControls
210
+ }
211
+
212
+ function ViewBuilderBuildingState({ controls }: ViewBuilderBuildingStateProps) {
213
+ const { hasStrokes } = useDrawingHistoryState(controls)
214
+
215
+ return (
216
+ <ViewBuilderStatusLayout>
217
+ {!hasStrokes && <Spinner className="size-6 text-muted-foreground" />}
218
+ </ViewBuilderStatusLayout>
219
+ )
206
220
  }
207
221
 
208
222
  type ViewBuilderStatusLayoutProps = {
@@ -18,6 +18,7 @@ import { Activity, type ComponentType, useCallback, useEffect, useRef, useState
18
18
  import { Spinner } from '@/client/components/ui/spinner'
19
19
  import { appletScope, appletStyleKey } from '@/client/features/applets/applet-cache'
20
20
  import { useAppletStyle } from '@/client/features/applets/applet-styles'
21
+ import { useAppletThumbnails } from '@/client/features/applets/applet-thumbnail'
21
22
  import {
22
23
  type AppletComponentProps,
23
24
  type AppletState,
@@ -140,6 +141,16 @@ function ViewSlot({ view, active, params }: ViewSlotProps) {
140
141
  )
141
142
 
142
143
  const failed = bundle.status === 'error'
144
+ useAppletThumbnails({
145
+ kind: 'view',
146
+ enabled: active && Boolean(current) && !failed,
147
+ targets: [
148
+ {
149
+ id: view.id,
150
+ revision: view.revision
151
+ }
152
+ ]
153
+ })
143
154
 
144
155
  return (
145
156
  <>
@@ -161,6 +172,7 @@ function ViewSlot({ view, active, params }: ViewSlotProps) {
161
172
  build={current}
162
173
  params={shownParams}
163
174
  entering={outgoing !== null}
175
+ thumbnailTarget
164
176
  />
165
177
  </Activity>
166
178
  )}
@@ -175,18 +187,22 @@ type ViewFrameProps = {
175
187
  // Play the rebuild dissolve. Set on the incoming build only, and only while
176
188
  // the build it replaced is still rendered underneath it.
177
189
  entering?: boolean
190
+ thumbnailTarget?: boolean
178
191
  }
179
192
 
180
193
  // One build of one view, in its style scope. Frames stack absolutely, so during
181
194
  // a rebuild the incoming one dissolves in over the outgoing one still on screen.
182
- function ViewFrame({ view, build, params, entering }: ViewFrameProps) {
195
+ function ViewFrame({ view, build, params, entering, thumbnailTarget }: ViewFrameProps) {
183
196
  const workspaceId = useWorkspaceId()
184
197
 
185
198
  return (
186
199
  <div
200
+ data-applet-thumbnail={thumbnailTarget ? `view:${view.id}` : undefined}
187
201
  data-applet={appletScope('views', view.id)}
188
202
  className={cn(
189
- 'absolute inset-0 overflow-auto',
203
+ // Keep applet z-indexes inside the view. Host overlays render after this
204
+ // frame and should always stack above the view as a single unit.
205
+ 'absolute inset-0 isolate overflow-auto',
190
206
  entering && 'animate-in duration-200 ease-out blur-in-4 fade-in'
191
207
  )}
192
208
  >
@@ -36,7 +36,7 @@ export function WidgetFrame({ editing, hidden, onRemove, children }: WidgetFrame
36
36
  className="group/widget relative size-full"
37
37
  >
38
38
  <div
39
- // Stable hook for widget snapshots: the capture clone overrides this
39
+ // Stable hook for widget thumbnails: the capture clone overrides this
40
40
  // element's chrome (radius/shadow/stroke) so thumbnails come out square.
41
41
  data-widget-chrome
42
42
  style={getWorkspaceThemeStyle(theme, 'widget')}
@@ -79,7 +79,7 @@ export function WidgetGridLayout({
79
79
  <div key={item.i}>
80
80
  <motion.div
81
81
  layoutId={item.i}
82
- data-snapshot-widget={item.i}
82
+ data-applet-thumbnail={`widget:${item.i}`}
83
83
  className="size-full"
84
84
  transition={{ type: 'spring', duration: 0.35, bounce: 0 }}
85
85
  >
@@ -1,9 +1,10 @@
1
- import { useCallback, useRef, useState } from 'react'
1
+ import { useCallback, useState } from 'react'
2
2
 
3
3
  import { AnimatePresence, LayoutGroup, motion } from 'motion/react'
4
4
 
5
5
  import { IconPlus } from '@tabler/icons-react'
6
6
 
7
+ import { useAppletThumbnails } from '@/client/features/applets/applet-thumbnail'
7
8
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
8
9
  import { findFreePosition } from '@/client/features/widgets/grid'
9
10
  import type { GridItem } from '@/client/features/widgets/grid'
@@ -15,7 +16,6 @@ import type { WidgetInfo } from '@/lib/types'
15
16
 
16
17
  import { HiddenPanel } from './HiddenPanel'
17
18
  import { WidgetGrid, WidgetGridLayout } from './WidgetGrid'
18
- import { useWidgetThumbnails } from './useWidgetThumbnails'
19
19
 
20
20
  function renderItem(id: string) {
21
21
  return <WidgetShell name={id} />
@@ -29,7 +29,7 @@ const EMPTY_WIDGET_ITEMS: GridItem[] = Array.from({ length: 10 }, (_, index) =>
29
29
 
30
30
  function renderEmptyWidget() {
31
31
  return (
32
- <Skeleton className="size-full animate-none rounded-2xl [corner-shape:superellipse(1.2)]" />
32
+ <Skeleton className="size-full animate-none rounded-2xl texture-checker [corner-shape:superellipse(1.2)]" />
33
33
  )
34
34
  }
35
35
 
@@ -45,15 +45,15 @@ function NoWidgetsCreated({ onCreateWidget }: NoWidgetsCreatedProps) {
45
45
  </div>
46
46
 
47
47
  <div className="absolute inset-0 flex items-center justify-center p-6">
48
- <div className="flex h-full w-full max-w-(--column-w) flex-col items-center justify-center gap-4 bg-radial from-background from-50% to-transparent to-75% text-center">
48
+ <div className="flex h-full w-full max-w-(--column-w) flex-col items-center justify-center gap-4 bg-radial from-background from-30% to-transparent to-80% text-center">
49
49
  <div className="flex flex-col gap-1.5">
50
50
  <h2 className="font-medium">A little empty here</h2>
51
- <p className="mx-auto max-w-sm text-sm text-muted-foreground">
52
- Widgets are small apps that can read data, perform tasks, and show a compact view of
53
- the information that matters.
51
+ <p className="mx-auto max-w-xs text-sm text-muted-foreground">
52
+ Widgets are small apps that can read data, perform tasks, and surface important
53
+ information
54
54
  </p>
55
55
  </div>
56
- <Button type="button" variant="secondary" size="sm" onClick={onCreateWidget}>
56
+ <Button type="button" variant="secondary" onClick={onCreateWidget}>
57
57
  <IconPlus data-icon="inline-start" stroke={1.5} />
58
58
  Create widget
59
59
  </Button>
@@ -166,12 +166,13 @@ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: W
166
166
  const [panelRef, panelHeight] = usePanelHeight()
167
167
  const panelOpen = editing && hiddenItems.length > 0
168
168
 
169
- const containerRef = useRef<HTMLDivElement>(null)
170
- useWidgetThumbnails({
171
- containerRef,
172
- widgets,
173
- visibleIds: visibleItems.map(item => item.id),
174
- editing
169
+ useAppletThumbnails({
170
+ kind: 'widget',
171
+ enabled: !editing,
172
+ targets: visibleItems.map(item => ({
173
+ id: item.id,
174
+ revision: widgets.find(widget => widget.id === item.id)?.revision
175
+ }))
175
176
  })
176
177
 
177
178
  function hide(id: string) {
@@ -193,7 +194,7 @@ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: W
193
194
  // Shared working area below the header and positioning context for the
194
195
  // bottom panel. Created-widget states scroll; the initial empty state clips
195
196
  // its fixed-height skeleton grid.
196
- <div ref={containerRef} className="group/widgets relative min-h-0 flex-1">
197
+ <div className="group/widgets relative min-h-0 flex-1">
197
198
  <LayoutGroup>
198
199
  <div
199
200
  className={cn(
@@ -24,14 +24,25 @@ const RADIUS_OPTIONS = Object.entries(RADIUS_THEMES) as [RadiusTheme, RadiusThem
24
24
 
25
25
  type CustomizeOptionGroupProps = {
26
26
  children: ReactNode
27
+ className?: string
28
+ gridClassName?: string
27
29
  label: string
28
30
  }
29
31
 
30
- function CustomizeOptionGroup({ children, label }: CustomizeOptionGroupProps) {
32
+ function CustomizeOptionGroup({
33
+ children,
34
+ className,
35
+ gridClassName,
36
+ label
37
+ }: CustomizeOptionGroupProps) {
31
38
  return (
32
- <div className="flex flex-col gap-2">
39
+ <div className={cn('flex flex-col gap-2', className)}>
33
40
  <p className="text-xs font-medium">{label}</p>
34
- <div role="group" aria-label={label} className="grid grid-cols-4 gap-2">
41
+ <div
42
+ role="group"
43
+ aria-label={label}
44
+ className={cn('grid grid-cols-4 gap-2 @4xl/workspace:grid-cols-2', gridClassName)}
45
+ >
35
46
  {children}
36
47
  </div>
37
48
  </div>
@@ -81,9 +92,12 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
81
92
  }
82
93
 
83
94
  return (
84
- <BottomPanel ref={ref} title="Customize" onClose={onClose}>
85
- <div className="flex flex-col gap-4">
86
- <CustomizeOptionGroup label="Font">
95
+ <BottomPanel ref={ref} title="Customize" onClose={onClose} className="@4xl/workspace:max-w-4xl">
96
+ <div className="grid grid-cols-1 gap-4 @4xl/workspace:grid-cols-[repeat(2,minmax(0,1fr))_0.5rem_repeat(2,minmax(0,1fr))_0.5rem_minmax(0,1fr)] @4xl/workspace:gap-x-2">
97
+ <CustomizeOptionGroup
98
+ label="Font"
99
+ className="@4xl/workspace:col-span-2 @4xl/workspace:col-start-1"
100
+ >
87
101
  {FONT_OPTIONS.map(([key, config]) => (
88
102
  <CustomizeOption
89
103
  key={key}
@@ -96,7 +110,10 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
96
110
  ))}
97
111
  </CustomizeOptionGroup>
98
112
 
99
- <CustomizeOptionGroup label="Colors">
113
+ <CustomizeOptionGroup
114
+ label="Colors"
115
+ className="@4xl/workspace:col-span-2 @4xl/workspace:col-start-4"
116
+ >
100
117
  {COLOR_OPTIONS.map(([key, preset]) => (
101
118
  <CustomizeOption
102
119
  key={key}
@@ -122,7 +139,11 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
122
139
  ))}
123
140
  </CustomizeOptionGroup>
124
141
 
125
- <CustomizeOptionGroup label="Radius">
142
+ <CustomizeOptionGroup
143
+ label="Radius"
144
+ className="@4xl/workspace:col-start-7"
145
+ gridClassName="@4xl/workspace:grid-cols-1"
146
+ >
126
147
  {RADIUS_OPTIONS.map(([key, preset]) => (
127
148
  <CustomizeOption
128
149
  key={key}
@@ -12,7 +12,6 @@ import {
12
12
  } from '@tabler/icons-react'
13
13
 
14
14
  import { IconGhost } from '@/client/components/shared/IconGhost'
15
- import { canAnnotateWorkspaceContent } from '@/client/features/drawings/annotation-availability'
16
15
  import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
17
16
  import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
18
17
  import { useChatAnnotation } from '@/client/features/drawings/useChatAnnotation'
@@ -311,11 +310,9 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
311
310
  ? activeBuilder
312
311
  : undefined
313
312
  const activeDraftBuilderId = activeDraftBuilder?.id
314
- const canAnnotate = canAnnotateWorkspaceContent(
315
- activeTab,
316
- widgetMode === 'idle',
317
- activeView !== undefined
318
- )
313
+ const canAnnotate =
314
+ widgetMode === 'idle' &&
315
+ ((activeTab === 'widgets' && widgets.length > 0) || activeView !== undefined)
319
316
  const annotation = useChatAnnotation({
320
317
  workspaceId,
321
318
  sessionId,
@@ -574,7 +571,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
574
571
  composerAvailability={composerAvailability}
575
572
  send={send}
576
573
  stop={stop}
577
- onSelectSession={selectSession}
578
574
  onClose={() => setMode('fullscreen')}
579
575
  annotation={annotation.docked}
580
576
  builderDraft={builderChatDraft}
@@ -595,13 +591,12 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
595
591
  composerAvailability={composerAvailability}
596
592
  send={send}
597
593
  stop={stop}
598
- onSelectSession={selectSession}
599
594
  />
600
595
  )
601
596
  const workspacePanel = (
602
597
  <div
603
598
  className={cn(
604
- 'flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-md transition-[border-radius]',
599
+ '@container/workspace relative flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-md transition-[border-radius]',
605
600
  mode === 'split' && 'rounded-xl'
606
601
  )}
607
602
  >
@@ -672,6 +667,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
672
667
  </DrawingLayer>
673
668
  </div>
674
669
 
670
+ <AnimatePresence>
671
+ {widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
672
+ </AnimatePresence>
673
+
675
674
  <PanelHeader>
676
675
  <div className="flex min-w-0 flex-1 items-center gap-4">
677
676
  <div className="flex items-center gap-2">
@@ -723,10 +722,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
723
722
  )}
724
723
  </div>
725
724
 
726
- <AnimatePresence>
727
- {widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
728
- </AnimatePresence>
729
-
730
725
  {mode === 'fullscreen' && activeTab !== 'agent' && hasWorkspaceContent && (
731
726
  <ChatPopup
732
727
  loading={hasRunningSession}
@@ -751,7 +746,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
751
746
  composerAvailability={composerAvailability}
752
747
  send={send}
753
748
  stop={stop}
754
- onSelectSession={selectSession}
755
749
  onClose={onClose}
756
750
  annotation={annotation.popup}
757
751
  builderDraft={builderChatDraft}
package/client/index.tsx CHANGED
@@ -21,7 +21,12 @@ if (import.meta.hot) {
21
21
  }
22
22
 
23
23
  export async function init(el: HTMLElement) {
24
- const { mount } = await import('./main')
24
+ // Startup config loads in parallel with the main chunk, so it is available
25
+ // synchronously to every component from the first render.
26
+ const [{ mount }] = await Promise.all([
27
+ import('./main'),
28
+ import('./api/app-config').then(m => m.loadAppConfig())
29
+ ])
25
30
  mount(el)
26
31
  }
27
32
 
@@ -56,6 +56,11 @@ export type WorkspaceEvent =
56
56
  type WorkspaceEventHandler = (event: WorkspaceEvent) => void
57
57
 
58
58
  const listeners = new Set<WorkspaceEventHandler>()
59
+ // Fired when the socket comes back after a drop — for the SPA that means the
60
+ // server restarted (it holds the connection for its whole lifetime), so
61
+ // restart-scoped state such as the startup config can refetch.
62
+ const reconnectListeners = new Set<() => void>()
63
+ let everConnected = false
59
64
  let ws: WebSocket | null = null
60
65
  let connecting = false
61
66
 
@@ -68,6 +73,8 @@ function ensureConnection() {
68
73
  socket.onopen = () => {
69
74
  ws = socket
70
75
  connecting = false
76
+ if (everConnected) for (const handler of reconnectListeners) handler()
77
+ everConnected = true
71
78
  }
72
79
 
73
80
  socket.onmessage = event => {
@@ -91,6 +98,16 @@ function ensureConnection() {
91
98
  }
92
99
  }
93
100
 
101
+ // Subscribe to reconnects; returns the unsubscribe. Only fires while some
102
+ // component holds the events socket open via useWorkspaceEvent (the app shell
103
+ // always does).
104
+ export function onWorkspaceEventsReconnect(handler: () => void): () => void {
105
+ reconnectListeners.add(handler)
106
+ return () => {
107
+ reconnectListeners.delete(handler)
108
+ }
109
+ }
110
+
94
111
  export function useWorkspaceEvent(handler: WorkspaceEventHandler) {
95
112
  const handlerRef = useRef(handler)
96
113
  handlerRef.current = handler