moi-computer 0.3.0-next.1 → 0.3.0-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 (146) hide show
  1. package/bunfig.toml +5 -1
  2. package/client/AGENTS.md +15 -0
  3. package/client/accept-hmr-dependencies.ts +22 -0
  4. package/client/api/http.ts +31 -0
  5. package/client/api/query-options.ts +6 -0
  6. package/client/api/workspace-keys.ts +17 -0
  7. package/client/app/AppRouter.tsx +35 -0
  8. package/client/app/routes/HomeRoute.tsx +13 -0
  9. package/client/app/routes/WorkspaceRoute.tsx +89 -0
  10. package/client/app/shell/SidebarLayout.tsx +191 -0
  11. package/client/assets.d.ts +9 -0
  12. package/client/components/playground/PixelPainter.tsx +10 -21
  13. package/client/components/playground/PlaygroundPage.tsx +9 -11
  14. package/client/components/playground/ToolCallsPage.tsx +9 -11
  15. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +1 -1
  16. package/client/components/shared/PanelHeader.tsx +9 -0
  17. package/client/components/shared/ReorderableList.tsx +199 -0
  18. package/client/components/ui/button.tsx +10 -7
  19. package/client/components/ui/collapsible.tsx +15 -0
  20. package/client/components/ui/dialog.tsx +2 -2
  21. package/client/components/ui/dropdown-menu.tsx +5 -5
  22. package/client/components/ui/hover-card.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/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  28. package/client/{components → features/applets}/WidgetShell.tsx +1 -1
  29. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  30. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +29 -23
  31. package/client/features/chat/ChatPanel.tsx +188 -0
  32. package/client/{components → features/chat}/ChatPopup.tsx +23 -12
  33. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  34. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  35. package/client/{components → features/chat}/ThreadSelector.tsx +11 -9
  36. package/client/{components → features/chat}/TurnView.tsx +16 -9
  37. package/client/features/chat/api.ts +78 -0
  38. package/client/features/chat/chat-connection.ts +107 -0
  39. package/client/features/chat/chat-frames.ts +131 -0
  40. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  41. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  42. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  43. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  44. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +12 -4
  45. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  46. package/client/{hooks → features/chat}/useChat.ts +7 -11
  47. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  48. package/client/features/connectors/McpMenu.tsx +162 -0
  49. package/client/features/connectors/api.ts +28 -0
  50. package/client/features/home/CreateWorkspaceDialog.tsx +224 -0
  51. package/client/features/home/HomePage.tsx +220 -0
  52. package/client/{components → features/home}/WorkspacePreview.tsx +2 -2
  53. package/client/features/home/api.ts +148 -0
  54. package/client/features/home/workspace-presentation.tsx +44 -0
  55. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  56. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  57. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  58. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  59. package/client/features/settings/GeneralSettings.tsx +90 -0
  60. package/client/{components → features}/settings/IconPicker.tsx +73 -222
  61. package/client/features/settings/SettingsLayout.tsx +53 -0
  62. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  63. package/client/features/settings/api.ts +88 -0
  64. package/client/features/settings/icon-picker-options.ts +161 -0
  65. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  66. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  67. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  68. package/client/{components → features/widgets}/WidgetGrid.tsx +2 -9
  69. package/client/features/widgets/Widgets.tsx +215 -0
  70. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  71. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  72. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  73. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +15 -8
  74. package/client/features/workspace/WorkspaceScreen.tsx +536 -0
  75. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  76. package/client/features/workspace/api.ts +56 -0
  77. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  78. package/client/global.d.ts +5 -0
  79. package/client/index.css +6 -10
  80. package/client/index.html +1 -1
  81. package/client/index.tsx +14 -31
  82. package/client/main.tsx +2 -2
  83. package/client/runtime/hmr-watchdog.ts +39 -0
  84. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +9 -6
  85. package/client/store/ui.ts +5 -1
  86. package/client/theme.css +0 -2
  87. package/dist/chunk-11cab5dq.css +1 -0
  88. package/dist/chunk-23cgr1tz.css +1 -0
  89. package/dist/chunk-3hy3qy6d.js +10 -0
  90. package/dist/chunk-c4j722at.js +546 -0
  91. package/dist/chunk-dyfaffyz.js +119 -0
  92. package/dist/chunk-kpe40hm8.js +1 -0
  93. package/dist/chunk-p68fnz3q.js +2 -0
  94. package/dist/chunk-pcnahct1.js +5 -0
  95. package/dist/chunk-tqd3pkg8.css +1 -0
  96. package/dist/chunk-ty6dvda0.js +1 -0
  97. package/dist/index.html +2 -2
  98. package/lib/types.ts +18 -7
  99. package/lib/workspace-name.ts +14 -0
  100. package/package.json +3 -2
  101. package/server/api.ts +119 -14
  102. package/server/cli.ts +11 -5
  103. package/server/layout.ts +38 -7
  104. package/server/mcp.ts +72 -15
  105. package/server/moi-scaffold.ts +55 -10
  106. package/server/registry.ts +16 -0
  107. package/server/web.ts +1 -0
  108. package/server/workspace-init.ts +5 -19
  109. package/tsconfig.json +1 -1
  110. package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -1
  111. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  112. package/client/api/workspaces.ts +0 -427
  113. package/client/components/App.tsx +0 -41
  114. package/client/components/ChatPanel.tsx +0 -275
  115. package/client/components/HomePage.tsx +0 -17
  116. package/client/components/McpMenu.tsx +0 -125
  117. package/client/components/Scratchpad.tsx +0 -935
  118. package/client/components/Widgets.tsx +0 -132
  119. package/client/components/WorkspacesPage.tsx +0 -245
  120. package/client/components/layout/SidebarLayout.tsx +0 -258
  121. package/client/components/routes/workspace/[id].tsx +0 -675
  122. package/client/components/routes/workspace/create.tsx +0 -155
  123. package/client/components/settings/SettingsPages.tsx +0 -255
  124. package/client/hooks/useFitsSidebar.ts +0 -34
  125. package/client/lib/connection.ts +0 -238
  126. package/dist/chunk-07qf2tv1.css +0 -1
  127. package/dist/chunk-w18801vn.js +0 -672
  128. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  129. /package/client/{lib → features/applets}/applet-cache.ts +0 -0
  130. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  131. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  132. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  133. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  134. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  135. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  136. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  137. /package/client/{components → features/chat}/tool-group/format.ts +0 -0
  138. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  139. /package/client/{lib → features/chat}/uploads.ts +0 -0
  140. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  141. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  142. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  143. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  144. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  145. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  146. /package/client/{hooks → features/workspace}/useWorkspaceTheme.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,18 @@ 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: 'bg-muted text-foreground hover:bg-accent hover:text-accent-foreground',
