moi-computer 0.9.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 (120) 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/assets/hermes.png +0 -0
  5. package/client/components/shared/IconGhost.tsx +15 -18
  6. package/client/components/ui/button.tsx +2 -2
  7. package/client/components/ui/hover-card.tsx +1 -1
  8. package/client/components/ui/popover.tsx +3 -1
  9. package/client/features/applets/api.ts +38 -0
  10. package/client/features/applets/applet-thumbnail.ts +208 -0
  11. package/client/features/chat/ChatEmptyState.tsx +30 -10
  12. package/client/features/chat/ChatPanel.tsx +67 -31
  13. package/client/features/chat/ChatPopup.tsx +3 -2
  14. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  15. package/client/features/chat/ChatSelector.tsx +29 -10
  16. package/client/features/chat/MarkdownContent.tsx +3 -3
  17. package/client/features/chat/attachment-staging.ts +153 -0
  18. package/client/features/chat/chat-send.ts +55 -0
  19. package/client/features/chat/chat-store.ts +32 -8
  20. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  21. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  22. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  23. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  24. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  25. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  26. package/client/features/chat/tool-group/format/claude.ts +48 -0
  27. package/client/features/chat/tool-group/format/codex.ts +126 -0
  28. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  29. package/client/features/chat/tool-group/format/index.ts +34 -0
  30. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  31. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  32. package/client/features/chat/tool-group/format/shared.ts +49 -0
  33. package/client/features/chat/useChat.ts +5 -10
  34. package/client/features/drawings/DrawingLayer.tsx +49 -0
  35. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  36. package/client/features/drawings/capture-element.ts +45 -0
  37. package/client/features/drawings/useChatAnnotation.ts +222 -0
  38. package/client/features/drawings/useDrawingLayer.ts +758 -0
  39. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  40. package/client/features/home/HomePage.tsx +13 -0
  41. package/client/features/home/WorkspacePreview.tsx +10 -5
  42. package/client/features/home/workspace-presentation.tsx +6 -2
  43. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
  44. package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
  45. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +13 -7
  46. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
  47. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  48. package/client/features/views/ViewBuilder.tsx +238 -0
  49. package/client/features/views/ViewManager.tsx +18 -2
  50. package/client/features/views/api.ts +1 -0
  51. package/client/features/views/useViewBuilderActions.ts +24 -3
  52. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  53. package/client/features/widgets/WidgetFrame.tsx +1 -1
  54. package/client/features/widgets/WidgetGrid.tsx +1 -1
  55. package/client/features/widgets/Widgets.tsx +39 -54
  56. package/client/features/workspace/CustomizePanel.tsx +30 -9
  57. package/client/features/workspace/WorkspaceScreen.tsx +158 -64
  58. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  59. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  60. package/client/index.css +8 -0
  61. package/client/index.tsx +6 -1
  62. package/client/runtime/useWorkspaceEvents.ts +17 -0
  63. package/client/runtime/workspace-theme.ts +29 -6
  64. package/client/store/ui.ts +19 -0
  65. package/client/theme.css +33 -8
  66. package/dist/chunk-5c19v3zr.js +10 -0
  67. package/dist/chunk-6wx91x8j.js +1 -0
  68. package/dist/chunk-8s41nd3g.js +1 -0
  69. package/dist/{chunk-kkj86722.js → chunk-a7fzp0z0.js} +78 -78
  70. package/dist/{chunk-2vaafjp4.js → chunk-b959mdkj.js} +1 -1
  71. package/dist/chunk-cagtq45k.js +1 -0
  72. package/dist/chunk-cva7jpt4.js +82 -0
  73. package/dist/chunk-sapvd7he.css +1 -0
  74. package/dist/{chunk-35fq49qa.js → chunk-zbeq02yc.js} +1 -1
  75. package/dist/chunk-zbt8emsw.js +2 -0
  76. package/dist/chunk-zfz3b4xg.js +2 -0
  77. package/dist/hermes-pznd63x9.png +0 -0
  78. package/dist/index.html +1 -1
  79. package/lib/format.ts +1 -1
  80. package/lib/themes.ts +8 -8
  81. package/lib/types.ts +68 -42
  82. package/lib/workspace-types.ts +2 -1
  83. package/package.json +2 -1
  84. package/server/api.ts +90 -33
  85. package/server/app-config.ts +144 -0
  86. package/server/applets.ts +17 -0
  87. package/server/cli.ts +235 -14
  88. package/server/harness/README.md +64 -17
  89. package/server/harness/acp/adapter.ts +220 -0
  90. package/server/harness/acp/archived.ts +88 -0
  91. package/server/harness/acp/client.ts +328 -0
  92. package/server/harness/acp/discovery.ts +130 -0
  93. package/server/harness/acp/run-durations.ts +68 -0
  94. package/server/harness/acp/session.ts +788 -0
  95. package/server/harness/acp/wire.ts +132 -0
  96. package/server/harness/executable.ts +15 -1
  97. package/server/harness/hermes/NOTES.md +815 -0
  98. package/server/harness/hermes/discovery.ts +155 -0
  99. package/server/harness/hermes/index.ts +155 -0
  100. package/server/harness/hermes/models.ts +79 -0
  101. package/server/harness/registry.ts +3 -1
  102. package/server/layout.ts +40 -45
  103. package/server/moi-scaffold.ts +37 -1
  104. package/server/thumbnails.ts +197 -0
  105. package/server/view-builders.ts +4 -2
  106. package/server/views.ts +10 -1
  107. package/server/widgets.ts +4 -18
  108. package/server/workspace-import.ts +30 -1
  109. package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
  110. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
  111. package/client/features/chat/tool-group/format.ts +0 -384
  112. package/client/features/views/ViewBuilderTab.tsx +0 -152
  113. package/client/features/widgets/api.ts +0 -47
  114. package/client/features/widgets/useWidgetThumbnails.ts +0 -107
  115. package/client/features/widgets/widget-snapshot.ts +0 -71
  116. package/dist/chunk-3b3rkjet.js +0 -1
  117. package/dist/chunk-gt7n06ef.js +0 -1
  118. package/dist/chunk-ty1sqbmn.js +0 -80
  119. package/dist/chunk-xeyxk7ep.js +0 -10
  120. package/dist/chunk-yz6wd5vc.css +0 -1
