moi-computer 0.3.0-next.1 → 0.3.0-next.3

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 (206) hide show
  1. package/README.md +1 -1
  2. package/bunfig.toml +5 -1
  3. package/client/AGENTS.md +17 -2
  4. package/client/accept-hmr-dependencies.ts +22 -0
  5. package/client/api/http.ts +31 -0
  6. package/client/api/query-options.ts +6 -0
  7. package/client/api/workspace-keys.ts +18 -0
  8. package/client/app/AppRouter.tsx +44 -0
  9. package/client/app/routes/HomeRoute.tsx +13 -0
  10. package/client/app/routes/WorkspaceRoute.tsx +95 -0
  11. package/client/app/shell/SidebarLayout.tsx +196 -0
  12. package/client/assets/openai.svg +3 -0
  13. package/client/assets.d.ts +9 -0
  14. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
  15. package/client/components/shared/PanelHeader.tsx +9 -0
  16. package/client/components/shared/ReorderableList.tsx +199 -0
  17. package/client/components/ui/button.tsx +11 -7
  18. package/client/components/ui/collapsible.tsx +15 -0
  19. package/client/components/ui/dialog.tsx +2 -2
  20. package/client/components/ui/dropdown-menu.tsx +5 -5
  21. package/client/components/ui/hover-card.tsx +1 -1
  22. package/client/components/ui/input.tsx +1 -1
  23. package/client/components/ui/popover.tsx +1 -1
  24. package/client/components/ui/skeleton.tsx +13 -0
  25. package/client/components/ui/tooltip.tsx +1 -1
  26. package/client/externalize-react.ts +7 -1
  27. package/client/features/applets/AppletMount.tsx +44 -0
  28. package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  29. package/client/{components → features/applets}/WidgetShell.tsx +5 -2
  30. package/client/{lib → features/applets}/applet-cache.ts +8 -0
  31. package/client/features/applets/applet-styles.ts +61 -0
  32. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  33. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
  34. package/client/features/chat/ChatPanel.tsx +171 -0
  35. package/client/{components → features/chat}/ChatPopup.tsx +24 -13
  36. package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
  37. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  38. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  39. package/client/{components → features/chat}/TurnView.tsx +17 -11
  40. package/client/features/chat/api.ts +78 -0
  41. package/client/features/chat/chat-connection.ts +107 -0
  42. package/client/features/chat/chat-frames.ts +131 -0
  43. package/client/features/chat/chat-send.ts +57 -0
  44. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  45. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  46. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  47. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  48. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
  49. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  50. package/client/{components → features/chat}/tool-group/format.ts +117 -0
  51. package/client/{hooks → features/chat}/useChat.ts +16 -44
  52. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  53. package/client/features/connectors/McpMenu.tsx +145 -0
  54. package/client/features/connectors/api.ts +28 -0
  55. package/client/features/dev/DevRoutes.tsx +18 -0
  56. package/client/features/dev/HarnessDebugPage.tsx +468 -0
  57. package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
  58. package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
  59. package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
  60. package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
  61. package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
  62. package/client/features/home/HomeLogo.tsx +344 -0
  63. package/client/features/home/HomePage.tsx +214 -0
  64. package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
  65. package/client/features/home/api.ts +156 -0
  66. package/client/features/home/workspace-presentation.tsx +44 -0
  67. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  68. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  69. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  70. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  71. package/client/features/settings/GeneralSettings.tsx +90 -0
  72. package/client/{components → features}/settings/IconPicker.tsx +76 -224
  73. package/client/features/settings/SettingsLayout.tsx +53 -0
  74. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  75. package/client/features/settings/api.ts +88 -0
  76. package/client/features/settings/icon-picker-options.ts +30 -0
  77. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  78. package/client/features/views/ViewBuilderTab.tsx +153 -0
  79. package/client/features/views/api.ts +124 -0
  80. package/client/features/views/useViewBuilderActions.ts +72 -0
  81. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  82. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  83. package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
  84. package/client/features/widgets/Widgets.tsx +265 -0
  85. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  86. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  87. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  88. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
  89. package/client/features/workspace/WorkspaceScreen.tsx +675 -0
  90. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  91. package/client/features/workspace/api.ts +56 -0
  92. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  93. package/client/global.d.ts +5 -0
  94. package/client/index.css +6 -45
  95. package/client/index.html +2 -2
  96. package/client/index.tsx +14 -31
  97. package/client/lib/app-icon-registry.ts +145 -0
  98. package/client/main.tsx +2 -2
  99. package/client/runtime/hmr-watchdog.ts +39 -0
  100. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
  101. package/client/store/ui.ts +5 -1
  102. package/client/theme.css +1 -3
  103. package/dist/chunk-11cab5dq.css +1 -0
  104. package/dist/chunk-4vf1t6v1.js +10 -0
  105. package/dist/chunk-6c24yndg.js +61 -0
  106. package/dist/chunk-6c8cwpzc.js +1 -0
  107. package/dist/chunk-b4b276wx.js +15 -0
  108. package/dist/chunk-cs8vbert.js +546 -0
  109. package/dist/chunk-cwqmay73.css +1 -0
  110. package/dist/chunk-kxmvv1ax.js +48 -0
  111. package/dist/chunk-pcnahct1.js +5 -0
  112. package/dist/chunk-rq0ar7vp.js +1 -0
  113. package/dist/chunk-tqd3pkg8.css +1 -0
  114. package/dist/chunk-vkvb3hjm.js +2 -0
  115. package/dist/chunk-zpxrb1ce.js +2 -0
  116. package/dist/index.html +3 -3
  117. package/dist/openai-h13pza4b.svg +3 -0
  118. package/lib/format.ts +2 -2
  119. package/lib/types.ts +56 -9
  120. package/lib/view-builder-meta.ts +35 -0
  121. package/lib/workspace-layout.ts +14 -0
  122. package/lib/workspace-name.ts +14 -0
  123. package/package.json +4 -2
  124. package/server/AGENTS.md +3 -3
  125. package/server/api.ts +279 -60
  126. package/server/applets.ts +1 -1
  127. package/server/bundle-queue.ts +19 -0
  128. package/server/bundler/applet-css.ts +50 -0
  129. package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
  130. package/server/cli.ts +90 -7
  131. package/server/control.ts +106 -8
  132. package/server/env-apply.ts +2 -2
  133. package/server/harness/README.md +228 -0
  134. package/server/harness/claude-code/NOTES.md +578 -0
  135. package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
  136. package/server/harness/claude-code/index.ts +124 -0
  137. package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
  138. package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
  139. package/server/harness/claude-code/sessions.ts +42 -0
  140. package/server/harness/codex/NOTES.md +239 -0
  141. package/server/harness/codex/adapter.ts +414 -0
  142. package/server/harness/codex/client.ts +343 -0
  143. package/server/harness/codex/index.ts +68 -0
  144. package/server/harness/codex/probe.ts +186 -0
  145. package/server/harness/codex/session.ts +617 -0
  146. package/server/harness/debug.ts +57 -0
  147. package/server/harness/openclaw/NOTES.md +316 -0
  148. package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
  149. package/server/harness/openclaw/index.ts +93 -0
  150. package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
  151. package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
  152. package/server/harness/registry.ts +36 -0
  153. package/server/harness/types.ts +87 -0
  154. package/server/layout.ts +36 -11
  155. package/server/moi-scaffold.ts +56 -11
  156. package/server/registry.ts +30 -52
  157. package/server/state.ts +5 -38
  158. package/server/status.ts +7 -46
  159. package/server/vendor.ts +1 -1
  160. package/server/view-builders.ts +428 -0
  161. package/server/views.ts +0 -0
  162. package/server/web.ts +19 -40
  163. package/server/workspace-init.ts +11 -25
  164. package/tsconfig.json +1 -1
  165. package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
  166. package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
  167. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  168. package/client/api/workspaces.ts +0 -427
  169. package/client/assets/hermes-nous.png +0 -0
  170. package/client/components/App.tsx +0 -41
  171. package/client/components/ChatPanel.tsx +0 -275
  172. package/client/components/HomePage.tsx +0 -17
  173. package/client/components/McpMenu.tsx +0 -125
  174. package/client/components/Scratchpad.tsx +0 -935
  175. package/client/components/Widgets.tsx +0 -132
  176. package/client/components/WorkspacesPage.tsx +0 -245
  177. package/client/components/layout/SidebarLayout.tsx +0 -258
  178. package/client/components/routes/workspace/[id].tsx +0 -675
  179. package/client/components/routes/workspace/create.tsx +0 -155
  180. package/client/components/settings/SettingsPages.tsx +0 -255
  181. package/client/hooks/useFitsSidebar.ts +0 -34
  182. package/client/hooks/useScrollFade.ts +0 -38
  183. package/client/lib/connection.ts +0 -238
  184. package/dist/chunk-07qf2tv1.css +0 -1
  185. package/dist/chunk-w18801vn.js +0 -672
  186. package/dist/hermes-nous-pznd63x9.png +0 -0
  187. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  188. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  189. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  190. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  191. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  192. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  193. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  194. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  195. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  196. /package/client/{lib → features/chat}/uploads.ts +0 -0
  197. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  198. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  199. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  200. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  201. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  202. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  203. /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
  204. /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
  205. /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
  206. /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
