moi-computer 0.3.0-next.0 → 0.3.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/bunfig.toml +5 -1
  2. package/client/AGENTS.md +15 -0
  3. package/client/accept-hmr-dependencies.ts +22 -0
  4. package/client/api/http.ts +31 -0
  5. package/client/api/query-options.ts +6 -0
  6. package/client/api/workspace-keys.ts +17 -0
  7. package/client/app/AppRouter.tsx +35 -0
  8. package/client/app/routes/HomeRoute.tsx +13 -0
  9. package/client/app/routes/WorkspaceRoute.tsx +89 -0
  10. package/client/app/shell/SidebarLayout.tsx +191 -0
  11. package/client/assets.d.ts +9 -0
  12. package/client/components/playground/PixelPainter.tsx +10 -21
  13. package/client/components/playground/PlaygroundPage.tsx +9 -11
  14. package/client/components/playground/ToolCallsPage.tsx +9 -11
  15. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +1 -1
  16. package/client/components/shared/PanelHeader.tsx +9 -0
  17. package/client/components/shared/ReorderableList.tsx +199 -0
  18. package/client/components/ui/button.tsx +10 -7
  19. package/client/components/ui/collapsible.tsx +15 -0
  20. package/client/components/ui/dialog.tsx +2 -2
  21. package/client/components/ui/dropdown-menu.tsx +5 -5
  22. package/client/components/ui/hover-card.tsx +1 -1
  23. package/client/components/ui/popover.tsx +1 -1
  24. package/client/components/ui/skeleton.tsx +13 -0
  25. package/client/components/ui/tooltip.tsx +1 -1
  26. package/client/externalize-react.ts +7 -1
  27. package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  28. package/client/{components → features/applets}/WidgetShell.tsx +1 -1
  29. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  30. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +29 -23
  31. package/client/features/chat/ChatPanel.tsx +188 -0
  32. package/client/{components → features/chat}/ChatPopup.tsx +23 -12
  33. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  34. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  35. package/client/{components → features/chat}/ThreadSelector.tsx +11 -9
  36. package/client/{components → features/chat}/TurnView.tsx +16 -9
  37. package/client/features/chat/api.ts +78 -0
  38. package/client/features/chat/chat-connection.ts +107 -0
  39. package/client/features/chat/chat-frames.ts +131 -0
  40. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  41. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  42. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  43. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  44. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +12 -4
  45. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  46. package/client/{hooks → features/chat}/useChat.ts +7 -11
  47. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  48. package/client/features/connectors/McpMenu.tsx +162 -0
  49. package/client/features/connectors/api.ts +28 -0
  50. package/client/features/home/CreateWorkspaceDialog.tsx +224 -0
  51. package/client/features/home/HomePage.tsx +220 -0
  52. package/client/{components → features/home}/WorkspacePreview.tsx +2 -2
  53. package/client/features/home/api.ts +148 -0
  54. package/client/features/home/workspace-presentation.tsx +44 -0
  55. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  56. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  57. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  58. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  59. package/client/features/settings/GeneralSettings.tsx +90 -0
  60. package/client/{components → features}/settings/IconPicker.tsx +73 -222
  61. package/client/features/settings/SettingsLayout.tsx +53 -0
  62. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  63. package/client/features/settings/api.ts +88 -0
  64. package/client/features/settings/icon-picker-options.ts +161 -0
  65. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  66. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  67. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  68. package/client/{components → features/widgets}/WidgetGrid.tsx +2 -9
  69. package/client/features/widgets/Widgets.tsx +215 -0
  70. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  71. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  72. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  73. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +15 -8
  74. package/client/features/workspace/WorkspaceScreen.tsx +536 -0
  75. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  76. package/client/features/workspace/api.ts +56 -0
  77. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  78. package/client/global.d.ts +5 -0
  79. package/client/index.css +6 -10
  80. package/client/index.html +1 -1
  81. package/client/index.tsx +14 -31
  82. package/client/lib/ws-url.ts +10 -0
  83. package/client/main.tsx +2 -2
  84. package/client/runtime/hmr-watchdog.ts +39 -0
  85. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +11 -7
  86. package/client/store/ui.ts +5 -1
  87. package/client/theme.css +0 -2
  88. package/dist/chunk-11cab5dq.css +1 -0
  89. package/dist/chunk-23cgr1tz.css +1 -0
  90. package/dist/chunk-3hy3qy6d.js +10 -0
  91. package/dist/chunk-c4j722at.js +546 -0
  92. package/dist/chunk-dyfaffyz.js +119 -0
  93. package/dist/chunk-kpe40hm8.js +1 -0
  94. package/dist/chunk-p68fnz3q.js +2 -0
  95. package/dist/chunk-pcnahct1.js +5 -0
  96. package/dist/chunk-tqd3pkg8.css +1 -0
  97. package/dist/chunk-ty6dvda0.js +1 -0
  98. package/dist/index.html +2 -2
  99. package/lib/types.ts +18 -7
  100. package/lib/workspace-name.ts +14 -0
  101. package/package.json +3 -2
  102. package/server/api.ts +127 -17
  103. package/server/applets.ts +84 -8
  104. package/server/cli.ts +11 -5
  105. package/server/layout.ts +38 -7
  106. package/server/mcp.ts +72 -15
  107. package/server/moi-scaffold.ts +55 -10
  108. package/server/registry.ts +16 -0
  109. package/server/views.ts +0 -0
  110. package/server/web.ts +1 -0
  111. package/server/widgets.ts +3 -2
  112. package/server/workspace-init.ts +5 -19
  113. package/tsconfig.json +1 -1
  114. package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -1
  115. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  116. package/client/api/workspaces.ts +0 -427
  117. package/client/components/App.tsx +0 -41
  118. package/client/components/ChatPanel.tsx +0 -275
  119. package/client/components/HomePage.tsx +0 -17
  120. package/client/components/McpMenu.tsx +0 -125
  121. package/client/components/Scratchpad.tsx +0 -935
  122. package/client/components/Widgets.tsx +0 -132
  123. package/client/components/WorkspacesPage.tsx +0 -245
  124. package/client/components/layout/SidebarLayout.tsx +0 -258
  125. package/client/components/routes/workspace/[id].tsx +0 -675
  126. package/client/components/routes/workspace/create.tsx +0 -155
  127. package/client/components/settings/SettingsPages.tsx +0 -255
  128. package/client/hooks/useFitsSidebar.ts +0 -34
  129. package/client/lib/connection.ts +0 -237
  130. package/dist/chunk-07qf2tv1.css +0 -1
  131. package/dist/chunk-c3zjp9ez.js +0 -672
  132. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  133. /package/client/{lib → features/applets}/applet-cache.ts +0 -0
  134. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  135. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  136. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  137. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  138. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  139. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  140. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  141. /package/client/{components → features/chat}/tool-group/format.ts +0 -0
  142. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  143. /package/client/{lib → features/chat}/uploads.ts +0 -0
  144. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  145. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  146. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  147. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  148. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  149. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  150. /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
