moi-computer 0.11.1-next.2 → 0.11.1-next.4

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 (222) hide show
  1. package/README.md +2 -2
  2. package/client/app/AppRouter.tsx +2 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +7 -9
  4. package/client/app/shell/SidebarLayout.tsx +18 -15
  5. package/client/components/shared/BottomPanel.tsx +26 -14
  6. package/client/components/shared/PanelHeader.tsx +1 -1
  7. package/client/components/shared/ReorderableList.tsx +7 -2
  8. package/client/components/shared/WorkspaceIcon.tsx +92 -0
  9. package/client/components/ui/alert-dialog.tsx +1 -0
  10. package/client/components/ui/checkbox.tsx +1 -0
  11. package/client/components/ui/inline-input.tsx +84 -0
  12. package/client/components/ui/toast.tsx +2 -2
  13. package/client/features/applets/AppletMount.tsx +1 -1
  14. package/client/features/applets/applet-cache.ts +3 -3
  15. package/client/features/applets/applet-runtime.ts +147 -108
  16. package/client/features/applets/applet-styles.ts +2 -2
  17. package/client/features/applets/applet-thumbnail.ts +6 -8
  18. package/client/features/applets/useApplet.ts +10 -9
  19. package/client/features/chat/ChatPanel.tsx +19 -10
  20. package/client/features/chat/ChatPopup.tsx +7 -2
  21. package/client/features/chat/applet-chat-intents.ts +170 -0
  22. package/client/features/chat/chat-send.ts +103 -62
  23. package/client/features/chat/chat-store.ts +50 -59
  24. package/client/features/chat/composer/ChatComposer.tsx +43 -132
  25. package/client/features/chat/composer/ModelPicker.tsx +3 -16
  26. package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
  27. package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
  28. package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
  29. package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
  30. package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
  31. package/client/features/chat/composer/attachments/types.ts +25 -0
  32. package/client/features/chat/composer/attachments/uploads.ts +26 -0
  33. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  34. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +2 -2
  35. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  36. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  37. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
  38. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  39. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  40. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +1 -1
  41. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  42. package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
  43. package/client/features/chat/useChat.ts +32 -15
  44. package/client/features/dev/ChatStatesPage.tsx +5 -6
  45. package/client/features/dev/HarnessDebugPage.tsx +10 -7
  46. package/client/features/dev/ToolCallsPage.tsx +1 -1
  47. package/client/features/dev/UiComponentPreviews.tsx +21 -0
  48. package/client/features/dev/chat-states-fixtures.ts +13 -2
  49. package/client/features/drawings/useChatAnnotation.ts +17 -17
  50. package/client/features/drawings/useDrawingLayer.ts +7 -9
  51. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  52. package/client/features/home/HomePage.tsx +8 -7
  53. package/client/features/home/WorkspacePreview.tsx +1 -1
  54. package/client/features/home/workspace-presentation.tsx +1 -11
  55. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  56. package/client/features/overview/HiddenPanel.tsx +109 -0
  57. package/client/features/overview/Overview.tsx +302 -0
  58. package/client/features/overview/WidgetCanvas.tsx +164 -0
  59. package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
  60. package/client/features/overview/WorkspaceName.tsx +60 -0
  61. package/client/features/overview/api.ts +30 -0
  62. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  63. package/client/features/overview/default/registry.tsx +36 -0
  64. package/client/features/{widgets → overview}/grid.ts +36 -0
  65. package/client/features/overview/useGridReconcile.ts +94 -0
  66. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  67. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  68. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  69. package/client/features/settings/GeneralSettings.tsx +55 -58
  70. package/client/features/settings/SettingsLayout.tsx +2 -2
  71. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  72. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  73. package/client/features/settings/api.ts +48 -24
  74. package/client/features/views/ViewBuilder.tsx +5 -4
  75. package/client/features/views/ViewManager.tsx +11 -13
  76. package/client/features/views/api.ts +36 -2
  77. package/client/features/views/useViewBuilderActions.ts +8 -5
  78. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  79. package/client/features/views/view-presentation.ts +13 -0
  80. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  81. package/client/features/workspace/UnavailablePage.tsx +21 -0
  82. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  83. package/client/features/workspace/WorkspaceScreen.tsx +205 -161
  84. package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
  85. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  86. package/client/features/workspace/api.ts +0 -26
  87. package/client/features/workspace/moi-context.ts +8 -9
  88. package/client/features/workspace/tab-resolution.ts +10 -33
  89. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  90. package/client/index.css +1 -1
  91. package/client/lib/app-icon-registry.ts +2 -0
  92. package/client/lib/use-latest-ref.ts +11 -0
  93. package/client/main.tsx +1 -1
  94. package/client/runtime/useWorkspaceEvents.ts +59 -14
  95. package/client/theme.css +5 -5
  96. package/dist/chunk-2gs8jjx4.css +1 -0
  97. package/dist/chunk-7vvg5fyz.js +68 -0
  98. package/dist/chunk-94m3q9ce.js +1 -0
  99. package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
  100. package/dist/chunk-by2wqgak.js +1 -0
  101. package/dist/chunk-m1fvqssh.js +2 -0
  102. package/dist/chunk-p34hvqt3.js +1 -0
  103. package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
  104. package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
  105. package/dist/chunk-xg01f6pn.js +10 -0
  106. package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
  107. package/dist/index.html +1 -1
  108. package/lib/app-icons.ts +1 -0
  109. package/lib/applet-selector.ts +24 -0
  110. package/lib/chat-title.ts +6 -1
  111. package/lib/default-widgets.ts +32 -0
  112. package/lib/format.ts +12 -1
  113. package/lib/message-attachments.ts +40 -0
  114. package/lib/moi-attachments.ts +204 -0
  115. package/lib/moi-context.ts +20 -35
  116. package/lib/navigation.ts +84 -0
  117. package/lib/types.ts +81 -25
  118. package/lib/workspace-icon.ts +20 -0
  119. package/lib/workspace-layout.ts +22 -2
  120. package/lib/workspace-tabs.ts +9 -33
  121. package/package.json +27 -27
  122. package/registry.json +13 -0
  123. package/server/AGENTS.md +1 -0
  124. package/server/api.ts +114 -37
  125. package/server/applet-typecheck.ts +95 -0
  126. package/server/{bundler → applets}/build-applet.ts +13 -246
  127. package/server/applets/config.ts +226 -0
  128. package/server/applets/dependencies.ts +206 -0
  129. package/server/{applets.ts → applets/index.ts} +15 -161
  130. package/server/applets/runtime/base.ts +4 -0
  131. package/server/applets/runtime/moi.ts +42 -0
  132. package/server/applets/runtime/rpc.ts +17 -0
  133. package/server/applets/view-source.ts +67 -0
  134. package/server/attachment-message.ts +95 -0
  135. package/server/cli.ts +163 -97
  136. package/server/control.ts +63 -42
  137. package/server/harness/README.md +4 -2
  138. package/server/harness/acp/adapter.ts +7 -21
  139. package/server/harness/acp/session.ts +31 -50
  140. package/server/harness/claude-code/NOTES.md +8 -2
  141. package/server/harness/claude-code/adapter.ts +8 -25
  142. package/server/harness/claude-code/index.ts +2 -0
  143. package/server/harness/claude-code/session.ts +42 -47
  144. package/server/harness/claude-code/sessions.ts +9 -4
  145. package/server/harness/codex/adapter.ts +8 -7
  146. package/server/harness/codex/index.ts +1 -0
  147. package/server/harness/codex/permissions.ts +1 -1
  148. package/server/harness/codex/session.ts +20 -47
  149. package/server/harness/hermes/NOTES.md +1 -1
  150. package/server/harness/hermes/index.ts +4 -0
  151. package/server/harness/openclaw/NOTES.md +1 -1
  152. package/server/harness/openclaw/adapter.ts +22 -4
  153. package/server/harness/openclaw/gateway.ts +5 -3
  154. package/server/harness/openclaw/session.ts +27 -27
  155. package/server/harness/types.ts +5 -3
  156. package/server/layout.ts +9 -14
  157. package/server/moi-scaffold.ts +21 -13
  158. package/server/navigation-relay.ts +110 -0
  159. package/server/registry.ts +8 -0
  160. package/server/selected-session.ts +24 -4
  161. package/server/skill-update.ts +5 -3
  162. package/server/skill-version.ts +4 -7
  163. package/server/skills-template.ts +48 -9
  164. package/server/tabs.ts +19 -33
  165. package/server/uploads.ts +0 -0
  166. package/server/view-builders.ts +18 -1
  167. package/server/views.ts +126 -6
  168. package/server/web.ts +35 -9
  169. package/server/widgets.ts +12 -5
  170. package/server/workspace-config.ts +13 -9
  171. package/ui-components/button.tsx +2 -2
  172. package/ui-components/docs/kbd.md +191 -0
  173. package/ui-components/dropdown-menu.tsx +1 -1
  174. package/ui-components/kbd.tsx +32 -0
  175. package/ui-components/slider.tsx +1 -1
  176. package/ui-components/switch.tsx +1 -1
  177. package/ui-components/tabs.tsx +1 -1
  178. package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
  179. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
  180. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  181. package/client/features/chat/attachment-staging.ts +0 -153
  182. package/client/features/chat/uploads.ts +0 -18
  183. package/client/features/chat/useAppletChatMessage.ts +0 -68
  184. package/client/features/settings/IconPicker.tsx +0 -442
  185. package/client/features/settings/WorkspaceSettings.tsx +0 -95
  186. package/client/features/settings/render-icon.ts +0 -173
  187. package/client/features/widgets/HiddenPanel.tsx +0 -80
  188. package/client/features/widgets/WidgetGrid.tsx +0 -123
  189. package/client/features/widgets/Widgets.tsx +0 -262
  190. package/client/features/widgets/useGridReconcile.ts +0 -73
  191. package/dist/chunk-245wt82v.css +0 -1
  192. package/dist/chunk-87thzbtw.js +0 -2
  193. package/dist/chunk-a6jad1a6.js +0 -1
  194. package/dist/chunk-dghwstd2.js +0 -9
  195. package/dist/chunk-eg120aca.js +0 -1
  196. package/dist/chunk-j7hh2ab4.js +0 -70
  197. package/dist/chunk-y8eyahwx.js +0 -1
  198. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  199. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  200. /package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +0 -0
  201. /package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +0 -0
  202. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  203. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  204. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  205. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  206. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  207. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  208. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  209. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  210. /package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +0 -0
  211. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  212. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  213. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  214. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  215. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  216. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  217. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  218. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  219. /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
  220. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
  221. /package/server/{bundler → applets}/applet-css.ts +0 -0
  222. /package/server/{bundler → applets}/build-worker.ts +0 -0
