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

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 (62) 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/components/ui/button.tsx +1 -1
  5. package/client/features/applets/api.ts +38 -0
  6. package/client/features/applets/applet-thumbnail.ts +208 -0
  7. package/client/features/chat/ChatEmptyState.tsx +5 -3
  8. package/client/features/chat/ChatPanel.tsx +2 -8
  9. package/client/features/chat/ChatSelector.tsx +29 -10
  10. package/client/features/chat/MarkdownContent.tsx +2 -2
  11. package/client/features/home/HomePage.tsx +13 -0
  12. package/client/features/home/WorkspacePreview.tsx +51 -33
  13. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
  14. package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
  15. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
  16. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
  17. package/client/features/views/ViewBuilder.tsx +18 -4
  18. package/client/features/views/ViewManager.tsx +18 -2
  19. package/client/features/widgets/WidgetFrame.tsx +1 -1
  20. package/client/features/widgets/WidgetGrid.tsx +1 -1
  21. package/client/features/widgets/Widgets.tsx +16 -15
  22. package/client/features/workspace/CustomizePanel.tsx +29 -8
  23. package/client/features/workspace/WorkspaceScreen.tsx +8 -14
  24. package/client/index.tsx +6 -1
  25. package/client/runtime/useWorkspaceEvents.ts +17 -0
  26. package/client/runtime/workspace-theme.ts +36 -6
  27. package/dist/chunk-87q78504.js +1 -0
  28. package/dist/chunk-8s41nd3g.js +1 -0
  29. package/dist/{chunk-pp62fnxh.js → chunk-b959mdkj.js} +1 -1
  30. package/dist/chunk-cagtq45k.js +1 -0
  31. package/dist/chunk-ek6zde7t.js +10 -0
  32. package/dist/chunk-n8tq2494.js +82 -0
  33. package/dist/chunk-v82nefjq.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-6w6j9g4b.js → chunk-zcyvyebg.js} +2 -2
  37. package/dist/chunk-zfz3b4xg.js +2 -0
  38. package/dist/index.html +1 -1
  39. package/lib/themes.ts +4 -4
  40. package/lib/types.ts +60 -41
  41. package/package.json +1 -1
  42. package/server/api.ts +69 -31
  43. package/server/app-config.ts +144 -0
  44. package/server/applets.ts +17 -0
  45. package/server/cli.ts +47 -11
  46. package/server/layout.ts +40 -45
  47. package/server/moi-scaffold.ts +37 -1
  48. package/server/session-config.ts +3 -13
  49. package/server/thumbnails.ts +197 -0
  50. package/server/views.ts +10 -1
  51. package/server/widgets.ts +4 -18
  52. package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
  53. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
  54. package/client/features/drawings/annotation-availability.ts +0 -10
  55. package/client/features/widgets/api.ts +0 -47
  56. package/client/features/widgets/useWidgetThumbnails.ts +0 -107
  57. package/client/features/widgets/widget-snapshot.ts +0 -71
  58. package/dist/chunk-3becmq75.js +0 -81
  59. package/dist/chunk-8ew39cvq.js +0 -10
  60. package/dist/chunk-c8gtrjwp.js +0 -1
  61. package/dist/chunk-v964b5g7.js +0 -1
  62. package/dist/chunk-zx33ts9d.css +0 -1
@@ -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,39 +88,46 @@ 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
89
- // out of the folder at a slightly different angle and lifts on card hover.
90
- const STACK = [
91
- cn(
92
- 'opacity-40',
93
- '-translate-x-3 translate-y-3 -rotate-6',
94
- 'group-hover:translate-y-2 group-focus-visible:translate-y-2'
95
- ),
96
- cn(
97
- 'opacity-50',
98
- 'translate-x-3 translate-y-2 rotate-5',
99
- 'group-hover:translate-y-1 group-focus-visible:translate-y-1'
100
- ),
101
- cn(
102
- 'opacity-100',
103
- '-translate-x-1 translate-y-1 -rotate-2',
104
- 'group-hover:-translate-y-2 group-focus-visible:-translate-y-2'
105
- )
106
- ]
91
+ // Bottom-to-top treatment for up to three applet thumbnails. The frame stays
92
+ // opaque while only the image fades.
93
+ const THUMBNAIL_STYLES = [
94
+ {
95
+ frame: cn(
96
+ '-translate-x-3 translate-y-3 -rotate-6',
97
+ 'group-hover:translate-y-2 group-focus-visible:translate-y-2'
98
+ ),
99
+ img: 'opacity-40'
100
+ },
101
+ {
102
+ frame: cn(
103
+ 'translate-x-3 translate-y-2 rotate-5',
104
+ 'group-hover:translate-y-1 group-focus-visible:translate-y-1'
105
+ ),
106
+ img: 'opacity-50'
107
+ },
108
+ {
109
+ frame: cn(
110
+ '-translate-x-1 translate-y-1 -rotate-2',
111
+ 'group-hover:-translate-y-2 group-focus-visible:-translate-y-2'
112
+ ),
113
+ img: 'opacity-100'
114
+ }
115
+ ] as const
107
116
 