14
+ outline: 'bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
15
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
16
+ destructive:
17
+ 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
16
18
  },
17
19
  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',
20
+ 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',
21
+ default:
22
+ 'h-8 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
23
+ lg: 'h-10 rounded-lg px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg]:size-5',
24
+ 'icon-sm': 'size-7 rounded-xs [&_svg]:size-4',
22
25
  icon: 'size-8 [&_svg]:size-5',
23
26
  'icon-lg': 'size-10 rounded-lg [&_svg]:size-5'
24
27
  }
@@ -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}
@@ -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
  })
@@ -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,6 @@
1
1
  import { AnimatePresence, motion } from 'motion/react'
2
2
 
3
- import { useWidget } from '@/client/hooks/useApplet'
3
+ import { useWidget } from '@/client/features/applets/useApplet'
4
4
 
5
5
  import { WidgetErrorBoundary } from './WidgetErrorBoundary'
6
6
 
@@ -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
  })
@@ -1,4 +1,4 @@
1
- import { useRef, useState } from 'react'
1
+ import { type RefObject, useRef, useState } from 'react'
2
2
 
3
3
  import {
4
4
  IconArrowUp,
@@ -10,14 +10,20 @@ import {
10
10
  } from '@tabler/icons-react'
11
11
 
12
12
  import { cn } from '@/client/lib/cn'
13
- import { useWorkspaceId } from '@/client/lib/WorkspaceContext'
14
- import { uploadFiles } from '@/client/lib/uploads'
15
- import { type ChatAttachment, draftKey, liveStore, useLive } from '@/client/store/live'
13
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
14
+ import { uploadFiles } from '@/client/features/chat/uploads'
15
+ import {
16
+ type ChatAttachment,
17
+ draftKey,
18
+ liveStore,
19
+ useLive
20
+ } from '@/client/features/chat/chat-store'
16
21
 
17
22
  import { ModelPicker } from './ModelPicker'
18
- import { Button } from './ui/button'
23
+ import { Button } from '@/client/components/ui/button'
19
24
 
20
- type ChatInputProps = {
25
+ type ChatComposerProps = {
26
+ composerRef: RefObject<HTMLTextAreaElement | null>
21
27
  onSend: (text: string) => void
22
28
  onStop: () => void
23
29
  processing: boolean
@@ -28,8 +34,7 @@ type ChatInputProps = {
28
34
  // panel, message list, or surrounding workspace. The draft is keyed by the
29
35
  // active thread, so switching threads swaps the unsent text with you. Attachments
30
36
  // (drag/drop, paste, attach button) are tracked the same way and cleared on send.
31
- export function ChatInput({ onSend, onStop, processing }: ChatInputProps) {
32
- const ref = useRef<HTMLTextAreaElement>(null)
37
+ export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatComposerProps) {
33
38
  const fileRef = useRef<HTMLInputElement>(null)
34
39
  const workspaceId = useWorkspaceId()
35
40
  const sessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
@@ -92,7 +97,7 @@ export function ChatInput({ onSend, onStop, processing }: ChatInputProps) {
92
97
  onMouseDown={e => {
93
98
  if (e.target instanceof HTMLElement && e.target.closest('button')) return
94
99
  e.preventDefault()
95
- ref.current?.focus()
100
+ composerRef.current?.focus()
96
101
  }}
97
102
  onDragOver={e => {
98
103
  if (!e.dataTransfer.types.includes('Files')) return
@@ -111,7 +116,7 @@ export function ChatInput({ onSend, onStop, processing }: ChatInputProps) {
111
116
  addFiles(Array.from(e.dataTransfer.files))
112
117
  }}
113
118
  className={cn(
114
- 'flex w-full cursor-text flex-col gap-1 rounded-lg bg-white p-2 shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
119
+ 'flex w-full cursor-text flex-col gap-1 rounded-lg bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
115
120
  dragOver && 'ring-2 ring-ring/60'
116
121
  )}
117
122
  >
@@ -130,7 +135,7 @@ export function ChatInput({ onSend, onStop, processing }: ChatInputProps) {
130
135
  )}
131
136
 
132
137
  <textarea
133
- ref={ref}
138
+ ref={composerRef}
134
139
  id="chat-input"
135
140
  name="message"
136
141
  value={value}
@@ -148,7 +153,6 @@ export function ChatInput({ onSend, onStop, processing }: ChatInputProps) {
148
153
  addFiles(files)
149
154
  }}
150
155
  placeholder={processing ? 'Queue a follow-up...' : 'Ask anything...'}
151
- autoFocus
152
156
  rows={1}
153
157
  className="field-sizing-content max-h-40 w-full resize-none bg-transparent px-2 py-1 text-sm leading-relaxed outline-none placeholder:text-muted-foreground disabled:opacity-50"
154
158
  />
@@ -204,9 +208,9 @@ function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {
204
208
  return (
205
209
  <div
206
210
  className={cn(
207
- 'group relative flex items-center gap-2 overflow-hidden rounded-md border border-black/10 bg-black/[0.03]',
211
+ 'group relative flex items-center gap-2 overflow-hidden rounded-md border border-border bg-accent text-accent-foreground',
208
212
  isImage ? 'size-14' : 'h-10 max-w-52 pr-2 pl-2',
209
- status === 'error' && 'border-red-300'
213
+ status === 'error' && 'border-destructive/50'
210
214
  )}
211
215
  title={error ?? name}
212
216
  >
@@ -214,30 +218,32 @@ function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {
214
218
  <img src={previewUrl} alt={name} className="size-full object-cover" />
215
219
  ) : (
216
220
  <>
217
- <IconFile size={16} stroke={1.5} className="shrink-0 text-muted-foreground" />
218
- <span className="truncate text-xs text-foreground/80">{name}</span>
221
+ <IconFile size={16} stroke={1.75} className="shrink-0 text-muted-foreground" />
222
+ <span className="truncate text-xs">{name}</span>
219
223
  </>
220
224
  )}
221
225
 
222
226
  {status === 'uploading' && (
223
- <div className="absolute inset-0 flex items-center justify-center bg-white/60">
224
- <IconLoader2 size={16} stroke={1.5} className="animate-spin text-muted-foreground" />
227
+ <div className="absolute inset-0 flex items-center justify-center bg-background/70">
228
+ <IconLoader2 size={16} stroke={1.75} className="animate-spin text-muted-foreground" />
225
229
  </div>
226
230
  )}
227
231
  {status === 'error' && (
228
- <div className="absolute inset-0 flex items-center justify-center bg-red-50/80 text-[10px] text-red-700">
232
+ <div className="absolute inset-0 flex items-center justify-center bg-destructive/10 text-[10px] text-destructive">
229
233
  Failed
230
234
  </div>
231
235
  )}
232
236
 
233
- <button
237
+ <Button
234
238
  type="button"
239
+ variant="ghost"
240
+ size="icon-sm"
235
241
  onClick={onRemove}
236
242
  aria-label={`Remove ${name}`}
237
- className="absolute top-0.5 right-0.5 flex size-4 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity group-hover:opacity-100"
243
+ className="absolute top-0.5 right-0.5 size-4 rounded-full bg-primary/70 text-primary-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-primary/80 [&_svg]:size-3"
238
244
  >
239
- <IconX size={10} stroke={2} />
240
- </button>
245
+ <IconX stroke={1.75} />
246
+ </Button>
241
247
  </div>
242
248
  )
243
249
  }