@@ -0,0 +1,199 @@
1
+ import { useMemo, useRef, useState } from 'react'
2
+ import type { ReactNode } from 'react'
3
+
4
+ import { motion } from 'motion/react'
5
+
6
+ import {
7
+ closestCenter,
8
+ DndContext,
9
+ DragOverlay,
10
+ KeyboardCode,
11
+ KeyboardSensor,
12
+ PointerSensor,
13
+ useDraggable,
14
+ useDroppable,
15
+ useSensor,
16
+ useSensors
17
+ } from '@dnd-kit/core'
18
+ import type { DragEndEvent, DragOverEvent, DraggableAttributes } from '@dnd-kit/core'
19
+
20
+ import { cn } from '@/client/lib/cn'
21
+
22
+ type ReorderableId = string
23
+
24
+ const KEYBOARD_CODES = {
25
+ start: [KeyboardCode.Space],
26
+ cancel: [KeyboardCode.Esc],
27
+ end: [KeyboardCode.Space, KeyboardCode.Tab]
28
+ }
29
+
30
+ export type ReorderableRenderState = {
31
+ isDragging: boolean
32
+ isOver: boolean
33
+ dragDisabled: boolean
34
+ dragHandleProps: Partial<DraggableAttributes> & Record<string, unknown>
35
+ }
36
+
37
+ type ReorderableListProps<T> = {
38
+ items: T[]
39
+ getId: (item: T) => ReorderableId
40
+ className?: string
41
+ itemClassName?: (item: T, state: ReorderableRenderState) => string | undefined
42
+ dragDisabled?: boolean
43
+ onReorder: (orderedIds: ReorderableId[]) => void
44
+ renderItem: (item: T, state: ReorderableRenderState) => ReactNode
45
+ renderPlaceholder?: (item: T) => ReactNode
46
+ renderOverlay?: (item: T) => ReactNode
47
+ }
48
+
49
+ export function reorderIds(order: ReorderableId[], active: ReorderableId, over: ReorderableId) {
50
+ const from = order.indexOf(active)
51
+ const to = order.indexOf(over)
52
+ if (from < 0 || to < 0 || from === to) return order
53
+
54
+ const next = [...order]
55
+ const [moved] = next.splice(from, 1)
56
+ next.splice(to, 0, moved)
57
+ return next
58
+ }
59
+
60
+ export function ReorderableList<T>({
61
+ items,
62
+ getId,
63
+ className,
64
+ itemClassName,
65
+ dragDisabled = false,
66
+ onReorder,
67
+ renderItem,
68
+ renderPlaceholder,
69
+ renderOverlay
70
+ }: ReorderableListProps<T>) {
71
+ const sensors = useSensors(
72
+ useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),
73
+ useSensor(KeyboardSensor, { keyboardCodes: KEYBOARD_CODES })
74
+ )
75
+ const [draggingId, setDraggingId] = useState<ReorderableId | null>(null)
76
+ const [dragOrder, setDragOrder] = useState<ReorderableId[] | null>(null)
77
+ const dragOrderRef = useRef<ReorderableId[] | null>(null)
78
+
79
+ const ids = useMemo(() => items.map(getId), [items, getId])
80
+ const itemById = useMemo(() => new Map(items.map(item => [getId(item), item])), [items, getId])
81
+ const displayedIds = draggingId && dragOrder ? dragOrder : ids
82
+ const displayedItems = displayedIds
83
+ .map(id => itemById.get(id))
84
+ .filter((item): item is T => Boolean(item))
85
+ const draggingItem = draggingId ? itemById.get(draggingId) : undefined
86
+ const disabled = dragDisabled || items.length < 2
87
+
88
+ const handleDragOver = (event: DragOverEvent) => {
89
+ const activeId = String(event.active.id)
90
+ const overId = event.over ? String(event.over.id) : undefined
91
+ const currentOrder = dragOrderRef.current
92
+ if (!overId || overId === activeId || !currentOrder) return
93
+
94
+ const nextOrder = reorderIds(currentOrder, activeId, overId)
95
+ if (nextOrder === currentOrder) return
96
+ dragOrderRef.current = nextOrder
97
+ setDragOrder(nextOrder)
98
+ }
99
+
100
+ const handleDragEnd = (event: DragEndEvent) => {
101
+ const activeId = String(event.active.id)
102
+ const finalOrder = dragOrderRef.current
103
+ dragOrderRef.current = null
104
+ setDraggingId(null)
105
+ setDragOrder(null)
106
+ if (!finalOrder || finalOrder.join('|') === ids.join('|')) return
107
+ if (!finalOrder.includes(activeId)) return
108
+ onReorder(finalOrder)
109
+ }
110
+
111
+ return (
112
+ <DndContext
113
+ sensors={sensors}
114
+ collisionDetection={closestCenter}
115
+ onDragStart={event => {
116
+ const order = items.map(getId)
117
+ setDraggingId(String(event.active.id))
118
+ dragOrderRef.current = order
119
+ setDragOrder(order)
120
+ }}
121
+ onDragOver={handleDragOver}
122
+ onDragCancel={() => {
123
+ dragOrderRef.current = null
124
+ setDraggingId(null)
125
+ setDragOrder(null)
126
+ }}
127
+ onDragEnd={handleDragEnd}
128
+ >
129
+ <div className={className}>
130
+ {displayedItems.map(item => (
131
+ <ReorderableListItem
132
+ key={getId(item)}
133
+ id={getId(item)}
134
+ item={item}
135
+ disabled={disabled}
136
+ itemClassName={itemClassName}
137
+ renderItem={renderItem}
138
+ renderPlaceholder={renderPlaceholder}
139
+ />
140
+ ))}
141
+ </div>
142
+ <DragOverlay dropAnimation={null}>
143
+ {draggingItem && renderOverlay ? renderOverlay(draggingItem) : null}
144
+ </DragOverlay>
145
+ </DndContext>
146
+ )
147
+ }
148
+
149
+ type ReorderableListItemProps<T> = {
150
+ id: ReorderableId
151
+ item: T
152
+ disabled: boolean
153
+ itemClassName?: (item: T, state: ReorderableRenderState) => string | undefined
154
+ renderItem: (item: T, state: ReorderableRenderState) => ReactNode
155
+ renderPlaceholder?: (item: T) => ReactNode
156
+ }
157
+
158
+ function ReorderableListItem<T>({
159
+ id,
160
+ item,
161
+ disabled,
162
+ itemClassName,
163
+ renderItem,
164
+ renderPlaceholder
165
+ }: ReorderableListItemProps<T>) {
166
+ const { setNodeRef: setDroppableRef, isOver } = useDroppable({ id, disabled })
167
+ const {
168
+ attributes,
169
+ listeners,
170
+ setNodeRef: setDraggableRef,
171
+ isDragging
172
+ } = useDraggable({
173
+ id,
174
+ disabled,
175
+ attributes: { roleDescription: 'sortable item' }
176
+ })
177
+ const setNodeRef = (el: HTMLElement | null) => {
178
+ setDroppableRef(el)
179
+ setDraggableRef(el)
180
+ }
181
+ const state: ReorderableRenderState = {
182
+ isDragging,
183
+ isOver,
184
+ dragDisabled: disabled,
185
+ dragHandleProps: disabled ? {} : { ...attributes, ...listeners }
186
+ }
187
+
188
+ return (
189
+ <motion.div
190
+ layout
191
+ ref={setNodeRef}
192
+ className={cn('relative', itemClassName?.(item, state))}
193
+ transition={{ type: 'spring', duration: 0.25, bounce: 0 }}
194
+ >
195
+ {isDragging && renderPlaceholder?.(item)}
196
+ {renderItem(item, state)}
197
+ </motion.div>
198
+ )
199
+ }
@@ -10,15 +10,19 @@ const buttonVariants = cva(
10
10
  variant: {
11
11
  default:
12
12
  'bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100',
13
- secondary: 'bg-muted text-foreground hover:bg-muted/80',
14
- outline: 'bg-background shadow-sm hover:bg-muted hover:text-foreground',
15
- ghost: 'hover:bg-muted'
13
+ secondary:
14
+ 'bg-accent text-foreground hover:bg-[color-mix(in_oklch,var(--accent),var(--foreground)_5%)] hover:text-accent-foreground',
15
+ outline: 'bg-background shadow-xs hover:text-accent-foreground hover:shadow-sm',
16
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
17
+ destructive:
18
+ 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
16
19
  },
17
20
  size: {
18
- sm: 'h-6 gap-1 rounded-xs px-2 text-xs has-[>svg]:px-1.5 [&_svg]:size-4',
19
- default: 'h-8 px-3 has-[>svg]:px-2.5 [&_svg]:size-5',
20
- lg: 'h-10 rounded-lg px-4 has-[>svg]:px-3 [&_svg]:size-5',
21
- 'icon-sm': 'size-6 rounded-xs [&_svg]:size-4',
21
+ sm: 'h-7 gap-1.5 rounded-xs px-2.5 text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg]:size-4',
22
+ default:
23
+ 'h-8 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
24
+ lg: 'h-10 rounded-lg px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg]:size-5',
25
+ 'icon-sm': 'size-7 rounded-xs [&_svg]:size-4',
22
26
  icon: 'size-8 [&_svg]:size-5',
23
27
  'icon-lg': 'size-10 rounded-lg [&_svg]:size-5'
24
28
  }
@@ -0,0 +1,15 @@
1
+ import { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible'
2
+
3
+ function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
4
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
5
+ }
6
+
7
+ function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
8
+ return <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
9
+ }
10
+
11
+ function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
12
+ return <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
13
+ }
14
+
15
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }
@@ -19,12 +19,12 @@ function DialogContent({ className, children, ...props }: DialogPrimitive.Popup.
19
19
  <DialogPrimitive.Portal>
20
20
  <DialogPrimitive.Backdrop
21
21
  data-slot="dialog-backdrop"
22
- className="fixed inset-0 z-50 bg-black/40 duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"
22
+ className="fixed inset-0 z-50 bg-foreground/40 duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"
23
23
  />
24
24
  <DialogPrimitive.Popup
25
25
  data-slot="dialog-content"
26
26
  className={cn(
27
- 'fixed top-1/2 left-1/2 z-50 origin-center -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl bg-card text-card-foreground shadow-xl ring-1 ring-foreground/10 outline-hidden duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
27
+ 'fixed top-1/2 left-1/2 z-50 origin-center -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl bg-card text-card-foreground shadow-xl ring-1 ring-border outline-hidden duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
28
28
  className
29
29
  )}
30
30
  {...props}
@@ -38,7 +38,7 @@ function DropdownMenuContent({
38
38
  <MenuPrimitive.Popup
39
39
  data-slot="dropdown-menu-content"
40
40
  className={cn(
41
- 'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
41
+ 'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
42
42
  className
43
43
  )}
44
44
  {...props}
@@ -118,7 +118,7 @@ function DropdownMenuSubTrigger({
118
118
  {...props}
119
119
  >
120
120
  {children}
121
- <IconChevronRight className="cn-rtl-flip ml-auto" stroke={1.5} />
121
+ <IconChevronRight className="cn-rtl-flip ml-auto" stroke={1.75} />
122
122
  </MenuPrimitive.SubmenuTrigger>
123
123
  )
124
124
  }
@@ -135,7 +135,7 @@ function DropdownMenuSubContent({
135
135
  <DropdownMenuContent
136
136
  data-slot="dropdown-menu-sub-content"
137
137
  className={cn(
138
- 'w-auto min-w-[96px] rounded-md bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
138
+ 'w-auto min-w-[96px] rounded-md bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
139
139
  className
140
140
  )}
141
141
  align={align}
@@ -172,7 +172,7 @@ function DropdownMenuCheckboxItem({
172
172
  data-slot="dropdown-menu-checkbox-item-indicator"
173
173
  >
174
174
  <MenuPrimitive.CheckboxItemIndicator>
175
- <IconCheck stroke={1.5} />
175
+ <IconCheck stroke={1.75} />
176
176
  </MenuPrimitive.CheckboxItemIndicator>
177
177
  </span>
178
178
  {children}
@@ -207,7 +207,7 @@ function DropdownMenuRadioItem({
207
207
  data-slot="dropdown-menu-radio-item-indicator"
208
208
  >
209
209
  <MenuPrimitive.RadioItemIndicator>
210
- <IconCheck stroke={1.5} />
210
+ <IconCheck stroke={1.75} />
211
211
  </MenuPrimitive.RadioItemIndicator>
212
212
  </span>
213
213
  {children}
@@ -31,7 +31,7 @@ function HoverCardContent({
31
31
  <PreviewCardPrimitive.Popup
32
32
  data-slot="hover-card-content"
33
33
  className={cn(
34
- 'z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
34
+ 'z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
35
35
  className
36
36
  )}
37
37
  {...props}
@@ -10,7 +10,7 @@ function Input({ className, type, ...props }: ComponentProps<'input'>) {
10
10
  type={type}
11
11
  data-slot="input"
12
12
  className={cn(
13
- 'h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
13
+ 'h-8 w-full min-w-0 rounded-sm border border-input bg-transparent px-2.5 py-1 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
14
14
  className
15
15
  )}
16
16
  {...props}
@@ -36,7 +36,7 @@ function PopoverContent({
36
36
  <PopoverPrimitive.Popup
37
37
  data-slot="popover-content"
38
38
  className={cn(
39
- 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-md bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/5 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
39
+ 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-md bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
40
40
  className
41
41
  )}
42
42
  {...props}
@@ -0,0 +1,13 @@
1
+ import { cn } from '@/client/lib/cn'
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn('animate-pulse rounded-md bg-muted', className)}
8
+ {...props}
9
+ />
10
+ )
11
+ }
12
+
13
+ export { Skeleton }
@@ -41,7 +41,7 @@ function TooltipContent({
41
41
  <TooltipPrimitive.Popup
42
42
  data-slot="tooltip-content"
43
43
  className={cn(
44
- 'z-50 origin-(--transform-origin) rounded-sm bg-white px-2 py-1 text-xs font-medium text-primary shadow-md outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
44
+ 'z-50 origin-(--transform-origin) rounded-sm bg-popover px-2 py-1 text-xs font-medium text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
45
45
  className
46
46
  )}
47
47
  {...props}
@@ -25,7 +25,13 @@ const externalizeReact: BunPlugin = {
25
25
 
26
26
  build.onLoad({ filter: /.*/, namespace: 'esm' }, args => {
27
27
  return {
28
- contents: `module.exports = globalThis.__esm["${args.path}"];`,
28
+ contents:
29
+ `module.exports = globalThis.__esm["${args.path}"];` +
30
+ // Self-accept under HMR: the exports are identical on every
31
+ // re-evaluation (a read of the same global), so a hot update must
32
+ // stop here instead of propagating up to the entry and forcing a
33
+ // full page reload. No-op outside the dev server.
34
+ `if (import.meta.hot) import.meta.hot.accept();`,
29
35
  loader: 'js'
30
36
  }
31
37
  })
@@ -0,0 +1,44 @@
1
+ import { type ReactElement, type ReactNode, cloneElement, isValidElement } from 'react'
2
+
3
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
4
+
5
+ import { type AppletSegment, appletStyleKey } from './applet-cache'
6
+ import { useAppletStyle } from './applet-styles'
7
+
8
+ type AppletMountProps = {
9
+ segment: AppletSegment
10
+ name: string
11
+ version: number
12
+ // Merge the scope attribute into the single child element instead of
13
+ // rendering a wrapper — use when the caller already has a filled container
14
+ // (e.g. the shells' motion.div), so no extra node enters the DOM. The child
15
+ // must forward unknown props to its DOM element.
16
+ asChild?: boolean
17
+ children: ReactNode
18
+ }
19
+
20
+ // The style scope for one mounted applet: puts the `data-applet` attribute the
21
+ // bundle's scoped CSS selectors key off (see server/bundler/applet-css.ts) on a
22
+ // container, and keeps the applet's <style> tag mounted exactly as long as the
23
+ // applet is — unmounting removes the styles from the page. Without `asChild`
24
+ // it renders its own wrapper div filling the parent box (the widget path —
25
+ // merging onto the shell's motion.div interferes with AnimatePresence there);
26
+ // with `asChild` it merges onto the child element instead (the view path).
27
+ export function AppletMount({ segment, name, version, asChild, children }: AppletMountProps) {
28
+ const workspaceId = useWorkspaceId()
29
+ useAppletStyle(appletStyleKey(segment, workspaceId, name), version)
30
+
31
+ const kind = segment === 'widgets' ? 'widget' : 'view'
32
+ const scope = `${kind}:${name}`
33
+
34
+ if (asChild && isValidElement(children)) {
35
+ return cloneElement(children as ReactElement<{ 'data-applet'?: string }>, {
36
+ 'data-applet': scope
37
+ })
38
+ }
39
+ return (
40
+ <div data-applet={scope} className="size-full">
41
+ {children}
42
+ </div>
43
+ )
44
+ }
@@ -32,7 +32,7 @@ export class WidgetErrorBoundary extends Component<Props, State> {
32
32
  return (
33
33
  <div className="flex h-full w-full flex-col items-start justify-start gap-1.5 p-4 text-xs">
34
34
  <div className="flex items-center gap-1.5 font-semibold text-destructive">
35
- <IconAlertTriangle size={14} stroke={1.5} />
35
+ <IconAlertTriangle size={16} stroke={1.75} />
36
36
  Widget crashed
37
37
  </div>
38
38
  <div className="font-mono break-words text-muted-foreground">
@@ -1,6 +1,7 @@
1
1
  import { AnimatePresence, motion } from 'motion/react'
2
2
 
3
- import { useWidget } from '@/client/hooks/useApplet'
3
+ import { AppletMount } from '@/client/features/applets/AppletMount'
4
+ import { useWidget } from '@/client/features/applets/useApplet'
4
5
 
5
6
  import { WidgetErrorBoundary } from './WidgetErrorBoundary'
6
7
 
@@ -23,7 +24,9 @@ export function WidgetShell({ name }: WidgetShellProps) {
23
24
  transition={{ duration: 0.45, ease: 'easeInOut' }}
24
25
  >
25
26
  <WidgetErrorBoundary name={name} resetKey={widget.version}>
26
- <widget.Component />
27
+ <AppletMount segment="widgets" name={name} version={widget.version}>
28
+ <widget.Component />
29
+ </AppletMount>
27
30
  </WidgetErrorBoundary>
28
31
  </motion.div>
29
32
  )}
@@ -35,6 +35,14 @@ export function appletUrl(segment: AppletSegment, workspaceId: string, name: str
35
35
  return `/api/workspaces/${workspaceId}/${segment}/${name}/index.js?v=${appletVersion(segment, workspaceId, name)}`
36
36
  }
37
37
 
38
+ // The key an applet bundle registers its CSS under (`window.__moiAppletCss`):
39
+ // the bundle-dir path, which the bundle derives from its own import.meta.url
40
+ // (see injectCss in server/bundler/build-applet.ts). Workspace-qualified so two
41
+ // workspaces sharing an applet name never read each other's styles.
42
+ export function appletStyleKey(segment: AppletSegment, workspaceId: string, name: string): string {
43
+ return `/api/workspaces/${workspaceId}/${segment}/${name}`
44
+ }
45
+
38
46
  export function getCachedApplet(key: string): Promise<unknown> | undefined {
39
47
  return moduleCache.get(key)
40
48
  }
@@ -0,0 +1,61 @@
1
+ import { useInsertionEffect } from 'react'
2
+
3
+ // Host-managed applet styles. An applet bundle no longer appends its own
4
+ // <style> to <head> (which stuck around forever — a cached ES module is never
5
+ // re-evaluated, let alone disposed). Instead its module side effect registers
6
+ // the compiled, container-scoped CSS on `window.__moiAppletCss`, keyed by the
7
+ // bundle-dir path (`/api/workspaces/<id>/<segment>/<name>` — see injectCss in
8
+ // server/bundler/build-applet.ts and `appletStyleKey`). The host injects a <style> for
9
+ // that key while at least one instance of the applet is mounted, and removes it
10
+ // when the last one unmounts.
11
+ declare global {
12
+ interface Window {
13
+ __moiAppletCss?: Map<string, string>
14
+ }
15
+ }
16
+
17
+ type ActiveStyle = {
18
+ el: HTMLStyleElement
19
+ refs: number
20
+ }
21
+
22
+ const active = new Map<string, ActiveStyle>()
23
+
24
+ // Mount the applet's registered CSS (refcounted); returns the release fn.
25
+ // Exported for tests — components should use `useAppletStyle`.
26
+ export function acquireAppletStyle(key: string): () => void {
27
+ const css = window.__moiAppletCss?.get(key) ?? ''
28
+
29
+ let entry = active.get(key)
30
+ if (!entry) {
31
+ const el = document.createElement('style')
32
+ el.dataset.appletStyle = key
33
+ document.head.appendChild(el)
34
+ entry = { el, refs: 0 }
35
+ active.set(key, entry)
36
+ }
37
+ // Always sync the text: after a rebuild the registry holds fresh CSS under
38
+ // the same key while an older instance may still be mounted (exit animation).
39
+ if (entry.el.textContent !== css) entry.el.textContent = css
40
+
41
+ entry.refs++
42
+ const acquired = entry
43
+ let released = false
44
+ return () => {
45
+ if (released) return
46
+ released = true
47
+ acquired.refs--
48
+ if (acquired.refs <= 0) {
49
+ acquired.el.remove()
50
+ active.delete(key)
51
+ }
52
+ }
53
+ }
54
+
55
+ // Keep the applet's <style> mounted for the lifetime of the calling component.
56
+ // `version` re-runs the effect after a rebuild so the tag picks up the fresh
57
+ // registry text. useInsertionEffect runs before layout effects and paint, so
58
+ // the styles are in place before the applet's first frame.
59
+ export function useAppletStyle(key: string, version: number): void {
60
+ useInsertionEffect(() => acquireAppletStyle(key), [key, version])
61
+ }
@@ -8,10 +8,9 @@ import {
8
8
  getCachedApplet,
9
9
  invalidateApplet,
10
10
  setCachedApplet
11
- } from '@/client/lib/applet-cache'
12
- import { useWorkspaceId } from '@/client/lib/WorkspaceContext'
13
-
14
- import { type MeiEvent, useMeiEvent } from './useMeiEvents'
11
+ } from '@/client/features/applets/applet-cache'
12
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
13
+ import { type WorkspaceEvent, useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
15
14
 
16
15
  type AppletState =
17
16
  | { status: 'loading'; version: number }
@@ -25,7 +24,7 @@ type AppletState =
25
24
  type AppletKind = {
26
25
  segment: AppletSegment
27
26
  // True when this MEI event means the named applet should cache-bust + reload.
28
- shouldReload: (event: MeiEvent, name: string) => boolean
27
+ shouldReload: (event: WorkspaceEvent, name: string) => boolean
29
28
  }
30
29
 
31
30
  const WIDGET_KIND: AppletKind = {
@@ -85,7 +84,7 @@ function useApplet(kind: AppletKind, name: string): AppletState {
85
84
  // unmounted case, but doing it here keeps this self-sufficient and
86
85
  // order-independent. The bumped version remounts the component and re-runs its
87
86
  // `rpc()` calls.
88
- useMeiEvent(event => {
87
+ useWorkspaceEvent(event => {
89
88
  if (kind.shouldReload(event, name)) {
90
89
  invalidateApplet(kind.segment, workspaceId, name)
91
90
  load()
@@ -110,7 +109,7 @@ export function useView(name: string): AppletState {
110
109
  // fires while that applet is on screen; this covers the (common) rest.
111
110
  export function useAppletCacheInvalidation(): void {
112
111
  const workspaceId = useWorkspaceId()
113
- useMeiEvent(event => {
112
+ useWorkspaceEvent(event => {
114
113
  if (event.type === 'view:updated') invalidateApplet('views', workspaceId, event.name)
115
114
  else if (event.type === 'widget:updated') invalidateApplet('widgets', workspaceId, event.name)
116
115
  })