moi-computer 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +2 -2
  2. package/bunfig.toml +4 -0
  3. package/client/api/workspaces.ts +277 -6
  4. package/client/assets/mcp/agentation.png +0 -0
  5. package/client/assets/mcp/airtable.png +0 -0
  6. package/client/assets/mcp/apollo.png +0 -0
  7. package/client/assets/mcp/asana.png +0 -0
  8. package/client/assets/mcp/box.png +0 -0
  9. package/client/assets/mcp/chrome.svg +33 -0
  10. package/client/assets/mcp/clickup.png +0 -0
  11. package/client/assets/mcp/cloudflare.png +0 -0
  12. package/client/assets/mcp/context7.png +0 -0
  13. package/client/assets/mcp/datadog.png +0 -0
  14. package/client/assets/mcp/dropbox.png +0 -0
  15. package/client/assets/mcp/elevenlabs.png +0 -0
  16. package/client/assets/mcp/exa.png +0 -0
  17. package/client/assets/mcp/firecrawl.png +0 -0
  18. package/client/assets/mcp/gmail.png +0 -0
  19. package/client/assets/mcp/googlecalendar.png +0 -0
  20. package/client/assets/mcp/googledrive.png +0 -0
  21. package/client/assets/mcp/grafana.png +0 -0
  22. package/client/assets/mcp/huggingface.png +0 -0
  23. package/client/assets/mcp/intercom.png +0 -0
  24. package/client/assets/mcp/monday.png +0 -0
  25. package/client/assets/mcp/mongodb.png +0 -0
  26. package/client/assets/mcp/paper.png +0 -0
  27. package/client/assets/mcp/paypal.png +0 -0
  28. package/client/assets/mcp/perplexity.png +0 -0
  29. package/client/assets/mcp/postgresql.png +0 -0
  30. package/client/assets/mcp/posthog.png +0 -0
  31. package/client/assets/mcp/puppeteer.png +0 -0
  32. package/client/assets/mcp/railway.png +0 -0
  33. package/client/assets/mcp/redis.png +0 -0
  34. package/client/assets/mcp/salesforce.png +0 -0
  35. package/client/assets/mcp/shopify.png +0 -0
  36. package/client/assets/mcp/snowflake.png +0 -0
  37. package/client/assets/mcp/telegram.png +0 -0
  38. package/client/assets/mcp/twilio.png +0 -0
  39. package/client/assets/mcp/zapier.png +0 -0
  40. package/client/components/App.tsx +7 -1
  41. package/client/components/ChatInput.tsx +194 -13
  42. package/client/components/ChatPanel.tsx +116 -47
  43. package/client/components/ChatPopup.tsx +1 -1
  44. package/client/components/IconMcp.tsx +21 -0
  45. package/client/components/McpMenu.tsx +125 -0
  46. package/client/components/ModelPicker.tsx +147 -0
  47. package/client/components/Scratchpad.tsx +775 -0
  48. package/client/components/ShimmerText.tsx +20 -0
  49. package/client/components/ThreadSelector.tsx +2 -2
  50. package/client/components/TurnView.tsx +111 -531
  51. package/client/components/WidgetShell.tsx +1 -1
  52. package/client/components/WorkspacesPage.tsx +12 -4
  53. package/client/components/layout/SidebarLayout.tsx +18 -9
  54. package/client/components/playground/ToolCallsPage.tsx +81 -0
  55. package/client/components/routes/workspace/[id].tsx +534 -141
  56. package/client/components/routes/workspace/create.tsx +155 -0
  57. package/client/components/settings/IconPicker.tsx +590 -0
  58. package/client/components/settings/SettingsPages.tsx +307 -0
  59. package/client/components/settings/WorkspaceSettings.tsx +92 -0
  60. package/client/components/tool-group/CodeBlock.tsx +41 -0
  61. package/client/components/tool-group/Collapse.tsx +28 -0
  62. package/client/components/tool-group/ReadImagePreview.tsx +46 -0
  63. package/client/components/tool-group/SubagentCard.tsx +135 -0
  64. package/client/components/tool-group/TimelineRow.tsx +147 -0
  65. package/client/components/tool-group/ToolCallGroup.tsx +231 -0
  66. package/client/components/tool-group/ToolOutput.tsx +139 -0
  67. package/client/components/tool-group/detect.ts +93 -0
  68. package/client/components/tool-group/fixtures.ts +315 -0
  69. package/client/components/tool-group/format.ts +211 -0
  70. package/client/components/tool-group/index.ts +9 -0
  71. package/client/components/ui/dialog.tsx +58 -0
  72. package/client/components/ui/hover-card.tsx +44 -0
  73. package/client/components/ui/switch.tsx +23 -0
  74. package/client/components/ui/tooltip.tsx +54 -0
  75. package/client/externalize-react.ts +6 -0
  76. package/client/hooks/useApplet.ts +117 -0
  77. package/client/hooks/useChat.ts +162 -62
  78. package/client/hooks/useMeiEvents.ts +9 -2
  79. package/client/hooks/useStickToBottom.ts +86 -0
  80. package/client/hooks/useWorkspaceTheme.ts +8 -2
  81. package/client/index.css +48 -2
  82. package/client/index.html +9 -5
  83. package/client/index.tsx +29 -2
  84. package/client/lib/WorkspaceContext.tsx +5 -8
  85. package/client/lib/WorkspaceLayoutContext.tsx +30 -10
  86. package/client/lib/applet-cache.ts +54 -0
  87. package/client/lib/connection.ts +237 -0
  88. package/client/lib/flags.ts +10 -0
  89. package/client/lib/mcp-icons.ts +142 -10
  90. package/client/lib/preview-turn.ts +37 -0
  91. package/client/lib/render-icon.ts +173 -0
  92. package/client/lib/scratch-executor.ts +20 -0
  93. package/client/lib/uploads.ts +18 -0
  94. package/client/main.tsx +5 -0
  95. package/client/store/live.ts +282 -0
  96. package/client/structured-clone-shim.ts +14 -0
  97. package/client/theme.css +2 -2
  98. package/client/vendor/emojibase/en/data.json +1 -0
  99. package/client/vendor/emojibase/en/messages.json +1 -0
  100. package/client/vendor/react/development/_impl/react-dom-client.js +15871 -0
  101. package/client/vendor/react/development/_impl/react-dom.js +223 -0
  102. package/client/vendor/react/development/_impl/react-jsx-dev-runtime.js +256 -0
  103. package/client/vendor/react/development/_impl/react-jsx-runtime.js +260 -0
  104. package/client/vendor/react/development/_impl/react.js +863 -0
  105. package/client/vendor/react/development/react-dom-client.js +6 -0
  106. package/client/vendor/react/development/react-dom.js +17 -0
  107. package/client/vendor/react/development/react-jsx-dev-runtime.js +5 -0
  108. package/client/vendor/react/development/react-jsx-runtime.js +6 -0
  109. package/client/vendor/react/development/react.js +47 -0
  110. package/client/vendor/react/production/_impl/react-dom-client.js +10361 -0
  111. package/client/vendor/react/production/_impl/react-dom.js +184 -0
  112. package/client/vendor/react/production/_impl/react-jsx-dev-runtime.js +37 -0
  113. package/client/vendor/react/production/_impl/react-jsx-runtime.js +60 -0
  114. package/client/vendor/react/production/_impl/react.js +428 -0
  115. package/client/vendor/react/production/react-dom-client.js +6 -0
  116. package/client/vendor/react/production/react-dom.js +17 -0
  117. package/client/vendor/react/production/react-jsx-dev-runtime.js +5 -0
  118. package/client/vendor/react/production/react-jsx-runtime.js +6 -0
  119. package/client/vendor/react/production/react.js +47 -0
  120. package/dist/agentation-4s0nn45p.png +0 -0
  121. package/dist/airtable-hsa66v6q.png +0 -0
  122. package/dist/apollo-2ed5dy2d.png +0 -0
  123. package/dist/asana-tvgtwbx2.png +0 -0
  124. package/dist/box-w3n36t5g.png +0 -0
  125. package/dist/chrome-tspm94rw.svg +33 -0
  126. package/dist/chunk-kc6e9nd4.css +1 -0
  127. package/dist/chunk-yf3p7qg7.js +673 -0
  128. package/dist/clickup-qqrqqvqb.png +0 -0
  129. package/dist/cloudflare-j9p931v6.png +0 -0
  130. package/dist/context7-8ht0xjfy.png +0 -0
  131. package/dist/datadog-70ne3yzt.png +0 -0
  132. package/dist/dropbox-4m5s9mgr.png +0 -0
  133. package/dist/elevenlabs-2nzzej1t.png +0 -0
  134. package/dist/exa-qqj3vr0x.png +0 -0
  135. package/dist/firecrawl-w2t8nehx.png +0 -0
  136. package/dist/gmail-sg6a5v3x.png +0 -0
  137. package/dist/googlecalendar-nqhh2v7r.png +0 -0
  138. package/dist/googledrive-6s8xyab7.png +0 -0
  139. package/dist/grafana-1yfsnwr6.png +0 -0
  140. package/dist/huggingface-kxzaxj83.png +0 -0
  141. package/dist/index.html +10 -6
  142. package/dist/intercom-td763jt8.png +0 -0
  143. package/dist/monday-jdbs4wwf.png +0 -0
  144. package/dist/mongodb-emzxvhd5.png +0 -0
  145. package/dist/paper-zbt34fab.png +0 -0
  146. package/dist/paypal-kwwf7xsc.png +0 -0
  147. package/dist/perplexity-4y63rxvj.png +0 -0
  148. package/dist/postgresql-qsspbsr1.png +0 -0
  149. package/dist/posthog-sphppc4w.png +0 -0
  150. package/dist/puppeteer-2xjt1a9b.png +0 -0
  151. package/dist/railway-834de8d2.png +0 -0
  152. package/dist/redis-spm6w2m1.png +0 -0
  153. package/dist/salesforce-1mk56v4z.png +0 -0
  154. package/dist/shopify-90dadaav.png +0 -0
  155. package/dist/snowflake-hfpykpgy.png +0 -0
  156. package/dist/telegram-v6tjyrs7.png +0 -0
  157. package/dist/twilio-dpyjdwpj.png +0 -0
  158. package/dist/zapier-p67qfch0.png +0 -0
  159. package/lib/attachment-note.ts +48 -0
  160. package/lib/claude-adapter.ts +219 -29
  161. package/lib/format.ts +32 -0
  162. package/lib/types.ts +314 -6
  163. package/package.json +11 -5
  164. package/server/CLAUDE.md +4 -1
  165. package/server/agent.ts +25 -118
  166. package/server/api.ts +593 -0
  167. package/server/applets.ts +396 -0
  168. package/server/build-applet.ts +580 -0
  169. package/server/cc-session.ts +611 -0
  170. package/server/cli-colors.ts +17 -0
  171. package/server/cli-ui.ts +52 -0
  172. package/server/cli.ts +965 -73
  173. package/server/constants.ts +1 -1
  174. package/server/control.ts +166 -19
  175. package/server/debug.ts +10 -0
  176. package/server/events.ts +24 -0
  177. package/server/functions-worker.ts +18 -2
  178. package/server/functions.ts +59 -12
  179. package/server/icon.ts +13 -0
  180. package/server/layout.ts +25 -3
  181. package/server/mcp.ts +125 -0
  182. package/server/moi-scaffold.ts +85 -0
  183. package/server/openclaw-session.ts +41 -10
  184. package/server/openclaw.ts +22 -0
  185. package/server/preview.ts +70 -0
  186. package/server/registry.ts +32 -2
  187. package/server/scratchpad-executor.ts +380 -0
  188. package/server/scratchpad-relay.ts +45 -0
  189. package/server/scratchpad.ts +171 -0
  190. package/server/skill-version.ts +146 -0
  191. package/server/skills-template.ts +6 -1
  192. package/server/state.ts +22 -36
  193. package/server/static.ts +23 -0
  194. package/server/status.ts +94 -0
  195. package/server/thread-config.ts +125 -0
  196. package/server/uploads.ts +0 -0
  197. package/server/vendor.ts +63 -0
  198. package/server/views.ts +0 -0
  199. package/server/web.ts +108 -253
  200. package/server/widgets.ts +52 -142
  201. package/server/workspace-config.ts +37 -0
  202. package/server/workspace-env.ts +407 -0
  203. package/server/workspace-init.ts +66 -0
  204. package/workspace/.claude/skills/moi-workspace/DESIGN.md +109 -0
  205. package/workspace/.claude/skills/moi-workspace/SCRATCHPAD.md +57 -0
  206. package/workspace/.claude/skills/moi-workspace/SKILL.md +252 -0
  207. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +22 -0
  208. package/client/hooks/useWidget.ts +0 -72
  209. package/client/hooks/useWidgetList.ts +0 -30
  210. package/client/lib/ws.ts +0 -129
  211. package/client/store/chat.tsx +0 -162
  212. package/dist/chunk-4615fa69.js +0 -67
  213. package/dist/chunk-582xmy05.css +0 -1
  214. package/server/build-widget.ts +0 -343
  215. package/workspace/.claude/skills/widgets/DESIGN.md +0 -630
  216. package/workspace/.claude/skills/widgets/SKILL.md +0 -176