@@ -0,0 +1,238 @@
1
+ import type { ReactNode, Ref } from 'react'
2
+ import { useImperativeHandle } from 'react'
3
+
4
+ import { Button } from '@/client/components/ui/button'
5
+ import { Spinner } from '@/client/components/ui/spinner'
6
+ import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
7
+ import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
8
+ import {
9
+ type DrawingControls,
10
+ useDrawingHistoryState
11
+ } from '@/client/features/drawings/useDrawingLayer'
12
+ import {
13
+ type ViewBuilderSketchController,
14
+ useViewBuilderSketch
15
+ } from '@/client/features/drawings/useViewBuilderSketch'
16
+ import { cn } from '@/client/lib/cn'
17
+ import type { ViewBuilder as ViewBuilderData } from '@/lib/types'
18
+ import { viewBuilderTabId } from '@/lib/workspace-tabs'
19
+ import { IconScribble } from '@tabler/icons-react'
20
+
21
+ export type ViewBuilderHandle = {
22
+ prepareSketchForSend: () => Promise<void>
23
+ resetSketch: () => Promise<void>
24
+ }
25
+
26
+ type ViewBuilderProps = {
27
+ ref?: Ref<ViewBuilderHandle>
28
+ active: boolean
29
+ builder: ViewBuilderData
30
+ chatDocked: boolean
31
+ workspaceId: string
32
+ onEditingStart: () => void
33
+ onContinueInChat: () => void
34
+ onOpenChat: () => void
35
+ onDiscard: () => void
36
+ }
37
+
38
+ export function ViewBuilder({
39
+ ref,
40
+ active,
41
+ builder,
42
+ chatDocked,
43
+ workspaceId,
44
+ onEditingStart,
45
+ onContinueInChat,
46
+ onOpenChat,
47
+ onDiscard
48
+ }: ViewBuilderProps) {
49
+ const sketch = useViewBuilderSketch({
50
+ active: active && builder.status === 'draft',
51
+ builderId: builder.id,
52
+ sessionId: builder.sessionId,
53
+ sourceTab: viewBuilderTabId(builder.id),
54
+ workspaceId,
55
+ onEditingStart,
56
+ onContinueInChat
57
+ })
58
+
59
+ useImperativeHandle(
60
+ ref,
61
+ () => ({
62
+ prepareSketchForSend: sketch.prepareForSend,
63
+ resetSketch: sketch.resetDocument
64
+ }),
65
+ [sketch.prepareForSend, sketch.resetDocument]
66
+ )
67
+
68
+ switch (builder.status) {
69
+ case 'ready':
70
+ return null
71
+ case 'draft':
72
+ case 'waiting':
73
+ case 'building':
74
+ return (
75
+ <ViewBuilderSketchSurface
76
+ active={active}
77
+ chatDocked={chatDocked}
78
+ error={builder.error}
79
+ sketch={sketch}
80
+ status={builder.status}
81
+ onDiscard={onDiscard}
82
+ onOpenChat={onOpenChat}
83
+ />
84
+ )
85
+ }
86
+ }
87
+
88
+ type ViewBuilderSketchSurfaceProps = {
89
+ active: boolean
90
+ chatDocked: boolean
91
+ error?: string
92
+ sketch: ViewBuilderSketchController
93
+ status: Exclude<ViewBuilderData['status'], 'ready'>
94
+ onDiscard: () => void
95
+ onOpenChat: () => void
96
+ }
97
+
98
+ function ViewBuilderSketchSurface({
99
+ active,
100
+ chatDocked,
101
+ error,
102
+ sketch,
103
+ status,
104
+ onDiscard,
105
+ onOpenChat
106
+ }: ViewBuilderSketchSurfaceProps) {
107
+ const draft = status === 'draft'
108
+
109
+ return (
110
+ <div
111
+ className={cn(
112
+ 'relative min-h-0 flex-1 overflow-hidden bg-background',
113
+ active ? 'flex' : 'hidden'
114
+ )}
115
+ >
116
+ {draft && <ViewBuilderDraftState chatDocked={chatDocked} sketch={sketch} />}
117
+ <div
118
+ inert={draft ? undefined : true}
119
+ className={cn(
120
+ 'absolute inset-0',
121
+ status === 'building' && 'pointer-events-none opacity-50',
122
+ status === 'waiting' && 'invisible'
123
+ )}
124
+ >
125
+ <DrawingLayer {...sketch.layerProps}>
126
+ {draft && (
127
+ <DrawingToolbar
128
+ controls={sketch.controls}
129
+ title="Sketch the view"
130
+ busy={sketch.continuing}
131
+ onComplete={() => void sketch.continueInChat()}
132
+ />
133
+ )}
134
+ </DrawingLayer>
135
+ </div>
136
+ <div
137
+ aria-hidden
138
+ className={cn(
139
+ 'pointer-events-none absolute inset-0 transition-shadow duration-500 ease-in-out',
140
+ status === 'building' &&
141
+ 'animate-glow texture-inset-shadow-50% motion-reduce:animate-none'
142
+ )}
143
+ />
144
+ {status === 'building' && <ViewBuilderBuildingState controls={sketch.controls} />}
145
+ {status === 'waiting' && (
146
+ <ViewBuilderWaitingState error={error} onDiscard={onDiscard} onOpenChat={onOpenChat} />
147
+ )}
148
+ </div>
149
+ )
150
+ }
151
+
152
+ type ViewBuilderDraftStateProps = {
153
+ chatDocked: boolean
154
+ sketch: ViewBuilderSketchController
155
+ }
156
+
157
+ function ViewBuilderDraftState({ chatDocked, sketch }: ViewBuilderDraftStateProps) {
158
+ const { hasStrokes } = useDrawingHistoryState(sketch.controls)
159
+
160
+ return (
161
+ <div
162
+ ref={sketch.targetRef}
163
+ className="absolute inset-0 flex items-center justify-center texture-checker-20"
164
+ >
165
+ {!sketch.controls.active && !hasStrokes && (
166
+ <div
167
+ className={cn(
168
+ 'mb-4 flex h-full flex-col items-center justify-center gap-2 p-12 text-center text-sm text-muted-foreground',
169
+ 'bg-radial from-background from-10% to-transparent',
170
+ chatDocked ? 'w-full' : 'mr-auto w-[calc(100%-var(--chat-max))]'
171
+ )}
172
+ >
173
+ <IconScribble size={56} stroke={0.5} />
174
+ <span className="max-w-32">Sketch how the view should look</span>
175
+ </div>
176
+ )}
177
+ </div>
178
+ )
179
+ }
180
+
181
+ type ViewBuilderWaitingStateProps = {
182
+ error?: string
183
+ onDiscard: () => void
184
+ onOpenChat: () => void
185
+ }
186
+
187
+ function ViewBuilderWaitingState({ error, onDiscard, onOpenChat }: ViewBuilderWaitingStateProps) {
188
+ return (
189
+ <ViewBuilderStatusLayout>
190
+ <div className="flex max-w-md flex-col items-center gap-4 bg-radial from-background from-50% to-transparent to-75% p-12 text-center">
191
+ <div className="flex flex-col gap-1">
192
+ <h1 className="font-medium">The view needs your attention</h1>
193
+ <p className="text-sm text-muted-foreground">
194
+ {error ?? 'Open the chat to answer or ask the agent to continue'}
195
+ </p>
196
+ </div>
197
+ <div className="flex gap-2">
198
+ <Button onClick={onOpenChat}>Open chat</Button>
199
+ <Button variant="secondary" onClick={onDiscard}>
200
+ Discard view
201
+ </Button>
202
+ </div>
203
+ </div>
204
+ </ViewBuilderStatusLayout>
205
+ )
206
+ }
207
+
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
+ )
220
+ }
221
+
222
+ type ViewBuilderStatusLayoutProps = {
223
+ children?: ReactNode
224
+ className?: string
225
+ }
226
+
227
+ function ViewBuilderStatusLayout({ children, className }: ViewBuilderStatusLayoutProps) {
228
+ return (
229
+ <div
230
+ className={cn(
231
+ 'relative flex min-h-0 flex-1 items-center justify-center texture-checker-20',
232
+ className
233
+ )}
234
+ >
235
+ {children}
236
+ </div>
237
+ )
238
+ }
@@ -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
  >
