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,205 @@
1
+ import { IconPlus, IconX, type TablerIcon } from '@tabler/icons-react'
2
+ import { cva } from 'class-variance-authority'
3
+
4
+ import { ReorderableList } from '@/client/components/shared/ReorderableList'
5
+ import type { ReorderableRenderState } from '@/client/components/shared/ReorderableList'
6
+ import { Button, buttonVariants } from '@/client/components/ui/button'
7
+ import {
8
+ DropdownMenu,
9
+ DropdownMenuContent,
10
+ DropdownMenuGroup,
11
+ DropdownMenuItem,
12
+ DropdownMenuTrigger
13
+ } from '@/client/components/ui/dropdown-menu'
14
+ import { cn } from '@/client/lib/cn'
15
+ import type { WorkspaceTabId } from '@/lib/types'
16
+
17
+ export type WorkspaceTabItem = {
18
+ key: WorkspaceTabId
19
+ Icon: TablerIcon
20
+ label: string
21
+ closable?: boolean
22
+ }
23
+
24
+ export type CreateWorkspaceTabItem = {
25
+ key: string
26
+ Icon: TablerIcon
27
+ label: string
28
+ onClick: () => void
29
+ }
30
+
31
+ type WorkspaceTabsProps = {
32
+ tabs: WorkspaceTabItem[]
33
+ active: WorkspaceTabId
34
+ createItems: CreateWorkspaceTabItem[]
35
+ onSelect: (tab: WorkspaceTabId) => void
36
+ onClose: (tab: WorkspaceTabId) => void
37
+ onReorder: (ordered: WorkspaceTabId[]) => void
38
+ }
39
+
40
+ const workspaceTabVariants = cva(
41
+ [buttonVariants({ variant: 'ghost', size: 'sm' }), 'group/tab min-w-0'],
42
+ {
43
+ variants: {
44
+ active: {
45
+ true: 'bg-accent text-accent-foreground'
46
+ },
47
+ dragging: {
48
+ true: 'invisible'
49
+ },
50
+ preview: {
51
+ true: 'cursor-grabbing ring-1 ring-border'
52
+ }
53
+ },
54
+ compoundVariants: [{ preview: true }]
55
+ }
56
+ )
57
+
58
+ function CreateTabMenu({ items }: { items: CreateWorkspaceTabItem[] }) {
59
+ return (
60
+ <DropdownMenu>
61
+ <DropdownMenuTrigger
62
+ render={
63
+ <Button
64
+ type="button"
65
+ variant="ghost"
66
+ size="icon-sm"
67
+ className="text-muted-foreground"
68
+ aria-label="Create tab"
69
+ >
70
+ <IconPlus stroke={1.75} />
71
+ </Button>
72
+ }
73
+ />
74
+ <DropdownMenuContent align="start" className="min-w-48">
75
+ <DropdownMenuGroup>
76
+ {items.map(({ key, Icon, label, onClick }) => (
77
+ <DropdownMenuItem key={key} onClick={onClick} className="font-medium">
78
+ <Icon stroke={2} />
79
+ {label}
80
+ </DropdownMenuItem>
81
+ ))}
82
+ </DropdownMenuGroup>
83
+ </DropdownMenuContent>
84
+ </DropdownMenu>
85
+ )
86
+ }
87
+
88
+ type WorkspaceTabBaseProps = {
89
+ tab: WorkspaceTabItem
90
+ active: boolean
91
+ }
92
+
93
+ type WorkspaceTabProps = WorkspaceTabBaseProps &
94
+ (
95
+ | {
96
+ preview: true
97
+ state?: never
98
+ onSelect?: never
99
+ onClose?: never
100
+ }
101
+ | {
102
+ preview?: false
103
+ state: ReorderableRenderState
104
+ onSelect: (tab: WorkspaceTabId) => void
105
+ onClose: (tab: WorkspaceTabId) => void
106
+ }
107
+ )
108
+
109
+ function WorkspaceTab(props: WorkspaceTabProps) {
110
+ const { tab, active } = props
111
+ const preview = props.preview === true
112
+
113
+ return (
114
+ <button
115
+ type="button"
116
+ aria-hidden={preview || undefined}
117
+ aria-label={tab.label}
118
+ disabled={preview}
119
+ tabIndex={preview ? -1 : undefined}
120
+ onClick={props.preview ? undefined : () => props.onSelect(tab.key)}
121
+ className={workspaceTabVariants({
122
+ active,
123
+ dragging: props.preview ? false : props.state.isDragging,
124
+ preview
125
+ })}
126
+ {...(props.preview ? {} : props.state.dragHandleProps)}
127
+ >
128
+ <div
129
+ className={cn(
130
+ 'flex items-center gap-1 overflow-hidden',
131
+ tab.closable && 'group-hover/tab:mr-3'
132
+ )}
133
+ >
134
+ <tab.Icon data-icon="inline-start" stroke={2} />
135
+ <span
136
+ className={cn(
137
+ 'truncate',
138
+ tab.closable &&
139
+ 'group-hover/tab:-mr-3 group-hover/tab:mask-r-from-[calc(100%-24px)] group-hover/tab:mask-r-to-[calc(100%-12px)]'
140
+ )}
141
+ >
142
+ {tab.label}
143
+ </span>
144
+ </div>
145
+ {tab.closable && (
146
+ <div
147
+ aria-label={`Close ${tab.label}`}
148
+ tabIndex={preview ? -1 : undefined}
149
+ className={cn(
150
+ 'absolute right-2 hidden size-3 items-center justify-center text-muted-foreground group-hover/tab:flex hover:text-foreground',
151
+ preview && 'pointer-events-none'
152
+ )}
153
+ onClick={
154
+ props.preview
155
+ ? undefined
156
+ : event => {
157
+ event.stopPropagation()
158
+ props.onClose(tab.key)
159
+ }
160
+ }
161
+ >
162
+ <IconX stroke={1.75} />
163
+ </div>
164
+ )}
165
+ </button>
166
+ )
167
+ }
168
+
169
+ export function WorkspaceTabs({
170
+ tabs,
171
+ active,
172
+ createItems,
173
+ onSelect,
174
+ onClose,
175
+ onReorder
176
+ }: WorkspaceTabsProps) {
177
+ return (
178
+ <div className="flex min-w-0 flex-1 items-center gap-1">
179
+ <div className="no-scrollbar min-w-0 scroll-fade-x overflow-x-auto overflow-y-hidden [--scroll-fade-reveal:16px]">
180
+ <ReorderableList
181
+ items={tabs}
182
+ getId={tab => tab.key}
183
+ className="flex w-max items-center gap-1"
184
+ onReorder={ordered => onReorder(ordered as WorkspaceTabId[])}
185
+ renderPlaceholder={() => (
186
+ <div className="pointer-events-none absolute inset-0 rounded-xs bg-muted" />
187
+ )}
188
+ renderOverlay={tab => <WorkspaceTab tab={tab} active={active === tab.key} preview />}
189
+ renderItem={(tab, state) => (
190
+ <WorkspaceTab
191
+ tab={tab}
192
+ active={active === tab.key}
193
+ state={state}
194
+ onSelect={onSelect}
195
+ onClose={onClose}
196
+ />
197
+ )}
198
+ />
199
+ </div>
200
+ <div className="shrink-0">
201
+ <CreateTabMenu items={createItems} />
202
+ </div>
203
+ </div>
204
+ )
205
+ }
@@ -0,0 +1,56 @@
1
+ import { useMutation, useQuery } from '@tanstack/react-query'
2
+
3
+ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
+ import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
5
+ import { workspaceKeys } from '@/client/api/workspace-keys'
6
+ import type { ViewInfo, WidgetInfo, WorkspaceLayout, WorkspaceType } from '@/lib/types'
7
+
8
+ export type WorkspaceLayoutResponse = WorkspaceLayout & {
9
+ cwd: string
10
+ name: string
11
+ provider?: WorkspaceType
12
+ agentId?: string
13
+ }
14
+
15
+ export function useWorkspaceLayout(workspaceId: string) {
16
+ return useQuery<WorkspaceLayoutResponse>({
17
+ queryKey: workspaceKeys.layout(workspaceId),
18
+ queryFn: () => requestJson(`/api/workspaces/${workspaceId}`),
19
+ ...WORKSPACE_RESOURCE_OPTIONS
20
+ })
21
+ }
22
+
23
+ export function useWorkspaceWidgets(workspaceId: string) {
24
+ return useQuery<WidgetInfo[]>({
25
+ queryKey: workspaceKeys.widgets(workspaceId),
26
+ queryFn: async () => {
27
+ const data = await requestJson<{ widgets: WidgetInfo[] }>(
28
+ `/api/workspaces/${workspaceId}/widgets`
29
+ )
30
+ return data.widgets
31
+ },
32
+ ...WORKSPACE_RESOURCE_OPTIONS
33
+ })
34
+ }
35
+
36
+ export function useWorkspaceViews(workspaceId: string) {
37
+ return useQuery<ViewInfo[]>({
38
+ queryKey: workspaceKeys.views(workspaceId),
39
+ queryFn: async () => {
40
+ const data = await requestJson<{ views: ViewInfo[] }>(`/api/workspaces/${workspaceId}/views`)
41
+ return data.views
42
+ },
43
+ ...WORKSPACE_RESOURCE_OPTIONS
44
+ })
45
+ }
46
+
47
+ export function useSaveLayout(workspaceId: string) {
48
+ return useMutation<void, Error, WorkspaceLayout>({
49
+ mutationFn: layout =>
50
+ requestVoid(
51
+ `/api/workspaces/${workspaceId}`,
52
+ jsonRequest('PUT', layout),
53
+ 'Failed to save layout'
54
+ )
55
+ })
56
+ }
@@ -0,0 +1,37 @@
1
+ import { useLayoutEffect, useRef, useState } from 'react'
2
+
3
+ function tokenPx(name: string): number {
4
+ const root = document.documentElement
5
+ const raw = getComputedStyle(root).getPropertyValue(name).trim()
6
+ const value = Number.parseFloat(raw)
7
+ if (!Number.isFinite(value)) return 0
8
+ return raw.endsWith('rem') ? value * Number.parseFloat(getComputedStyle(root).fontSize) : value
9
+ }
10
+
11
+ // Observe the full workspace row, not either pane, so split-fit measurement does
12
+ // not oscillate when the chat column appears or disappears.
13
+ export function useFitsSplitLayout<T extends HTMLElement>() {
14
+ const ref = useRef<T>(null)
15
+ const [fits, setFits] = useState(false)
16
+
17
+ useLayoutEffect(() => {
18
+ const el = ref.current
19
+ if (!el) return
20
+
21
+ const update = (width: number) => {
22
+ const columnWidth = tokenPx('--column-w')
23
+ const chatMin = tokenPx('--chat-min')
24
+ setFits(width - chatMin >= columnWidth)
25
+ }
26
+
27
+ update(el.getBoundingClientRect().width)
28
+
29
+ const ro = new ResizeObserver(([entry]) => {
30
+ if (entry) update(entry.contentRect.width)
31
+ })
32
+ ro.observe(el)
33
+ return () => ro.disconnect()
34
+ }, [])
35
+
36
+ return { ref, fits }
37
+ }
@@ -0,0 +1,5 @@
1
+ declare global {
2
+ var __init: (element: HTMLElement) => Promise<void>
3
+ }
4
+
5
+ export {}
package/client/index.css CHANGED
@@ -22,21 +22,19 @@
22
22
  --popover-foreground: oklch(0.145 0 0);
