moi-computer 0.3.0-next.1 → 0.3.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bunfig.toml +5 -1
- package/client/AGENTS.md +17 -2
- package/client/accept-hmr-dependencies.ts +22 -0
- package/client/api/http.ts +31 -0
- package/client/api/query-options.ts +6 -0
- package/client/api/workspace-keys.ts +18 -0
- package/client/app/AppRouter.tsx +44 -0
- package/client/app/routes/HomeRoute.tsx +13 -0
- package/client/app/routes/WorkspaceRoute.tsx +95 -0
- package/client/app/shell/SidebarLayout.tsx +196 -0
- package/client/assets/openai.svg +3 -0
- package/client/assets.d.ts +9 -0
- package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
- package/client/components/shared/PanelHeader.tsx +9 -0
- package/client/components/shared/ReorderableList.tsx +199 -0
- package/client/components/ui/button.tsx +11 -7
- package/client/components/ui/collapsible.tsx +15 -0
- package/client/components/ui/dialog.tsx +2 -2
- package/client/components/ui/dropdown-menu.tsx +5 -5
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +13 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/externalize-react.ts +7 -1
- package/client/features/applets/AppletMount.tsx +44 -0
- package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
- package/client/{components → features/applets}/WidgetShell.tsx +5 -2
- package/client/{lib → features/applets}/applet-cache.ts +8 -0
- package/client/features/applets/applet-styles.ts +61 -0
- package/client/{hooks → features/applets}/useApplet.ts +6 -7
- package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
- package/client/features/chat/ChatPanel.tsx +171 -0
- package/client/{components → features/chat}/ChatPopup.tsx +24 -13
- package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
- package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
- package/client/{components → features/chat}/ModelPicker.tsx +68 -17
- package/client/{components → features/chat}/TurnView.tsx +17 -11
- package/client/features/chat/api.ts +78 -0
- package/client/features/chat/chat-connection.ts +107 -0
- package/client/features/chat/chat-frames.ts +131 -0
- package/client/features/chat/chat-send.ts +57 -0
- package/client/{lib → features/chat}/preview-turn.ts +1 -1
- package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
- package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
- package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
- package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
- package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
- package/client/{components → features/chat}/tool-group/format.ts +117 -0
- package/client/{hooks → features/chat}/useChat.ts +16 -44
- package/client/features/connectors/ConnectorsPage.tsx +92 -0
- package/client/features/connectors/McpMenu.tsx +145 -0
- package/client/features/connectors/api.ts +28 -0
- package/client/features/dev/DevRoutes.tsx +18 -0
- package/client/features/dev/HarnessDebugPage.tsx +468 -0
- package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
- package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
- package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
- package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
- package/client/features/home/HomeLogo.tsx +344 -0
- package/client/features/home/HomePage.tsx +214 -0
- package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
- package/client/features/home/api.ts +156 -0
- package/client/features/home/workspace-presentation.tsx +44 -0
- package/client/features/scratchpad/Scratchpad.tsx +312 -0
- package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
- package/client/features/settings/EnvironmentSettings.tsx +149 -0
- package/client/features/settings/GeneralSettings.tsx +90 -0
- package/client/{components → features}/settings/IconPicker.tsx +76 -224
- package/client/features/settings/SettingsLayout.tsx +53 -0
- package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
- package/client/features/settings/api.ts +88 -0
- package/client/features/settings/icon-picker-options.ts +30 -0
- package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
- package/client/features/views/ViewBuilderTab.tsx +153 -0
- package/client/features/views/api.ts +124 -0
- package/client/features/views/useViewBuilderActions.ts +72 -0
- package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
- package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
- package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
- package/client/features/widgets/Widgets.tsx +265 -0
- package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
- package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
- package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
- package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
- package/client/features/workspace/WorkspaceScreen.tsx +675 -0
- package/client/features/workspace/WorkspaceTabs.tsx +205 -0
- package/client/features/workspace/api.ts +56 -0
- package/client/features/workspace/useFitsSplitLayout.ts +37 -0
- package/client/global.d.ts +5 -0
- package/client/index.css +6 -45
- package/client/index.html +2 -2
- package/client/index.tsx +14 -31
- package/client/lib/app-icon-registry.ts +145 -0
- package/client/main.tsx +2 -2
- package/client/runtime/hmr-watchdog.ts +39 -0
- package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
- package/client/store/ui.ts +5 -1
- package/client/theme.css +1 -3
- package/dist/chunk-11cab5dq.css +1 -0
- package/dist/chunk-4vf1t6v1.js +10 -0
- package/dist/chunk-6c24yndg.js +61 -0
- package/dist/chunk-6c8cwpzc.js +1 -0
- package/dist/chunk-b4b276wx.js +15 -0
- package/dist/chunk-cs8vbert.js +546 -0
- package/dist/chunk-cwqmay73.css +1 -0
- package/dist/chunk-kxmvv1ax.js +48 -0
- package/dist/chunk-pcnahct1.js +5 -0
- package/dist/chunk-rq0ar7vp.js +1 -0
- package/dist/chunk-tqd3pkg8.css +1 -0
- package/dist/chunk-vkvb3hjm.js +2 -0
- package/dist/chunk-zpxrb1ce.js +2 -0
- package/dist/index.html +3 -3
- package/dist/openai-h13pza4b.svg +3 -0
- package/lib/format.ts +2 -2
- package/lib/types.ts +56 -9
- package/lib/view-builder-meta.ts +35 -0
- package/lib/workspace-layout.ts +14 -0
- package/lib/workspace-name.ts +14 -0
- package/package.json +4 -2
- package/server/AGENTS.md +3 -3
- package/server/api.ts +279 -60
- package/server/applets.ts +1 -1
- package/server/bundle-queue.ts +19 -0
- package/server/bundler/applet-css.ts +50 -0
- package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
- package/server/cli.ts +90 -7
- package/server/control.ts +106 -8
- package/server/env-apply.ts +2 -2
- package/server/harness/README.md +228 -0
- package/server/harness/claude-code/NOTES.md +578 -0
- package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
- package/server/harness/claude-code/index.ts +124 -0
- package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
- package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
- package/server/harness/claude-code/sessions.ts +42 -0
- package/server/harness/codex/NOTES.md +239 -0
- package/server/harness/codex/adapter.ts +414 -0
- package/server/harness/codex/client.ts +343 -0
- package/server/harness/codex/index.ts +68 -0
- package/server/harness/codex/probe.ts +186 -0
- package/server/harness/codex/session.ts +617 -0
- package/server/harness/debug.ts +57 -0
- package/server/harness/openclaw/NOTES.md +316 -0
- package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
- package/server/harness/openclaw/index.ts +93 -0
- package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
- package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
- package/server/harness/registry.ts +36 -0
- package/server/harness/types.ts +87 -0
- package/server/layout.ts +36 -11
- package/server/moi-scaffold.ts +56 -11
- package/server/registry.ts +30 -52
- package/server/state.ts +5 -38
- package/server/status.ts +7 -46
- package/server/vendor.ts +1 -1
- package/server/view-builders.ts +428 -0
- package/server/views.ts +0 -0
- package/server/web.ts +19 -40
- package/server/workspace-init.ts +11 -25
- package/tsconfig.json +1 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
- package/client/api/workspaces.ts +0 -427
- package/client/assets/hermes-nous.png +0 -0
- package/client/components/App.tsx +0 -41
- package/client/components/ChatPanel.tsx +0 -275
- package/client/components/HomePage.tsx +0 -17
- package/client/components/McpMenu.tsx +0 -125
- package/client/components/Scratchpad.tsx +0 -935
- package/client/components/Widgets.tsx +0 -132
- package/client/components/WorkspacesPage.tsx +0 -245
- package/client/components/layout/SidebarLayout.tsx +0 -258
- package/client/components/routes/workspace/[id].tsx +0 -675
- package/client/components/routes/workspace/create.tsx +0 -155
- package/client/components/settings/SettingsPages.tsx +0 -255
- package/client/hooks/useFitsSidebar.ts +0 -34
- package/client/hooks/useScrollFade.ts +0 -38
- package/client/lib/connection.ts +0 -238
- package/dist/chunk-07qf2tv1.css +0 -1
- package/dist/chunk-w18801vn.js +0 -672
- package/dist/hermes-nous-pznd63x9.png +0 -0
- /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
- /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
- /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
- /package/client/{lib → features/chat}/group-turns.ts +0 -0
- /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
- /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
- /package/client/{components → features/chat}/tool-group/index.ts +0 -0
- /package/client/{lib → features/chat}/uploads.ts +0 -0
- /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
- /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
- /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
- /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
- /package/client/{lib → features/settings}/render-icon.ts +0 -0
- /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
- /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
- /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
- /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
- /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
|
@@ -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
|
-
|
|
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,10 @@ import {
|
|
|
78
14
|
type EmojiPickerListRowProps
|
|
79
15
|
} from 'frimousse'
|
|
80
16
|
|
|
81
|
-
import { useResetWorkspaceIcon, useSaveWorkspaceIcon } from '@/client/api
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
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'
|
|
20
|
+
import { APP_ICON_CHOICES } from '@/client/lib/app-icon-registry'
|
|
85
21
|
import { cn } from '@/client/lib/cn'
|
|
86
22
|
import {
|
|
87
23
|
GRADIENT_PRESETS,
|
|
@@ -90,119 +26,15 @@ import {
|
|
|
90
26
|
randomGradient,
|
|
91
27
|
renderEmojiIcon,
|
|
92
28
|
renderGlyphIcon
|
|
93
|
-
} from '@/client/
|
|
29
|
+
} from '@/client/features/settings/render-icon'
|
|
30
|
+
import { EMOJI_FONT, FAVORITE_EMOJI } from './icon-picker-options'
|
|
94
31
|
|
|
95
32
|
type Mode = 'emoji' | 'icon' | 'upload'
|
|
96
33
|
|
|
97
|
-
//
|
|
98
|
-
//
|
|
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.
|
|
34
|
+
// The selected background: a preset id (or 'shuffle'), and its gradient — null
|
|
35
|
+
// means transparent. Only the rasterized result is persisted.
|
|
167
36
|
type IconBg = { id: string; gradient: IconGradient | null }
|
|
168
37
|
|
|
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
38
|
// ── Frimousse list parts (module-level so the virtualized list keeps stable
|
|
207
39
|
// component identities across re-renders) ───────────────────────────────────
|
|
208
40
|
|
|
@@ -246,8 +78,8 @@ type IconPickerProps = {
|
|
|
246
78
|
|
|
247
79
|
export function IconPicker({ icon }: IconPickerProps) {
|
|
248
80
|
const { workspaceId, provider } = useWorkspaceLayoutCtx()
|
|
249
|
-
const saveIcon = useSaveWorkspaceIcon(workspaceId)
|
|
250
|
-
const resetIcon = useResetWorkspaceIcon(workspaceId)
|
|
81
|
+
const { isPending: savePending, mutateAsync: saveIcon } = useSaveWorkspaceIcon(workspaceId)
|
|
82
|
+
const { isPending: resetPending, mutate: resetIcon } = useResetWorkspaceIcon(workspaceId)
|
|
251
83
|
|
|
252
84
|
const [mode, setMode] = useState<Mode>('emoji')
|
|
253
85
|
const [bg, setBg] = useState<IconBg>({ id: 'sunrise', gradient: GRADIENT_PRESETS[0].gradient })
|
|
@@ -267,16 +99,9 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
267
99
|
const glyphRef = useRef<HTMLSpanElement>(null)
|
|
268
100
|
const uploadBlob = useRef<Blob | null>(null)
|
|
269
101
|
|
|
270
|
-
const selectedIcon =
|
|
102
|
+
const selectedIcon = APP_ICON_CHOICES.find(c => c.id === iconId)
|
|
271
103
|
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
|
|
104
|
+
const saving = savePending || resetPending
|
|
280
105
|
|
|
281
106
|
const shuffle = () => {
|
|
282
107
|
const gradient = randomGradient()
|
|
@@ -288,15 +113,13 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
288
113
|
setError(null)
|
|
289
114
|
uploadBlob.current = file
|
|
290
115
|
setMode('upload')
|
|
291
|
-
setUploadPreview(
|
|
292
|
-
if (prev) URL.revokeObjectURL(prev)
|
|
293
|
-
return URL.createObjectURL(file)
|
|
294
|
-
})
|
|
116
|
+
setUploadPreview(URL.createObjectURL(file))
|
|
295
117
|
}
|
|
296
118
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
let cancelled = false
|
|
121
|
+
|
|
122
|
+
const save = async () => {
|
|
300
123
|
let blob: Blob
|
|
301
124
|
if (mode === 'upload') {
|
|
302
125
|
if (!uploadBlob.current) return
|
|
@@ -309,20 +132,49 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
309
132
|
if (!svg) return
|
|
310
133
|
blob = await renderGlyphIcon(new XMLSerializer().serializeToString(svg), bg.gradient)
|
|
311
134
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
setError(err instanceof Error ? err.message : 'Failed to save icon')
|
|
135
|
+
|
|
136
|
+
if (!cancelled) await saveIcon(blob)
|
|
315
137
|
}
|
|
138
|
+
|
|
139
|
+
setError(null)
|
|
140
|
+
// Collapse quick swatch/emoji changes before rasterizing. Requests that have
|
|
141
|
+
// already started are serialized by the shared mutation scope in the API
|
|
142
|
+
// hooks, so an older image can never overwrite the final choice.
|
|
143
|
+
const timer = window.setTimeout(() => {
|
|
144
|
+
void save().catch(err => {
|
|
145
|
+
if (!cancelled) setError(err instanceof Error ? err.message : 'Failed to save icon')
|
|
146
|
+
})
|
|
147
|
+
}, 150)
|
|
148
|
+
|
|
149
|
+
return () => {
|
|
150
|
+
cancelled = true
|
|
151
|
+
window.clearTimeout(timer)
|
|
152
|
+
}
|
|
153
|
+
}, [bg.gradient, emoji, mode, saveIcon, selectedIcon, uploadPreview])
|
|
154
|
+
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
return () => {
|
|
157
|
+
if (uploadPreview) URL.revokeObjectURL(uploadPreview)
|
|
158
|
+
}
|
|
159
|
+
}, [uploadPreview])
|
|
160
|
+
|
|
161
|
+
const reset = () => {
|
|
162
|
+
uploadBlob.current = null
|
|
163
|
+
setEmoji(null)
|
|
164
|
+
setIconId(null)
|
|
165
|
+
setUploadPreview(null)
|
|
166
|
+
setError(null)
|
|
167
|
+
resetIcon()
|
|
316
168
|
}
|
|
317
169
|
|
|
318
|
-
// The live preview reflects the
|
|
319
|
-
// icon (or provider default) when
|
|
170
|
+
// The live preview reflects the current selection, falling back to the saved
|
|
171
|
+
// icon (or provider default) when the current tab has no selection.
|
|
320
172
|
const previewKind: 'emoji' | 'glyph' | 'image' =
|
|
321
173
|
mode === 'emoji' && emoji ? 'emoji' : mode === 'icon' && selectedIcon ? 'glyph' : 'image'
|
|
322
174
|
const previewImage =
|
|
323
175
|
mode === 'upload' && uploadPreview
|
|
324
176
|
? uploadPreview
|
|
325
|
-
: (icon ??
|
|
177
|
+
: (icon ?? workspaceProviderIcon[provider ?? 'claude-code'])
|
|
326
178
|
|
|
327
179
|
return (
|
|
328
180
|
<div className="flex gap-6">
|
|
@@ -330,7 +182,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
330
182
|
<div className="flex w-24 shrink-0 flex-col items-center gap-2.5">
|
|
331
183
|
<div
|
|
332
184
|
className={cn(
|
|
333
|
-
'flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-
|
|
185
|
+
'flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-border',
|
|
334
186
|
// Checkerboard hints at transparency when no background is chosen.
|
|
335
187
|
previewKind !== 'image' &&
|
|
336
188
|
!onGradient &&
|
|
@@ -352,7 +204,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
352
204
|
</span>
|
|
353
205
|
) : previewKind === 'glyph' && selectedIcon ? (
|
|
354
206
|
<selectedIcon.Icon
|
|
355
|
-
stroke={1.
|
|
207
|
+
stroke={1.5}
|
|
356
208
|
className={cn(onGradient ? 'size-14 text-white' : 'size-18 text-foreground')}
|
|
357
209
|
/>
|
|
358
210
|
) : (
|
|
@@ -361,7 +213,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
361
213
|
</div>
|
|
362
214
|
<button
|
|
363
215
|
type="button"
|
|
364
|
-
onClick={
|
|
216
|
+
onClick={reset}
|
|
365
217
|
disabled={saving}
|
|
366
218
|
className="text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50"
|
|
367
219
|
>
|
|
@@ -408,10 +260,10 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
408
260
|
'flex size-7 items-center justify-center rounded-full bg-muted ring-offset-2 ring-offset-card transition-shadow',
|
|
409
261
|
bg.id === 'none'
|
|
410
262
|
? 'ring-2 ring-primary'
|
|
411
|
-
: 'ring-1 ring-border hover:ring-foreground/30'
|
|
263
|
+
: 'ring-1 ring-border hover:ring-muted-foreground/30'
|
|
412
264
|
)}
|
|
413
265
|
>
|
|
414
|
-
<IconCircleOff size={
|
|
266
|
+
<IconCircleOff size={16} stroke={1.75} className="text-muted-foreground" />
|
|
415
267
|
</button>
|
|
416
268
|
{GRADIENT_PRESETS.map(preset => (
|
|
417
269
|
<button
|
|
@@ -426,7 +278,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
426
278
|
'size-7 rounded-full ring-offset-2 ring-offset-card transition-shadow',
|
|
427
279
|
bg.id === preset.id
|
|
428
280
|
? 'ring-2 ring-primary'
|
|
429
|
-
: 'hover:ring-2 hover:ring-foreground/
|
|
281
|
+
: 'hover:ring-2 hover:ring-muted-foreground/30'
|
|
430
282
|
)}
|
|
431
283
|
/>
|
|
432
284
|
))}
|
|
@@ -441,10 +293,10 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
441
293
|
shuffled ? 'text-white' : 'bg-muted text-muted-foreground ring-1 ring-border',
|
|
442
294
|
bg.id === 'shuffle'
|
|
443
295
|
? 'ring-2 ring-primary'
|
|
444
|
-
: 'hover:ring-2 hover:ring-foreground/
|
|
296
|
+
: 'hover:ring-2 hover:ring-muted-foreground/30'
|
|
445
297
|
)}
|
|
446
298
|
>
|
|
447
|
-
<IconArrowsShuffle size={
|
|
299
|
+
<IconArrowsShuffle size={16} stroke={1.75} />
|
|
448
300
|
</button>
|
|
449
301
|
</div>
|
|
450
302
|
</div>
|
|
@@ -465,7 +317,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
465
317
|
onChange={e => setEmojiSearch(e.target.value)}
|
|
466
318
|
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
319
|
/>
|
|
468
|
-
<EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-md text-lg hover:bg-
|
|
320
|
+
<EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-md text-lg hover:bg-accent" />
|
|
469
321
|
</div>
|
|
470
322
|
<EmojiPicker.Viewport className="relative scrollbar-thin flex-1 overflow-y-auto outline-none">
|
|
471
323
|
<EmojiPicker.Loading className="absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground">
|
|
@@ -491,7 +343,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
491
343
|
className={cn(
|
|
492
344
|
'flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75',
|
|
493
345
|
EMOJI_FONT,
|
|
494
|
-
emoji === e ? 'bg-primary/10' : 'hover:bg-
|
|
346
|
+
emoji === e ? 'bg-primary/10' : 'hover:bg-accent'
|
|
495
347
|
)}
|
|
496
348
|
>
|
|
497
349
|
{e}
|
|
@@ -516,7 +368,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
516
368
|
</EmojiPicker.Root>
|
|
517
369
|
) : mode === 'icon' ? (
|
|
518
370
|
<div className="grid scrollbar-thin h-72 grid-cols-[repeat(auto-fill,minmax(2.25rem,1fr))] content-start gap-1 overflow-y-auto rounded-lg border border-border bg-background p-1.5">
|
|
519
|
-
{
|
|
371
|
+
{APP_ICON_CHOICES.map(({ id, Icon }) => (
|
|
520
372
|
<button
|
|
521
373
|
key={id}
|
|
522
374
|
type="button"
|
|
@@ -526,10 +378,10 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
526
378
|
'flex aspect-square items-center justify-center rounded-lg text-muted-foreground transition-colors [&_svg]:size-5',
|
|
527
379
|
iconId === id
|
|
528
380
|
? 'bg-primary/10 text-primary'
|
|
529
|
-
: 'hover:bg-
|
|
381
|
+
: 'hover:bg-accent hover:text-accent-foreground'
|
|
530
382
|
)}
|
|
531
383
|
>
|
|
532
|
-
<Icon stroke={1.
|
|
384
|
+
<Icon stroke={1.5} />
|
|
533
385
|
</button>
|
|
534
386
|
))}
|
|
535
387
|
</div>
|
|
@@ -552,21 +404,21 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
552
404
|
'flex h-72 flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors',
|
|
553
405
|
dragOver
|
|
554
406
|
? 'border-primary bg-primary/5 text-primary'
|
|
555
|
-
: 'border-border text-muted-foreground hover:border-foreground/30 hover:text-foreground'
|
|
407
|
+
: 'border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground'
|
|
556
408
|
)}
|
|
557
409
|
>
|
|
558
|
-
<IconUpload size={
|
|
410
|
+
<IconUpload size={24} stroke={1.5} />
|
|
559
411
|
<span className="text-xs font-medium">Click or drop an image</span>
|
|
560
412
|
<span className="text-[11px] text-muted-foreground/70">PNG, JPG, GIF, or WebP</span>
|
|
561
413
|
</button>
|
|
562
414
|
)}
|
|
563
415
|
|
|
564
|
-
<div className="
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
416
|
+
<div className="min-h-4" aria-live="polite">
|
|
417
|
+
{error ? (
|
|
418
|
+
<p className="text-xs text-destructive">{error}</p>
|
|
419
|
+
) : saving ? (
|
|
420
|
+
<p className="text-xs text-muted-foreground">Saving…</p>
|
|
421
|
+
) : null}
|
|
570
422
|
</div>
|
|
571
423
|
</div>
|
|
572
424
|
|
|
@@ -583,7 +435,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
583
435
|
}}
|
|
584
436
|
/>
|
|
585
437
|
<span ref={glyphRef} aria-hidden className="hidden">
|
|
586
|
-
{selectedIcon && <selectedIcon.Icon stroke={1.
|
|
438
|
+
{selectedIcon && <selectedIcon.Icon stroke={1.5} />}
|
|
587
439
|
</span>
|
|
588
440
|
</div>
|
|
589
441
|
)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
type SettingsPageProps = {
|
|
4
|
+
title: string
|
|
5
|
+
description?: string
|
|
6
|
+
children: ReactNode
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function SettingsPage({ title, description, children }: SettingsPageProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex flex-col gap-6">
|
|
12
|
+
<header className="flex flex-col gap-1">
|
|
13
|
+
<h2 className="text-xl font-semibold tracking-tight">{title}</h2>
|
|
14
|
+
{description && <p className="text-sm text-muted-foreground">{description}</p>}
|
|
15
|
+
</header>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type SettingsSectionProps = {
|
|
22
|
+
label?: string
|
|
23
|
+
children: ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SettingsSection({ label, children }: SettingsSectionProps) {
|
|
27
|
+
return (
|
|
28
|
+
<section className="flex flex-col gap-2">
|
|
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-lg border border-border bg-card text-card-foreground">
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
</section>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type SettingsRowProps = {
|
|
38
|
+
title: string
|
|
39
|
+
description?: string
|
|
40
|
+
control?: ReactNode
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function SettingsRow({ title, description, control }: SettingsRowProps) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="flex items-center gap-3 px-3.5 py-3">
|
|
46
|
+
<div className="flex min-w-0 flex-col">
|
|
47
|
+
<span className="text-sm font-medium">{title}</span>
|
|
48
|
+
{description && <span className="text-xs text-muted-foreground">{description}</span>}
|
|
49
|
+
</div>
|
|
50
|
+
{control && <div className="ml-auto flex shrink-0 items-center pl-3">{control}</div>}
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -5,9 +5,9 @@ import { IconKey, IconSettings, IconX } from '@tabler/icons-react'
|
|
|
5
5
|
import { Button } from '@/client/components/ui/button'
|
|
6
6
|
import { Dialog, DialogClose, DialogContent, DialogTitle } from '@/client/components/ui/dialog'
|
|
7
7
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
8
|
-
import { cn } from '@/client/lib/cn'
|
|
9
8
|
|
|
10
|
-
import { EnvironmentSettings
|
|
9
|
+
import { EnvironmentSettings } from './EnvironmentSettings'
|
|
10
|
+
import { GeneralSettings } from './GeneralSettings'
|
|
11
11
|
|
|
12
12
|
type SettingsNav = 'general' | 'environment'
|
|
13
13
|
|
|
@@ -27,21 +27,20 @@ export function WorkspaceSettings() {
|
|
|
27
27
|
render={
|
|
28
28
|
<Button
|
|
29
29
|
variant="ghost"
|
|
30
|
-
size="icon"
|
|
31
|
-
aria-label="
|
|
32
|
-
className="size-7 text-primary [&_svg]:size-[20px]"
|
|
30
|
+
size="icon-sm"
|
|
31
|
+
aria-label="Space settings"
|
|
33
32
|
onClick={() => setOpen(true)}
|
|
34
33
|
>
|
|
35
34
|
<IconSettings stroke={1.75} />
|
|
36
35
|
</Button>
|
|
37
36
|
}
|
|
38
37
|
/>
|
|
39
|
-
<TooltipContent>
|
|
38
|
+
<TooltipContent>Space settings</TooltipContent>
|
|
40
39
|
</Tooltip>
|
|
41
40
|
|
|
42
41
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
43
42
|
<DialogContent className="flex h-[min(680px,90vh)] w-[880px] max-w-[94vw]">
|
|
44
|
-
<DialogTitle className="sr-only">
|
|
43
|
+
<DialogTitle className="sr-only">Space settings</DialogTitle>
|
|
45
44
|
|
|
46
45
|
{/* Sidebar nav — top padding lines the "Settings" label up with the
|
|
47
46
|
page title across the divider. */}
|
|
@@ -50,20 +49,17 @@ export function WorkspaceSettings() {
|
|
|
50
49
|
Settings
|
|
51
50
|
</p>
|
|
52
51
|
{NAV.map(item => (
|
|
53
|
-
<
|
|
52
|
+
<Button
|
|
54
53
|
key={item.id}
|
|
55
54
|
type="button"
|
|
55
|
+
variant={page === item.id ? 'secondary' : 'ghost'}
|
|
56
|
+
size="sm"
|
|
56
57
|
onClick={() => setPage(item.id)}
|
|
57
|
-
className=
|
|
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
|
-
)}
|
|
58
|
+
className="justify-start"
|
|
63
59
|
>
|
|
64
60
|
<item.icon stroke={1.75} />
|
|
65
61
|
{item.label}
|
|
66
|
-
</
|
|
62
|
+
</Button>
|
|
67
63
|
))}
|
|
68
64
|
</nav>
|
|
69
65
|
|
|
@@ -75,7 +71,7 @@ export function WorkspaceSettings() {
|
|
|
75
71
|
variant="ghost"
|
|
76
72
|
size="icon"
|
|
77
73
|
aria-label="Close"
|
|
78
|
-
className="absolute top-3 right-3 z-10
|
|
74
|
+
className="absolute top-3 right-3 z-10"
|
|
79
75
|
>
|
|
80
76
|
<IconX stroke={1.5} />
|
|
81
77
|
</Button>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
|
+
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
|
+
import type { WorkspaceEntry, WorkspaceEnvView } from '@/lib/types'
|
|
7
|
+
|
|
8
|
+
export function useWorkspaceEnv(workspaceId: string) {
|
|
9
|
+
return useQuery<WorkspaceEnvView>({
|
|
10
|
+
queryKey: workspaceKeys.env(workspaceId),
|
|
11
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/env`),
|
|
12
|
+
...WORKSPACE_RESOURCE_OPTIONS
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type EnvPatch = {
|
|
17
|
+
set?: Record<string, string>
|
|
18
|
+
remove?: string[]
|
|
19
|
+
inheritDotenv?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useUpdateEnv(workspaceId: string) {
|
|
23
|
+
const queryClient = useQueryClient()
|
|
24
|
+
return useMutation<WorkspaceEnvView, Error, EnvPatch>({
|
|
25
|
+
mutationFn: patch =>
|
|
26
|
+
requestJson(`/api/workspaces/${workspaceId}/env`, jsonRequest('PUT', patch)),
|
|
27
|
+
onSuccess: next => {
|
|
28
|
+
queryClient.setQueryData<WorkspaceEnvView>(workspaceKeys.env(workspaceId), next)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useSaveWorkspaceName(workspaceId: string) {
|
|
34
|
+
const queryClient = useQueryClient()
|
|
35
|
+
return useMutation<void, Error, string | null>({
|
|
36
|
+
mutationFn: name =>
|
|
37
|
+
requestVoid(
|
|
38
|
+
`/api/workspaces/${workspaceId}/config`,
|
|
39
|
+
jsonRequest('PUT', { name }),
|
|
40
|
+
'Failed to save name'
|
|
41
|
+
),
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function useSaveWorkspaceIcon(workspaceId: string) {
|
|
50
|
+
const queryClient = useQueryClient()
|
|
51
|
+
return useMutation<{ icon: string }, Error, Blob>({
|
|
52
|
+
scope: { id: `workspace-icon:${workspaceId}` },
|
|
53
|
+
mutationFn: blob =>
|
|
54
|
+
requestJson(`/api/workspaces/${workspaceId}/icon`, {
|
|
55
|
+
method: 'PUT',
|
|
56
|
+
headers: { 'Content-Type': blob.type || 'application/octet-stream' },
|
|
57
|
+
body: blob
|
|
58
|
+
}),
|
|
59
|
+
onSuccess: () => {
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
61
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function useResetWorkspaceIcon(workspaceId: string) {
|
|
67
|
+
const queryClient = useQueryClient()
|
|
68
|
+
return useMutation<void, Error, void>({
|
|
69
|
+
scope: { id: `workspace-icon:${workspaceId}` },
|
|
70
|
+
mutationFn: () =>
|
|
71
|
+
requestVoid(
|
|
72
|
+
`/api/workspaces/${workspaceId}/icon`,
|
|
73
|
+
{ method: 'DELETE' },
|
|
74
|
+
'Failed to reset icon'
|
|
75
|
+
),
|
|
76
|
+
onSuccess: () => {
|
|
77
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
78
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function removeWorkspaceFromCache(
|
|
84
|
+
workspaces: WorkspaceEntry[] | undefined,
|
|
85
|
+
workspaceId: string
|
|
86
|
+
) {
|
|
87
|
+
return (workspaces ?? []).filter(workspace => workspace.id !== workspaceId)
|
|
88
|
+
}
|