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,468 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
+
3
+ import { Button } from '@/client/components/ui/button'
4
+ import { cn } from '@/client/lib/cn'
5
+ import { wsUrl } from '@/client/lib/ws-url'
6
+ import type { Model, WorkspaceEntry, WorkspaceModels } from '@/lib/types'
7
+
8
+ // Scratch route for driving any harness end to end: pick a workspace, fire
9
+ // canned scenarios (or your own prompt), and watch three synchronized logs —
10
+ // the backend's native wire (Codex: app-server JSON-RPC; Claude Code: raw SDK
11
+ // messages), the frames the server pushes to chat clients, and the durable
12
+ // events REST replay. See server/harness/README.md.
13
+
14
+ type WireFrame = { seq: number; ts: number; dir: 'send' | 'recv'; frame: unknown }
15
+ type BroadcastFrame = { seq: number; ts: number; frame: unknown }
16
+ type ProcessInfo = { running: boolean; pid?: number; binary: string | null }
17
+
18
+ type DebugPayload = {
19
+ provider: string
20
+ process: ProcessInfo | null
21
+ wire: WireFrame[]
22
+ broadcasts: BroadcastFrame[]
23
+ }
24
+
25
+ const SCENARIOS: { label: string; prompt: string }[] = [
26
+ {
27
+ label: 'Trivial',
28
+ prompt: 'Reply with exactly: pong'
29
+ },
30
+ {
31
+ label: 'Reasoning',
32
+ prompt:
33
+ 'Think carefully: a farmer has 17 sheep, all but 9 run away, then he buys twice as many as remain. How many sheep now? Reason it out before answering.'
34
+ },
35
+ {
36
+ label: 'Command',
37
+ prompt: 'Run `ls -la` and summarize what you see in one sentence.'
38
+ },
39
+ {
40
+ label: 'File edit',
41
+ prompt: 'Create or overwrite scratch.txt with three random words, one per line.'
42
+ },
43
+ {
44
+ label: 'Plan',
45
+ prompt:
46
+ 'Make a 3-step plan (use your plan tool) for adding a README to this folder, then execute it.'
47
+ },
48
+ {
49
+ label: 'Subagent',
50
+ prompt:
51
+ 'Spawn a subagent (collab/agent tool) to count the files in this directory and report back its answer.'
52
+ },
53
+ {
54
+ label: 'Web search',
55
+ prompt: 'Search the web for the current Bun version and tell me what you find.'
56
+ },
57
+ {
58
+ label: 'Slow (interrupt me)',
59
+ prompt: 'Run this exact command: sleep 30 && echo done. Nothing else.'
60
+ }
61
+ ]
62
+
63
+ function shortJson(value: unknown, max = 110): string {
64
+ const s = JSON.stringify(value)
65
+ if (!s) return ''
66
+ return s.length > max ? s.slice(0, max) + '…' : s
67
+ }
68
+
69
+ function frameLabel(frame: unknown): string {
70
+ const f = frame as Record<string, unknown>
71
+ if (typeof f?.method === 'string') {
72
+ return 'id' in f ? `${f.method} #${f.id}` : f.method
73
+ }
74
+ if ('id' in (f ?? {})) return `response #${f.id}`
75
+ if (typeof f?.kind === 'string') return `${f.kind}`
76
+ if (typeof f?.type === 'string') return `${f.type}`
77
+ return '?'
78
+ }
79
+
80
+ function ts(t: number): string {
81
+ return (
82
+ new Date(t).toLocaleTimeString('en-GB', { hour12: false }) +
83
+ '.' +
84
+ String(t % 1000).padStart(3, '0')
85
+ )
86
+ }
87
+
88
+ type LogRowProps = {
89
+ time: number
90
+ badge: string
91
+ badgeClass: string
92
+ label: string
93
+ body: unknown
94
+ }
95
+
96
+ function LogRow({ time, badge, badgeClass, label, body }: LogRowProps) {
97
+ return (
98
+ <details className="group border-b border-border/40 px-2 py-1 text-[11px] leading-tight">
99
+ <summary className="flex cursor-pointer items-baseline gap-2 font-mono whitespace-nowrap">
100
+ <span className="text-muted-foreground/60 tabular-nums">{ts(time)}</span>
101
+ <span className={cn('rounded px-1 font-semibold', badgeClass)}>{badge}</span>
102
+ <span className="shrink-0 font-semibold">{label}</span>
103
+ <span className="truncate text-muted-foreground">{shortJson(body)}</span>
104
+ </summary>
105
+ <pre className="mt-1 max-h-80 overflow-auto rounded bg-muted p-2 text-[10px] whitespace-pre-wrap">
106
+ {JSON.stringify(body, null, 2)}
107
+ </pre>
108
+ </details>
109
+ )
110
+ }
111
+
112
+ type PaneProps = {
113
+ title: string
114
+ hint?: string
115
+ onClear?: () => void
116
+ children: React.ReactNode
117
+ }
118
+
119
+ function Pane({ title, hint, onClear, children }: PaneProps) {
120
+ const scroller = useRef<HTMLDivElement>(null)
121
+ const [follow, setFollow] = useState(true)
122
+ useEffect(() => {
123
+ if (follow && scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight
124
+ })
125
+ return (
126
+ <div className="flex min-h-0 flex-1 flex-col rounded-lg border border-border bg-background">
127
+ <div className="flex items-center gap-2 border-b border-border px-2 py-1">
128
+ <span className="text-xs font-semibold">{title}</span>
129
+ {hint && <span className="truncate text-[10px] text-muted-foreground">{hint}</span>}
130
+ <span className="grow" />
131
+ <label className="flex items-center gap-1 text-[10px] text-muted-foreground">
132
+ <input type="checkbox" checked={follow} onChange={e => setFollow(e.target.checked)} />
133
+ follow
134
+ </label>
135
+ {onClear && (
136
+ <Button type="button" variant="ghost" size="sm" onClick={onClear}>
137
+ Clear
138
+ </Button>
139
+ )}
140
+ </div>
141
+ <div ref={scroller} className="min-h-0 flex-1 overflow-y-auto">
142
+ {children}
143
+ </div>
144
+ </div>
145
+ )
146
+ }
147
+
148
+ export function HarnessDebugPage() {
149
+ const [workspaces, setWorkspaces] = useState<WorkspaceEntry[]>([])
150
+ const [workspaceId, setWorkspaceId] = useState('')
151
+ const [models, setModels] = useState<Model[]>([])
152
+ const [model, setModel] = useState('')
153
+ const [effort, setEffort] = useState('')
154
+ const [stream, setStream] = useState(true)
155
+ const [sessionId, setSessionId] = useState<string>(() => crypto.randomUUID())
156
+ const [isNew, setIsNew] = useState(true)
157
+ const [prompt, setPrompt] = useState('')
158
+ const [proc, setProc] = useState<ProcessInfo | null>(null)
159
+ const [wire, setWire] = useState<WireFrame[]>([])
160
+ const [clientFrames, setClientFrames] = useState<BroadcastFrame[]>([])
161
+ const [events, setEvents] = useState<unknown[] | null>(null)
162
+ const [hidePreviews, setHidePreviews] = useState(false)
163
+
164
+ const wireCursor = useRef(0)
165
+ const wsRef = useRef<WebSocket | null>(null)
166
+ const localSeq = useRef(0)
167
+ const sessionRef = useRef(sessionId)
168
+ sessionRef.current = sessionId
169
+
170
+ // Every workspace is drivable — the panes adapt to its harness type.
171
+ useEffect(() => {
172
+ fetch('/api/workspaces')
173
+ .then(r => r.json())
174
+ .then((list: WorkspaceEntry[]) => {
175
+ setWorkspaces(list)
176
+ setWorkspaceId(id => id || (list[0]?.id ?? ''))
177
+ })
178
+ .catch(() => {})
179
+ }, [])
180
+
181
+ const provider = workspaces.find(w => w.id === workspaceId)?.type ?? 'claude-code'
182
+
183
+ // Model list for the selected workspace.
184
+ useEffect(() => {
185
+ if (!workspaceId) return
186
+ fetch(`/api/workspaces/${workspaceId}/models`)
187
+ .then(r => r.json())
188
+ .then((m: WorkspaceModels) => setModels(m.models))
189
+ .catch(() => setModels([]))
190
+ }, [workspaceId])
191
+
192
+ // Switching workspace targets a different harness — the old thread id is
193
+ // meaningless there (a codex resume of a Claude session id just errors),
194
+ // so start a fresh thread.
195
+ useEffect(() => {
196
+ setSessionId(crypto.randomUUID())
197
+ setIsNew(true)
198
+ setEvents(null)
199
+ }, [workspaceId])
200
+
201
+ // Poll the wire tap (the backend's native frames) once a second.
202
+ useEffect(() => {
203
+ if (!workspaceId) return
204
+ wireCursor.current = 0
205
+ setWire([])
206
+ const timer = setInterval(async () => {
207
+ try {
208
+ const r = await fetch(
209
+ `/api/workspaces/${workspaceId}/harness/debug?sinceWire=${wireCursor.current}&sinceBroadcast=-1`
210
+ )
211
+ if (!r.ok) return
212
+ const d = (await r.json()) as DebugPayload
213
+ setProc(d.process)
214
+ if (d.wire.length) {
215
+ wireCursor.current = d.wire[d.wire.length - 1].seq
216
+ setWire(prev => [...prev, ...d.wire].slice(-1000))
217
+ }
218
+ } catch {}
219
+ }, 1000)
220
+ return () => clearInterval(timer)
221
+ }, [workspaceId])
222
+
223
+ // Live client frames: our own chat socket, same protocol as the real UI.
224
+ useEffect(() => {
225
+ if (!workspaceId) return
226
+ const sock = new WebSocket(wsUrl('/ws'))
227
+ wsRef.current = sock
228
+ sock.onmessage = e => {
229
+ try {
230
+ const frame = JSON.parse(String(e.data)) as Record<string, unknown>
231
+ if (frame.workspaceId && frame.workspaceId !== workspaceId) return
232
+ if (frame.type === 'session_renamed' && frame.from === sessionRef.current) {
233
+ setSessionId(frame.to as string)
234
+ setIsNew(false)
235
+ }
236
+ setClientFrames(prev =>
237
+ [...prev, { seq: ++localSeq.current, ts: Date.now(), frame }].slice(-1000)
238
+ )
239
+ } catch {}
240
+ }
241
+ return () => {
242
+ wsRef.current = null
243
+ sock.close()
244
+ }
245
+ }, [workspaceId])
246
+
247
+ const send = useCallback(
248
+ (content: string) => {
249
+ if (!content.trim() || !wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) return
250
+ wsRef.current.send(
251
+ JSON.stringify({
252
+ type: 'chat',
253
+ workspaceId,
254
+ sessionId: sessionRef.current,
255
+ isNew,
256
+ content,
257
+ optimisticId: crypto.randomUUID(),
258
+ ...(model ? { model } : {}),
259
+ ...(effort ? { effort } : {}),
260
+ stream
261
+ })
262
+ )
263
+ setIsNew(false)
264
+ },
265
+ [workspaceId, isNew, model, effort, stream]
266
+ )
267
+
268
+ const stop = useCallback(() => {
269
+ wsRef.current?.send(
270
+ JSON.stringify({ type: 'stop', workspaceId, sessionId: sessionRef.current })
271
+ )
272
+ }, [workspaceId])
273
+
274
+ const newThread = useCallback(() => {
275
+ setSessionId(crypto.randomUUID())
276
+ setIsNew(true)
277
+ setEvents(null)
278
+ }, [])
279
+
280
+ const fetchEvents = useCallback(async () => {
281
+ const r = await fetch(`/api/workspaces/${workspaceId}/sessions/${sessionRef.current}/events`)
282
+ setEvents(r.ok ? ((await r.json()) as unknown[]) : [])
283
+ }, [workspaceId])
284
+
285
+ const effortLevels = useMemo(
286
+ () => models.find(m => m.value === model)?.supportedEffortLevels ?? [],
287
+ [models, model]
288
+ )
289
+
290
+ const visibleClientFrames = useMemo(
291
+ () =>
292
+ hidePreviews
293
+ ? clientFrames.filter(f => (f.frame as { type?: string }).type !== 'preview')
294
+ : clientFrames,
295
+ [clientFrames, hidePreviews]
296
+ )
297
+
298
+ return (
299
+ <div className="flex h-dvh flex-col gap-2 bg-muted p-2">
300
+ <div className="flex flex-wrap items-center gap-2 rounded-lg border border-border bg-background px-2 py-1.5 text-xs">
301
+ <span className="font-semibold tracking-widest text-muted-foreground uppercase">
302
+ Harness debug
303
+ </span>
304
+ <select
305
+ className="rounded border border-border bg-background px-1 py-0.5"
306
+ value={workspaceId}
307
+ onChange={e => setWorkspaceId(e.target.value)}
308
+ >
309
+ {workspaces.length === 0 && <option value="">no workspaces</option>}
310
+ {workspaces.map(w => (
311
+ <option key={w.id} value={w.id}>
312
+ {`${w.name ?? w.displayPath ?? w.path} · ${w.type ?? 'claude-code'}`}
313
+ </option>
314
+ ))}
315
+ </select>
316
+ <select
317
+ className="rounded border border-border bg-background px-1 py-0.5"
318
+ value={model}
319
+ onChange={e => setModel(e.target.value)}
320
+ >
321
+ <option value="">default model</option>
322
+ {models.map(m => (
323
+ <option key={m.value} value={m.value}>
324
+ {m.displayName}
325
+ </option>
326
+ ))}
327
+ </select>
328
+ <select
329
+ className="rounded border border-border bg-background px-1 py-0.5"
330
+ value={effort}
331
+ onChange={e => setEffort(e.target.value)}
332
+ >
333
+ <option value="">default effort</option>
334
+ {effortLevels.map(l => (
335
+ <option key={l} value={l}>
336
+ {l}
337
+ </option>
338
+ ))}
339
+ </select>
340
+ <label className="flex items-center gap-1">
341
+ <input type="checkbox" checked={stream} onChange={e => setStream(e.target.checked)} />
342
+ stream
343
+ </label>
344
+ <span className="grow" />
345
+ {provider === 'codex' && (
346
+ <span
347
+ className={cn(
348
+ 'rounded px-1.5 py-0.5 font-mono text-[10px]',
349
+ proc?.running ? 'bg-green-500/15 text-green-600' : 'bg-muted text-muted-foreground'
350
+ )}
351
+ >
352
+ {proc?.running ? `app-server pid ${proc.pid}` : 'app-server not running'}
353
+ </span>
354
+ )}
355
+ <span className="max-w-56 truncate font-mono text-[10px] text-muted-foreground">
356
+ thread {sessionId}
357
+ </span>
358
+ <Button type="button" size="sm" variant="outline" onClick={newThread}>
359
+ New thread
360
+ </Button>
361
+ <Button type="button" size="sm" variant="outline" onClick={stop}>
362
+ Stop
363
+ </Button>
364
+ </div>
365
+
366
+ <div className="flex flex-wrap items-center gap-1.5 rounded-lg border border-border bg-background px-2 py-1.5">
367
+ {SCENARIOS.map(s => (
368
+ <Button
369
+ key={s.label}
370
+ type="button"
371
+ size="sm"
372
+ variant="secondary"
373
+ onClick={() => send(s.prompt)}
374
+ >
375
+ {s.label}
376
+ </Button>
377
+ ))}
378
+ <input
379
+ className="min-w-48 grow rounded border border-border bg-background px-2 py-1 text-xs"
380
+ placeholder="or type a custom prompt and hit Enter…"
381
+ value={prompt}
382
+ onChange={e => setPrompt(e.target.value)}
383
+ onKeyDown={e => {
384
+ if (e.key === 'Enter') {
385
+ send(prompt)
386
+ setPrompt('')
387
+ }
388
+ }}
389
+ />
390
+ </div>
391
+
392
+ <div className="flex min-h-0 flex-1 gap-2">
393
+ <Pane
394
+ title={provider === 'codex' ? 'App-server wire' : 'Harness wire'}
395
+ hint={
396
+ provider === 'codex'
397
+ ? 'raw JSON-RPC, both directions'
398
+ : provider === 'openclaw'
399
+ ? 'no wire tap for OpenClaw yet'
400
+ : 'raw Agent SDK messages + enqueued inputs'
401
+ }
402
+ onClear={() => setWire([])}
403
+ >
404
+ {wire.map(f => (
405
+ <LogRow
406
+ key={f.seq}
407
+ time={f.ts}
408
+ badge={f.dir === 'send' ? '→' : '←'}
409
+ badgeClass={
410
+ f.dir === 'send' ? 'bg-blue-500/15 text-blue-600' : 'bg-amber-500/15 text-amber-600'
411
+ }
412
+ label={frameLabel(f.frame)}
413
+ body={f.frame}
414
+ />
415
+ ))}
416
+ </Pane>
417
+
418
+ <Pane
419
+ title="Client frames"
420
+ hint="what the browser receives on /ws"
421
+ onClear={() => setClientFrames([])}
422
+ >
423
+ <div className="border-b border-border/40 px-2 py-1">
424
+ <label className="flex items-center gap-1 text-[10px] text-muted-foreground">
425
+ <input
426
+ type="checkbox"
427
+ checked={hidePreviews}
428
+ onChange={e => setHidePreviews(e.target.checked)}
429
+ />
430
+ hide preview frames
431
+ </label>
432
+ </div>
433
+ {visibleClientFrames.map(f => (
434
+ <LogRow
435
+ key={f.seq}
436
+ time={f.ts}
437
+ badge="ws"
438
+ badgeClass="bg-purple-500/15 text-purple-600"
439
+ label={frameLabel(f.frame)}
440
+ body={f.frame}
441
+ />
442
+ ))}
443
+ </Pane>
444
+
445
+ <Pane title="Durable events" hint="GET /sessions/:id/events replay">
446
+ <div className="border-b border-border/40 px-2 py-1">
447
+ <Button type="button" size="sm" variant="secondary" onClick={fetchEvents}>
448
+ Fetch events
449
+ </Button>
450
+ </div>
451
+ {events?.map((ev, i) => (
452
+ <LogRow
453
+ key={i}
454
+ time={Date.now()}
455
+ badge="ev"
456
+ badgeClass="bg-teal-500/15 text-teal-600"
457
+ label={frameLabel(ev)}
458
+ body={ev}
459
+ />
460
+ ))}
461
+ {events?.length === 0 && (
462
+ <div className="p-2 text-[11px] text-muted-foreground">no events</div>
463
+ )}
464
+ </Pane>
465
+ </div>
466
+ </div>
467
+ )
468
+ }
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
 
3
+ import { Button } from '@/client/components/ui/button'
3
4
  import { cn } from '@/client/lib/cn'
4
5
 
5
6
  const COLS = 5
@@ -60,45 +61,33 @@ export function PixelPainter() {
60
61
 
61
62
  return (
62
63
  <div className="flex flex-col items-center gap-4">
63
- <div className="grid w-fit grid-cols-[repeat(5,28px)] gap-px bg-black/15 p-px select-none">
64
+ <div className="grid w-fit grid-cols-[repeat(5,28px)] gap-px bg-border p-px select-none">
64
65
  {grid.map((row, r) =>
65
66
  row.map((on, c) => (
66
67
  <div
67
68
  key={`${r}-${c}`}
68
69
  onMouseDown={() => handleDown(r, c)}
69
70
  onMouseEnter={() => handleEnter(r, c)}
70
- className={cn('size-7 cursor-pointer', on ? 'bg-neutral-900' : 'bg-white')}
71
+ className={cn('size-7 cursor-pointer', on ? 'bg-foreground' : 'bg-background')}
71
72
  />
72
73
  ))
73
74
  )}
74
75
  </div>
75
76
 
76
- <pre className="rounded-md border border-border bg-white px-3 py-2 text-center font-mono text-sm leading-snug text-neutral-900">
77
+ <pre className="rounded-md border border-border bg-card px-3 py-2 text-center font-mono text-sm leading-snug text-card-foreground">
77
78
  {ascii}
78
79
  </pre>
79
80
 
80
81
  <div className="flex gap-2">
81
- <button
82
- type="button"
83
- onClick={copy}
84
- className="rounded-md bg-neutral-900 px-3 py-1 text-xs font-medium text-white"
85
- >
82
+ <Button type="button" size="sm" onClick={copy}>
86
83
  {copied ? 'Copied!' : 'Copy'}
87
- </button>
88
- <button
89
- type="button"
90
- onClick={() => setGrid(emptyGrid())}
91
- className="rounded-md bg-black/[0.06] px-3 py-1 text-xs font-medium text-black/60 hover:text-black/80"
92
- >
84
+ </Button>
85
+ <Button type="button" variant="secondary" size="sm" onClick={() => setGrid(emptyGrid())}>
93
86
  Clear
94
- </button>
95
- <button
96
- type="button"
97
- onClick={() => setGrid(fromRows(SEED))}
98
- className="rounded-md bg-black/[0.06] px-3 py-1 text-xs font-medium text-black/60 hover:text-black/80"
99
- >
87
+ </Button>
88
+ <Button type="button" variant="secondary" size="sm" onClick={() => setGrid(fromRows(SEED))}>
100
89
  Reset
101
- </button>
90
+ </Button>
102
91
  </div>
103
92
  </div>
104
93
  )
@@ -1,13 +1,13 @@
1
1
  import { useState } from 'react'
2
2
 
3
- import { cn } from '@/client/lib/cn'
3
+ import { Button } from '@/client/components/ui/button'
4
4
 
5
- import { type Effect, LedLogo, type Sprite } from './LedLogo'
5
+ import { type Effect, LedLogo, type Sprite } from '@/client/components/shared/LedLogo'
6
6
  import { PixelPainter } from './PixelPainter'
7
7
 
8
8
  const SPRITES: { value: Sprite; label: string }[] = [
9
9
  { value: 'moi', label: 'M' },
10
- { value: 'moi-full', label: 'MOI' }
10
+ { value: 'moi-full', label: 'moi' }
11
11
  ]
12
12
 
13
13
  const EFFECTS: { value: Effect | 'none'; label: string }[] = [
@@ -24,19 +24,17 @@ type SegmentedProps<T extends string | number> = {
24
24
 
25
25
  function Segmented<T extends string | number>({ options, value, onChange }: SegmentedProps<T>) {
26
26
  return (
27
- <div className="flex gap-1 rounded-lg bg-black/[0.04] p-1">
27
+ <div className="flex gap-1 rounded-lg bg-accent p-1">
28
28
  {options.map(o => (
29
- <button
29
+ <Button
30
30
  key={String(o.value)}
31
31
  type="button"
32
+ variant={value === o.value ? 'default' : 'ghost'}
33
+ size="sm"
32
34
  onClick={() => onChange(o.value)}
33
- className={cn(
34
- 'rounded-md px-3 py-1 text-xs transition-colors',
35
- value === o.value ? 'bg-neutral-900 text-white' : 'text-black/50 hover:text-black/80'
36
- )}
37
35
  >
38
36
  {o.label}
39
- </button>
37
+ </Button>
40
38
  ))}
41
39
  </div>
42
40
  )
@@ -48,8 +46,8 @@ export function PlaygroundPage() {
48
46
  const [effect, setEffect] = useState<Effect | 'none'>('none')
49
47
 
50
48
  return (
51
- <div className="relative flex min-h-dvh flex-col items-center justify-center gap-8 bg-[#f2f1ee]">
52
- <span className="absolute top-5 left-5 text-[11px] font-medium tracking-widest text-black/30 uppercase">
49
+ <div className="relative flex min-h-dvh flex-col items-center justify-center gap-8 bg-muted">
50
+ <span className="absolute top-5 left-5 text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
53
51
  Playground
54
52
  </span>
55
53
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react'
2
2
 
3
- import { cn } from '@/client/lib/cn'
3
+ import { Button } from '@/client/components/ui/button'
4
4
  import {
5
5
  FIXTURE_CWD,
6
6
  liveToolCalls,
@@ -9,7 +9,7 @@ import {
9
9
  subagentDoneTrace,
10
10
  subagentTrace,
11
11
  ToolCallGroup
12
- } from '@/client/components/tool-group'
12
+ } from '@/client/features/chat/tool-group'
13
13
 
14
14
  const VARIANTS = [
15
15
  { value: 'single', label: 'Single' },
@@ -28,19 +28,17 @@ type SegmentedProps = {
28
28
 
29
29
  function Segmented({ value, onChange }: SegmentedProps) {
30
30
  return (
31
- <div className="flex gap-1 rounded-lg bg-black/[0.04] p-1">
31
+ <div className="flex gap-1 rounded-lg bg-accent p-1">
32
32
  {VARIANTS.map(o => (
33
- <button
33
+ <Button
34
34
  key={o.value}
35
35
  type="button"
36
+ variant={value === o.value ? 'default' : 'ghost'}
37
+ size="sm"
36
38
  onClick={() => onChange(o.value)}
37
- className={cn(
38
- 'rounded-md px-3 py-1 text-xs transition-colors',
39
- value === o.value ? 'bg-neutral-900 text-white' : 'text-black/50 hover:text-black/80'
40
- )}
41
39
  >
42
40
  {o.label}
43
- </button>
41
+ </Button>
44
42
  ))}
45
43
  </div>
46
44
  )
@@ -60,8 +58,8 @@ export function ToolCallsPage() {
60
58
  const [variant, setVariant] = useState<Variant>('multiple')
61
59
 
62
60
  return (
63
- <div className="flex min-h-dvh flex-col items-center gap-6 bg-[#f2f1ee] px-4 py-16">
64
- <span className="text-[11px] font-medium tracking-widest text-black/30 uppercase">
61
+ <div className="flex min-h-dvh flex-col items-center gap-6 bg-muted px-4 py-16">
62
+ <span className="text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
65
63
  Playground / Tool calls
66
64
  </span>
67
65