@@ -1,79 +1,51 @@
1
- import { useState } from 'react'
2
-
3
1
  import { IconLoader2 } from '@tabler/icons-react'
4
2
  import { useLocation } from 'wouter'
5
3
 
6
4
  import { useAppConfig } from '@/client/api/app-config'
5
+ import {
6
+ AlertDialog,
7
+ AlertDialogAction,
8
+ AlertDialogCancel,
9
+ AlertDialogContent,
10
+ AlertDialogDescription,
11
+ AlertDialogFooter,
12
+ AlertDialogHeader,
13
+ AlertDialogTitle,
14
+ AlertDialogTrigger
15
+ } from '@/client/components/ui/alert-dialog'
7
16
  import { Button } from '@/client/components/ui/button'
8
17
  import { Input } from '@/client/components/ui/input'
9
- import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
10
18
  import { useRemoveWorkspace } from '@/client/features/home/api'
19
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
11
20
 
12
- import { useSaveWorkspaceName } from './api'
13
- import { IconPicker } from './IconPicker'
14
21
  import { SettingsPage, SettingsRow, SettingsSection } from './SettingsLayout'
15
22
 
16
23
  export function GeneralSettings() {
17
24
  const { cloudDemo } = useAppConfig()
18
- const { name, icon, cwd, workspaceId } = useWorkspaceLayoutCtx()
25
+ const { name, cwd, workspaceId } = useWorkspaceLayoutCtx()
19
26
  const [, navigate] = useLocation()
20
- const saveName = useSaveWorkspaceName(workspaceId)
21
27
  const removeWorkspace = useRemoveWorkspace()
22
- const [draft, setDraft] = useState(name ?? '')
23
-
24
- const commit = () => {
25
- const next = draft.trim()
26
- if (next === (name ?? '')) return
27
- saveName.mutate(next === '' ? null : next)
28
- }
28
+ const label = name ?? cwd ?? 'this space'
29
29
 
30
30
  const remove = () => {
31
- const label = name ?? cwd ?? 'this space'
32
- const message = `Remove "${label}" from your workspaces?\n\nThis only removes it from your list. The folder and its sessions stay on disk. You can add it back any time.`
33
- if (!window.confirm(message)) return
34
31
  removeWorkspace.mutate(workspaceId, { onSuccess: () => navigate('/') })
35
32
  }
36
33
 
37
34
  return (
38
35
  <SettingsPage title="General" description="Basic details for this space.">
39
36
  <SettingsSection>
40
- <SettingsRow
41
- title="Name"
42
- description="Shown in the sidebar and the workspace header."
43
- control={
44
- <Input
45
- value={draft}
46
- onChange={event => setDraft(event.target.value)}
47
- onBlur={commit}
48
- onKeyDown={event => {
49
- if (event.key === 'Enter') event.currentTarget.blur()
50
- }}
51
- placeholder="Space name"
52
- className="w-56"
53
- />
54
- }
55
- />
56
37
  <SettingsRow
57
38
  title="Path"
58
39
  control={
59
40
  <Input
60
41
  value={cwd ?? ''}
61
- readOnly
62
42
  aria-label="Workspace path"
63
43
  title={cwd ?? undefined}
64
44
  className="w-56"
45
+ readOnly
65
46
  />
66
47
  }
67
48
  />
68
- <div className="flex flex-col gap-4 px-3.5 py-3.5">
69
- <div className="flex flex-col">
70
- <span className="text-sm font-medium">Icon</span>
71
- <span className="text-xs text-muted-foreground">
72
- Pick an emoji or a glyph on a generated background, or upload an image.
73
- </span>
74
- </div>
75
- <IconPicker icon={icon} />
76
- </div>
77
49
  </SettingsSection>
78
50
 
79
51
  {!cloudDemo && (
@@ -82,23 +54,48 @@ export function GeneralSettings() {
82
54
  title="Remove space"
83
55
  description="Remove this space from moi. Its folder and sessions stay on disk."
84
56
  control={
85
- <Button
86
- type="button"
87
- variant="destructive"
88
- size="sm"
89
- onClick={remove}
90
- disabled={removeWorkspace.isPending}
91
- >
92
- {removeWorkspace.isPending && (
93
- <IconLoader2 data-icon="inline-start" stroke={1.75} className="animate-spin" />
94
- )}
95
- Remove
96
- </Button>
57
+ <AlertDialog>
58
+ <AlertDialogTrigger
59
+ render={<Button type="button" variant="destructive" size="sm" />}
60
+ disabled={removeWorkspace.isPending}
61
+ >
62
+ Remove
63
+ </AlertDialogTrigger>
64
+ <AlertDialogContent>
65
+ <AlertDialogHeader>
66
+ <AlertDialogTitle>Remove “{label}” from your workspaces?</AlertDialogTitle>
67
+ <AlertDialogDescription>
68
+ This only removes it from your list. The folder and its sessions stay on disk.
69
+ You can add it back any time.
70
+ </AlertDialogDescription>
71
+ </AlertDialogHeader>
72
+ {removeWorkspace.isError && (
73
+ <p className="text-xs text-destructive">{removeWorkspace.error.message}</p>
74
+ )}
75
+ <AlertDialogFooter>
76
+ <AlertDialogCancel disabled={removeWorkspace.isPending}>
77
+ Cancel
78
+ </AlertDialogCancel>
79
+ <AlertDialogAction
80
+ type="button"
81
+ variant="destructive"
82
+ onClick={remove}
83
+ disabled={removeWorkspace.isPending}
84
+ >
85
+ {removeWorkspace.isPending && (
86
+ <IconLoader2
87
+ data-icon="inline-start"
88
+ stroke={1.75}
89
+ className="animate-spin"
90
+ />
91
+ )}
92
+ Remove
93
+ </AlertDialogAction>
94
+ </AlertDialogFooter>
95
+ </AlertDialogContent>
96
+ </AlertDialog>
97
97
  }
98
98
  />
99
- {removeWorkspace.isError && (
100
- <p className="px-3.5 py-3 text-xs text-destructive">{removeWorkspace.error.message}</p>
101
- )}
102
99
  </SettingsSection>
103
100
  )}
104
101
  </SettingsPage>
@@ -10,7 +10,7 @@ export function SettingsPage({ title, description, children }: SettingsPageProps
10
10
  return (
11
11
  <div className="flex flex-col gap-6">
12
12
  <header className="flex flex-col gap-0.5">
13
- <h2 className="text-lg font-medium tracking-tight">{title}</h2>
13
+ <h2 className="text-lg font-medium">{title}</h2>
14
14
  {description && <p className="text-sm text-muted-foreground">{description}</p>}
15
15
  </header>
16
16
  {children}
@@ -27,7 +27,7 @@ export function SettingsSection({ label, children }: SettingsSectionProps) {
27
27
  return (
28
28
  <section className="flex flex-col gap-2">
29
29
  {label && <p className="px-0.5 text-xs font-medium text-muted-foreground">{label}</p>}
30
- <div className="flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-xl border bg-background text-foreground">
30
+ <div className="flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-xl border">
31
31
  {children}
32
32
  </div>
33
33
  </section>
@@ -0,0 +1,318 @@
1
+ import { type ComponentProps, createContext, useContext, useEffect, useRef, useState } from 'react'
2
+
3
+ import { IconArrowBack, IconLoader2, IconMoodSad, IconUpload } from '@tabler/icons-react'
4
+ import {
5
+ EmojiPicker,
6
+ type EmojiPickerListCategoryHeaderProps,
7
+ type EmojiPickerListEmojiProps,
8
+ type EmojiPickerListRowProps
9
+ } from 'frimousse'
10
+
11
+ import { Button } from '@/client/components/ui/button'
12
+ import { Checkbox } from '@/client/components/ui/checkbox'
13
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/client/components/ui/tabs'
14
+ import { useUpdateWorkspaceIcon } from '@/client/features/settings/api'
15
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
16
+ import { APP_ICON_CHOICES } from '@/client/lib/app-icon-registry'
17
+ import { cn } from '@/client/lib/cn'
18
+ import type { WorkspaceIcon } from '@/lib/types'
19
+ import { EMOJI_FONT, FAVORITE_EMOJI } from './icon-picker-options'
20
+
21
+ type IconSelection = Exclude<WorkspaceIcon, { type: 'upload' }>
22
+
23
+ const PICKER_ITEM_SIZE = 32
24
+ const PICKER_ITEM_GAP = 4
25
+ const PICKER_ROW_PADDING = 12
26
+ const GROUP_LABEL_CLASS =
27
+ 'flex pt-4 pb-2 items-center bg-background px-3 text-xs font-medium text-muted-foreground'
28
+ const SelectedEmojiContext = createContext<string | null>(null)
29
+
30
+ function withThemeBackground(icon: IconSelection, enabled: boolean): IconSelection {
31
+ if (enabled) return { ...icon, background: 'theme' }
32
+ if (icon.type === 'emoji') return { type: 'emoji', value: icon.value }
33
+ return { type: 'glyph', value: icon.value }
34
+ }
35
+
36
+ // ── Frimousse list parts (module-level so the virtualized list keeps stable
37
+ // component identities across re-renders) ───────────────────────────────────
38
+
39
+ function EmojiCategoryHeader({
40
+ category,
41
+ className,
42
+ ...props
43
+ }: EmojiPickerListCategoryHeaderProps) {
44
+ return (
45
+ <div {...props} className={cn(GROUP_LABEL_CLASS, className)}>
46
+ {category.label}
47
+ </div>
48
+ )
49
+ }
50
+
51
+ type PickerItemsProps = ComponentProps<'div'>
52
+
53
+ function PickerItems({ className, ...props }: PickerItemsProps) {
54
+ return <div className={cn('flex flex-wrap content-start gap-1', className)} {...props} />
55
+ }
56
+
57
+ type PickerItemProps = Omit<ComponentProps<typeof Button>, 'size' | 'type' | 'variant'> & {
58
+ selected?: boolean
59
+ }
60
+
61
+ function PickerItem({ className, selected = false, ...props }: PickerItemProps) {
62
+ return (
63
+ <Button
64
+ type="button"
65
+ variant="ghost"
66
+ size="icon"
67
+ aria-pressed={selected}
68
+ className={cn('shrink-0 data-active:bg-accent', selected && 'bg-accent', className)}
69
+ {...props}
70
+ />
71
+ )
72
+ }
73
+
74
+ function EmojiRow({ children, className, ...props }: EmojiPickerListRowProps) {
75
+ return (
76
+ <div {...props} className={cn('flex h-8 gap-1 px-1.5', className)}>
77
+ {children}
78
+ </div>
79
+ )
80
+ }
81
+
82
+ function EmojiButton({ emoji, ...props }: EmojiPickerListEmojiProps) {
83
+ const selectedEmoji = useContext(SelectedEmojiContext)
84
+ return (
85
+ <PickerItem selected={selectedEmoji === emoji.emoji} className={EMOJI_FONT} {...props}>
86
+ <span className="text-xl leading-none">{emoji.emoji}</span>
87
+ </PickerItem>
88
+ )
89
+ }
90
+
91
+ export function WorkspaceIconPicker() {
92
+ const { layout, workspaceId } = useWorkspaceLayoutCtx()
93
+ const { icon } = layout
94
+ const updateIcon = useUpdateWorkspaceIcon(workspaceId)
95
+
96
+ const [mode, setMode] = useState<WorkspaceIcon['type']>(icon?.type ?? 'glyph')
97
+ const [useThemeBackground, setUseThemeBackground] = useState(
98
+ !icon || (icon.type !== 'upload' && icon.background === 'theme')
99
+ )
100
+ const selection = icon?.type === 'upload' ? undefined : icon
101
+ // Mirrors the emoji search input so the pinned favorites hide while the list
102
+ // is showing filtered results.
103
+ const [emojiSearch, setEmojiSearch] = useState('')
104
+ const [emojiColumns, setEmojiColumns] = useState(13)
105
+ const [emojiViewport, setEmojiViewport] = useState<HTMLDivElement | null>(null)
106
+ const [dragOver, setDragOver] = useState(false)
107
+
108
+ const fileRef = useRef<HTMLInputElement>(null)
109
+
110
+ const selectIcon = (next: IconSelection) => {
111
+ const icon = withThemeBackground(next, useThemeBackground)
112
+ updateIcon.mutate({ kind: 'set', icon })
113
+ }
114
+
115
+ const selectFile = (file: File) => {
116
+ updateIcon.mutate({ kind: 'upload', file })
117
+ }
118
+
119
+ const setThemeBackground = (checked: boolean) => {
120
+ setUseThemeBackground(checked)
121
+ if (selection) {
122
+ const icon = withThemeBackground(selection, checked)
123
+ updateIcon.mutate({ kind: 'set', icon })
124
+ }
125
+ }
126
+
127
+ useEffect(() => {
128
+ if (!emojiViewport) return
129
+
130
+ const updateColumns = (width: number) => {
131
+ const columns = Math.max(
132
+ 1,
133
+ Math.floor(
134
+ (width - PICKER_ROW_PADDING + PICKER_ITEM_GAP) / (PICKER_ITEM_SIZE + PICKER_ITEM_GAP)
135
+ )
136
+ )
137
+ setEmojiColumns(current => (current === columns ? current : columns))
138
+ }
139
+
140
+ updateColumns(emojiViewport.clientWidth)
141
+ const observer = new ResizeObserver(([entry]) => {
142
+ updateColumns(entry?.contentRect.width ?? emojiViewport.clientWidth)
143
+ })
144
+ observer.observe(emojiViewport)
145
+ return () => observer.disconnect()
146
+ }, [emojiViewport])
147
+
148
+ return (
149
+ <Tabs
150
+ value={mode}
151
+ onValueChange={value => setMode(value as WorkspaceIcon['type'])}
152
+ className="min-w-0 gap-4"
153
+ >
154
+ <div className="flex items-center justify-between gap-4">
155
+ <TabsList aria-label="Icon source">
156
+ <TabsTrigger value="glyph">Icon</TabsTrigger>
157
+ <TabsTrigger value="emoji">Emoji</TabsTrigger>
158
+ <TabsTrigger value="upload">Upload</TabsTrigger>
159
+ </TabsList>
160
+ {icon && (
161
+ <Button
162
+ type="button"
163
+ variant="ghost"
164
+ onClick={() => {
165
+ setUseThemeBackground(true)
166
+ updateIcon.mutate({ kind: 'reset' })
167
+ }}
168
+ className="text-muted-foreground"
169
+ >
170
+ <IconArrowBack data-icon="inline-start" stroke={1.5} />
171
+ Reset
172
+ </Button>
173
+ )}
174
+ </div>
175
+
176
+ {/* Picker body — fixed height across tabs so the dialog never jumps. */}
177
+ <TabsContent value="emoji" className="flex-none">
178
+ <SelectedEmojiContext value={selection?.type === 'emoji' ? selection.value : null}>
179
+ <EmojiPicker.Root
180
+ onEmojiSelect={picked => selectIcon({ type: 'emoji', value: picked.emoji })}
181
+ // Same-origin emojibase data (vendored under client/vendor/emojibase,
182
+ // served by server/vendor.ts) — the picker works fully offline.
183
+ emojibaseUrl="/vendor/emojibase"
184
+ columns={emojiColumns}
185
+ className="isolate flex h-72 flex-col overflow-hidden rounded-xl border border-border bg-background"
186
+ >
187
+ <div className="flex items-center gap-1.5 p-1.5 pb-0">
188
+ <EmojiPicker.Search
189
+ placeholder="Search emoji"
190
+ onChange={e => setEmojiSearch(e.target.value)}
191
+ className="h-8 min-w-0 flex-1 appearance-none rounded-md bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"
192
+ />
193
+ <EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-lg text-lg hover:bg-accent" />
194
+ </div>
195
+ <EmojiPicker.Viewport
196
+ ref={setEmojiViewport}
197
+ className="relative scrollbar-thin flex-1 overflow-y-auto outline-none"
198
+ >
199
+ <EmojiPicker.Loading className="absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground">
200
+ <IconLoader2 size={16} stroke={1.75} className="animate-spin" />
201
+ Loading emoji…
202
+ </EmojiPicker.Loading>
203
+ {/* Pinned workspace favorites — rendered inside the scroll area so
204
+ they read as the first category; hidden while searching so
205
+ results stay on top. */}
206
+ {emojiSearch.trim() === '' && (
207
+ <div className="border-b border-dashed border-border">
208
+ <p className={cn('sticky top-0', GROUP_LABEL_CLASS)}>Favorites</p>
209
+ <PickerItems className="px-1.5 pb-1.5">
210
+ {FAVORITE_EMOJI.map(e => (
211
+ <PickerItem
212
+ key={e}
213
+ onClick={() => selectIcon({ type: 'emoji', value: e })}
214
+ selected={selection?.type === 'emoji' && selection.value === e}
215
+ className={EMOJI_FONT}
216
+ >
217
+ <span className="text-xl leading-none">{e}</span>
218
+ </PickerItem>
219
+ ))}
220
+ </PickerItems>
221
+ </div>
222
+ )}
223
+ <EmojiPicker.Empty className="absolute inset-0 flex flex-col items-center justify-center gap-1 text-xs text-muted-foreground">
224
+ <IconMoodSad size={20} stroke={1.5} />
225
+ No emoji found
226
+ </EmojiPicker.Empty>
227
+ <EmojiPicker.List
228
+ className="select-none"
229
+ components={{
230
+ CategoryHeader: EmojiCategoryHeader,
231
+ Row: EmojiRow,
232
+ Emoji: EmojiButton
233
+ }}
234
+ />
235
+ </EmojiPicker.Viewport>
236
+ </EmojiPicker.Root>
237
+ </SelectedEmojiContext>
238
+ </TabsContent>
239
+ <TabsContent
240
+ value="glyph"
241
+ className="scrollbar-thin h-72 overflow-y-auto rounded-xl border border-border bg-background p-1.5"
242
+ >
243
+ <PickerItems>
244
+ {APP_ICON_CHOICES.map(({ id, Icon }) => (
245
+ <PickerItem
246
+ key={id}
247
+ aria-label={id}
248
+ onClick={() => selectIcon({ type: 'glyph', value: id })}
249
+ selected={selection?.type === 'glyph' && selection.value === id}
250
+ className="text-muted-foreground aria-pressed:text-accent-foreground"
251
+ >
252
+ <Icon stroke={1.75} />
253
+ </PickerItem>
254
+ ))}
255
+ </PickerItems>
256
+ </TabsContent>
257
+ <TabsContent value="upload" className="flex-none">
258
+ <button
259
+ type="button"
260
+ onClick={() => fileRef.current?.click()}
261
+ onDragOver={e => {
262
+ e.preventDefault()
263
+ setDragOver(true)
264
+ }}
265
+ onDragLeave={() => setDragOver(false)}
266
+ onDrop={e => {
267
+ e.preventDefault()
268
+ setDragOver(false)
269
+ const file = e.dataTransfer.files?.[0]
270
+ if (file) selectFile(file)
271
+ }}
272
+ className={cn(
273
+ 'flex h-72 w-full flex-col items-center justify-center gap-2 rounded-xl border border-dashed transition-colors',
274
+ dragOver
275
+ ? 'border-primary bg-primary/5 text-primary'
276
+ : 'border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground'
277
+ )}
278
+ >
279
+ <IconUpload size={24} stroke={1.5} />
280
+ <span className="text-xs font-medium">Click or drop an image</span>
281
+ <span className="text-[11px] text-muted-foreground/70">PNG, JPG, GIF, or WebP</span>
282
+ </button>
283
+ </TabsContent>
284
+
285
+ {mode !== 'upload' && (
286
+ <label
287
+ htmlFor="workspace-icon-theme-background"
288
+ className="flex w-fit cursor-pointer items-center gap-2 text-sm font-medium"
289
+ >
290
+ <Checkbox
291
+ id="workspace-icon-theme-background"
292
+ checked={useThemeBackground}
293
+ onCheckedChange={setThemeBackground}
294
+ />
295
+ Use theme background
296
+ </label>
297
+ )}
298
+
299
+ {updateIcon.error && (
300
+ <p className="text-xs text-destructive" aria-live="polite">
301
+ {updateIcon.error.message}
302
+ </p>
303
+ )}
304
+
305
+ <input
306
+ ref={fileRef}
307
+ type="file"
308
+ accept="image/png,image/jpeg,image/gif,image/webp"
309
+ className="hidden"
310
+ onChange={e => {
311
+ const file = e.target.files?.[0]
312
+ if (file) selectFile(file)
313
+ e.target.value = ''
314
+ }}
315
+ />
316
+ </Tabs>
317
+ )
318
+ }
@@ -0,0 +1,65 @@
1
+ import { type ReactNode, useState } from 'react'
2
+
3
+ import { IconKey, IconPlugConnected, IconSettings } from '@tabler/icons-react'
4
+
5
+ import { Button } from '@/client/components/ui/button'
6
+ import { Dialog, DialogContent, DialogTitle } from '@/client/components/ui/dialog'
7
+
8
+ import { ConnectorsSettings } from './ConnectorsSettings'
9
+ import { EnvironmentSettings } from './EnvironmentSettings'
10
+ import { GeneralSettings } from './GeneralSettings'
11
+
12
+ export { DialogTrigger as WorkspaceSettingsDialogTrigger } from '@/client/components/ui/dialog'
13
+
14
+ type SettingsNav = 'general' | 'connectors' | 'environment'
15
+
16
+ const NAV: { id: SettingsNav; label: string; icon: typeof IconSettings }[] = [
17
+ { id: 'general', label: 'General', icon: IconSettings },
18
+ { id: 'connectors', label: 'Connectors', icon: IconPlugConnected },
19
+ { id: 'environment', label: 'Environment', icon: IconKey }
20
+ ]
21
+
22
+ type WorkspaceSettingsDialogProps = {
23
+ children: ReactNode
24
+ }
25
+
26
+ export function WorkspaceSettingsDialog({ children }: WorkspaceSettingsDialogProps) {
27
+ const [page, setPage] = useState<SettingsNav>('general')
28
+
29
+ return (
30
+ <Dialog>
31
+ {children}
32
+ <DialogContent className="flex h-[min(680px,90vh)] w-[880px] gap-0 overflow-hidden p-0 sm:max-w-[94vw]">
33
+ <DialogTitle className="sr-only">Space settings</DialogTitle>
34
+
35
+ {/* Sidebar nav — top padding lines the "Settings" label up with the
36
+ page title across the divider. */}
37
+ <nav className="flex w-48 shrink-0 flex-col gap-0.5 border-r bg-muted p-3">
38
+ <p className="px-2.5 pt-4 pb-2 text-xs text-muted-foreground">Settings</p>
39
+ {NAV.map(item => (
40
+ <Button
41
+ key={item.id}
42
+ type="button"
43
+ variant={page === item.id ? 'secondary' : 'ghost'}
44
+ size="sm"
45
+ onClick={() => setPage(item.id)}
46
+ className="justify-start"
47
+ >
48
+ <item.icon stroke={1.75} />
49
+ {item.label}
50
+ </Button>
51
+ ))}
52
+ </nav>
53
+
54
+ {/* Page */}
55
+ <div className="relative scrollbar-thin min-w-0 flex-1 overflow-y-auto">
56
+ <div className="px-8 py-7">
57
+ {page === 'general' && <GeneralSettings />}
58
+ {page === 'connectors' && <ConnectorsSettings />}
59
+ {page === 'environment' && <EnvironmentSettings />}
60
+ </div>
61
+ </div>
62
+ </DialogContent>
63
+ </Dialog>
64
+ )
65
+ }
@@ -3,8 +3,9 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
3
3
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
4
  import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
+ import type { WorkspaceLayoutResponse } from '@/client/features/workspace/api'
6
7
  import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
7
- import type { AppSettings, WorkspaceEntry, WorkspaceEnvView } from '@/lib/types'
8
+ import type { AppSettings, WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
8
9
 
9
10
  // App-wide settings (server-side settings.json, GET/PATCH /api/settings) —
10
11
  // shared by every workspace, unlike the per-workspace queries below.
@@ -78,33 +79,56 @@ export function useSaveWorkspaceName(workspaceId: string) {
78
79
  })
79
80
  }
80
81
 
81
- export function useSaveWorkspaceIcon(workspaceId: string) {
82
+ type WorkspaceIconMutation =
83
+ | { kind: 'set'; icon: WorkspaceIcon }
84
+ | { kind: 'upload'; file: Blob }
85
+ | { kind: 'reset' }
86
+
87
+ export function useUpdateWorkspaceIcon(workspaceId: string) {
82
88
  const queryClient = useQueryClient()
83
- return useMutation<{ icon: string }, Error, Blob>({
89
+ return useMutation<void, Error, WorkspaceIconMutation>({
84
90
  scope: { id: `workspace-icon:${workspaceId}` },
85
- mutationFn: blob =>
86
- requestJson(`/api/workspaces/${workspaceId}/icon`, {
91
+ mutationFn: async update => {
92
+ if (update.kind === 'set') {
93
+ await requestVoid(
94
+ `/api/workspaces/${workspaceId}/config`,
95
+ jsonRequest('PUT', { icon: update.icon }),
96
+ 'Failed to save icon'
97
+ )
98
+ return
99
+ }
100
+ if (update.kind === 'reset') {
101
+ await requestVoid(
102
+ `/api/workspaces/${workspaceId}/icon`,
103
+ { method: 'DELETE' },
104
+ 'Failed to reset icon'
105
+ )
106
+ return
107
+ }
108
+ await requestJson(`/api/workspaces/${workspaceId}/icon`, {
87
109
  method: 'PUT',
88
- headers: { 'Content-Type': blob.type || 'application/octet-stream' },
89
- body: blob
90
- }),
91
- onSuccess: () => {
110
+ headers: { 'Content-Type': update.file.type || 'application/octet-stream' },
111
+ body: update.file
112
+ })
113
+ },
114
+ onMutate: update => {
115
+ if (update.kind !== 'set') return
116
+ const presentation = { icon: update.icon }
117
+ queryClient.setQueryData<WorkspaceLayoutResponse>(
118
+ workspaceKeys.layout(workspaceId),
119
+ current => (current ? { ...current, ...presentation } : current)
120
+ )
121
+ queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, current =>
122
+ current?.map(workspace =>
123
+ workspace.id === workspaceId ? { ...workspace, ...presentation } : workspace
124
+ )
125
+ )
126
+ },
127
+ onError: (_error, update) => {
128
+ if (update.kind !== 'set') return
92
129
  queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
93
- queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
94
- }
95
- })
96
- }
97
-
98
- export function useResetWorkspaceIcon(workspaceId: string) {
99
- const queryClient = useQueryClient()
100
- return useMutation<void, Error, void>({
101
- scope: { id: `workspace-icon:${workspaceId}` },
102
- mutationFn: () =>
103
- requestVoid(
104
- `/api/workspaces/${workspaceId}/icon`,
105
- { method: 'DELETE' },
106
- 'Failed to reset icon'
107
- ),
130
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
131
+ },
108
132
  onSuccess: () => {
109
133
  queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
110
134
  queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
@@ -50,7 +50,7 @@ export function ViewBuilder({
50
50
  active: active && builder.status === 'draft',
51
51
  builderId: builder.id,
52
52
  sessionId: builder.sessionId,
53
- sourceTab: viewBuilderTabId(builder.id),
53
+ source: viewBuilderTabId(builder.id),
54
54
  workspaceId,
55
55
  onEditingStart,
56
56
  onContinueInChat
@@ -155,14 +155,15 @@ type ViewBuilderDraftStateProps = {
155
155
  }
156
156
 
157
157
  function ViewBuilderDraftState({ chatDocked, sketch }: ViewBuilderDraftStateProps) {
158
- const { hasStrokes } = useDrawingHistoryState(sketch.controls)
158
+ const { controls, targetRef } = sketch
159
+ const { hasStrokes } = useDrawingHistoryState(controls)
159
160
 
160
161
  return (
161
162
  <div
162
- ref={sketch.targetRef}
163
+ ref={targetRef}
163
164
  className="absolute inset-0 flex items-center justify-center texture-checker-20"
164
165
  >
165
- {!sketch.controls.active && !hasStrokes && (
166
+ {!controls.active && !hasStrokes && (
166
167
  <div
167
168
  className={cn(
168
169
  'mb-4 flex h-full flex-col items-center justify-center gap-2 p-12 text-center text-sm text-muted-foreground',