23
23
  --primary: oklch(0.205 0 0);
24
24
  --primary-foreground: oklch(0.985 0 0);
25
- --secondary: oklch(0.97 0 0);
26
- --secondary-foreground: oklch(0.205 0 0);
27
25
  --muted: oklch(0.97 0 0);
28
26
  --muted-foreground: oklch(0.64 0 0);
29
- --accent: oklch(0.97 0 0);
27
+ --accent: oklch(0 0 0 / 0.07);
30
28
  --accent-foreground: oklch(0.205 0 0);
31
29
  --destructive: oklch(0.58 0.22 27);
32
- --border: oklch(0.922 0 0);
30
+ --border: oklch(0 0 0 / 0.07);
33
31
  --input: oklch(0.922 0 0);
34
32
  --ring: oklch(0.708 0 0);
35
33
  --radius: 1rem;
36
34
 
37
35
  /* Workspace page layout — single source of truth for the widget/chat panel.
38
- Read by routes/workspace/[id].tsx and useFitsSidebar.ts; don't hardcode
39
- equivalents. (The app sidebar's own widths live in SidebarLayout.tsx.) */
36
+ Read by routes/workspace/[id].tsx; don't hardcode equivalents. (The app
37
+ sidebar's own widths live in SidebarLayout.tsx.) */
40
38
  --page-pad: 2rem; /* padding around the working area */
