moi-computer 0.4.0 → 0.4.1-next.0
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 +41 -5
- package/bin/moi.mjs +11 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +5 -1
- package/client/app/routes/WorkspaceRoute.tsx +9 -5
- package/client/app/shell/SidebarLayout.tsx +9 -7
- package/client/components/shared/BottomPanel.tsx +24 -5
- package/client/components/shared/Composer.tsx +1 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/ui/button.tsx +5 -5
- package/client/components/ui/dropdown-menu.tsx +6 -6
- 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 +1 -1
- package/client/components/ui/textarea.tsx +1 -1
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/applets/applet-cache.ts +20 -1
- package/client/features/applets/applet-log.ts +10 -30
- package/client/features/applets/applet-runtime.ts +272 -0
- package/client/features/applets/useApplet.ts +36 -10
- package/client/features/chat/ChatComposer.tsx +1 -1
- package/client/features/chat/ChatEmptyState.tsx +186 -0
- package/client/features/chat/ChatPanel.tsx +95 -54
- package/client/features/chat/ChatPopup.tsx +3 -13
- package/client/features/chat/ChatPromptBubbles.tsx +74 -0
- package/client/features/chat/MarkdownContent.tsx +15 -3
- package/client/features/chat/ModelPicker.tsx +1 -1
- package/client/features/chat/TurnView.tsx +6 -17
- package/client/features/chat/chat-send.ts +26 -1
- package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
- package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
- package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
- package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
- package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
- package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
- package/client/features/chat/tool-group/format.ts +3 -3
- package/client/features/chat/useAppletChatMessage.ts +69 -0
- package/client/features/chat/useChat.ts +49 -14
- package/client/features/chat/useStickToBottom.ts +11 -1
- package/client/features/connectors/McpServerCards.tsx +3 -3
- package/client/features/dev/HarnessDebugPage.tsx +4 -4
- package/client/features/dev/PixelPainter.tsx +1 -1
- package/client/features/dev/PlaygroundPage.tsx +1 -1
- package/client/features/dev/ToolCallsPage.tsx +2 -2
- package/client/features/home/HomePage.tsx +17 -14
- package/client/features/home/WorkspacePreview.tsx +12 -13
- package/client/features/home/api.ts +8 -5
- package/client/features/home/workspace-presentation.tsx +1 -1
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
- package/client/features/scratchpad/Scratchpad.tsx +41 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
- package/client/features/settings/EnvironmentSettings.tsx +1 -1
- package/client/features/settings/IconPicker.tsx +11 -11
- package/client/features/settings/SettingsLayout.tsx +1 -1
- package/client/features/settings/WorkspaceSettings.tsx +2 -2
- package/client/features/settings/api.ts +33 -1
- package/client/features/widgets/HiddenPanel.tsx +4 -3
- package/client/features/widgets/Widgets.tsx +1 -0
- package/client/features/workspace/CustomizePanel.tsx +96 -82
- package/client/features/workspace/WorkspaceScreen.tsx +129 -107
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +52 -0
- package/client/features/workspace/moi-context.ts +63 -17
- package/client/features/workspace/tab-resolution.ts +75 -0
- package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
- package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
- package/client/index.css +10 -15
- package/client/lib/app-icon-registry.ts +77 -70
- package/client/lib/rate-limit.ts +77 -0
- package/client/runtime/useWorkspaceEvents.ts +15 -2
- package/client/runtime/workspace-theme.ts +115 -0
- package/client/store/ui.ts +42 -17
- package/client/theme.css +20 -15
- package/dist/{chunk-fh2mf6v9.js → chunk-3m1xe1j3.js} +94 -94
- package/dist/chunk-5vaevt8z.js +2 -0
- package/dist/{chunk-69nhbjhy.js → chunk-7bzpmtxp.js} +4 -4
- package/dist/chunk-h0hk61pm.js +9 -0
- package/dist/{chunk-35fq49qa.js → chunk-h3evrtyp.js} +1 -1
- package/dist/chunk-k5sjx9s5.js +1 -0
- package/dist/{chunk-2vaafjp4.js → chunk-m9qja0nx.js} +1 -1
- package/dist/chunk-s7za1qsv.css +1 -0
- package/dist/{chunk-72atbmh3.js → chunk-tcfa3vt3.js} +1 -1
- package/dist/chunk-v797g6ap.js +51 -0
- package/dist/chunk-xyrw8318.js +27 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +73 -0
- package/lib/moi-context.ts +104 -3
- package/lib/themes.ts +83 -45
- package/lib/types.ts +44 -9
- package/lib/workspace-tabs.ts +48 -0
- package/package.json +4 -1
- package/server/api.ts +57 -5
- package/server/app-settings.ts +65 -0
- package/server/applets.ts +132 -22
- package/server/bundler/build-applet.ts +74 -16
- package/server/cli.ts +144 -17
- package/server/control.ts +53 -7
- package/server/data-dir.ts +1 -1
- package/server/events.ts +1 -1
- package/server/functions-worker.ts +15 -1
- package/server/functions.ts +51 -6
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +37 -3
- package/server/registry.ts +1 -1
- package/server/skill-update.ts +47 -0
- package/server/skill-version.ts +2 -11
- package/server/tabs.ts +59 -0
- package/server/theme.ts +8 -14
- package/server/view-builders.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
- package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
- package/client/features/workspace/useWorkspaceTheme.ts +0 -82
- package/dist/chunk-19g80zc9.css +0 -1
- package/dist/chunk-7mkv2gr0.js +0 -2
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-jwmc32rp.js +0 -63
- package/dist/chunk-kh24bstm.js +0 -10
- package/dist/chunk-sfa4mbmx.js +0 -15
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type TLAssetStore,
|
|
6
6
|
type TLComponents,
|
|
7
7
|
type TLEditorSnapshot,
|
|
8
|
+
type TLGridProps,
|
|
8
9
|
type TLUiOverrides,
|
|
9
10
|
DefaultFillStyle,
|
|
10
11
|
DefaultFontStyle,
|
|
@@ -12,7 +13,9 @@ import {
|
|
|
12
13
|
DefaultVerticalAlignStyle,
|
|
13
14
|
Tldraw,
|
|
14
15
|
getSnapshot,
|
|
15
|
-
loadSnapshot
|
|
16
|
+
loadSnapshot,
|
|
17
|
+
useEditor,
|
|
18
|
+
useUniqueSafeId
|
|
16
19
|
} from 'tldraw'
|
|
17
20
|
import 'tldraw/tldraw.css'
|
|
18
21
|
|
|
@@ -103,7 +106,42 @@ function makeAssetStore(workspaceId: string): TLAssetStore {
|
|
|
103
106
|
// native zoom control — but Minimap is nulled, which also strips its toggle button
|
|
104
107
|
// from the panel, leaving just the zoom menu. Kept on defaults: NavigationPanel
|
|
105
108
|
// (zoom), ContextMenu, KeyboardShortcutsDialog.
|
|
109
|
+
function ScratchBackground() {
|
|
110
|
+
return (
|
|
111
|
+
<div className="absolute inset-0 bg-[color-mix(in_oklch,var(--muted),var(--background)_50%)]" />
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function UniformGrid({ x, y, z, size }: TLGridProps) {
|
|
116
|
+
const id = useUniqueSafeId('scratch-grid')
|
|
117
|
+
const editor = useEditor()
|
|
118
|
+
let step = editor.options.gridSteps[0]?.step ?? 1
|
|
119
|
+
|
|
120
|
+
for (const gridStep of editor.options.gridSteps) {
|
|
121
|
+
if (z >= gridStep.min) step = gridStep.step
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const spacing = step * size * z
|
|
125
|
+
const offsetX = 0.5 + x * z
|
|
126
|
+
const offsetY = 0.5 + y * z
|
|
127
|
+
const dotX = offsetX > 0 ? offsetX % spacing : spacing + (offsetX % spacing)
|
|
128
|
+
const dotY = offsetY > 0 ? offsetY % spacing : spacing + (offsetY % spacing)
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<svg className="tl-grid" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
132
|
+
<defs>
|
|
133
|
+
<pattern id={id} width={spacing} height={spacing} patternUnits="userSpaceOnUse">
|
|
134
|
+
<circle className="fill-accent" cx={dotX} cy={dotY} r={1} />
|
|
135
|
+
</pattern>
|
|
136
|
+
</defs>
|
|
137
|
+
<rect width="100%" height="100%" fill={`url(#${id})`} />
|
|
138
|
+
</svg>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
106
142
|
const SCRATCH_COMPONENTS: TLComponents = {
|
|
143
|
+
Background: ScratchBackground,
|
|
144
|
+
Grid: UniformGrid,
|
|
107
145
|
Toolbar: null,
|
|
108
146
|
StylePanel: null,
|
|
109
147
|
Minimap: null,
|
|
@@ -112,7 +150,8 @@ const SCRATCH_COMPONENTS: TLComponents = {
|
|
|
112
150
|
ActionsMenu: null,
|
|
113
151
|
QuickActions: null,
|
|
114
152
|
HelpMenu: null,
|
|
115
|
-
DebugMenu: null
|
|
153
|
+
DebugMenu: null,
|
|
154
|
+
ZoomMenu: null
|
|
116
155
|
}
|
|
117
156
|
|
|
118
157
|
// Remove dropped tools (kills their shortcuts too) and hard-disable export/print.
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
IconTypography
|
|
32
32
|
} from '@tabler/icons-react'
|
|
33
33
|
|
|
34
|
+
import { Button } from '@/client/components/ui/button'
|
|
34
35
|
import { cn } from '@/client/lib/cn'
|
|
35
36
|
|
|
36
37
|
type IconC = typeof IconPointer2
|
|
@@ -70,18 +71,17 @@ type ToolButtonProps = {
|
|
|
70
71
|
|
|
71
72
|
function ToolButton({ label, active, Icon, onClick }: ToolButtonProps) {
|
|
72
73
|
return (
|
|
73
|
-
<
|
|
74
|
+
<Button
|
|
74
75
|
type="button"
|
|
76
|
+
size="icon"
|
|
77
|
+
variant={active ? 'default' : 'ghost'}
|
|
78
|
+
aria-label={label}
|
|
75
79
|
title={label}
|
|
76
80
|
onClick={onClick}
|
|
77
|
-
className={cn(
|
|
78
|
-
'flex size-9 items-center justify-center rounded-lg text-muted-foreground hover:bg-accent hover:text-accent-foreground',
|
|
79
|
-
active &&
|
|
80
|
-
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground'
|
|
81
|
-
)}
|
|
81
|
+
className={cn(!active && 'text-muted-foreground hover:text-foreground')}
|
|
82
82
|
>
|
|
83
|
-
<Icon
|
|
84
|
-
</
|
|
83
|
+
<Icon stroke={1.5} />
|
|
84
|
+
</Button>
|
|
85
85
|
)
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -148,12 +148,12 @@ export function ScratchToolbar({ editor }: ScratchToolbarProps) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
return (
|
|
151
|
-
<div className="absolute top-1/2 left-
|
|
151
|
+
<div className="absolute top-1/2 left-2 z-10 -translate-y-1/2">
|
|
152
152
|
<motion.div
|
|
153
153
|
initial={{ x: -72, opacity: 0 }}
|
|
154
154
|
animate={{ x: 0, opacity: 1 }}
|
|
155
|
-
transition={{ type: 'spring', bounce: 0.
|
|
156
|
-
className="flex flex-col gap-1 rounded-xl bg-background/95 p-1 shadow-
|
|
155
|
+
transition={{ type: 'spring', bounce: 0.2, duration: 0.55 }}
|
|
156
|
+
className="flex flex-col gap-1 rounded-xl bg-background/95 p-1 shadow-md backdrop-blur"
|
|
157
157
|
>
|
|
158
158
|
{TOOL_ENTRIES.map((entry, i) => {
|
|
159
159
|
if (entry.kind === 'sep') {
|
|
@@ -483,7 +483,7 @@ export function ScratchStyleBar({ editor }: ScratchStyleBarProps) {
|
|
|
483
483
|
state.fill === f.value && 'bg-accent text-accent-foreground'
|
|
484
484
|
)}
|
|
485
485
|
>
|
|
486
|
-
<span className={cn('size-4.5 rounded-
|
|
486
|
+
<span className={cn('size-4.5 rounded-lg', f.preview)} />
|
|
487
487
|
</button>
|
|
488
488
|
))}
|
|
489
489
|
</div>
|
|
@@ -491,7 +491,7 @@ export function ScratchStyleBar({ editor }: ScratchStyleBarProps) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
return (
|
|
494
|
-
<div className="absolute top-1/2 left-
|
|
494
|
+
<div className="absolute top-1/2 left-14 z-10 flex -translate-y-1/2 flex-col items-center gap-1.5 rounded-full bg-background/95 px-1 py-1 shadow-[0_2px_8px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06),0_0_0_1px_rgba(0,0,0,0.04)] backdrop-blur">
|
|
495
495
|
{state.controls.map((control, i) => (
|
|
496
496
|
<Fragment key={control}>
|
|
497
497
|
{i > 0 && <div className="h-px w-5 bg-border" />}
|
|
@@ -88,7 +88,7 @@ export function useScratchpadSnapshot(workspaceId: string): {
|
|
|
88
88
|
export function ScratchpadSkewNotice({ skew }: { skew: ScratchpadSkew }) {
|
|
89
89
|
return (
|
|
90
90
|
<div className="flex min-h-0 flex-1 items-center justify-center bg-muted/40 bg-[radial-gradient(var(--color-border)_1px,transparent_1px)] [background-size:16px_16px] p-6">
|
|
91
|
-
<div className="flex max-w-md animate-in flex-col gap-3 rounded-
|
|
91
|
+
<div className="flex max-w-md animate-in flex-col gap-3 rounded-lg bg-background p-6 shadow-xs duration-200 fade-in-0 zoom-in-95">
|
|
92
92
|
<div className="flex items-center gap-2">
|
|
93
93
|
<IconVersions size={20} stroke={1.5} className="shrink-0 text-amber-600" />
|
|
94
94
|
<h2 className="font-medium text-foreground">
|
|
@@ -71,7 +71,7 @@ export function EnvironmentSettings() {
|
|
|
71
71
|
</span>
|
|
72
72
|
<span
|
|
73
73
|
className={cn(
|
|
74
|
-
'rounded-
|
|
74
|
+
'rounded-lg px-1.5 py-0.5 text-[11px] font-medium',
|
|
75
75
|
variable.source === 'dotenv'
|
|
76
76
|
? 'bg-muted text-muted-foreground'
|
|
77
77
|
: 'bg-primary/10 text-primary'
|
|
@@ -61,7 +61,7 @@ function EmojiButton({ emoji, ...props }: EmojiPickerListEmojiProps) {
|
|
|
61
61
|
return (
|
|
62
62
|
<button
|
|
63
63
|
className={cn(
|
|
64
|
-
'flex size-9 items-center justify-center rounded-
|
|
64
|
+
'flex size-9 items-center justify-center rounded-xl text-[22px] transition-colors duration-75 data-active:bg-muted',
|
|
65
65
|
EMOJI_FONT
|
|
66
66
|
)}
|
|
67
67
|
{...props}
|
|
@@ -182,7 +182,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
182
182
|
<div className="flex w-24 shrink-0 flex-col items-center gap-2.5">
|
|
183
183
|
<div
|
|
184
184
|
className={cn(
|
|
185
|
-
'flex size-24 items-center justify-center overflow-hidden rounded-
|
|
185
|
+
'flex size-24 items-center justify-center overflow-hidden rounded-xl shadow-sm ring-1 ring-border',
|
|
186
186
|
// Checkerboard hints at transparency when no background is chosen.
|
|
187
187
|
previewKind !== 'image' &&
|
|
188
188
|
!onGradient &&
|
|
@@ -224,14 +224,14 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
224
224
|
{/* Controls */}
|
|
225
225
|
<div className="flex min-w-0 flex-1 flex-col gap-3">
|
|
226
226
|
{/* Mode tabs */}
|
|
227
|
-
<div className="flex gap-1 self-start rounded-
|
|
227
|
+
<div className="flex gap-1 self-start rounded-xl bg-muted p-0.5">
|
|
228
228
|
{(['emoji', 'icon', 'upload'] as const).map(m => (
|
|
229
229
|
<button
|
|
230
230
|
key={m}
|
|
231
231
|
type="button"
|
|
232
232
|
onClick={() => setMode(m)}
|
|
233
233
|
className={cn(
|
|
234
|
-
'rounded-
|
|
234
|
+
'rounded-lg px-3.5 py-1 text-xs font-medium capitalize transition-colors',
|
|
235
235
|
mode === m
|
|
236
236
|
? 'bg-background text-foreground shadow-sm'
|
|
237
237
|
: 'text-muted-foreground hover:text-foreground'
|
|
@@ -309,15 +309,15 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
309
309
|
// served by server/vendor.ts) — the picker works fully offline.
|
|
310
310
|
emojibaseUrl="/vendor/emojibase"
|
|
311
311
|
columns={13}
|
|
312
|
-
className="isolate flex h-72 flex-col overflow-hidden rounded-
|
|
312
|
+
className="isolate flex h-72 flex-col overflow-hidden rounded-xl border border-border bg-background"
|
|
313
313
|
>
|
|
314
314
|
<div className="flex items-center gap-1.5 p-1.5 pb-0">
|
|
315
315
|
<EmojiPicker.Search
|
|
316
316
|
placeholder="Search emoji…"
|
|
317
317
|
onChange={e => setEmojiSearch(e.target.value)}
|
|
318
|
-
className="h-8 min-w-0 flex-1 appearance-none rounded-
|
|
318
|
+
className="h-8 min-w-0 flex-1 appearance-none rounded-lg bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"
|
|
319
319
|
/>
|
|
320
|
-
<EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-
|
|
320
|
+
<EmojiPicker.SkinToneSelector className="size-8 shrink-0 rounded-lg text-lg hover:bg-accent" />
|
|
321
321
|
</div>
|
|
322
322
|
<EmojiPicker.Viewport className="relative scrollbar-thin flex-1 overflow-y-auto outline-none">
|
|
323
323
|
<EmojiPicker.Loading className="absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground">
|
|
@@ -341,7 +341,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
341
341
|
type="button"
|
|
342
342
|
onClick={() => setEmoji(e)}
|
|
343
343
|
className={cn(
|
|
344
|
-
'flex size-9 items-center justify-center rounded-
|
|
344
|
+
'flex size-9 items-center justify-center rounded-xl text-[22px] transition-colors duration-75',
|
|
345
345
|
EMOJI_FONT,
|
|
346
346
|
emoji === e ? 'bg-primary/10' : 'hover:bg-accent'
|
|
347
347
|
)}
|
|
@@ -367,7 +367,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
367
367
|
</EmojiPicker.Viewport>
|
|
368
368
|
</EmojiPicker.Root>
|
|
369
369
|
) : mode === 'icon' ? (
|
|
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-
|
|
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-xl border border-border bg-background p-1.5">
|
|
371
371
|
{APP_ICON_CHOICES.map(({ id, Icon }) => (
|
|
372
372
|
<button
|
|
373
373
|
key={id}
|
|
@@ -375,7 +375,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
375
375
|
aria-label={id}
|
|
376
376
|
onClick={() => setIconId(id)}
|
|
377
377
|
className={cn(
|
|
378
|
-
'flex aspect-square items-center justify-center rounded-
|
|
378
|
+
'flex aspect-square items-center justify-center rounded-xl text-muted-foreground transition-colors [&_svg]:size-5',
|
|
379
379
|
iconId === id
|
|
380
380
|
? 'bg-primary/10 text-primary'
|
|
381
381
|
: 'hover:bg-accent hover:text-accent-foreground'
|
|
@@ -401,7 +401,7 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
401
401
|
if (file) onFile(file)
|
|
402
402
|
}}
|
|
403
403
|
className={cn(
|
|
404
|
-
'flex h-72 flex-col items-center justify-center gap-2 rounded-
|
|
404
|
+
'flex h-72 flex-col items-center justify-center gap-2 rounded-xl border border-dashed transition-colors',
|
|
405
405
|
dragOver
|
|
406
406
|
? 'border-primary bg-primary/5 text-primary'
|
|
407
407
|
: 'border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground'
|
|
@@ -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-
|
|
30
|
+
<div className="flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-xl border border-border bg-card text-card-foreground">
|
|
31
31
|
{children}
|
|
32
32
|
</div>
|
|
33
33
|
</section>
|
|
@@ -30,14 +30,14 @@ export function WorkspaceSettings() {
|
|
|
30
30
|
<Button
|
|
31
31
|
variant="ghost"
|
|
32
32
|
size="icon-sm"
|
|
33
|
-
aria-label="
|
|
33
|
+
aria-label="Settings"
|
|
34
34
|
onClick={() => setOpen(true)}
|
|
35
35
|
>
|
|
36
36
|
<IconSettings stroke={1.75} />
|
|
37
37
|
</Button>
|
|
38
38
|
}
|
|
39
39
|
/>
|
|
40
|
-
<TooltipContent>
|
|
40
|
+
<TooltipContent>Settings</TooltipContent>
|
|
41
41
|
</Tooltip>
|
|
42
42
|
|
|
43
43
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
@@ -3,7 +3,39 @@ 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
|
|
6
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
7
|
+
import type { AppSettings, WorkspaceEntry, WorkspaceEnvView } from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
// App-wide settings (server-side settings.json, GET/PATCH /api/settings) —
|
|
10
|
+
// shared by every workspace, unlike the per-workspace queries below.
|
|
11
|
+
export const appSettingsKey = ['app-settings'] as const
|
|
12
|
+
|
|
13
|
+
export function useAppSettings() {
|
|
14
|
+
const queryClient = useQueryClient()
|
|
15
|
+
// Another client can change settings; the server broadcasts the new value
|
|
16
|
+
// over the live-events socket so every open client stays in sync.
|
|
17
|
+
useWorkspaceEvent(event => {
|
|
18
|
+
if (event.type === 'settings:updated') {
|
|
19
|
+
queryClient.setQueryData<AppSettings>(appSettingsKey, event.settings)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
return useQuery<AppSettings>({
|
|
23
|
+
queryKey: appSettingsKey,
|
|
24
|
+
queryFn: () => requestJson('/api/settings'),
|
|
25
|
+
staleTime: 30_000
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useSaveAppSettings() {
|
|
30
|
+
const queryClient = useQueryClient()
|
|
31
|
+
return useMutation<AppSettings, Error, Partial<AppSettings>>({
|
|
32
|
+
mutationFn: patch =>
|
|
33
|
+
requestJson('/api/settings', jsonRequest('PATCH', patch), 'Failed to save settings'),
|
|
34
|
+
onSuccess: next => {
|
|
35
|
+
queryClient.setQueryData<AppSettings>(appSettingsKey, next)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
7
39
|
|
|
8
40
|
export function useWorkspaceEnv(workspaceId: string) {
|
|
9
41
|
return useQuery<WorkspaceEnvView>({
|
|
@@ -43,17 +43,18 @@ const ROW_SPAN: Record<number, string> = {
|
|
|
43
43
|
type HiddenPanelProps = {
|
|
44
44
|
items: GridItem[]
|
|
45
45
|
renderItem: (id: string) => ReactNode
|
|
46
|
+
onClose: () => void
|
|
46
47
|
onRestore: (id: string) => void
|
|
47
48
|
ref?: Ref<HTMLDivElement>
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
export function HiddenPanel({ items, renderItem, onRestore, ref }: HiddenPanelProps) {
|
|
51
|
+
export function HiddenPanel({ items, renderItem, onClose, onRestore, ref }: HiddenPanelProps) {
|
|
51
52
|
const layout = useMemo(() => packItems(items), [items])
|
|
52
53
|
|
|
53
54
|
return (
|
|
54
|
-
<BottomPanel ref={ref} title="Hidden">
|
|
55
|
+
<BottomPanel ref={ref} title="Hidden widgets" onClose={onClose} className="max-h-[60vh]">
|
|
55
56
|
{/* gap-2 + grid-cols-4 + [grid-auto-rows:160px] matches RGL's margin/rowHeight exactly */}
|
|
56
|
-
<div className="grid
|
|
57
|
+
<div className="grid auto-rows-[160px] grid-cols-4 gap-2">
|
|
57
58
|
<AnimatePresence>
|
|
58
59
|
{layout.map(item => (
|
|
59
60
|
<motion.div
|
|
@@ -1,115 +1,129 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CSSProperties, ReactNode, Ref } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconCircleCheckFilled } from '@tabler/icons-react'
|
|
2
4
|
|
|
3
5
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
4
6
|
import { BottomPanel } from '@/client/components/shared/BottomPanel'
|
|
5
7
|
import { cn } from '@/client/lib/cn'
|
|
8
|
+
import { getWorkspaceThemeStyle, usePreloadWorkspaceFonts } from '@/client/runtime/workspace-theme'
|
|
6
9
|
import { COLOR_THEMES, type ColorThemeConfig, FONT_THEMES } from '@/lib/themes'
|
|
7
10
|
import type { ColorTheme, FontTheme } from '@/lib/types'
|
|
8
11
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.filter(Boolean)
|
|
13
|
-
.join('&family=')
|
|
12
|
+
const FONT_OPTIONS = Object.entries(FONT_THEMES) as [FontTheme, (typeof FONT_THEMES)[FontTheme]][]
|
|
13
|
+
|
|
14
|
+
const COLOR_OPTIONS = Object.entries(COLOR_THEMES) as [ColorTheme, ColorThemeConfig][]
|
|
14
15
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
if (document.getElementById(ALL_FONT_PREVIEW_ID)) return
|
|
18
|
-
const link = document.createElement('link')
|
|
19
|
-
link.id = ALL_FONT_PREVIEW_ID
|
|
20
|
-
link.rel = 'stylesheet'
|
|
21
|
-
link.href = `https://fonts.googleapis.com/css2?family=${ALL_FONTS_QUERY}&display=swap`
|
|
22
|
-
document.head.appendChild(link)
|
|
23
|
-
}, [])
|
|
16
|
+
function presetMatches(preset: ColorThemeConfig, primary?: string): boolean {
|
|
17
|
+
return (preset.primary ?? undefined) === primary
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
type CustomizeOptionGroupProps = {
|
|
21
|
+
children: ReactNode
|
|
22
|
+
label: string
|
|
23
|
+
}
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
function CustomizeOptionGroup({ children, label }: CustomizeOptionGroupProps) {
|
|
26
|
+
return (
|
|
27
|
+
<div className="flex flex-col gap-2">
|
|
28
|
+
<p className="text-xs font-medium">{label}</p>
|
|
29
|
+
<div role="group" aria-label={label} className="grid grid-cols-3 gap-2">
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
type CustomizeOptionProps = {
|
|
37
|
+
active: boolean
|
|
38
|
+
children: ReactNode
|
|
39
|
+
className?: string
|
|
40
|
+
onSelect: () => void
|
|
41
|
+
style?: CSSProperties
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function CustomizeOption({ active, children, className, onSelect, style }: CustomizeOptionProps) {
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
aria-pressed={active}
|
|
49
|
+
onClick={onSelect}
|
|
50
|
+
className={cn(
|
|
51
|
+
'relative w-full rounded-lg bg-card text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
|
|
52
|
+
'flex items-center gap-2 p-3',
|
|
53
|
+
className,
|
|
54
|
+
!active && 'cursor-pointer pr-9 opacity-70 hover:opacity-100'
|
|
55
|
+
)}
|
|
56
|
+
style={style}
|
|
57
|
+
>
|
|
58
|
+
<div className="flex-1">{children}</div>
|
|
59
|
+
{active && <IconCircleCheckFilled size={20} stroke={1.5} aria-hidden="true" />}
|
|
60
|
+
</button>
|
|
61
|
+
)
|
|
32
62
|
}
|
|
33
63
|
|
|
34
64
|
type CustomizePanelProps = {
|
|
65
|
+
onClose: () => void
|
|
35
66
|
ref?: Ref<HTMLDivElement>
|
|
36
67
|
}
|
|
37
68
|
|
|
38
|
-
export function CustomizePanel({ ref }: CustomizePanelProps) {
|
|
39
|
-
|
|
69
|
+
export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
|
|
70
|
+
usePreloadWorkspaceFonts()
|
|
40
71
|
const { layout, setLayout } = useWorkspaceLayoutCtx()
|
|
41
72
|
const currentFont = layout.theme?.font ?? 'default'
|
|
42
|
-
const
|
|
43
|
-
const currentFg = layout.theme?.foreground
|
|
73
|
+
const currentPrimary = layout.theme?.primary
|
|
44
74
|
|
|
45
|
-
function setTheme(
|
|
46
|
-
setLayout({ theme: {
|
|
75
|
+
function setTheme(font: FontTheme, primary: string | undefined) {
|
|
76
|
+
setLayout({ theme: { font, ...(primary ? { primary } : {}) } })
|
|
47
77
|
}
|
|
48
78
|
|
|
49
79
|
return (
|
|
50
|
-
<BottomPanel ref={ref} title="Customize">
|
|
51
|
-
<div className="flex flex-col gap-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
className={cn(
|
|
62
|
-
'flex flex-col items-start rounded-md px-3 py-2 text-left transition-colors',
|
|
63
|
-
key === currentFont
|
|
64
|
-
? 'bg-primary/5 ring-2 ring-primary'
|
|
65
|
-
: 'border-transparent hover:bg-accent'
|
|
66
|
-
)}
|
|
67
|
-
style={{ fontFamily: config.sans }}
|
|
68
|
-
>
|
|
80
|
+
<BottomPanel ref={ref} title="Customize" onClose={onClose}>
|
|
81
|
+
<div className="flex flex-col gap-4">
|
|
82
|
+
<CustomizeOptionGroup label="Font">
|
|
83
|
+
{FONT_OPTIONS.map(([key, config]) => (
|
|
84
|
+
<CustomizeOption
|
|
85
|
+
key={key}
|
|
86
|
+
active={key === currentFont}
|
|
87
|
+
onSelect={() => setTheme(key, currentPrimary)}
|
|
88
|
+
style={{ fontFamily: config.sans }}
|
|
89
|
+
>
|
|
90
|
+
<div className="flex flex-col">
|
|
69
91
|
<span className="text-sm font-medium">{config.label}</span>
|
|
70
92
|
<span className="text-xs text-muted-foreground">{config.feel}</span>
|
|
71
|
-
</
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</
|
|
93
|
+
</div>
|
|
94
|
+
</CustomizeOption>
|
|
95
|
+
))}
|
|
96
|
+
</CustomizeOptionGroup>
|
|
75
97
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
<CustomizeOptionGroup label="Colors">
|
|
99
|
+
{COLOR_OPTIONS.map(([key, preset]) => (
|
|
100
|
+
<CustomizeOption
|
|
101
|
+
key={key}
|
|
102
|
+
active={presetMatches(preset, currentPrimary)}
|
|
103
|
+
className={preset.primary && 'bg-background text-foreground'}
|
|
104
|
+
onSelect={() => setTheme(currentFont, preset.primary)}
|
|
105
|
+
style={
|
|
106
|
+
preset.primary
|
|
107
|
+
? getWorkspaceThemeStyle({ font: currentFont, primary: preset.primary })
|
|
108
|
+
: undefined
|
|
109
|
+
}
|
|
110
|
+
>
|
|
111
|
+
<div className="flex gap-2">
|
|
112
|
+
<span
|
|
89
113
|
className={cn(
|
|
90
|
-
'flex items-center
|
|
91
|
-
|
|
92
|
-
? 'bg-primary
|
|
93
|
-
: '
|
|
114
|
+
'flex size-5 shrink-0 items-center justify-center rounded-sm text-[9px] leading-none font-bold',
|
|
115
|
+
preset.primary
|
|
116
|
+
? 'bg-primary text-primary-foreground'
|
|
117
|
+
: 'bg-foreground text-background'
|
|
94
118
|
)}
|
|
95
119
|
>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
>
|
|
104
|
-
A
|
|
105
|
-
</span>
|
|
106
|
-
</span>
|
|
107
|
-
<span className="text-sm">{preset.label}</span>
|
|
108
|
-
</button>
|
|
109
|
-
)
|
|
110
|
-
})}
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
120
|
+
Aa
|
|
121
|
+
</span>
|
|
122
|
+
<span className="text-sm font-medium">{preset.label}</span>
|
|
123
|
+
</div>
|
|
124
|
+
</CustomizeOption>
|
|
125
|
+
))}
|
|
126
|
+
</CustomizeOptionGroup>
|
|
113
127
|
</div>
|
|
114
128
|
</BottomPanel>
|
|
115
129
|
)
|