@@ -80,6 +80,7 @@ export type SubmitViewBuilderInput = {
80
80
  builderId: string
81
81
  requirements: string
82
82
  optimisticId: string
83
+ attachments?: string[]
83
84
  model?: string
84
85
  effort?: string
85
86
  fastMode?: boolean
@@ -1,6 +1,12 @@
1
1
  import { useQueryClient } from '@tanstack/react-query'
2
2
 
3
- import { resolveChatRunOptions, startOptimisticTurn } from '@/client/features/chat/chat-send'
3
+ import {
4
+ attachmentPartsForOptimisticTurn,
5
+ attachmentsForSend,
6
+ resolveChatRunOptions,
7
+ startOptimisticSession,
8
+ startOptimisticTurn
9
+ } from '@/client/features/chat/chat-send'
4
10
  import { liveStore } from '@/client/features/chat/chat-store'
5
11
  import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
6
12
  import { useWorkspaceAgent } from '@/client/features/workspace/api'
@@ -30,13 +36,24 @@ export function useViewBuilderActions() {
30
36
 
31
37
  const submit = async (builder: ViewBuilder, requirements: string) => {
32
38
  const text = requirements.trim()
33
- if (!text) return
39
+ const attachments = attachmentsForSend(workspaceId, builder.sessionId)
40
+ if (!text && attachments.length === 0) return
41
+
42
+ startOptimisticSession({
43
+ queryClient,
44
+ workspaceId,
45
+ sessionId: builder.sessionId,
46
+ text,
47
+ filenames: attachments.map(attachment => attachment.name)
48
+ })
49
+ const parts = attachmentPartsForOptimisticTurn(attachments)
50
+ if (text) parts.push({ type: 'text', text })
34
51
 
35
52
  const optimisticId = startOptimisticTurn({
36
53
  queryClient,
37
54
  workspaceId,
38
55
  sessionId: builder.sessionId,
39
- parts: [{ type: 'text', text }]
56
+ parts
40
57
  })
41
58
  selectSession(builder.sessionId)
42
59
 
@@ -52,11 +69,15 @@ export function useViewBuilderActions() {
52
69
  builderId: builder.id,
53
70
  requirements: text,
54
71
  optimisticId,
72
+ ...(attachments.length > 0
73
+ ? { attachments: attachments.map(attachment => attachment.upload!.id) }
74
+ : {}),
55
75
  model,
56
76
  effort,
57
77
  fastMode,
58
78
  stream
59
79
  })
80
+ liveStore.getState().clearAttachments(workspaceId, builder.sessionId)
60
81
  } catch (error) {
61
82
  liveStore.getState().setActivity(workspaceId, builder.sessionId, 'idle')
62
83
  liveStore
@@ -0,0 +1,66 @@
1
+ import { useCallback, useEffect, useRef } from 'react'
2
+
3
+ import { toast } from '@/client/components/ui/toast'
4
+ import { useUiStore } from '@/client/store/ui'
5
+ import type { ViewBuilder } from '@/lib/types'
6
+
7
+ type UseViewBuilderDraftsOptions = {
8
+ builders: ViewBuilder[]
9
+ onSave: (builderId: string, requirements: string) => Promise<unknown>
10
+ }
11
+
12
+ // Builder draft text lives in the UI store and is subscribed from the
13
+ // composer, so a keystroke re-renders only the composer — never the workspace
14
+ // screen with its tab bar, widgets, mounted views, and builder canvases. This
15
+ // hook owns the writes: the store update, the debounced server save, and the
16
+ // cleanup when a builder leaves its draft state.
17
+ export function useViewBuilderDrafts({ builders, onSave }: UseViewBuilderDraftsOptions) {
18
+ const timersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>())
19
+ const buildersRef = useRef(builders)
20
+ const onSaveRef = useRef(onSave)
21
+ buildersRef.current = builders
22
+ onSaveRef.current = onSave
23
+
24
+ const clear = useCallback((builderId: string) => {
25
+ const timer = timersRef.current.get(builderId)
26
+ if (timer) clearTimeout(timer)
27
+ timersRef.current.delete(builderId)
28
+ useUiStore.getState().setViewBuilderDraft(builderId, null)
29
+ }, [])
30
+
31
+ const change = useCallback((builderId: string, value: string) => {
32
+ useUiStore.getState().setViewBuilderDraft(builderId, value)
33
+ const existing = timersRef.current.get(builderId)
34
+ if (existing) clearTimeout(existing)
35
+ timersRef.current.set(
36
+ builderId,
37
+ setTimeout(() => {
38
+ timersRef.current.delete(builderId)
39
+ const builder = buildersRef.current.find(candidate => candidate.id === builderId)
40
+ if (!builder || builder.status !== 'draft') return
41
+ void onSaveRef.current(builderId, value).catch(() => {
42
+ toast.add({ title: 'Couldn’t save view description', type: 'error' })
43
+ })
44
+ }, 500)
45
+ )
46
+ }, [])
47
+
48
+ // Drop drafts for builders that left draft status through any path (submit
49
+ // from another surface, server-side transition). Builders absent from the
50
+ // list are cleared by the explicit discard/close paths, not here — the
51
+ // store outlives this screen and may hold other workspaces' drafts.
52
+ useEffect(() => {
53
+ for (const builder of builders) {
54
+ if (builder.status !== 'draft') clear(builder.id)
55
+ }
56
+ }, [builders, clear])
57
+
58
+ useEffect(
59
+ () => () => {
60
+ for (const timer of timersRef.current.values()) clearTimeout(timer)
61
+ },
62
+ []
63
+ )
64
+
65
+ return { change, clear }
66
+ }
@@ -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>
@@ -85,46 +85,30 @@ function WidgetActions({ editing, onCreateWidget, onEditingChange }: WidgetActio
85
85
  </Button>
86
86
  )}