@@ -0,0 +1,307 @@
1
+ import { type ReactNode, useState } from 'react'
2
+
3
+ import { IconChevronDown, IconLoader2, IconPlus, IconTrash } from '@tabler/icons-react'
4
+
5
+ import { useUpdateEnv, useSaveWorkspaceName, useWorkspaceEnv } from '@/client/api/workspaces'
6
+ import {
7
+ DropdownMenu,
8
+ DropdownMenuContent,
9
+ DropdownMenuRadioGroup,
10
+ DropdownMenuRadioItem,
11
+ DropdownMenuTrigger
12
+ } from '@/client/components/ui/dropdown-menu'
13
+ import { Button } from '@/client/components/ui/button'
14
+ import { Input } from '@/client/components/ui/input'
15
+ import { Switch } from '@/client/components/ui/switch'
16
+ import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
17
+ import { cn } from '@/client/lib/cn'
18
+ import type { EnvScope, WorkspaceEnvVar } from '@/lib/types'
19
+
20
+ import { IconPicker } from './IconPicker'
21
+
22
+ // ── Shared page primitives ──────────────────────────────────────────────────
23
+
24
+ type SettingsPageProps = {
25
+ title: string
26
+ description?: string
27
+ children: ReactNode
28
+ }
29
+
30
+ function SettingsPage({ title, description, children }: SettingsPageProps) {
31
+ return (
32
+ <div className="flex flex-col gap-6">
33
+ <header className="flex flex-col gap-1">
34
+ <h2 className="text-xl font-semibold tracking-tight">{title}</h2>
35
+ {description && <p className="text-sm text-muted-foreground">{description}</p>}
36
+ </header>
37
+ {children}
38
+ </div>
39
+ )
40
+ }
41
+
42
+ type SettingsSectionProps = {
43
+ label?: string
44
+ children: ReactNode
45
+ }
46
+
47
+ function SettingsSection({ label, children }: SettingsSectionProps) {
48
+ return (
49
+ <section className="flex flex-col gap-2">
50
+ {label && <p className="px-0.5 text-xs font-medium text-muted-foreground">{label}</p>}
51
+ <div className="flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-lg border border-border bg-card">
52
+ {children}
53
+ </div>
54
+ </section>
55
+ )
56
+ }
57
+
58
+ type SettingsRowProps = {
59
+ title: string
60
+ description?: string
61
+ control?: ReactNode
62
+ }
63
+
64
+ function SettingsRow({ title, description, control }: SettingsRowProps) {
65
+ return (
66
+ <div className="flex items-center gap-3 px-3.5 py-3">
67
+ <div className="flex min-w-0 flex-col">
68
+ <span className="text-sm font-medium">{title}</span>
69
+ {description && <span className="text-xs text-muted-foreground">{description}</span>}
70
+ </div>
71
+ {control && <div className="ml-auto flex shrink-0 items-center pl-3">{control}</div>}
72
+ </div>
73
+ )
74
+ }
75
+
76
+ // ── General ─────────────────────────────────────────────────────────────────
77
+
78
+ export function GeneralSettings() {
79
+ const { name, icon, workspaceId } = useWorkspaceLayoutCtx()
80
+ const saveName = useSaveWorkspaceName(workspaceId)
81
+ const [draft, setDraft] = useState(name ?? '')
82
+
83
+ // Persist on blur (or Enter): an empty value clears the override so the name
84
+ // falls back to the folder name.
85
+ const commit = () => {
86
+ const next = draft.trim()
87
+ if (next === (name ?? '')) return
88
+ saveName.mutate(next === '' ? null : next)
89
+ }
90
+
91
+ return (
92
+ <SettingsPage title="General" description="Basic details for this workspace.">
93
+ <SettingsSection>
94
+ <SettingsRow
95
+ title="Name"
96
+ description="Shown in the sidebar and the workspace header."
97
+ control={
98
+ <Input
99
+ value={draft}
100
+ onChange={e => setDraft(e.target.value)}
101
+ onBlur={commit}
102
+ onKeyDown={e => {
103
+ if (e.key === 'Enter') e.currentTarget.blur()
104
+ }}
105
+ placeholder="Workspace name"
106
+ className="w-56"
107
+ />
108
+ }
109
+ />
110
+ <div className="flex flex-col gap-4 px-3.5 py-3.5">
111
+ <div className="flex flex-col">
112
+ <span className="text-sm font-medium">Icon</span>
113
+ <span className="text-xs text-muted-foreground">
114
+ Pick an emoji or a glyph on a generated background, or upload an image.
115
+ </span>
116
+ </div>
117
+ <IconPicker icon={icon} />
118
+ </div>
119
+ </SettingsSection>
120
+ </SettingsPage>
121
+ )
122
+ }
123
+
124
+ // ── Environment ─────────────────────────────────────────────────────────────
125
+
126
+ const SCOPE_LABEL: Record<EnvScope, string> = {
127
+ widgets: 'Widgets',
128
+ agent: 'Agent',
129
+ both: 'Both'
130
+ }
131
+
132
+ // Source badge copy: where the key actually comes from.
133
+ const SOURCE_LABEL: Record<WorkspaceEnvVar['source'], string> = {
134
+ dotenv: '.env',
135
+ custom: 'secret',
136
+ both: 'override'
137
+ }
138
+
139
+ const ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/
140
+
141
+ type ScopeSelectProps = {
142
+ value: EnvScope
143
+ onChange: (scope: EnvScope) => void
144
+ }
145
+
146
+ function ScopeSelect({ value, onChange }: ScopeSelectProps) {
147
+ return (
148
+ <DropdownMenu>
149
+ <DropdownMenuTrigger
150
+ render={
151
+ <Button variant="outline" size="sm" className="h-7 gap-1 px-2 font-normal">
152
+ {SCOPE_LABEL[value]}
153
+ <IconChevronDown stroke={1.75} className="text-muted-foreground" />
154
+ </Button>
155
+ }
156
+ />
157
+ <DropdownMenuContent align="end" className="w-32">
158
+ <DropdownMenuRadioGroup value={value} onValueChange={v => onChange(v as EnvScope)}>
159
+ {(Object.keys(SCOPE_LABEL) as EnvScope[]).map(scope => (
160
+ <DropdownMenuRadioItem key={scope} value={scope}>
161
+ {SCOPE_LABEL[scope]}
162
+ </DropdownMenuRadioItem>
163
+ ))}
164
+ </DropdownMenuRadioGroup>
165
+ </DropdownMenuContent>
166
+ </DropdownMenu>
167
+ )
168
+ }
169
+
170
+ export function EnvironmentSettings() {
171
+ const { workspaceId } = useWorkspaceLayoutCtx()
172
+ const env = useWorkspaceEnv(workspaceId)
173
+ const update = useUpdateEnv(workspaceId)
174
+
175
+ const [draftKey, setDraftKey] = useState('')
176
+ const [draftValue, setDraftValue] = useState('')
177
+ const [draftScope, setDraftScope] = useState<EnvScope>('both')
178
+
179
+ const keyValid = ENV_KEY_RE.test(draftKey)
180
+ const canAdd = keyValid && draftValue.length > 0 && !update.isPending
181
+
182
+ const addVar = () => {
183
+ if (!canAdd) return
184
+ update.mutate(
185
+ { set: { [draftKey]: draftValue }, scopes: { [draftKey]: draftScope } },
186
+ {
187
+ onSuccess: () => {
188
+ setDraftKey('')
189
+ setDraftValue('')
190
+ setDraftScope('both')
191
+ }
192
+ }
193
+ )
194
+ }
195
+
196
+ const vars = env.data?.vars ?? []
197
+ const fileCount = env.data?.files.reduce((n, f) => n + f.count, 0) ?? 0
198
+ const dotenvFiles = env.data?.files.length ?? 0
199
+
200
+ return (
201
+ <SettingsPage
202
+ title="Environment"
203
+ description="Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved."
204
+ >
205
+ <SettingsSection label="Variables">
206
+ {env.isLoading ? (
207
+ <div className="flex items-center justify-center px-3.5 py-6 text-muted-foreground">
208
+ <IconLoader2 className="size-4 animate-spin" stroke={1.75} />
209
+ </div>
210
+ ) : vars.length === 0 ? (
211
+ <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet.</p>
212
+ ) : (
213
+ vars.map(v => {
214
+ const editable = v.source !== 'dotenv'
215
+ return (
216
+ <div key={v.key} className="flex items-center gap-3 px-3.5 py-2.5">
217
+ <code className="min-w-0 flex-1 truncate font-mono text-xs text-foreground">
218
+ {v.key}
219
+ </code>
220
+ <span className="text-xs tracking-widest text-muted-foreground/60 select-none">
221
+ ••••••
222
+ </span>
223
+ <span
224
+ className={cn(
225
+ 'rounded-sm px-1.5 py-0.5 text-[11px] font-medium',
226
+ v.source === 'dotenv'
227
+ ? 'bg-muted text-muted-foreground'
228
+ : 'bg-primary/10 text-primary'
229
+ )}
230
+ >
231
+ {SOURCE_LABEL[v.source]}
232
+ </span>
233
+ {editable ? (
234
+ <ScopeSelect
235
+ value={v.scope ?? 'both'}
236
+ onChange={scope => update.mutate({ scopes: { [v.key]: scope } })}
237
+ />
238
+ ) : (
239
+ <span className="w-[60px] text-right text-[11px] text-muted-foreground/60">
240
+ from file
241
+ </span>
242
+ )}
243
+ <button
244
+ type="button"
245
+ onClick={() => update.mutate({ remove: [v.key] })}
246
+ disabled={!editable}
247
+ aria-label={`Delete ${v.key}`}
248
+ className="text-muted-foreground/50 transition-colors not-disabled:hover:text-foreground disabled:invisible [&_svg]:size-4"
249
+ >
250
+ <IconTrash stroke={1.5} />
251
+ </button>
252
+ </div>
253
+ )
254
+ })
255
+ )}
256
+
257
+ {/* Add row */}
258
+ <div className="flex items-center gap-2 px-3.5 py-2.5">
259
+ <Input
260
+ value={draftKey}
261
+ onChange={e => setDraftKey(e.target.value)}
262
+ placeholder="NEW_KEY"
263
+ aria-invalid={draftKey.length > 0 && !keyValid}
264
+ className="h-7 w-40 font-mono text-xs"
265
+ />
266
+ <Input
267
+ value={draftValue}
268
+ onChange={e => setDraftValue(e.target.value)}
269
+ onKeyDown={e => {
270
+ if (e.key === 'Enter') addVar()
271
+ }}
272
+ type="password"
273
+ placeholder="value"
274
+ className="h-7 flex-1 text-xs"
275
+ />
276
+ <ScopeSelect value={draftScope} onChange={setDraftScope} />
277
+ <Button variant="outline" size="sm" className="h-7" onClick={addVar} disabled={!canAdd}>
278
+ {update.isPending ? (
279
+ <IconLoader2 className="animate-spin" />
280
+ ) : (
281
+ <IconPlus stroke={1.75} />
282
+ )}
283
+ Add
284
+ </Button>
285
+ </div>
286
+ </SettingsSection>
287
+
288
+ <SettingsSection label="From .env files">
289
+ <SettingsRow
290
+ title="Inherit .env files"
291
+ description={
292
+ dotenvFiles > 0
293
+ ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this workspace.`
294
+ : 'No .env files found in this workspace.'
295
+ }
296
+ control={
297
+ <Switch
298
+ checked={env.data?.inheritDotenv ?? true}
299
+ disabled={env.isLoading}
300
+ onCheckedChange={checked => update.mutate({ inheritDotenv: checked })}
301
+ />
302
+ }
303
+ />
304
+ </SettingsSection>
305
+ </SettingsPage>
306
+ )
307
+ }
@@ -0,0 +1,92 @@
1
+ import { useState } from 'react'
2
+
3
+ import { IconKey, IconSettings, IconX } from '@tabler/icons-react'
4
+
5
+ import { Button } from '@/client/components/ui/button'
6
+ import { Dialog, DialogClose, DialogContent, DialogTitle } from '@/client/components/ui/dialog'
7
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
8
+ import { cn } from '@/client/lib/cn'
9
+
10
+ import { EnvironmentSettings, GeneralSettings } from './SettingsPages'
11
+
12
+ type SettingsNav = 'general' | 'environment'
13
+
14
+ const NAV: { id: SettingsNav; label: string; icon: typeof IconSettings }[] = [
15
+ { id: 'general', label: 'General', icon: IconSettings },
16
+ { id: 'environment', label: 'Environment', icon: IconKey }
17
+ ]
18
+
19
+ export function WorkspaceSettings() {
20
+ const [open, setOpen] = useState(false)
21
+ const [page, setPage] = useState<SettingsNav>('general')
22
+
23
+ return (
24
+ <>
25
+ <Tooltip delay={50}>
26
+ <TooltipTrigger
27
+ render={
28
+ <Button
29
+ variant="ghost"
30
+ size="icon"
31
+ aria-label="Workspace settings"
32
+ className="size-7 text-primary [&_svg]:size-[20px]"
33
+ onClick={() => setOpen(true)}
34
+ >
35
+ <IconSettings stroke={1.75} />
36
+ </Button>
37
+ }
38
+ />
39
+ <TooltipContent>Workspace settings</TooltipContent>
40
+ </Tooltip>
41
+
42
+ <Dialog open={open} onOpenChange={setOpen}>
43
+ <DialogContent className="flex h-[min(680px,90vh)] w-[880px] max-w-[94vw]">
44
+ <DialogTitle className="sr-only">Workspace settings</DialogTitle>
45
+
46
+ {/* Sidebar nav — top padding lines the "Settings" label up with the
47
+ page title across the divider. */}
48
+ <nav className="flex w-48 shrink-0 flex-col gap-0.5 border-r border-border bg-muted/30 p-3">
49
+ <p className="px-2.5 pt-4 pb-2 text-[11px] font-semibold tracking-wider text-muted-foreground/80 uppercase">
50
+ Settings
51
+ </p>
52
+ {NAV.map(item => (
53
+ <button
54
+ key={item.id}
55
+ type="button"
56
+ onClick={() => setPage(item.id)}
57
+ className={cn(
58
+ 'flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors [&_svg]:size-[18px]',
59
+ page === item.id
60
+ ? 'bg-muted text-foreground'
61
+ : 'text-muted-foreground hover:bg-muted/60 hover:text-foreground'
62
+ )}
63
+ >
64
+ <item.icon stroke={1.75} />
65
+ {item.label}
66
+ </button>
67
+ ))}
68
+ </nav>
69
+
70
+ {/* Page */}
71
+ <div className="relative scrollbar-thin min-w-0 flex-1 overflow-y-auto">
72
+ <DialogClose
73
+ render={
74
+ <Button
75
+ variant="ghost"
76
+ size="icon"
77
+ aria-label="Close"
78
+ className="absolute top-3 right-3 z-10 size-7 text-muted-foreground"
79
+ >
80
+ <IconX stroke={1.5} />
81
+ </Button>
82
+ }
83
+ />
84
+ <div className="px-8 py-7">
85
+ {page === 'general' ? <GeneralSettings /> : <EnvironmentSettings />}
86
+ </div>
87
+ </div>
88
+ </DialogContent>
89
+ </Dialog>
90
+ </>
91
+ )
92
+ }
@@ -0,0 +1,41 @@
1
+ import { useMemo } from 'react'
2
+
3
+ import { highlight } from 'sugar-high'
4
+
5
+ import { cn } from '@/client/lib/cn'
6
+
7
+ type CodeBlockProps = { code: string; className?: string }
8
+
9
+ // sugar-high colors each token with `style="color:var(--sh-*)"`, so a theme is
10
+ // just these CSS vars on an ancestor. Muted palette tuned for the light
11
+ // `bg-muted` output box. Set once via Tailwind arbitrary properties.
12
+ const SH_THEME = cn(
13
+ '[--sh-identifier:#1f2937]',
14
+ '[--sh-keyword:#cf222e]',
15
+ '[--sh-string:#16a34a]',
16
+ '[--sh-class:#2d6e7e]',
17
+ '[--sh-property:#0550ae]',
18
+ '[--sh-entity:#6f42c1]',
19
+ '[--sh-jsxliterals:#6f42c1]',
20
+ '[--sh-sign:#8b949e]',
21
+ '[--sh-comment:#9ca3af]'
22
+ )
23
+
24
+ // Lightweight syntax highlight via sugar-high (~1KB, no language config). The
25
+ // tokenize pass is pure, so memoize on `code` — it only re-runs when the source
26
+ // changes, and the component only mounts while the row is expanded.
27
+ export function CodeBlock({ code, className }: CodeBlockProps) {
28
+ const html = useMemo(() => highlight(code), [code])
29
+ return (
30
+ <pre
31
+ className={cn(
32
+ 'overflow-auto font-mono text-xs leading-relaxed whitespace-pre',
33
+ SH_THEME,
34
+ className
35
+ )}
36
+ >
37
+ {/* sugar-high escapes token text, so this HTML is safe to inject. */}
38
+ <code dangerouslySetInnerHTML={{ __html: html }} />
39
+ </pre>
40
+ )
41
+ }
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ import { AnimatePresence, motion } from 'motion/react'
4
+
5
+ type CollapseProps = { open: boolean; children: ReactNode }
6
+
7
+ // Height auto-animation — the same spring as the meta-ficus FAQ accordion
8
+ // (height 0 ↔ auto, opacity, overflow-hidden). The body is mounted only while
9
+ // open (AnimatePresence), so heavy children (highlighted code) neither render
10
+ // nor tokenize until expanded — and unmount again on collapse.
11
+ export function Collapse({ open, children }: CollapseProps) {
12
+ return (
13
+ <AnimatePresence initial={false}>
14
+ {open && (
15
+ <motion.div
16
+ key="content"
17
+ initial={{ height: 0, opacity: 0 }}
18
+ animate={{ height: 'auto', opacity: 1 }}
19
+ exit={{ height: 0, opacity: 0 }}
20
+ transition={{ type: 'spring', duration: 0.25, bounce: 0.1 }}
21
+ className="overflow-hidden"
22
+ >
23
+ {children}
24
+ </motion.div>
25
+ )}
26
+ </AnimatePresence>
27
+ )
28
+ }
@@ -0,0 +1,46 @@
1
+ import { useState } from 'react'
2
+
3
+ import { useWorkspaceId } from '@/client/lib/WorkspaceContext'
4
+ import type { ToolCall } from '@/lib/types'
5
+
6
+ // Image extensions the server's preview route can render (see server/preview.ts).
7
+ const IMAGE_PATH_RE = /\.(png|jpe?g|gif|webp|avif|svg)$/i
8
+
9
+ // When the agent `Read`s an image that lives inside the workspace, return its
10
+ // workspace-relative path so the expanded row can show the actual picture.
11
+ // Anything else — non-Read tools, non-image paths, files outside the workspace
12
+ // (the preview route can only serve workspace files) — returns null.
13
+ export function readImageRelPath(call: ToolCall, cwd: string | null): string | null {
14
+ if (call.name !== 'Read' || !cwd) return null
15
+ const input = call.input as { file_path?: unknown }
16
+ const p = typeof input.file_path === 'string' ? input.file_path : null
17
+ if (!p || !IMAGE_PATH_RE.test(p)) return null
18
+ const root = cwd.endsWith('/') ? cwd : `${cwd}/`
19
+ if (!p.startsWith(root)) return null
20
+ return p.slice(root.length)
21
+ }
22
+
23
+ type ReadImagePreviewProps = { relPath: string }
24
+
25
+ // The picture a Read tool call opened, loaded on demand from the workspace via
26
+ // the preview route (server-side downscaled). The file can be gone or
27
+ // undecodable by the time the row is expanded — on any load error the preview
28
+ // just disappears, leaving the normal output view.
29
+ export function ReadImagePreview({ relPath }: ReadImagePreviewProps) {
30
+ const workspaceId = useWorkspaceId()
31
+ const [failed, setFailed] = useState(false)
32
+ if (failed) return null
33
+ const src = `/api/workspaces/${workspaceId}/preview/${relPath
34
+ .split('/')
35
+ .map(encodeURIComponent)
36
+ .join('/')}`
37
+ return (
38
+ <img
39
+ src={src}
40
+ alt={relPath}
41
+ loading="lazy"
42
+ onError={() => setFailed(true)}
43
+ className="max-h-64 max-w-full self-start rounded-md border border-border object-contain"
44
+ />
45
+ )
46
+ }
@@ -0,0 +1,135 @@
1
+ // Subagent ("Agent" tool) row — matches the chat card: a node + the "Agent: <task>"
2
+ // header, and the LATEST ACTION (the last `progress` line) as a muted sub-row
3
+ // while running, switching to the step count once done. While running the node
4
+ // cycles sport glyphs and the header shimmers; once finished a duration badge sits
5
+ // top-right and expanding shows the subagent's nested transcript as a recursive
6
+ // sub-timeline, then its final summary. The `subagent` record
7
+ // (progress/status/usage/transcript) is built live from `task_*` events and isn't
8
+ // persisted, so a finished/replayed call shows only the header.
9
+ import { useEffect, useState } from 'react'
10
+
11
+ import { IconPlayBasketball, IconPlayFootball, IconPlayVolleyball } from '@tabler/icons-react'
12
+
13
+ import { ShimmerText } from '@/client/components/ShimmerText'
14
+ import { cn } from '@/client/lib/cn'
15
+ import type { ToolCall } from '@/lib/types'
16
+
17
+ import { Collapse } from './Collapse'
18
+ import { NodeBox, type RowPosition, RowChevron, TimelineRow } from './TimelineRow'
19
+ import { ToolCallGroup } from './ToolCallGroup'
20
+ import { formatDuration } from './format'
21
+
22
+ // While a subagent runs, its node cycles through "playing sport" glyphs — a
23
+ // light-hearted "still working" animation in place of a spinner.
24
+ const SPORT_ICONS = [IconPlayBasketball, IconPlayVolleyball, IconPlayFootball]
25
+ function RunningSportNode() {
26
+ const [i, setI] = useState(0)
27
+ useEffect(() => {
28
+ const t = setInterval(() => setI(n => (n + 1) % SPORT_ICONS.length), 600)
29
+ return () => clearInterval(t)
30
+ }, [])
31
+ const Icon = SPORT_ICONS[i]
32
+ return (
33
+ <NodeBox className="size-5">
34
+ <Icon size={16} stroke={1.75} className="text-foreground" />
35
+ </NodeBox>
36
+ )
37
+ }
38
+
39
+ type SubagentCardProps = RowPosition & { call: ToolCall; cwd: string | null }
40
+ export function SubagentCard({ call, cwd, isFirst, isLast }: SubagentCardProps) {
41
+ const [open, setOpen] = useState(false)
42
+ const sub = call.subagent
43
+ const input = (call.input ?? {}) as { description?: string }
44
+ const description = sub?.description ?? input.description ?? 'Subtask'
45
+ const status = sub?.status
46
+ const isError = call.state === 'error' || status === 'failed'
47
+ const isRunning = call.state === 'running' || status === 'running'
48
+ const toolUses = sub?.usage?.toolUses
49
+ // Wall-clock runtime, shown as a badge once the agent has finished.
50
+ const durationMs = sub?.usage?.durationMs
51
+
52
+ // While running → the latest action (last progress line); once done → a verb +
53
+ // count of the steps it took. Same rule as the chat card.
54
+ const latest = isRunning && sub?.progress?.length ? sub.progress[sub.progress.length - 1] : null
55
+ const subLine =
56
+ latest ?? (toolUses != null ? `Took ${toolUses} step${toolUses === 1 ? '' : 's'}` : null)
57
+
58
+ const nestedParts = (sub?.transcript ?? []).flatMap(t => t.parts)
59
+ const summary = typeof call.output === 'string' ? call.output : ''
60
+ const hasBody = nestedParts.length > 0 || !!summary
61
+
62
+ return (
63
+ <TimelineRow
64
+ isFirst={isFirst}
65
+ isLast={isLast}
66
+ marker={
67
+ isRunning ? (
68
+ <RunningSportNode />
69
+ ) : (
70
+ // Done → the runner reaches the finish: freeze on the football glyph.
71
+ <NodeBox className="size-5">
72
+ <IconPlayFootball size={16} stroke={1.75} className="text-foreground" />
73
+ </NodeBox>
74
+ )
75
+ }
76
+ isError={isError}
77
+ >
78
+ <div className="min-w-0 flex-1">
79
+ <button
80
+ type="button"
81
+ title={`Agent: ${description}`}
82
+ onClick={() => hasBody && setOpen(o => !o)}
83
+ className={cn(
84
+ 'group/row flex w-full flex-col items-start gap-0.5 py-1.5 text-left select-none',
85
+ hasBody ? 'cursor-pointer' : 'cursor-default'
86
+ )}
87
+ >
88
+ <span className="flex w-full items-center gap-2">
89
+ <ShimmerText active={isRunning} className="min-w-0 flex-1 truncate text-xs font-medium">
90
+ Agent: {description}
91
+ </ShimmerText>
92
+ {!isRunning && durationMs != null && (
93
+ <span className="shrink-0 rounded-full border border-border px-1.5 text-[10px] font-medium text-muted-foreground tabular-nums">
94
+ {formatDuration(durationMs)}
95
+ </span>
96
+ )}
97
+ {status === 'failed' && <span className="shrink-0 text-xs text-red-600">✗</span>}
98
+ {status === 'stopped' && (
99
+ <span className="shrink-0 text-xs text-muted-foreground">✗</span>
100
+ )}
101
+ {hasBody && <RowChevron open={open} />}
102
+ </span>
103
+ {subLine && (
104
+ <span className="w-full truncate text-xs text-muted-foreground">{subLine}</span>
105
+ )}
106
+ </button>
107
+ {hasBody && (
108
+ <Collapse open={open}>
109
+ {/* One card, two segments: the nested steps (default bg) on top and
110
+ the final summary (muted bg, roomier padding) below, split by a
111
+ border. The divider + summary segment only render when there's a
112
+ summary, so a steps-only card has no trailing border. */}
113
+ <div className="mt-1 mb-1 overflow-hidden rounded-md border border-border">
114
+ {nestedParts.length > 0 && (
115
+ <div className="py-1.5 pr-2 pl-3">
116
+ <ToolCallGroup parts={nestedParts} cwd={cwd} />
117
+ </div>
118
+ )}
119
+ {summary && (
120
+ <div
121
+ className={cn(
122
+ 'bg-muted/30 px-3.5 py-3 text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground',
123
+ nestedParts.length > 0 && 'border-t border-border'
124
+ )}
125
+ >
126
+ {summary}
127
+ </div>
128
+ )}
129
+ </div>
130
+ </Collapse>
131
+ )}
132
+ </div>
133
+ </TimelineRow>
134
+ )
135
+ }