@@ -0,0 +1,149 @@
1
+ import { useState } from 'react'
2
+
3
+ import { IconLoader2, IconPlus, IconTrash } from '@tabler/icons-react'
4
+
5
+ import { Button } from '@/client/components/ui/button'
6
+ import { Input } from '@/client/components/ui/input'
7
+ import { Switch } from '@/client/components/ui/switch'
8
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
9
+ import { cn } from '@/client/lib/cn'
10
+ import type { WorkspaceEnvVar } from '@/lib/types'
11
+
12
+ import { SettingsPage, SettingsRow, SettingsSection } from './SettingsLayout'
13
+ import { useEnvVars } from './useEnvVars'
14
+
15
+ const SOURCE_LABEL: Record<WorkspaceEnvVar['source'], string> = {
16
+ dotenv: '.env',
17
+ custom: 'secret',
18
+ both: 'override'
19
+ }
20
+
21
+ const ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/
22
+
23
+ export function EnvironmentSettings() {
24
+ const { workspaceId } = useWorkspaceLayoutCtx()
25
+ const { env, update } = useEnvVars(workspaceId)
26
+ const [draftKey, setDraftKey] = useState('')
27
+ const [draftValue, setDraftValue] = useState('')
28
+
29
+ const keyValid = ENV_KEY_RE.test(draftKey)
30
+ const canAdd = keyValid && draftValue.length > 0 && !update.isPending
31
+
32
+ const addVariable = () => {
33
+ if (!canAdd) return
34
+ update.mutate(
35
+ { set: { [draftKey]: draftValue } },
36
+ {
37
+ onSuccess: () => {
38
+ setDraftKey('')
39
+ setDraftValue('')
40
+ }
41
+ }
42
+ )
43
+ }
44
+
45
+ const variables = env.data?.vars ?? []
46
+ const fileCount = env.data?.files.reduce((count, file) => count + file.count, 0) ?? 0
47
+ const dotenvFiles = env.data?.files.length ?? 0
48
+
49
+ return (
50
+ <SettingsPage
51
+ title="Environment"
52
+ description="Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved."
53
+ >
54
+ <SettingsSection label="Variables">
55
+ {env.isLoading ? (
56
+ <div className="flex items-center justify-center px-3.5 py-6 text-muted-foreground">
57
+ <IconLoader2 className="size-4 animate-spin" stroke={1.75} />
58
+ </div>
59
+ ) : variables.length === 0 ? (
60
+ <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet.</p>
61
+ ) : (
62
+ variables.map(variable => {
63
+ const editable = variable.source !== 'dotenv'
64
+ return (
65
+ <div key={variable.key} className="flex items-center gap-3 px-3.5 py-2.5">
66
+ <code className="min-w-0 flex-1 truncate font-mono text-xs text-foreground">
67
+ {variable.key}
68
+ </code>
69
+ <span className="text-xs tracking-widest text-muted-foreground/60 select-none">
70
+ ••••••
71
+ </span>
72
+ <span
73
+ className={cn(
74
+ 'rounded-sm px-1.5 py-0.5 text-[11px] font-medium',
75
+ variable.source === 'dotenv'
76
+ ? 'bg-muted text-muted-foreground'
77
+ : 'bg-primary/10 text-primary'
78
+ )}
79
+ >
80
+ {SOURCE_LABEL[variable.source]}
81
+ </span>
82
+ {!editable && (
83
+ <span className="text-right text-[11px] text-muted-foreground/60">from file</span>
84
+ )}
85
+ <Button
86
+ type="button"
87
+ variant="ghost"
88
+ size="icon-sm"
89
+ onClick={() => update.mutate({ remove: [variable.key] })}
90
+ disabled={!editable}
91
+ aria-label={`Delete ${variable.key}`}
92
+ className="disabled:invisible"
93
+ >
94
+ <IconTrash stroke={1.75} />
95
+ </Button>
96
+ </div>
97
+ )
98
+ })
99
+ )}
100
+
101
+ <div className="flex items-center gap-2 px-3.5 py-2.5">
102
+ <Input
103
+ value={draftKey}
104
+ onChange={event => setDraftKey(event.target.value)}
105
+ placeholder="NEW_KEY"
106
+ aria-invalid={draftKey.length > 0 && !keyValid}
107
+ className="h-7 w-40 font-mono text-xs"
108
+ />
109
+ <Input
110
+ value={draftValue}
111
+ onChange={event => setDraftValue(event.target.value)}
112
+ onKeyDown={event => {
113
+ if (event.key === 'Enter') addVariable()
114
+ }}
115
+ type="password"
116
+ placeholder="value"
117
+ className="h-7 flex-1 text-xs"
118
+ />
119
+ <Button variant="outline" size="sm" onClick={addVariable} disabled={!canAdd}>
120
+ {update.isPending ? (
121
+ <IconLoader2 stroke={1.75} className="animate-spin" />
122
+ ) : (
123
+ <IconPlus stroke={1.75} />
124
+ )}
125
+ Add
126
+ </Button>
127
+ </div>
128
+ </SettingsSection>
129
+
130
+ <SettingsSection label="From .env files">
131
+ <SettingsRow
132
+ title="Inherit .env files"
133
+ description={
134
+ dotenvFiles > 0
135
+ ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space.`
136
+ : 'No .env files found in this space.'
137
+ }
138
+ control={
139
+ <Switch
140
+ checked={env.data?.inheritDotenv ?? true}
141
+ disabled={env.isLoading}
142
+ onCheckedChange={checked => update.mutate({ inheritDotenv: checked })}
143
+ />
144
+ }
145
+ />
146
+ </SettingsSection>
147
+ </SettingsPage>
148
+ )
149
+ }
@@ -0,0 +1,90 @@
1
+ import { useState } from 'react'
2
+
3
+ import { IconLoader2 } from '@tabler/icons-react'
4
+ import { useLocation } from 'wouter'
5
+
6
+ import { Button } from '@/client/components/ui/button'
7
+ import { Input } from '@/client/components/ui/input'
8
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
9
+ import { useRemoveWorkspace } from '@/client/features/home/api'
10
+
11
+ import { useSaveWorkspaceName } from './api'
12
+ import { IconPicker } from './IconPicker'
13
+ import { SettingsPage, SettingsRow, SettingsSection } from './SettingsLayout'
14
+
15
+ export function GeneralSettings() {
16
+ const { name, icon, cwd, workspaceId } = useWorkspaceLayoutCtx()
17
+ const [, navigate] = useLocation()
18
+ const saveName = useSaveWorkspaceName(workspaceId)
19
+ const removeWorkspace = useRemoveWorkspace()
20
+ const [draft, setDraft] = useState(name ?? '')
21
+
22
+ const commit = () => {
23
+ const next = draft.trim()
24
+ if (next === (name ?? '')) return
25
+ saveName.mutate(next === '' ? null : next)
26
+ }
27
+
28
+ const remove = () => {
29
+ const label = name ?? cwd ?? 'this space'
30
+ const message = `Remove "${label}" from your spaces?\n\nThis only removes it from your list. The folder and its sessions stay on disk. You can add it back any time.`
31
+ if (!window.confirm(message)) return
32
+ removeWorkspace.mutate(workspaceId, { onSuccess: () => navigate('/') })
33
+ }
34
+
35
+ return (
36
+ <SettingsPage title="General" description="Basic details for this space.">
37
+ <SettingsSection>
38
+ <SettingsRow
39
+ title="Name"
40
+ description="Shown in the sidebar and the space header."
41
+ control={
42
+ <Input
43
+ value={draft}
44
+ onChange={event => setDraft(event.target.value)}
45
+ onBlur={commit}
46
+ onKeyDown={event => {
47
+ if (event.key === 'Enter') event.currentTarget.blur()
48
+ }}
49
+ placeholder="Space name"
50
+ className="w-56"
51
+ />
52
+ }
53
+ />
54
+ <div className="flex flex-col gap-4 px-3.5 py-3.5">
55
+ <div className="flex flex-col">
56
+ <span className="text-sm font-medium">Icon</span>
57
+ <span className="text-xs text-muted-foreground">
58
+ Pick an emoji or a glyph on a generated background, or upload an image.
59
+ </span>
60
+ </div>
61
+ <IconPicker icon={icon} />
62
+ </div>
63
+ </SettingsSection>
64
+
65
+ <SettingsSection label="Danger zone">
66
+ <SettingsRow
67
+ title="Remove space"
68
+ description="Remove this space from Moi. Its folder and sessions stay on disk."
69
+ control={
70
+ <Button
71
+ type="button"
72
+ variant="destructive"
73
+ size="sm"
74
+ onClick={remove}
75
+ disabled={removeWorkspace.isPending}
76
+ >
77
+ {removeWorkspace.isPending && (
78
+ <IconLoader2 data-icon="inline-start" stroke={1.75} className="animate-spin" />
79
+ )}
80
+ Remove
81
+ </Button>
82
+ }
83
+ />
84
+ {removeWorkspace.isError && (
85
+ <p className="px-3.5 py-3 text-xs text-destructive">{removeWorkspace.error.message}</p>
86
+ )}
87
+ </SettingsSection>
88
+ </SettingsPage>
89
+ )
90
+ }
@@ -1,75 +1,11 @@
1
- import { useRef, useState } from 'react'
1
+ import { useEffect, useRef, useState } from 'react'
2
2
 
3
- import type { Icon } from '@tabler/icons-react'
4
3
  import {
5
- IconActivity,
6
- IconApi,
7
4
  IconArrowsShuffle,
8
- IconAtom,
9
- IconBell,
10
- IconBolt,
11
- IconBook,
12
- IconBrain,
13
- IconBriefcase,
14
- IconBug,
15
- IconBulb,
16
- IconCalendar,
17
- IconCamera,
18
- IconChartBar,
19
- IconCheck,
20
- IconChefHat,
21
5
  IconCircleOff,
22
- IconCloud,
23
- IconCode,
24
- IconCompass,
25
- IconCpu,
26
- IconCube,
27
- IconDatabase,
28
- IconDeviceGamepad2,
29
- IconDiamond,
30
- IconFeather,
31
- IconFile,
32
- IconFlame,
33
- IconFlask,
34
- IconFolder,
35
- IconGhost,
36
- IconGift,
37
- IconGlobe,
38
- IconHeart,
39
- IconHexagon,
40
- IconHome,
41
- IconKey,
42
- IconLeaf,
43
6
  IconLoader2,
44
- IconMail,
45
- IconMap,
46
- IconMessage,
47
7
  IconMoodSad,
48
- IconMoon,
49
- IconMountain,
50
- IconMusic,
51
- IconPalette,
52
- IconPaperclip,
53
- IconPhoto,
54
- IconPlanet,
55
- IconPlug,
56
- IconRobot,
57
- IconRocket,
58
- IconSettings,
59
- IconShield,
60
- IconShoppingCart,
61
- IconSnowflake,
62
- IconSparkles,
63
- IconStar,
64
- IconSun,
65
- IconTarget,
66
- IconTerminal2,
67
- IconTool,
68
- IconTrophy,
69
- IconUpload,
70
- IconUser,
71
- IconWand,
72
- IconWorld
8
+ IconUpload
73
9
  } from '@tabler/icons-react'
74
10
  import {
75
11
  EmojiPicker,
@@ -78,10 +14,9 @@ import {
78
14
  type EmojiPickerListRowProps
79
15
  } from 'frimousse'
80
16
 
81
- import { useResetWorkspaceIcon, useSaveWorkspaceIcon } from '@/client/api/workspaces'
82
- import { PROVIDER_ICON } from '@/client/components/layout/SidebarLayout'
83
- import { Button } from '@/client/components/ui/button'
84
- import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
17
+ import { useResetWorkspaceIcon, useSaveWorkspaceIcon } from '@/client/features/settings/api'
18
+ import { workspaceProviderIcon } from '@/client/features/home/workspace-presentation'
19
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
85
20
  import { cn } from '@/client/lib/cn'
86
21
  import {
87
22
  GRADIENT_PRESETS,
@@ -90,119 +25,15 @@ import {
90
25
  randomGradient,
91
26
  renderEmojiIcon,
92
27
  renderGlyphIcon
93
- } from '@/client/lib/render-icon'
28
+ } from '@/client/features/settings/render-icon'
29
+ import { EMOJI_FONT, FAVORITE_EMOJI, ICON_CHOICES } from './icon-picker-options'
94
30
 
95
31
  type Mode = 'emoji' | 'icon' | 'upload'
96
32
 
97
- // A curated set of the 64 most common Tabler glyphs — enough variety to brand a
98
- // workspace without a search box. `id` keys selection; `Icon` renders the glyph.
99
- const ICON_CHOICES: { id: string; Icon: Icon }[] = [
100
- { id: 'rocket', Icon: IconRocket },
101
- { id: 'sparkles', Icon: IconSparkles },
102
- { id: 'bolt', Icon: IconBolt },
103
- { id: 'flame', Icon: IconFlame },
104
- { id: 'star', Icon: IconStar },
105
- { id: 'heart', Icon: IconHeart },
106
- { id: 'diamond', Icon: IconDiamond },
107
- { id: 'trophy', Icon: IconTrophy },
108
- { id: 'target', Icon: IconTarget },
109
- { id: 'bulb', Icon: IconBulb },
110
- { id: 'brain', Icon: IconBrain },
111
- { id: 'robot', Icon: IconRobot },
112
- { id: 'wand', Icon: IconWand },
113
- { id: 'atom', Icon: IconAtom },
114
- { id: 'flask', Icon: IconFlask },
115
- { id: 'cpu', Icon: IconCpu },
116
- { id: 'code', Icon: IconCode },
117
- { id: 'terminal', Icon: IconTerminal2 },
118
- { id: 'api', Icon: IconApi },
119
- { id: 'database', Icon: IconDatabase },
120
- { id: 'cube', Icon: IconCube },
121
- { id: 'hexagon', Icon: IconHexagon },
122
- { id: 'plug', Icon: IconPlug },
123
- { id: 'tool', Icon: IconTool },
124
- { id: 'settings', Icon: IconSettings },
125
- { id: 'bug', Icon: IconBug },
126
- { id: 'activity', Icon: IconActivity },
127
- { id: 'chart', Icon: IconChartBar },
128
- { id: 'briefcase', Icon: IconBriefcase },
129
- { id: 'folder', Icon: IconFolder },
130
- { id: 'file', Icon: IconFile },
131
- { id: 'book', Icon: IconBook },
132
- { id: 'message', Icon: IconMessage },
133
- { id: 'mail', Icon: IconMail },
134
- { id: 'bell', Icon: IconBell },
135
- { id: 'paperclip', Icon: IconPaperclip },
136
- { id: 'key', Icon: IconKey },
137
- { id: 'shield', Icon: IconShield },
138
- { id: 'user', Icon: IconUser },
139
- { id: 'home', Icon: IconHome },
140
- { id: 'globe', Icon: IconGlobe },
141
- { id: 'world', Icon: IconWorld },
142
- { id: 'planet', Icon: IconPlanet },
143
- { id: 'compass', Icon: IconCompass },
144
- { id: 'map', Icon: IconMap },
145
- { id: 'calendar', Icon: IconCalendar },
146
- { id: 'cloud', Icon: IconCloud },
147
- { id: 'sun', Icon: IconSun },
148
- { id: 'moon', Icon: IconMoon },
149
- { id: 'snowflake', Icon: IconSnowflake },
150
- { id: 'leaf', Icon: IconLeaf },
151
- { id: 'mountain', Icon: IconMountain },
152
- { id: 'feather', Icon: IconFeather },
153
- { id: 'ghost', Icon: IconGhost },
154
- { id: 'music', Icon: IconMusic },
155
- { id: 'camera', Icon: IconCamera },
156
- { id: 'photo', Icon: IconPhoto },
157
- { id: 'palette', Icon: IconPalette },
158
- { id: 'gamepad', Icon: IconDeviceGamepad2 },
159
- { id: 'gift', Icon: IconGift },
160
- { id: 'cart', Icon: IconShoppingCart },
161
- { id: 'chef', Icon: IconChefHat }
162
- ]
163
-
164
- // The staged background: a preset id (or 'shuffle'), and its gradient — null
165
- // means transparent. Only the rasterized result is persisted, so this state
166
- // lives and dies with the dialog.
33
+ // The selected background: a preset id (or 'shuffle'), and its gradient — null
34
+ // means transparent. Only the rasterized result is persisted.
167
35
  type IconBg = { id: string; gradient: IconGradient | null }
168
36
 
169
- // Force a color-emoji font: the default UI stack can fall back to monochrome
170
- // outline glyphs (notably on Linux), while the canvas rasterizer already pins
171
- // these families — this keeps the DOM preview true to the saved icon.
172
- const EMOJI_FONT = 'font-[Apple_Color_Emoji,Segoe_UI_Emoji,Noto_Color_Emoji,sans-serif]'
173
-
174
- // Hand-picked workspace-flavored emoji pinned above the full list — the full
175
- // emojibase catalog opens with smileys, which are rarely what a project icon
176
- // wants. Two rows of 13, matching the picker's column count.
177
- const FAVORITE_EMOJI = [
178
- '🚀',
179
- '✨',
180
- '🔥',
181
- '⚡',
182
- '💡',
183
- '🧠',
184
- '🤖',
185
- '🪄',
186
- '🧪',
187
- '⚙️',
188
- '🛠️',
189
- '💻',
190
- '📦',
191
- '📊',
192
- '📈',
193
- '📝',
194
- '📚',
195
- '🎯',
196
- '🏆',
197
- '💎',
198
- '🪐',
199
- '🌍',
200
- '🧭',
201
- '🎨',
202
- '🎮',
203
- '☕'
204
- ]
205
-
206
37
  // ── Frimousse list parts (module-level so the virtualized list keeps stable
207
38
  // component identities across re-renders) ───────────────────────────────────
208
39
 
@@ -246,8 +77,8 @@ type IconPickerProps = {
246
77
 
247
78
  export function IconPicker({ icon }: IconPickerProps) {
248
79
  const { workspaceId, provider } = useWorkspaceLayoutCtx()
249
- const saveIcon = useSaveWorkspaceIcon(workspaceId)
250
- const resetIcon = useResetWorkspaceIcon(workspaceId)
80
+ const { isPending: savePending, mutateAsync: saveIcon } = useSaveWorkspaceIcon(workspaceId)
81
+ const { isPending: resetPending, mutate: resetIcon } = useResetWorkspaceIcon(workspaceId)
251
82
 
252
83
  const [mode, setMode] = useState<Mode>('emoji')
253
84
  const [bg, setBg] = useState<IconBg>({ id: 'sunrise', gradient: GRADIENT_PRESETS[0].gradient })
@@ -269,14 +100,7 @@ export function IconPicker({ icon }: IconPickerProps) {
269
100
 
270
101
  const selectedIcon = ICON_CHOICES.find(c => c.id === iconId)
271
102
  const onGradient = bg.gradient !== null
272
-
273
- // Whether the current tab has a selection ready to apply.
274
- const hasSelection =
275
- (mode === 'emoji' && !!emoji) ||
276
- (mode === 'icon' && !!selectedIcon) ||
277
- (mode === 'upload' && !!uploadBlob.current)
278
-
279
- const saving = saveIcon.isPending || resetIcon.isPending
103
+ const saving = savePending || resetPending
280
104
 
281
105
  const shuffle = () => {
282
106
  const gradient = randomGradient()
@@ -288,15 +112,13 @@ export function IconPicker({ icon }: IconPickerProps) {
288
112
  setError(null)
289
113
  uploadBlob.current = file
290
114
  setMode('upload')
291
- setUploadPreview(prev => {
292
- if (prev) URL.revokeObjectURL(prev)
293
- return URL.createObjectURL(file)
294
- })
115
+ setUploadPreview(URL.createObjectURL(file))
295
116
  }
296
117
 
297
- const apply = async () => {
298
- setError(null)
299
- try {
118
+ useEffect(() => {
119
+ let cancelled = false
120
+
121
+ const save = async () => {
300
122
  let blob: Blob
301
123
  if (mode === 'upload') {
302
124
  if (!uploadBlob.current) return
@@ -309,20 +131,49 @@ export function IconPicker({ icon }: IconPickerProps) {
309
131
  if (!svg) return
310
132
  blob = await renderGlyphIcon(new XMLSerializer().serializeToString(svg), bg.gradient)
311
133
  }
312
- await saveIcon.mutateAsync(blob)
313
- } catch (err) {
314
- setError(err instanceof Error ? err.message : 'Failed to save icon')
134
+
135
+ if (!cancelled) await saveIcon(blob)
315
136
  }
137
+
138
+ setError(null)
139
+ // Collapse quick swatch/emoji changes before rasterizing. Requests that have
140
+ // already started are serialized by the shared mutation scope in the API
141
+ // hooks, so an older image can never overwrite the final choice.
142
+ const timer = window.setTimeout(() => {
143
+ void save().catch(err => {
144
+ if (!cancelled) setError(err instanceof Error ? err.message : 'Failed to save icon')
145
+ })
146
+ }, 150)
147
+
148
+ return () => {
149
+ cancelled = true
150
+ window.clearTimeout(timer)
151
+ }
152
+ }, [bg.gradient, emoji, mode, saveIcon, selectedIcon, uploadPreview])
153
+
154
+ useEffect(() => {
155
+ return () => {
156
+ if (uploadPreview) URL.revokeObjectURL(uploadPreview)
157
+ }
158
+ }, [uploadPreview])
159
+
160
+ const reset = () => {
161
+ uploadBlob.current = null
162
+ setEmoji(null)
163
+ setIconId(null)
164
+ setUploadPreview(null)
165
+ setError(null)
166
+ resetIcon()
316
167
  }
317
168
 
318
- // The live preview reflects the pending selection, falling back to the saved
319
- // icon (or provider default) when nothing is staged on the current tab.
169
+ // The live preview reflects the current selection, falling back to the saved
170
+ // icon (or provider default) when the current tab has no selection.
320
171
  const previewKind: 'emoji' | 'glyph' | 'image' =
321
172
  mode === 'emoji' && emoji ? 'emoji' : mode === 'icon' && selectedIcon ? 'glyph' : 'image'
322
173
  const previewImage =
323
174
  mode === 'upload' && uploadPreview
324
175
  ? uploadPreview
325
- : (icon ?? PROVIDER_ICON[provider ?? 'claude-code'])
176
+ : (icon ?? workspaceProviderIcon[provider ?? 'claude-code'])
326
177
 
327
178
  return (
328
179
  <div className="flex gap-6">
@@ -330,7 +181,7 @@ export function IconPicker({ icon }: IconPickerProps) {
330
181
  <div className="flex w-24 shrink-0 flex-col items-center gap-2.5">
331
182
  <div
332
183
  className={cn(
333
- 'flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-foreground/10',
184
+ 'flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-border',
334
185
  // Checkerboard hints at transparency when no background is chosen.
335
186
  previewKind !== 'image' &&
336
187
  !onGradient &&
@@ -352,7 +203,7 @@ export function IconPicker({ icon }: IconPickerProps) {
352
203
  </span>
353
204
  ) : previewKind === 'glyph' && selectedIcon ? (
354
205
  <selectedIcon.Icon
355
- stroke={1.75}
206
+ stroke={1.5}
356
207
  className={cn(onGradient ? 'size-14 text-white' : 'size-18 text-foreground')}
357
208
  />
358
209
  ) : (
@@ -361,7 +212,7 @@ export function IconPicker({ icon }: IconPickerProps) {
361
212
  </div>
362
213
  <button
363
214
  type="button"
364
- onClick={() => resetIcon.mutate()}
215
+ onClick={reset}
365
216
  disabled={saving}
366
217
  className="text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50"
367
218
  >
@@ -408,10 +259,10 @@ export function IconPicker({ icon }: IconPickerProps) {
408
259
  'flex size-7 items-center justify-center rounded-full bg-muted ring-offset-2 ring-offset-card transition-shadow',
409
260
  bg.id === 'none'
410
261
  ? 'ring-2 ring-primary'
411
- : 'ring-1 ring-border hover:ring-foreground/30'
262
+ : 'ring-1 ring-border hover:ring-muted-foreground/30'
412
263
  )}
413
264
  >
414
- <IconCircleOff size={14} stroke={1.75} className="text-muted-foreground" />
265
+ <IconCircleOff size={16} stroke={1.75} className="text-muted-foreground" />
415
266
  </button>
416
267
  {GRADIENT_PRESETS.map(preset => (
417
268
  <button
@@ -426,7 +277,7 @@ export function IconPicker({ icon }: IconPickerProps) {
426
277
  'size-7 rounded-full ring-offset-2 ring-offset-card transition-shadow',
427
278
  bg.id === preset.id
428
279
  ? 'ring-2 ring-primary'
429
- : 'hover:ring-2 hover:ring-foreground/25'
280
+ : 'hover:ring-2 hover:ring-muted-foreground/30'
430
281
  )}
431
282
  />
432
283
  ))}
@@ -441,10 +292,10 @@ export function IconPicker({ icon }: IconPickerProps) {
441
292
  shuffled ? 'text-white' : 'bg-muted text-muted-foreground ring-1 ring-border',
442
293
  bg.id === 'shuffle'
443
294
  ? 'ring-2 ring-primary'
444
- : 'hover:ring-2 hover:ring-foreground/25'
295
+ : 'hover:ring-2 hover:ring-muted-foreground/30'
445
296
  )}
446
297
  >
447
- <IconArrowsShuffle size={14} stroke={2} />
298
+ <IconArrowsShuffle size={16} stroke={1.75} />
448
299
  </button>
449
300
  </div>
450
301
  </div>
@@ -465,7 +316,7 @@ export function IconPicker({ icon }: IconPickerProps) {
465
316
  onChange={e => setEmojiSearch(e.target.value)}
466
317
  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"
467
318
  />
468
- <EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-md text-lg hover:bg-muted" />
319
+ <EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-md text-lg hover:bg-accent" />
469
320
  </div>
470
321
  <EmojiPicker.Viewport className="relative scrollbar-thin flex-1 overflow-y-auto outline-none">
471
322
  <EmojiPicker.Loading className="absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground">
@@ -491,7 +342,7 @@ export function IconPicker({ icon }: IconPickerProps) {
491
342
  className={cn(
492
343
  'flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75',
493
344
  EMOJI_FONT,
494
- emoji === e ? 'bg-primary/10' : 'hover:bg-muted'
345
+ emoji === e ? 'bg-primary/10' : 'hover:bg-accent'
495
346
  )}
496
347
  >
497
348
  {e}
@@ -526,10 +377,10 @@ export function IconPicker({ icon }: IconPickerProps) {
526
377
  'flex aspect-square items-center justify-center rounded-lg text-muted-foreground transition-colors [&_svg]:size-5',
527
378
  iconId === id
528
379
  ? 'bg-primary/10 text-primary'
529
- : 'hover:bg-muted hover:text-foreground'
380
+ : 'hover:bg-accent hover:text-accent-foreground'
530
381
  )}
531
382
  >
532
- <Icon stroke={1.75} />
383
+ <Icon stroke={1.5} />
533
384
  </button>
534
385
  ))}
535
386
  </div>
@@ -552,21 +403,21 @@ export function IconPicker({ icon }: IconPickerProps) {
552
403
  'flex h-72 flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors',
553
404
  dragOver
554
405
  ? 'border-primary bg-primary/5 text-primary'
555
- : 'border-border text-muted-foreground hover:border-foreground/30 hover:text-foreground'
406
+ : 'border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground'
556
407
  )}
557
408
  >
558
- <IconUpload size={22} stroke={1.5} />
409
+ <IconUpload size={24} stroke={1.5} />
559
410
  <span className="text-xs font-medium">Click or drop an image</span>
560
411
  <span className="text-[11px] text-muted-foreground/70">PNG, JPG, GIF, or WebP</span>
561
412
  </button>
562
413
  )}
563
414
 
564
- <div className="flex items-center justify-between gap-3">
565
- <p className={cn('text-xs text-destructive', !error && 'invisible')}>{error}</p>
566
- <Button size="sm" onClick={apply} disabled={!hasSelection || saving}>
567
- {saving ? <IconLoader2 className="animate-spin" /> : <IconCheck stroke={1.75} />}
568
- Apply icon
569
- </Button>
415
+ <div className="min-h-4" aria-live="polite">
416
+ {error ? (
417
+ <p className="text-xs text-destructive">{error}</p>
418
+ ) : saving ? (
419
+ <p className="text-xs text-muted-foreground">Saving…</p>
420
+ ) : null}
570
421
  </div>
571
422
  </div>
572
423
 
@@ -583,7 +434,7 @@ export function IconPicker({ icon }: IconPickerProps) {
583
434
  }}
584
435
  />
585
436
  <span ref={glyphRef} aria-hidden className="hidden">
586
- {selectedIcon && <selectedIcon.Icon stroke={1.75} />}
437
+ {selectedIcon && <selectedIcon.Icon stroke={1.5} />}
587
438
  </span>
588
439
  </div>
589
440
  )