87
87
  <AnimatePresence mode="popLayout" initial={false}>
88
- {editing ? (
89
- <motion.div
90
- key="done"
91
- variants={{
92
- from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
93
- to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
94
- }}
95
- initial="from"
96
- animate="to"
97
- exit="from"
98
- transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
99
- >
100
- <Button type="button" size="sm" onClick={() => onEditingChange(false)}>
101
- Done
102
- </Button>
103
- </motion.div>
104
- ) : (
105
- <motion.div
106
- key="actions"
107
- className="flex items-center gap-1"
108
- variants={{
109
- from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
110
- to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
111
- }}
112
- initial="from"
113
- animate="to"
114
- exit="from"
115
- transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
88
+ <motion.div
89
+ key={editing ? 'done' : 'edit'}
90
+ variants={{
91
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
92
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
93
+ }}
94
+ initial="from"
95
+ animate="to"
96
+ exit="from"
97
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
98
+ >
99
+ <Button
100
+ type="button"
101
+ variant={editing ? 'default' : 'ghost'}
102
+ size="sm"
103
+ className={cn(
104
+ !editing &&
105
+ 'text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0'
106
+ )}
107
+ onClick={() => onEditingChange(!editing)}
116
108
  >
117
- <Button
118
- type="button"
119
- variant="ghost"
120
- size="sm"
121
- className="text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0"
122
- onClick={() => onEditingChange(true)}
123
- >
124
- Edit widgets
125
- </Button>
126
- </motion.div>
127
- )}
109
+ {editing ? 'Done' : 'Edit widgets'}
110
+ </Button>
111
+ </motion.div>
128
112
  </AnimatePresence>