41
39
  --column-w: 40rem; /* grid content width; also the widget area's min before the chat yields */
42
40
  --chat-min: 380px; /* docked chat min width — narrower than this and it floats */
@@ -65,14 +63,12 @@
65
63
  --popover-foreground: oklch(0.985 0 0);
66
64
  --primary: oklch(0.985 0 0);
67
65
  --primary-foreground: oklch(0.205 0 0);
68
- --secondary: oklch(0.269 0 0);
69
- --secondary-foreground: oklch(0.985 0 0);
70
66
  --muted: oklch(0.269 0 0);
71
67
  --muted-foreground: oklch(0.708 0 0);
72
- --accent: oklch(0.269 0 0);
68
+ --accent: oklch(1 0 0 / 0.1);
73
69
  --accent-foreground: oklch(0.985 0 0);
74
70
  --destructive: oklch(0.58 0.22 27);
75
- --border: oklch(0.35 0 0);
71
+ --border: oklch(1 0 0 / 0.1);
76
72
  --input: oklch(0.35 0 0);
77
73
  --ring: oklch(0.556 0 0);
78
74
  }
@@ -157,41 +153,6 @@
157
153
  --tw-prose-bullets: inherit;
158
154
  }
159
155
 
160
- @utility mask-fade-bottom {
161
- mask-image: linear-gradient(black 0px, black calc(100% - 24px), transparent 100%);
162
- mask-size: 100% 100%;
163
- mask-position: 0px 0px;
164
- mask-repeat: no-repeat;
165
- }
166
-
167
- @utility mask-fade-top {
168
- mask-image: linear-gradient(transparent 0%, black 24px);
169
- mask-size: 100% 100%;
170
- mask-position: 0px 0px;
171
- mask-repeat: no-repeat;
172
- }
173
-
174
- @utility mask-fade-y {
175
- mask-image: linear-gradient(
176
- transparent 0%,
177
- black 24px,
178
- black calc(100% - 24px),
179
- transparent 100%
180
- );
181
- mask-size: 100% 100%;
182
- mask-position: 0px 0px;
183
- mask-repeat: no-repeat;
184
- }
185
-
186
- /* Hide the scrollbar entirely (e.g. the MCP hover card, which signals overflow
187
- with top/bottom mask fades instead — see useScrollFade + mask-fade-*). */
188
- @utility scrollbar-none {
189
- scrollbar-width: none;
190
- &::-webkit-scrollbar {
191
- display: none;
192
- }
193
- }
194
-
195
156
  /* Slim, unobtrusive scrollbar — keeps a clear scroll affordance while taming
196
157
  the chunky macOS "always show" scrollbar (a transparent border insets the
197
158
  thumb into a thin floating pill). */
