moi-computer 0.3.1-next.1 → 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.
Files changed (130) hide show
  1. package/README.md +85 -12
  2. package/bin/moi.mjs +11 -0
  3. package/client/api/workspace-keys.ts +1 -0
  4. package/client/app/AppRouter.tsx +5 -1
  5. package/client/app/routes/WorkspaceRoute.tsx +9 -5
  6. package/client/app/shell/SidebarLayout.tsx +9 -7
  7. package/client/components/shared/BottomPanel.tsx +24 -5
  8. package/client/components/shared/Composer.tsx +1 -1
  9. package/client/components/shared/PanelHeader.tsx +1 -1
  10. package/client/components/ui/button.tsx +5 -5
  11. package/client/components/ui/dropdown-menu.tsx +6 -6
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/input.tsx +1 -1
  14. package/client/components/ui/popover.tsx +1 -1
  15. package/client/components/ui/skeleton.tsx +1 -1
  16. package/client/components/ui/textarea.tsx +1 -1
  17. package/client/components/ui/tooltip.tsx +1 -1
  18. package/client/features/applets/applet-cache.ts +20 -1
  19. package/client/features/applets/applet-log.ts +10 -30
  20. package/client/features/applets/applet-runtime.ts +272 -0
  21. package/client/features/applets/useApplet.ts +36 -10
  22. package/client/features/chat/ChatComposer.tsx +1 -1
  23. package/client/features/chat/ChatEmptyState.tsx +186 -0
  24. package/client/features/chat/ChatPanel.tsx +95 -54
  25. package/client/features/chat/ChatPopup.tsx +3 -13
  26. package/client/features/chat/ChatPromptBubbles.tsx +74 -0
  27. package/client/features/chat/MarkdownContent.tsx +15 -3
  28. package/client/features/chat/ModelPicker.tsx +1 -1
  29. package/client/features/chat/TurnView.tsx +6 -17
  30. package/client/features/chat/chat-send.ts +26 -1
  31. package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
  32. package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
  33. package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
  34. package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
  35. package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
  36. package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
  37. package/client/features/chat/tool-group/format.ts +25 -4
  38. package/client/features/chat/useAppletChatMessage.ts +69 -0
  39. package/client/features/chat/useChat.ts +49 -14
  40. package/client/features/chat/useStickToBottom.ts +11 -1
  41. package/client/features/connectors/McpServerCards.tsx +3 -3
  42. package/client/features/dev/HarnessDebugPage.tsx +213 -77
  43. package/client/features/dev/PixelPainter.tsx +1 -1
  44. package/client/features/dev/PlaygroundPage.tsx +1 -1
  45. package/client/features/dev/ToolCallsPage.tsx +2 -2
  46. package/client/features/home/HomePage.tsx +17 -14
  47. package/client/features/home/WorkspacePreview.tsx +12 -13
  48. package/client/features/home/api.ts +8 -5
  49. package/client/features/home/workspace-presentation.tsx +1 -1
  50. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
  51. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
  52. package/client/features/scratchpad/Scratchpad.tsx +41 -2
  53. package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
  54. package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
  55. package/client/features/settings/EnvironmentSettings.tsx +1 -1
  56. package/client/features/settings/IconPicker.tsx +11 -11
  57. package/client/features/settings/SettingsLayout.tsx +1 -1
  58. package/client/features/settings/WorkspaceSettings.tsx +2 -2
  59. package/client/features/settings/api.ts +33 -1
  60. package/client/features/widgets/HiddenPanel.tsx +4 -3
  61. package/client/features/widgets/Widgets.tsx +1 -0
  62. package/client/features/workspace/CustomizePanel.tsx +96 -82
  63. package/client/features/workspace/WorkspaceScreen.tsx +129 -107
  64. package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
  65. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  66. package/client/features/workspace/api.ts +52 -0
  67. package/client/features/workspace/moi-context.ts +63 -17
  68. package/client/features/workspace/tab-resolution.ts +75 -0
  69. package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
  70. package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
  71. package/client/index.css +10 -15
  72. package/client/lib/app-icon-registry.ts +77 -70
  73. package/client/lib/rate-limit.ts +77 -0
  74. package/client/main.tsx +10 -2
  75. package/client/runtime/useWorkspaceEvents.ts +15 -2
  76. package/client/runtime/workspace-theme.ts +115 -0
  77. package/client/store/ui.ts +42 -17
  78. package/client/theme.css +20 -15
  79. package/dist/{chunk-1dfbr7n2.js → chunk-3m1xe1j3.js} +94 -94
  80. package/dist/chunk-5vaevt8z.js +2 -0
  81. package/dist/chunk-7bzpmtxp.js +50 -0
  82. package/dist/chunk-h0hk61pm.js +9 -0
  83. package/dist/{chunk-vkvb3hjm.js → chunk-h3evrtyp.js} +1 -1
  84. package/dist/chunk-k5sjx9s5.js +1 -0
  85. package/dist/{chunk-jen6xcm1.js → chunk-m9qja0nx.js} +1 -1
  86. package/dist/chunk-s7za1qsv.css +1 -0
  87. package/dist/{chunk-sxbfh73c.js → chunk-tcfa3vt3.js} +1 -1
  88. package/dist/chunk-v797g6ap.js +51 -0
  89. package/dist/chunk-xyrw8318.js +27 -0
  90. package/dist/index.html +1 -1
  91. package/lib/app-icons.ts +73 -0
  92. package/lib/moi-context.ts +104 -3
  93. package/lib/themes.ts +83 -45
  94. package/lib/types.ts +44 -9
  95. package/lib/workspace-tabs.ts +48 -0
  96. package/package.json +4 -1
  97. package/server/api.ts +57 -5
  98. package/server/app-settings.ts +65 -0
  99. package/server/applets.ts +132 -22
  100. package/server/bundler/build-applet.ts +74 -16
  101. package/server/cli.ts +144 -17
  102. package/server/control.ts +53 -7
  103. package/server/data-dir.ts +1 -1
  104. package/server/events.ts +1 -1
  105. package/server/functions-worker.ts +15 -1
  106. package/server/functions.ts +51 -6
  107. package/server/harness/claude-code/index.ts +2 -1
  108. package/server/harness/codex/adapter.ts +100 -9
  109. package/server/harness/codex/client.ts +34 -1
  110. package/server/harness/codex/index.ts +2 -1
  111. package/server/harness/codex/session.ts +32 -8
  112. package/server/layout.ts +9 -14
  113. package/server/moi-scaffold.ts +37 -3
  114. package/server/registry.ts +1 -1
  115. package/server/skill-update.ts +47 -0
  116. package/server/skill-version.ts +2 -11
  117. package/server/tabs.ts +59 -0
  118. package/server/theme.ts +8 -14
  119. package/server/view-builders.ts +6 -2
  120. package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
  121. package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
  122. package/client/features/workspace/useWorkspaceTheme.ts +0 -82
  123. package/dist/chunk-339jds4x.js +0 -15
  124. package/dist/chunk-3xsvsnhr.css +0 -1
  125. package/dist/chunk-6c8cwpzc.js +0 -1
  126. package/dist/chunk-anqmsbjt.js +0 -2
  127. package/dist/chunk-hbvfb6sk.js +0 -63
  128. package/dist/chunk-qwm5f6qk.js +0 -48
  129. package/dist/chunk-yp4srgqt.js +0 -10
  130. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