129
113
  </div>
130
114
  )
@@ -182,12 +166,13 @@ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: W
182
166
  const [panelRef, panelHeight] = usePanelHeight()
183
167
  const panelOpen = editing && hiddenItems.length > 0
184
168
 
185
- const containerRef = useRef<HTMLDivElement>(null)
186
- useWidgetThumbnails({
187
- containerRef,
188
- widgets,
189
- visibleIds: visibleItems.map(item => item.id),
190
- 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
+ }))
191
176
  })
192
177
 
193
178
  function hide(id: string) {
@@ -209,7 +194,7 @@ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: W
209
194
  // Shared working area below the header and positioning context for the
210
195
  // bottom panel. Created-widget states scroll; the initial empty state clips
211
196
  // its fixed-height skeleton grid.
212
- <div ref={containerRef} className="group/widgets relative min-h-0 flex-1">
197
+ <div className="group/widgets relative min-h-0 flex-1">
213
198
  <LayoutGroup>
214
199
  <div
215
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}
@@ -132,7 +153,7 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
132
153
  >
133
154
  <div className="flex items-center gap-2">
134
155
  <span
135
- className="size-5 shrink-0 rounded-sm bg-card texture-checker-[10px] shadow-xs"
156
+ className="size-5 shrink-0 rounded-sm bg-card texture-checker-2.5 shadow-xs"
136
157
  aria-hidden="true"
137
158
  />
138
159
  <span className="text-sm font-medium">{preset.label}</span>