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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/bunfig.toml +5 -1
  2. package/client/AGENTS.md +15 -0
  3. package/client/accept-hmr-dependencies.ts +22 -0
  4. package/client/api/http.ts +31 -0
  5. package/client/api/query-options.ts +6 -0
  6. package/client/api/workspace-keys.ts +17 -0
  7. package/client/app/AppRouter.tsx +35 -0
  8. package/client/app/routes/HomeRoute.tsx +13 -0
  9. package/client/app/routes/WorkspaceRoute.tsx +89 -0
  10. package/client/app/shell/SidebarLayout.tsx +191 -0
  11. package/client/assets.d.ts +9 -0
  12. package/client/components/playground/PixelPainter.tsx +10 -21
  13. package/client/components/playground/PlaygroundPage.tsx +9 -11
  14. package/client/components/playground/ToolCallsPage.tsx +9 -11
  15. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +1 -1
  16. package/client/components/shared/PanelHeader.tsx +9 -0
  17. package/client/components/shared/ReorderableList.tsx +199 -0
  18. package/client/components/ui/button.tsx +10 -7
  19. package/client/components/ui/collapsible.tsx +15 -0
  20. package/client/components/ui/dialog.tsx +2 -2
  21. package/client/components/ui/dropdown-menu.tsx +5 -5
  22. package/client/components/ui/hover-card.tsx +1 -1
  23. package/client/components/ui/popover.tsx +1 -1
  24. package/client/components/ui/skeleton.tsx +13 -0
  25. package/client/components/ui/tooltip.tsx +1 -1
  26. package/client/externalize-react.ts +7 -1
  27. package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  28. package/client/{components → features/applets}/WidgetShell.tsx +1 -1
  29. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  30. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +29 -23
  31. package/client/features/chat/ChatPanel.tsx +188 -0
  32. package/client/{components → features/chat}/ChatPopup.tsx +23 -12
  33. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  34. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  35. package/client/{components → features/chat}/ThreadSelector.tsx +11 -9
  36. package/client/{components → features/chat}/TurnView.tsx +16 -9
  37. package/client/features/chat/api.ts +78 -0
  38. package/client/features/chat/chat-connection.ts +107 -0
  39. package/client/features/chat/chat-frames.ts +131 -0
  40. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  41. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  42. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  43. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  44. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +12 -4
  45. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  46. package/client/{hooks → features/chat}/useChat.ts +7 -11
  47. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  48. package/client/features/connectors/McpMenu.tsx +162 -0
  49. package/client/features/connectors/api.ts +28 -0
  50. package/client/features/home/CreateWorkspaceDialog.tsx +224 -0
  51. package/client/features/home/HomePage.tsx +220 -0
  52. package/client/{components → features/home}/WorkspacePreview.tsx +2 -2
  53. package/client/features/home/api.ts +148 -0
  54. package/client/features/home/workspace-presentation.tsx +44 -0
  55. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  56. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  57. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  58. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  59. package/client/features/settings/GeneralSettings.tsx +90 -0
  60. package/client/{components → features}/settings/IconPicker.tsx +73 -222
  61. package/client/features/settings/SettingsLayout.tsx +53 -0
  62. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  63. package/client/features/settings/api.ts +88 -0
  64. package/client/features/settings/icon-picker-options.ts +161 -0
  65. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  66. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  67. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  68. package/client/{components → features/widgets}/WidgetGrid.tsx +2 -9
  69. package/client/features/widgets/Widgets.tsx +215 -0
  70. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  71. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  72. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  73. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +15 -8
  74. package/client/features/workspace/WorkspaceScreen.tsx +536 -0
  75. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  76. package/client/features/workspace/api.ts +56 -0
  77. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  78. package/client/global.d.ts +5 -0
  79. package/client/index.css +6 -10
  80. package/client/index.html +1 -1
  81. package/client/index.tsx +14 -31
  82. package/client/lib/ws-url.ts +10 -0
  83. package/client/main.tsx +2 -2
  84. package/client/runtime/hmr-watchdog.ts +39 -0
  85. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +11 -7
  86. package/client/store/ui.ts +5 -1
  87. package/client/theme.css +0 -2
  88. package/dist/chunk-11cab5dq.css +1 -0
  89. package/dist/chunk-23cgr1tz.css +1 -0
  90. package/dist/chunk-3hy3qy6d.js +10 -0
  91. package/dist/chunk-c4j722at.js +546 -0
  92. package/dist/chunk-dyfaffyz.js +119 -0
  93. package/dist/chunk-kpe40hm8.js +1 -0
  94. package/dist/chunk-p68fnz3q.js +2 -0
  95. package/dist/chunk-pcnahct1.js +5 -0
  96. package/dist/chunk-tqd3pkg8.css +1 -0
  97. package/dist/chunk-ty6dvda0.js +1 -0
  98. package/dist/index.html +2 -2
  99. package/lib/types.ts +18 -7
  100. package/lib/workspace-name.ts +14 -0
  101. package/package.json +3 -2
  102. package/server/api.ts +127 -17
  103. package/server/applets.ts +84 -8
  104. package/server/cli.ts +11 -5
  105. package/server/layout.ts +38 -7
  106. package/server/mcp.ts +72 -15
  107. package/server/moi-scaffold.ts +55 -10
  108. package/server/registry.ts +16 -0
  109. package/server/views.ts +0 -0
  110. package/server/web.ts +1 -0
  111. package/server/widgets.ts +3 -2
  112. package/server/workspace-init.ts +5 -19
  113. package/tsconfig.json +1 -1
  114. package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -1
  115. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  116. package/client/api/workspaces.ts +0 -427
  117. package/client/components/App.tsx +0 -41
  118. package/client/components/ChatPanel.tsx +0 -275
  119. package/client/components/HomePage.tsx +0 -17
  120. package/client/components/McpMenu.tsx +0 -125
  121. package/client/components/Scratchpad.tsx +0 -935
  122. package/client/components/Widgets.tsx +0 -132
  123. package/client/components/WorkspacesPage.tsx +0 -245
  124. package/client/components/layout/SidebarLayout.tsx +0 -258
  125. package/client/components/routes/workspace/[id].tsx +0 -675
  126. package/client/components/routes/workspace/create.tsx +0 -155
  127. package/client/components/settings/SettingsPages.tsx +0 -255
  128. package/client/hooks/useFitsSidebar.ts +0 -34
  129. package/client/lib/connection.ts +0 -237
  130. package/dist/chunk-07qf2tv1.css +0 -1
  131. package/dist/chunk-c3zjp9ez.js +0 -672
  132. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  133. /package/client/{lib → features/applets}/applet-cache.ts +0 -0
  134. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  135. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  136. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  137. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  138. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  139. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  140. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  141. /package/client/{components → features/chat}/tool-group/format.ts +0 -0
  142. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  143. /package/client/{lib → features/chat}/uploads.ts +0 -0
  144. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  145. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  146. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  147. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  148. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  149. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  150. /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