108
117
  export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
109
118
  const query = useWorkspacePreview(workspaceId)
110
119
  const thumbnails = query.data ? [...query.data.thumbnails].reverse() : []
111
- const slots = STACK.slice(STACK.length - thumbnails.length)
120
+ const slots = THUMBNAIL_STYLES.slice(THUMBNAIL_STYLES.length - thumbnails.length)
112
121
  const firstUserMessage = query.data?.firstUserMessage
113
122
  const theme = query.data?.theme
114
123
  const { ref, horizontalRadiusScale } = useFolderRadiusScale()
115
124
  const backdropPath = folderBackdropPath(horizontalRadiusScale)
116
125
  const noiseFilterId = `folder-noise-${workspaceId}`
117
126
  const themeStyle = getWorkspaceThemeStyle(theme)
127
+ const folderThemeStyle = getWorkspaceThemeColorStyle(theme)
118
128
 
119
129
  return (
120
- <div ref={ref} style={themeStyle} className="relative h-45 w-full font-sans">
130
+ <div ref={ref} style={folderThemeStyle} className="relative h-45 w-full">
121
131
  <svg
122
132
  viewBox={`0 0 ${FOLDER.width} ${FOLDER.height}`}
123
133
  preserveAspectRatio="none"
@@ -152,27 +162,35 @@ export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
152
162
  </svg>
153
163
 
154
164
  {thumbnails.map((src, index) => (
155
- <img
156
- key={index}
157
- src={src}
158
- alt=""
159
- loading="lazy"
165
+ <div
166
+ key={src}
160
167
  className={cn(
161
- 'absolute top-[12%] left-[14%] aspect-4/3 w-[72%] rounded-lg object-cover object-top shadow-xs',
162
- 'animate-in transition-transform duration-300 ease-out fade-in',
163
- slots[index]
168
+ 'absolute top-[12%] left-[14%] w-fit max-w-[72%] overflow-hidden rounded-[calc(var(--radius-2xl)*0.4)] bg-background shadow-xs [corner-shape:superellipse(1.2)]',
169
+ 'animate-in duration-300 ease-out fade-in',
170
+ slots[index].frame
164
171
  )}
165
- />
172
+ >
173
+ <img
174
+ src={src}
175
+ alt=""
176
+ loading="lazy"
177
+ className={cn(
178
+ 'block h-auto max-h-32 w-auto max-w-full object-contain',
179
+ slots[index].img
180
+ )}
181
+ />
182
+ </div>
166
183
  ))}
167
184
 
168
185
  {thumbnails.length === 0 && firstUserMessage && (
169
186
  <div className="absolute inset-x-[12%] top-[22%] flex justify-end">
170
187
  <div
171
188
  aria-hidden="true"
189
+ style={themeStyle}
172
190
  className={cn(
173
- 'w-max max-w-40 origin-center rounded-lg bg-card px-3 py-2 shadow-xs',
191
+ 'w-max max-w-40 origin-center rounded-lg bg-card px-3 py-2 font-sans shadow-xs',
174
192
  'animate-in transition-transform duration-300 ease-out fade-in',
175
- STACK[STACK.length - 1],
193
+ '-translate-x-1 translate-y-1 -rotate-2',
176
194
  'group-hover:translate-y-0.5 group-focus-visible:translate-y-0.5'
177
195
  )}
178
196
  >
@@ -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}`)
@@ -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(