package/client/index.html CHANGED
@@ -3,10 +3,10 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>moi.computer</title>
6
+ <title>moi</title>
7
7
  <link rel="icon" type="image/png" href="./assets/favicon.png" />
8
8
  <!-- React is vendored locally (client/vendor/react, generated by
9
- scripts/build-vendor.ts) and served by the /vendor/react route, so Moi
9
+ scripts/build-vendor.ts) and served by the /vendor/react route, so moi
10
10
  runs fully offline — no CDN fetch. The server picks the development or
11
11
  production build per environment behind these stable URLs. -->
12
12
  <script type="importmap">
package/client/index.tsx CHANGED
@@ -3,38 +3,21 @@ import './structured-clone-shim'
3
3
 
4
4
  import './index.css'
5
5
 
6
- // React is externalized to the locally-vendored ESM (see client/externalize-react.ts
7
- // + the importmap in index.html → /vendor/react), so Bun's bundled Fast Refresh
8
- // runtime isn't bound to the React
9
- // instance that actually renders the app: it registers component families but
10
- // performReactRefresh() no-ops, leaving stale modules mounted after an edit.
11
- // Downgrade HMR to plain live-reload — every hot update triggers a full page
12
- // reload, which re-fetches a clean bundle. Dead-code-eliminated in production.
13
- if (import.meta.hot) {
14
- import.meta.hot.on('bun:beforeUpdate', () => location.reload())
6
+ import { startHmrWatchdog } from './runtime/hmr-watchdog'
15
7
 
16
- // Bun's HMR client (≤1.3.14) never re-arms `onclose` on the socket it
17
- // creates while reconnecting, so the second disconnect in a tab's life
18
- // (e.g. laptop sleep, then a dev-supervisor restart) silently kills
19
- // live-reload and the tab serves a stale bundle forever. Watchdog: poll
20
- // the shell and hard-reload when the served script generation no longer
21
- // matches the one this page is running.
22
- const devScript = document.querySelector<HTMLScriptElement>('[data-bun-dev-server-script]')
23
- if (devScript) {
24
- const scriptPath = new URL(devScript.src).pathname
25
- const checkStale = async () => {
26
- try {
27
- const html = await (await fetch('/', { cache: 'no-store' })).text()
28
- if (!html.includes(scriptPath)) location.reload()
29
- } catch {
30
- // server mid-restart — the next tick will catch it
31
- }
32
- }
33
- setInterval(checkStale, 5_000)
34
- document.addEventListener('visibilitychange', () => {
35
- if (document.visibilityState === 'visible') checkStale()
36
- })
37
- }
8
+ // React Fast Refresh works here despite React being externalized to the
9
+ // locally-vendored ESM (client/externalize-react.ts + the importmap in
10
+ // index.html → /vendor/react): Bun's bundled refresh runtime wraps
11
+ // `__REACT_DEVTOOLS_GLOBAL_HOOK__` before the vendored react-dom registers,
12
+ // and the hook is a plain global, so the renderer link works across the
13
+ // bundle/vendor boundary. The one missing piece was that the externalized
14
+ // virtual modules (`esm:react/jsx-dev-runtime` etc.) were never hot-accepted,
15
+ // which made EVERY edit propagate to the entry and force a full reload —
16
+ // fixed by the `import.meta.hot.accept()` in externalize-react.ts. Component
17
+ // edits now apply in place; non-component modules (main.tsx, lib/*) still
18
+ // fall back to a full reload via Bun's runtime, which is correct.
19
+ if (import.meta.hot) {
20
+ startHmrWatchdog()
38
21
  }
39
22
 
40
23
  export async function init(el: HTMLElement) {
@@ -0,0 +1,145 @@
1
+ import type { TablerIcon } from '@tabler/icons-react'
2
+ import {
3
+ IconActivity,
4
+ IconApi,
5
+ IconAtom,
6
+ IconBell,
7
+ IconBolt,
8
+ IconBook,
9
+ IconBrain,
10
+ IconBriefcase,
11
+ IconBug,
12
+ IconBulb,
13
+ IconCalendar,
14
+ IconCamera,
15
+ IconChartBar,
16
+ IconChefHat,
17
+ IconCloud,
18
+ IconCode,
19
+ IconCompass,
20
+ IconCpu,
21
+ IconCube,
22
+ IconDatabase,
23
+ IconDeviceGamepad2,
24
+ IconDiamond,
25
+ IconFeather,
26
+ IconFile,
27
+ IconFlame,
28
+ IconFlask,
29
+ IconFolder,
30
+ IconGhost,
31
+ IconGift,
32
+ IconGlobe,
33
+ IconHeart,
34
+ IconHexagon,
35
+ IconHome,
36
+ IconKey,
37
+ IconLeaf,
38
+ IconMail,
39
+ IconMap,
40
+ IconMessage,
41
+ IconMoon,
42
+ IconMountain,
43
+ IconMusic,
44
+ IconPalette,
45
+ IconPaperclip,
46
+ IconPhoto,
47
+ IconPlanet,
48
+ IconPlug,
49
+ IconRobot,
50
+ IconRocket,
51
+ IconSettings,
52
+ IconShield,
53
+ IconShoppingCart,
54
+ IconSnowflake,
55
+ IconSparkles,
56
+ IconStar,
57
+ IconSun,
58
+ IconTarget,
59
+ IconTerminal2,
60
+ IconTool,
61
+ IconTrophy,
62
+ IconUser,
63
+ IconWand,
64
+ IconWorld
65
+ } from '@tabler/icons-react'
66
+
67
+ export type AppIconChoice = {
68
+ id: string
69
+ Icon: TablerIcon
70
+ }
71
+
72
+ // Shared by the workspace icon picker and view tabs. Add new app-level icon
73
+ // choices here so both surfaces and the view-builder prompt stay in sync.
74
+ export const APP_ICON_CHOICES: AppIconChoice[] = [
75
+ { id: 'rocket', Icon: IconRocket },
76
+ { id: 'sparkles', Icon: IconSparkles },
77
+ { id: 'bolt', Icon: IconBolt },
78
+ { id: 'flame', Icon: IconFlame },
79
+ { id: 'star', Icon: IconStar },
80
+ { id: 'heart', Icon: IconHeart },
81
+ { id: 'diamond', Icon: IconDiamond },
82
+ { id: 'trophy', Icon: IconTrophy },
83
+ { id: 'target', Icon: IconTarget },
84
+ { id: 'bulb', Icon: IconBulb },
85
+ { id: 'brain', Icon: IconBrain },
86
+ { id: 'robot', Icon: IconRobot },
87
+ { id: 'wand', Icon: IconWand },
88
+ { id: 'atom', Icon: IconAtom },
89
+ { id: 'flask', Icon: IconFlask },
90
+ { id: 'cpu', Icon: IconCpu },
91
+ { id: 'code', Icon: IconCode },
92
+ { id: 'terminal', Icon: IconTerminal2 },
93
+ { id: 'api', Icon: IconApi },
94
+ { id: 'database', Icon: IconDatabase },
95
+ { id: 'cube', Icon: IconCube },
96
+ { id: 'hexagon', Icon: IconHexagon },
97
+ { id: 'plug', Icon: IconPlug },
98
+ { id: 'tool', Icon: IconTool },
99
+ { id: 'settings', Icon: IconSettings },
100
+ { id: 'bug', Icon: IconBug },
101
+ { id: 'activity', Icon: IconActivity },
102
+ { id: 'chart', Icon: IconChartBar },
103
+ { id: 'briefcase', Icon: IconBriefcase },
104
+ { id: 'folder', Icon: IconFolder },
105
+ { id: 'file', Icon: IconFile },
106
+ { id: 'book', Icon: IconBook },
107
+ { id: 'message', Icon: IconMessage },
108
+ { id: 'mail', Icon: IconMail },
109
+ { id: 'bell', Icon: IconBell },
110
+ { id: 'paperclip', Icon: IconPaperclip },
111
+ { id: 'key', Icon: IconKey },
112
+ { id: 'shield', Icon: IconShield },
113
+ { id: 'user', Icon: IconUser },
114
+ { id: 'home', Icon: IconHome },
115
+ { id: 'globe', Icon: IconGlobe },
116
+ { id: 'world', Icon: IconWorld },
117
+ { id: 'planet', Icon: IconPlanet },
118
+ { id: 'compass', Icon: IconCompass },
119
+ { id: 'map', Icon: IconMap },
120
+ { id: 'calendar', Icon: IconCalendar },
121
+ { id: 'cloud', Icon: IconCloud },
122
+ { id: 'sun', Icon: IconSun },
123
+ { id: 'moon', Icon: IconMoon },
124
+ { id: 'snowflake', Icon: IconSnowflake },
125
+ { id: 'leaf', Icon: IconLeaf },
126
+ { id: 'mountain', Icon: IconMountain },
127
+ { id: 'feather', Icon: IconFeather },
128
+ { id: 'ghost', Icon: IconGhost },
129
+ { id: 'music', Icon: IconMusic },
130
+ { id: 'camera', Icon: IconCamera },
131
+ { id: 'photo', Icon: IconPhoto },
132
+ { id: 'palette', Icon: IconPalette },
133
+ { id: 'gamepad', Icon: IconDeviceGamepad2 },
134
+ { id: 'gift', Icon: IconGift },
135
+ { id: 'cart', Icon: IconShoppingCart },
136
+ { id: 'chef', Icon: IconChefHat }
137
+ ]
138
+
139
+ export const APP_ICON_IDS = APP_ICON_CHOICES.map(choice => choice.id)
140
+
141
+ const appIconById = new Map(APP_ICON_CHOICES.map(choice => [choice.id, choice.Icon]))
142
+
143
+ export function resolveAppIcon(id: string | undefined): TablerIcon | null {
144
+ return id ? (appIconById.get(id) ?? null) : null
145
+ }
package/client/main.tsx CHANGED
@@ -3,8 +3,8 @@ import { Agentation } from 'agentation'
3
3
  import { createRoot } from 'react-dom/client'
4
4
  import { Router } from 'wouter'
5
5
 
6
- import { initConnection } from './lib/connection'
7
- import { AppRouter } from './components/App'
6
+ import { initConnection } from '@/client/features/chat/chat-connection'
7
+ import { AppRouter } from './app/AppRouter'
8
8
 
9
9
  const queryClient = new QueryClient()
10
10
 
@@ -0,0 +1,39 @@
1
+ export function startHmrWatchdog() {
2
+ if (!import.meta.hot) return
3
+ let lastEventAt = Date.now()
4
+ for (const event of ['bun:beforeUpdate', 'bun:afterUpdate', 'bun:ws:connect'] as const) {
5
+ import.meta.hot.on(event, () => (lastEventAt = Date.now()))
6
+ }
7
+
8
+ const devScript = document.querySelector<HTMLScriptElement>('[data-bun-dev-server-script]')
9
+ if (!devScript) return
10
+
11
+ let baseline = new URL(devScript.src).pathname
12
+ let staleSince: number | null = null
13
+
14
+ const checkStale = async () => {
15
+ try {
16
+ const html = await (await fetch('/', { cache: 'no-store' })).text()
17
+ const current = html.match(/\/_bun\/client\/index-[0-9a-f]+\.js/)?.[0]
18
+ if (!current || current === baseline) {
19
+ staleSince = null
20
+ return
21
+ }
22
+
23
+ staleSince ??= Date.now()
24
+ if (lastEventAt >= staleSince - 5_000) {
25
+ baseline = current
26
+ staleSince = null
27
+ } else if (Date.now() - staleSince > 10_000) {
28
+ location.reload()
29
+ }
30
+ } catch {
31
+ // The server may be between supervisor restarts. The next check retries.
32
+ }
33
+ }
34
+
35
+ setInterval(checkStale, 5_000)
36
+ document.addEventListener('visibilitychange', () => {
37
+ if (document.visibilityState === 'visible') checkStale()
38
+ })
39
+ }