@@ -0,0 +1,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, GeneralSettings } from './SettingsPages'
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="Workspace settings"
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>Workspace settings</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">Workspace settings</DialogTitle>
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
- <button
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={cn(
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
- </button>
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 size-7 text-muted-foreground"
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
+ }
@@ -0,0 +1,161 @@
1
+ import type { Icon } from '@tabler/icons-react'
2
+ import {
3
+ IconActivity,
4
+ IconApi,
5
+ IconAtom,
6
+ IconBell,
7
+ IconBolt,
8
+ IconBook,
9
+ IconBrain,
10
+ IconBriefcase,
11
+ IconBug,
12
+ IconBulb,
13
+ IconCalendar,
14
+ IconCamera,
15
+ IconChartBar,
16
+ IconChefHat,
17
+ IconCloud,
18
+ IconCode,
19
+ IconCompass,
20
+ IconCpu,
21
+ IconCube,
22
+ IconDatabase,
23
+ IconDeviceGamepad2,
24
+ IconDiamond,
25
+ IconFeather,
26
+ IconFile,
27
+ IconFlame,
28
+ IconFlask,
29
+ IconFolder,
30
+ IconGhost,
31
+ IconGift,
32
+ IconGlobe,
33
+ IconHeart,
34
+ IconHexagon,
35
+ IconHome,
36
+ IconKey,
37
+ IconLeaf,
38
+ IconMail,
39
+ IconMap,
40
+ IconMessage,
41
+ IconMoon,
42
+ IconMountain,
43
+ IconMusic,
44
+ IconPalette,
45
+ IconPaperclip,
46
+ IconPhoto,
47
+ IconPlanet,
48
+ IconPlug,
49
+ IconRobot,
50
+ IconRocket,
51
+ IconSettings,
52
+ IconShield,
53
+ IconShoppingCart,
54
+ IconSnowflake,
55
+ IconSparkles,
56
+ IconStar,
57
+ IconSun,
58
+ IconTarget,
59
+ IconTerminal2,
60
+ IconTool,
61
+ IconTrophy,
62
+ IconUser,
63
+ IconWand,
64
+ IconWorld
65
+ } from '@tabler/icons-react'
66
+
67
+ export const ICON_CHOICES: { id: string; Icon: Icon }[] = [
68
+ { id: 'rocket', Icon: IconRocket },
69
+ { id: 'sparkles', Icon: IconSparkles },
70
+ { id: 'bolt', Icon: IconBolt },
71
+ { id: 'flame', Icon: IconFlame },
72
+ { id: 'star', Icon: IconStar },
73
+ { id: 'heart', Icon: IconHeart },
74
+ { id: 'diamond', Icon: IconDiamond },
75
+ { id: 'trophy', Icon: IconTrophy },
76
+ { id: 'target', Icon: IconTarget },
77
+ { id: 'bulb', Icon: IconBulb },
78
+ { id: 'brain', Icon: IconBrain },
79
+ { id: 'robot', Icon: IconRobot },
80
+ { id: 'wand', Icon: IconWand },
81
+ { id: 'atom', Icon: IconAtom },
82
+ { id: 'flask', Icon: IconFlask },
83
+ { id: 'cpu', Icon: IconCpu },
84
+ { id: 'code', Icon: IconCode },
85
+ { id: 'terminal', Icon: IconTerminal2 },
86
+ { id: 'api', Icon: IconApi },
87
+ { id: 'database', Icon: IconDatabase },
88
+ { id: 'cube', Icon: IconCube },
89
+ { id: 'hexagon', Icon: IconHexagon },
90
+ { id: 'plug', Icon: IconPlug },
91
+ { id: 'tool', Icon: IconTool },
92
+ { id: 'settings', Icon: IconSettings },
93
+ { id: 'bug', Icon: IconBug },
94
+ { id: 'activity', Icon: IconActivity },
95
+ { id: 'chart', Icon: IconChartBar },
96
+ { id: 'briefcase', Icon: IconBriefcase },
97
+ { id: 'folder', Icon: IconFolder },
98
+ { id: 'file', Icon: IconFile },
99
+ { id: 'book', Icon: IconBook },
100
+ { id: 'message', Icon: IconMessage },
101
+ { id: 'mail', Icon: IconMail },
102
+ { id: 'bell', Icon: IconBell },
103
+ { id: 'paperclip', Icon: IconPaperclip },
104
+ { id: 'key', Icon: IconKey },
105
+ { id: 'shield', Icon: IconShield },
106
+ { id: 'user', Icon: IconUser },
107
+ { id: 'home', Icon: IconHome },
108
+ { id: 'globe', Icon: IconGlobe },
109
+ { id: 'world', Icon: IconWorld },
110
+ { id: 'planet', Icon: IconPlanet },
111
+ { id: 'compass', Icon: IconCompass },
112
+ { id: 'map', Icon: IconMap },
113
+ { id: 'calendar', Icon: IconCalendar },
114
+ { id: 'cloud', Icon: IconCloud },
115
+ { id: 'sun', Icon: IconSun },
116
+ { id: 'moon', Icon: IconMoon },
117
+ { id: 'snowflake', Icon: IconSnowflake },
118
+ { id: 'leaf', Icon: IconLeaf },
119
+ { id: 'mountain', Icon: IconMountain },
120
+ { id: 'feather', Icon: IconFeather },
121
+ { id: 'ghost', Icon: IconGhost },
122
+ { id: 'music', Icon: IconMusic },
123
+ { id: 'camera', Icon: IconCamera },
124
+ { id: 'photo', Icon: IconPhoto },
125
+ { id: 'palette', Icon: IconPalette },
126
+ { id: 'gamepad', Icon: IconDeviceGamepad2 },
127
+ { id: 'gift', Icon: IconGift },
128
+ { id: 'cart', Icon: IconShoppingCart },
129
+ { id: 'chef', Icon: IconChefHat }
130
+ ]
131
+
132
+ export const FAVORITE_EMOJI = [
133
+ '🚀',
134
+ '✨',
135
+ '🔥',
136
+ '⚡',
137
+ '💡',
138
+ '🧠',
139
+ '🤖',
140
+ '🪄',
141
+ '🧪',
142
+ '⚙️',
143
+ '🛠️',
144
+ '💻',
145
+ '📦',
146
+ '📊',
147
+ '📈',
148
+ '📝',
149
+ '📚',
150
+ '🎯',
151
+ '🏆',
152
+ '💎',
153
+ '🪐',
154
+ '🌍',
155
+ '🧭',
156
+ '🎨',
157
+ '🎮',
158
+ '☕'
159
+ ]
160
+
161
+ export const EMOJI_FONT = 'font-[Apple_Color_Emoji,Segoe_UI_Emoji,Noto_Color_Emoji,sans-serif]'
@@ -1,8 +1,8 @@
1
1
  import { useQueryClient } from '@tanstack/react-query'
2
2
 
3
- import { useUpdateEnv, useWorkspaceEnv, workspaceKeys } from '@/client/api/workspaces'
4
-
5
- import { useMeiEvent } from './useMeiEvents'
3
+ import { workspaceKeys } from '@/client/api/workspace-keys'
4
+ import { useUpdateEnv, useWorkspaceEnv } from '@/client/features/settings/api'
5
+ import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
6
6
 
7
7
  // Workspace env state in one hook: the masked env view (query), the patch
8
8
  // mutation, and live tracking — anything that changes the env outside this
@@ -11,7 +11,7 @@ import { useMeiEvent } from './useMeiEvents'
11
11
  // wiring the subscription themselves.
12
12
  export function useEnvVars(workspaceId: string) {
13
13
  const qc = useQueryClient()
14
- useMeiEvent(e => {
14
+ useWorkspaceEvent(e => {
15
15
  if (e.type === 'env:updated' && e.workspaceId === workspaceId) {
16
16
  qc.invalidateQueries({ queryKey: workspaceKeys.env(workspaceId) })
17
17
  }
@@ -4,11 +4,11 @@ import { useMemo } from 'react'
4
4
  import { AnimatePresence, motion } from 'motion/react'
5
5
 
6
6
  import { cn } from '@/client/lib/cn'
7
- import { packItems } from '@/client/lib/grid-pack'
7
+ import { packItems } from '@/client/features/widgets/grid'
8
+ import type { GridItem } from '@/client/features/widgets/grid'
9
+ import { BottomPanel } from '@/client/components/shared/BottomPanel'
8
10
 
9
- import { BottomPanel } from './BottomPanel'
10
11
  import { WidgetFrame } from './WidgetFrame'
11
- import type { GridItem } from './WidgetGrid'
12
12
 
13
13
  // Static maps so Tailwind includes these classes (dynamic strings get purged)
14
14
  const COL_START: Record<number, string> = {
@@ -6,7 +6,7 @@ import { IconMinus, IconPlus } from '@tabler/icons-react'
6
6
 
7
7
  import { cn } from '@/client/lib/cn'
8
8
 
9
- import { Button } from './ui/button'
9
+ import { Button } from '@/client/components/ui/button'
10
10
 
11
11
  type WidgetFrameProps = {
12
12
  editing?: boolean
@@ -51,13 +51,8 @@ export function WidgetFrame({ editing, hidden, onRemove, children }: WidgetFrame
51
51
 
52
52
  {editing && onRemove && (
53
53
  <div className="absolute -top-2 -right-2 opacity-0 transition-opacity group-hover/widget:opacity-100">
54
- <Button
55
- size="icon-sm"
56
- variant="outline"
57
- className="size-7 rounded-full"
58
- onClick={onRemove}
59
- >
60
- {hidden ? <IconPlus stroke={1.5} /> : <IconMinus stroke={1.5} />}
54
+ <Button size="icon-sm" variant="outline" className="rounded-full" onClick={onRemove}>
55
+ {hidden ? <IconPlus stroke={1.75} /> : <IconMinus stroke={1.75} />}
61
56
  </Button>
62
57
  </div>
63
58
  )}
@@ -7,18 +7,11 @@ import { GridLayout, type Layout, useContainerWidth, verticalCompactor } from 'r
7
7
  import 'react-grid-layout/css/styles.css'
8
8
  import 'react-resizable/css/styles.css'
9
9
 
10
- import { packItems } from '@/client/lib/grid-pack'
10
+ import { packItems } from '@/client/features/widgets/grid'
11
+ import type { GridItem } from '@/client/features/widgets/grid'
11
12
 
12
13
  import { WidgetFrame } from './WidgetFrame'
13
14
 
14
- export type GridItem = {
15
- id: string
16
- w: number
17
- h: number
18
- x?: number
19
- y?: number
20
- }
21
-
22
15
  export type WidgetGridProps = {
23
16
  cols?: number
24
17
  rowHeight?: number
@@ -0,0 +1,215 @@
1
+ import { useCallback, useState } from 'react'
2
+
3
+ import { AnimatePresence, LayoutGroup, motion } from 'motion/react'
4
+
5
+ import { IconPlus } from '@tabler/icons-react'
6
+
7
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
8
+ import { findFreePosition } from '@/client/features/widgets/grid'
9
+ import type { GridItem } from '@/client/features/widgets/grid'
10
+ import { WidgetShell } from '@/client/features/applets/WidgetShell'
11
+ import { Button } from '@/client/components/ui/button'
12
+ import type { WidgetInfo } from '@/lib/types'
13
+
14
+ import { HiddenPanel } from './HiddenPanel'
15
+ import { WidgetGrid } from './WidgetGrid'
16
+
17
+ function renderItem(id: string) {
18
+ return <WidgetShell name={id} />
19
+ }
20
+
21
+ type NoWidgetsCreatedProps = {
22
+ onCreateWidget: () => void
23
+ }
24
+
25
+ function NoWidgetsCreated({ onCreateWidget }: NoWidgetsCreatedProps) {
26
+ return (
27
+ <div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-3">
28
+ <p className="text-sm text-muted-foreground">No widgets created yet</p>
29
+ <Button type="button" variant="secondary" size="sm" onClick={onCreateWidget}>
30
+ <IconPlus data-icon="inline-start" stroke={1.75} />
31
+ Create widget
32
+ </Button>
33
+ </div>
34
+ )
35
+ }
36
+
37
+ function NoWidgetsAdded() {
38
+ return (
39
+ <div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-3">
40
+ <p className="text-sm text-muted-foreground">No widgets added yet</p>
41
+ </div>
42
+ )
43
+ }
44
+
45
+ // Tracks the rendered (border-box) height of whichever bottom panel is open, so
46
+ // the grid can reserve matching space below it and every card stays reachable.
47
+ function usePanelHeight() {
48
+ const [height, setHeight] = useState(0)
49
+ const ref = useCallback((node: HTMLDivElement | null) => {
50
+ if (!node) return
51
+ const ro = new ResizeObserver(([entry]) => {
52
+ const box = entry.borderBoxSize?.[0]
53
+ setHeight(box ? box.blockSize : entry.contentRect.height)
54
+ })
55
+ ro.observe(node)
56
+ return () => ro.disconnect()
57
+ }, [])
58
+ return [ref, height] as const
59
+ }
60
+
61
+ type WidgetsProps = {
62
+ onCreateWidget: () => void
63
+ editing: boolean
64
+ onEditingChange: (editing: boolean) => void
65
+ // Authoritative widget set from the widgets query; positions come from layout.
66
+ widgets: WidgetInfo[]
67
+ }
68
+
69
+ export function Widgets({ onCreateWidget, editing, onEditingChange, widgets }: WidgetsProps) {
70
+ const { layout, setLayout } = useWorkspaceLayoutCtx()
71
+
72
+ const gridIds = new Set(layout.widgetGrid.map(g => g.i))
73
+
74
+ const visibleItems: GridItem[] = layout.widgetGrid
75
+ .filter(g => widgets.some(w => w.id === g.i))
76
+ .map(g => {
77
+ const widget = widgets.find(w => w.id === g.i)!
78
+ return { id: g.i, w: widget.config.colSpan, h: widget.config.rowSpan, x: g.x, y: g.y }
79
+ })
80
+
81
+ const hiddenItems: GridItem[] = widgets
82
+ .filter(w => !gridIds.has(w.id))
83
+ .map(w => ({ id: w.id, w: w.config.colSpan, h: w.config.rowSpan }))
84
+
85
+ const [panelRef, panelHeight] = usePanelHeight()
86
+ const panelOpen = editing && hiddenItems.length > 0
87
+
88
+ function hide(id: string) {
89
+ setLayout({ widgetGrid: layout.widgetGrid.filter(g => g.i !== id) })
90
+ }
91
+
92
+ function restore(id: string) {
93
+ const widget = widgets.find(w => w.id === id)
94
+ if (!widget) return
95
+ const gridWithSizes = layout.widgetGrid.map(g => {
96
+ const w = widgets.find(w => w.id === g.i)
97
+ return { ...g, w: w?.config.colSpan ?? 1, h: w?.config.rowSpan ?? 1 }
98
+ })
99
+ const pos = findFreePosition(gridWithSizes, widget.config.colSpan, widget.config.rowSpan, 4)
100
+ setLayout({ widgetGrid: [...layout.widgetGrid, { i: id, x: pos.x, y: pos.y }] })
101
+ }
102
+
103
+ if (widgets.length === 0) {
104
+ return <NoWidgetsCreated onCreateWidget={onCreateWidget} />
105
+ }
106
+
107
+ return (
108
+ // Working area: everything below the header. It scrolls, and it's the
109
+ // positioning context for the bottom panel (which is anchored to this box,
110
+ // not to the grid). The grid lives in a centered max-w container and grows
111
+ // to its natural height.
112
+ <div className="group/widgets relative min-h-0 flex-1">
113
+ <LayoutGroup>
114
+ <div className="flex h-full flex-col overflow-y-auto p-4">
115
+ <div className="mx-auto mb-4 flex w-full max-w-[var(--column-w)] shrink-0 items-center justify-end gap-2">
116
+ {editing && (
117
+ <Button
118
+ type="button"
119
+ variant="ghost"
120
+ size="sm"
121
+ className="mr-auto"
122
+ onClick={onCreateWidget}
123
+ >
124
+ <IconPlus data-icon="inline-start" stroke={1.75} />
125
+ New widget
126
+ </Button>
127
+ )}
128
+ <AnimatePresence mode="popLayout" initial={false}>
129
+ {editing ? (
130
+ <motion.div
131
+ key="done"
132
+ variants={{
133
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
134
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
135
+ }}
136
+ initial="from"
137
+ animate="to"
138
+ exit="from"
139
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
140
+ >
141
+ <Button type="button" size="sm" onClick={() => onEditingChange(false)}>
142
+ Done
143
+ </Button>
144
+ </motion.div>
145
+ ) : (
146
+ <motion.div
147
+ key="actions"
148
+ className="flex items-center gap-1"
149
+ variants={{
150
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
151
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
152
+ }}
153
+ initial="from"
154
+ animate="to"
155
+ exit="from"
156
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
157
+ >
158
+ <Button
159
+ type="button"
160
+ variant="ghost"
161
+ size="sm"
162
+ className="text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0"
163
+ onClick={() => onEditingChange(true)}
164
+ >
165
+ Edit widgets
166
+ </Button>
167
+ </motion.div>
168
+ )}
169
+ </AnimatePresence>
170
+ </div>
171
+ {visibleItems.length === 0 ? (
172
+ <motion.div
173
+ className="mx-auto flex min-h-0 w-full max-w-[var(--column-w)] flex-1 flex-col"
174
+ animate={{ paddingBottom: panelOpen ? panelHeight : 0 }}
175
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
176
+ >
177
+ <NoWidgetsAdded />
178
+ </motion.div>
179
+ ) : (
180
+ // The open panel's height is reserved below the grid so every card
181
+ // can scroll clear of the panel.
182
+ <motion.div
183
+ className="mx-auto w-full max-w-[var(--column-w)]"
184
+ animate={{ marginBottom: panelOpen ? panelHeight : 0 }}
185
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
186
+ >
187
+ <WidgetGrid
188
+ items={visibleItems}
189
+ editing={editing}
190
+ renderItem={renderItem}
191
+ onRemove={hide}
192
+ onLayoutChange={items =>
193
+ setLayout({
194
+ widgetGrid: items.map(i => ({ i: i.id, x: i.x ?? 0, y: i.y ?? 0 }))
195
+ })
196
+ }
197
+ />
198
+ </motion.div>
199
+ )}
200
+ </div>
201
+
202
+ <AnimatePresence>
203
+ {editing && hiddenItems.length > 0 && (
204
+ <HiddenPanel
205
+ ref={panelRef}
206
+ items={hiddenItems}
207
+ renderItem={renderItem}
208
+ onRestore={restore}
209
+ />
210
+ )}
211
+ </AnimatePresence>
212
+ </LayoutGroup>
213
+ </div>
214
+ )
215
+ }
@@ -1,6 +1,12 @@
1
1
  import type { LayoutItem } from 'react-grid-layout'
2
2
 
3
- import type { GridItem } from '@/client/components/WidgetGrid'
3
+ export type GridItem = {
4
+ id: string
5
+ w: number
6
+ h: number
7
+ x?: number
8
+ y?: number
9
+ }
4
10
 
5
11
  export function findFreePosition(
6
12
  existing: LayoutItem[],