@@ -10,6 +10,7 @@ import {
10
10
  workspaceTypeLabel
11
11
  } from '@/client/features/home/workspace-presentation'
12
12
  import { cn } from '@/client/lib/cn'
13
+ import { useUiStore } from '@/client/store/ui'
13
14
  import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
14
15
  import type { HarnessAvailability, WorkspaceType } from '@/lib/types'
15
16
 
@@ -18,8 +19,8 @@ const OPENCLAW_LOCKED_DESCRIPTION =
18
19
  'Initialize OpenClaw in the folder\nmanually, then import it to moi'
19
20
 
20
21
  const workspaceAgentDescription: Record<WorkspaceType, string> = {
21
- 'claude-code': 'By Anthropic',
22
- codex: 'By OpenAI',
22
+ 'claude-code': 'Anthropic',
23
+ codex: 'OpenAI',
23
24
  openclaw: 'Open-source'
24
25
  }
25
26
 
@@ -91,9 +92,16 @@ export function WorkspaceAgentStep({
91
92
  onTypeChange,
92
93
  onSubmit
93
94
  }: WorkspaceAgentStepProps) {
95
+ const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
94
96
  const options = getWorkspaceAgentOptions({ availability, detectedTypes })
95
97
  const selectableType = resolveWorkspaceAgentSelection(options, selectedType)
96
98
  const selectedUnavailable = selectableType !== selectedType
99
+ const subscriptionTip =
100
+ selectableType === 'claude-code'
101
+ ? 'Tip: you can use your existing Claude subscription in moi'
102
+ : selectableType === 'codex'
103
+ ? 'Tip: you can use your existing ChatGPT subscription in moi'
104
+ : undefined
97
105
 
98
106
  useEffect(() => {
99
107
  if (selectableType && selectedUnavailable) onTypeChange(selectableType)
@@ -106,11 +114,16 @@ export function WorkspaceAgentStep({
106
114
  <DialogDescription>{WORKSPACE_AGENT_DESCRIPTION}</DialogDescription>
107
115
  </div>
108
116
 
109
- <WorkspaceAgentSelector
110
- options={options}
111
- selectedType={selectedUnavailable ? undefined : selectedType}
112
- onTypeChange={onTypeChange}
113
- />
117
+ <div className="flex flex-col gap-4">
118
+ <WorkspaceAgentSelector
119
+ options={options}
120
+ selectedType={selectedUnavailable ? undefined : selectedType}
121
+ onTypeChange={onTypeChange}
122
+ />
123
+ {!hasSentMessageFromMoi && subscriptionTip && (
124
+ <p className="text-sm text-muted-foreground">{subscriptionTip}</p>
125
+ )}
126
+ </div>
114
127
 
115
128
  {errorMessage && (
116
129
  <p role="alert" className="text-xs text-destructive">
@@ -183,7 +196,7 @@ function WorkspaceAgentOptionButton({
183
196
  onSelect(option.type)
184
197
  }}
185
198
  className={cn(
186
- 'relative flex w-full flex-col items-start justify-between gap-6 rounded-lg bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
199
+ 'relative flex w-full flex-col items-start justify-between gap-6 rounded-xl bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
187
200
  !selected && 'opacity-70',
188
201
  !selected && !option.disabled && 'cursor-pointer hover:opacity-100',
189
202
  option.disabled && 'cursor-not-allowed'
@@ -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
- <button
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 size={20} stroke={1.5} />
84
- </button>
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-3 z-10 -translate-y-1/2">
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.4, duration: 0.55 }}
156
- className="flex flex-col gap-1 rounded-xl bg-background/95 p-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"
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-sm', f.preview)} />
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-15 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">
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-md bg-background p-6 shadow-xs duration-200 fade-in-0 zoom-in-95">
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-sm px-1.5 py-0.5 text-[11px] font-medium',
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-lg text-[22px] transition-colors duration-75 data-[active]:bg-muted',
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-[24px] shadow-sm ring-1 ring-border',
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-lg bg-muted p-0.5">
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-md px-3.5 py-1 text-xs font-medium capitalize transition-colors',
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-lg border border-border bg-background"
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-md bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"
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-md text-lg hover:bg-accent" />
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-lg text-[22px] transition-colors duration-75',
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-lg border border-border bg-background p-1.5">
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-lg text-muted-foreground transition-colors [&_svg]:size-5',
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-lg border border-dashed transition-colors',
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-lg border border-border bg-card text-card-foreground">
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="Space settings"
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>Space settings</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 type { WorkspaceEntry, WorkspaceEnvView } from '@/lib/types'
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 [grid-auto-rows:160px] grid-cols-4 gap-2">
57
+ <div className="grid auto-rows-[160px] grid-cols-4 gap-2">
57
58
  <AnimatePresence>
58
59
  {layout.map(item => (
59
60
  <motion.div
@@ -264,6 +264,7 @@ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: W
264
264
  ref={panelRef}
265
265
  items={hiddenItems}
266
266
  renderItem={renderItem}
267
+ onClose={() => onEditingChange(false)}
267
268
  onRestore={restore}
268
269
  />
269
270
  )}
@@ -1,115 +1,129 @@
1
- import { type Ref, useEffect } from 'react'
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 ALL_FONT_PREVIEW_ID = 'mei-font-previews'
10
- const ALL_FONTS_QUERY = Object.values(FONT_THEMES)
11
- .map(f => f.googleFontsQuery)
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 usePreloadAllFonts() {
16
- useEffect(() => {
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
- const FONT_OPTIONS = Object.entries(FONT_THEMES) as [FontTheme, (typeof FONT_THEMES)[FontTheme]][]
20
+ type CustomizeOptionGroupProps = {
21
+ children: ReactNode
22
+ label: string
23
+ }
27
24
 
28
- const COLOR_OPTIONS = Object.entries(COLOR_THEMES) as [ColorTheme, ColorThemeConfig][]
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
- function presetMatches(preset: ColorThemeConfig, bg?: string, fg?: string): boolean {
31
- return (preset.background ?? undefined) === bg && (preset.foreground ?? undefined) === fg
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
- usePreloadAllFonts()
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 currentBg = layout.theme?.background
43
- const currentFg = layout.theme?.foreground
73
+ const currentPrimary = layout.theme?.primary
44
74
 
45
- function setTheme(update: Partial<NonNullable<typeof layout.theme>>) {
46
- setLayout({ theme: { ...layout.theme, font: currentFont, ...update } })
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-6">
52
- {/* Font picker */}
53
- <div className="flex flex-col gap-2">
54
- <p className="text-xs font-medium text-muted-foreground">Font</p>
55
- <div className="grid grid-cols-3 gap-2">
56
- {FONT_OPTIONS.map(([key, config]) => (
57
- <button
58
- key={key}
59
- type="button"
60
- onClick={() => setTheme({ font: key })}
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
- </button>
72
- ))}
73
- </div>
74
- </div>
93
+ </div>
94
+ </CustomizeOption>
95
+ ))}
96
+ </CustomizeOptionGroup>
75
97
 
76
- {/* Color palette */}
77
- <div className="flex flex-col gap-2">
78
- <p className="text-xs font-medium text-muted-foreground">Colors</p>
79
- <div className="grid grid-cols-3 gap-2">
80
- {COLOR_OPTIONS.map(([key, preset]) => {
81
- const active = presetMatches(preset, currentBg, currentFg)
82
- return (
83
- <button
84
- key={key}
85
- type="button"
86
- onClick={() =>
87
- setTheme({ background: preset.background, foreground: preset.foreground })
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 gap-2 rounded-md border px-3 py-2 transition-colors',
91
- active
92
- ? 'bg-primary/5 ring-2 ring-primary'
93
- : 'border-transparent hover:bg-accent'
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
- <span
97
- className="size-5 shrink-0 rounded-full border border-border"
98
- style={{ backgroundColor: preset.background ?? 'oklch(1 0 0)' }}
99
- >
100
- <span
101
- className="flex size-full items-center justify-center text-[9px] leading-none font-bold"
102
- style={{ color: preset.foreground ?? 'oklch(0.145 0 0)' }}
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
  )