moi-computer 0.11.1-next.2 → 0.11.1-next.4

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 (222) hide show
  1. package/README.md +2 -2
  2. package/client/app/AppRouter.tsx +2 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +7 -9
  4. package/client/app/shell/SidebarLayout.tsx +18 -15
  5. package/client/components/shared/BottomPanel.tsx +26 -14
  6. package/client/components/shared/PanelHeader.tsx +1 -1
  7. package/client/components/shared/ReorderableList.tsx +7 -2
  8. package/client/components/shared/WorkspaceIcon.tsx +92 -0
  9. package/client/components/ui/alert-dialog.tsx +1 -0
  10. package/client/components/ui/checkbox.tsx +1 -0
  11. package/client/components/ui/inline-input.tsx +84 -0
  12. package/client/components/ui/toast.tsx +2 -2
  13. package/client/features/applets/AppletMount.tsx +1 -1
  14. package/client/features/applets/applet-cache.ts +3 -3
  15. package/client/features/applets/applet-runtime.ts +147 -108
  16. package/client/features/applets/applet-styles.ts +2 -2
  17. package/client/features/applets/applet-thumbnail.ts +6 -8
  18. package/client/features/applets/useApplet.ts +10 -9
  19. package/client/features/chat/ChatPanel.tsx +19 -10
  20. package/client/features/chat/ChatPopup.tsx +7 -2
  21. package/client/features/chat/applet-chat-intents.ts +170 -0
  22. package/client/features/chat/chat-send.ts +103 -62
  23. package/client/features/chat/chat-store.ts +50 -59
  24. package/client/features/chat/composer/ChatComposer.tsx +43 -132
  25. package/client/features/chat/composer/ModelPicker.tsx +3 -16
  26. package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
  27. package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
  28. package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
  29. package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
  30. package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
  31. package/client/features/chat/composer/attachments/types.ts +25 -0
  32. package/client/features/chat/composer/attachments/uploads.ts +26 -0
  33. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  34. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +2 -2
  35. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  36. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  37. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
  38. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  39. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  40. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +1 -1
  41. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  42. package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
  43. package/client/features/chat/useChat.ts +32 -15
  44. package/client/features/dev/ChatStatesPage.tsx +5 -6
  45. package/client/features/dev/HarnessDebugPage.tsx +10 -7
  46. package/client/features/dev/ToolCallsPage.tsx +1 -1
  47. package/client/features/dev/UiComponentPreviews.tsx +21 -0
  48. package/client/features/dev/chat-states-fixtures.ts +13 -2
  49. package/client/features/drawings/useChatAnnotation.ts +17 -17
  50. package/client/features/drawings/useDrawingLayer.ts +7 -9
  51. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  52. package/client/features/home/HomePage.tsx +8 -7
  53. package/client/features/home/WorkspacePreview.tsx +1 -1
  54. package/client/features/home/workspace-presentation.tsx +1 -11
  55. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  56. package/client/features/overview/HiddenPanel.tsx +109 -0
  57. package/client/features/overview/Overview.tsx +302 -0
  58. package/client/features/overview/WidgetCanvas.tsx +164 -0
  59. package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
  60. package/client/features/overview/WorkspaceName.tsx +60 -0
  61. package/client/features/overview/api.ts +30 -0
  62. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  63. package/client/features/overview/default/registry.tsx +36 -0
  64. package/client/features/{widgets → overview}/grid.ts +36 -0
  65. package/client/features/overview/useGridReconcile.ts +94 -0
  66. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  67. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  68. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  69. package/client/features/settings/GeneralSettings.tsx +55 -58
  70. package/client/features/settings/SettingsLayout.tsx +2 -2
  71. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  72. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  73. package/client/features/settings/api.ts +48 -24
  74. package/client/features/views/ViewBuilder.tsx +5 -4
  75. package/client/features/views/ViewManager.tsx +11 -13
  76. package/client/features/views/api.ts +36 -2
  77. package/client/features/views/useViewBuilderActions.ts +8 -5
  78. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  79. package/client/features/views/view-presentation.ts +13 -0
  80. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  81. package/client/features/workspace/UnavailablePage.tsx +21 -0
  82. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  83. package/client/features/workspace/WorkspaceScreen.tsx +205 -161
  84. package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
  85. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  86. package/client/features/workspace/api.ts +0 -26
  87. package/client/features/workspace/moi-context.ts +8 -9
  88. package/client/features/workspace/tab-resolution.ts +10 -33
  89. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  90. package/client/index.css +1 -1
  91. package/client/lib/app-icon-registry.ts +2 -0
  92. package/client/lib/use-latest-ref.ts +11 -0
  93. package/client/main.tsx +1 -1
  94. package/client/runtime/useWorkspaceEvents.ts +59 -14
  95. package/client/theme.css +5 -5
  96. package/dist/chunk-2gs8jjx4.css +1 -0
  97. package/dist/chunk-7vvg5fyz.js +68 -0
  98. package/dist/chunk-94m3q9ce.js +1 -0
  99. package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
  100. package/dist/chunk-by2wqgak.js +1 -0
  101. package/dist/chunk-m1fvqssh.js +2 -0
  102. package/dist/chunk-p34hvqt3.js +1 -0
  103. package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
  104. package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
  105. package/dist/chunk-xg01f6pn.js +10 -0
  106. package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
  107. package/dist/index.html +1 -1
  108. package/lib/app-icons.ts +1 -0
  109. package/lib/applet-selector.ts +24 -0
  110. package/lib/chat-title.ts +6 -1
  111. package/lib/default-widgets.ts +32 -0
  112. package/lib/format.ts +12 -1
  113. package/lib/message-attachments.ts +40 -0
  114. package/lib/moi-attachments.ts +204 -0
  115. package/lib/moi-context.ts +20 -35
  116. package/lib/navigation.ts +84 -0
  117. package/lib/types.ts +81 -25
  118. package/lib/workspace-icon.ts +20 -0
  119. package/lib/workspace-layout.ts +22 -2
  120. package/lib/workspace-tabs.ts +9 -33
  121. package/package.json +27 -27
  122. package/registry.json +13 -0
  123. package/server/AGENTS.md +1 -0
  124. package/server/api.ts +114 -37
  125. package/server/applet-typecheck.ts +95 -0
  126. package/server/{bundler → applets}/build-applet.ts +13 -246
  127. package/server/applets/config.ts +226 -0
  128. package/server/applets/dependencies.ts +206 -0
  129. package/server/{applets.ts → applets/index.ts} +15 -161
  130. package/server/applets/runtime/base.ts +4 -0
  131. package/server/applets/runtime/moi.ts +42 -0
  132. package/server/applets/runtime/rpc.ts +17 -0
  133. package/server/applets/view-source.ts +67 -0
  134. package/server/attachment-message.ts +95 -0
  135. package/server/cli.ts +163 -97
  136. package/server/control.ts +63 -42
  137. package/server/harness/README.md +4 -2
  138. package/server/harness/acp/adapter.ts +7 -21
  139. package/server/harness/acp/session.ts +31 -50
  140. package/server/harness/claude-code/NOTES.md +8 -2
  141. package/server/harness/claude-code/adapter.ts +8 -25
  142. package/server/harness/claude-code/index.ts +2 -0
  143. package/server/harness/claude-code/session.ts +42 -47
  144. package/server/harness/claude-code/sessions.ts +9 -4
  145. package/server/harness/codex/adapter.ts +8 -7
  146. package/server/harness/codex/index.ts +1 -0
  147. package/server/harness/codex/permissions.ts +1 -1
  148. package/server/harness/codex/session.ts +20 -47
  149. package/server/harness/hermes/NOTES.md +1 -1
  150. package/server/harness/hermes/index.ts +4 -0
  151. package/server/harness/openclaw/NOTES.md +1 -1
  152. package/server/harness/openclaw/adapter.ts +22 -4
  153. package/server/harness/openclaw/gateway.ts +5 -3
  154. package/server/harness/openclaw/session.ts +27 -27
  155. package/server/harness/types.ts +5 -3
  156. package/server/layout.ts +9 -14
  157. package/server/moi-scaffold.ts +21 -13
  158. package/server/navigation-relay.ts +110 -0
  159. package/server/registry.ts +8 -0
  160. package/server/selected-session.ts +24 -4
  161. package/server/skill-update.ts +5 -3
  162. package/server/skill-version.ts +4 -7
  163. package/server/skills-template.ts +48 -9
  164. package/server/tabs.ts +19 -33
  165. package/server/uploads.ts +0 -0
  166. package/server/view-builders.ts +18 -1
  167. package/server/views.ts +126 -6
  168. package/server/web.ts +35 -9
  169. package/server/widgets.ts +12 -5
  170. package/server/workspace-config.ts +13 -9
  171. package/ui-components/button.tsx +2 -2
  172. package/ui-components/docs/kbd.md +191 -0
  173. package/ui-components/dropdown-menu.tsx +1 -1
  174. package/ui-components/kbd.tsx +32 -0
  175. package/ui-components/slider.tsx +1 -1
  176. package/ui-components/switch.tsx +1 -1
  177. package/ui-components/tabs.tsx +1 -1
  178. package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
  179. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
  180. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  181. package/client/features/chat/attachment-staging.ts +0 -153
  182. package/client/features/chat/uploads.ts +0 -18
  183. package/client/features/chat/useAppletChatMessage.ts +0 -68
  184. package/client/features/settings/IconPicker.tsx +0 -442
  185. package/client/features/settings/WorkspaceSettings.tsx +0 -95
  186. package/client/features/settings/render-icon.ts +0 -173
  187. package/client/features/widgets/HiddenPanel.tsx +0 -80
  188. package/client/features/widgets/WidgetGrid.tsx +0 -123
  189. package/client/features/widgets/Widgets.tsx +0 -262
  190. package/client/features/widgets/useGridReconcile.ts +0 -73
  191. package/dist/chunk-245wt82v.css +0 -1
  192. package/dist/chunk-87thzbtw.js +0 -2
  193. package/dist/chunk-a6jad1a6.js +0 -1
  194. package/dist/chunk-dghwstd2.js +0 -9
  195. package/dist/chunk-eg120aca.js +0 -1
  196. package/dist/chunk-j7hh2ab4.js +0 -70
  197. package/dist/chunk-y8eyahwx.js +0 -1
  198. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  199. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  200. /package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +0 -0
  201. /package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +0 -0
  202. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  203. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  204. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  205. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  206. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  207. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  208. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  209. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  210. /package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +0 -0
  211. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  212. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  213. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  214. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  215. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  216. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  217. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  218. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  219. /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
  220. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
  221. /package/server/{bundler → applets}/applet-css.ts +0 -0
  222. /package/server/{bundler → applets}/build-worker.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { lazy, Suspense, useEffect, useRef, useState } from 'react'
1
+ import { lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react'
2
2
 
3
3
  import { AnimatePresence } from 'motion/react'
4
4
 
@@ -9,6 +9,7 @@ import {
9
9
  IconLayoutSidebarRight,
10
10
  IconLetterCase,
11
11
  IconMessages,
12
+ IconSettings,
12
13
  IconSketching
13
14
  } from '@tabler/icons-react'
14
15
 
@@ -16,20 +17,33 @@ import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
16
17
  import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
17
18
  import { useChatAnnotation } from '@/client/features/drawings/useChatAnnotation'
18
19
  import { ChatPanel } from '@/client/features/chat/ChatPanel'
19
- import type { WelcomeDestination } from '@/client/features/chat/ChatEmptyState'
20
+ import type { WelcomeDestination } from '@/client/features/chat/messages/ChatEmptyState'
20
21
  import { ChatPopup } from '@/client/features/chat/ChatPopup'
21
- import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
22
- import { useAppletEvent } from '@/client/features/applets/applet-runtime'
23
- import { Widgets } from '@/client/features/widgets/Widgets'
22
+ import { ThemePanel } from '@/client/features/workspace/ThemePanel'
23
+ import { Overview } from '@/client/features/overview/Overview'
24
24
  import { PanelHeader } from '@/client/components/shared/PanelHeader'
25
- import { workspaceProviderIcon } from '@/client/features/home/workspace-presentation'
25
+ import { WorkspaceIcon } from '@/client/components/shared/WorkspaceIcon'
26
26
  import { Button } from '@/client/components/ui/button'
27
+ import {
28
+ DropdownMenu,
29
+ DropdownMenuContent,
30
+ DropdownMenuGroup,
31
+ DropdownMenuItem,
32
+ DropdownMenuTrigger
33
+ } from '@/client/components/ui/dropdown-menu'
27
34
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
28
- import { WorkspaceSettings } from '@/client/features/settings/WorkspaceSettings'
29
- import { useAppletChatMessage } from '@/client/features/chat/useAppletChatMessage'
35
+ import {
36
+ useAppletChatMessage,
37
+ useAppletChatAttachment
38
+ } from '@/client/features/chat/applet-chat-intents'
30
39
  import { useChat } from '@/client/features/chat/useChat'
40
+ import {
41
+ WorkspaceSettingsDialog,
42
+ WorkspaceSettingsDialogTrigger
43
+ } from '@/client/features/settings/WorkspaceSettingsDialog'
31
44
  import { ViewBuilder, type ViewBuilderHandle } from '@/client/features/views/ViewBuilder'
32
45
  import { ViewManager } from '@/client/features/views/ViewManager'
46
+ import { getViewIcon, getViewLabel } from '@/client/features/views/view-presentation'
33
47
  import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
34
48
  import { useViewBuilderDrafts } from '@/client/features/views/useViewBuilderDrafts'
35
49
  import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
@@ -57,6 +71,7 @@ import {
57
71
  type WorkspaceTabItem,
58
72
  WorkspaceTabs
59
73
  } from '@/client/features/workspace/WorkspaceTabs'
74
+ import { isDefaultWidget } from '@/lib/default-widgets'
60
75
  import type {
61
76
  LayoutMode,
62
77
  ViewBuilder as ViewBuilderData,
@@ -72,6 +87,7 @@ import {
72
87
  } from '@/lib/workspace-tabs'
73
88
 
74
89
  import { WorkspaceSplitLayout } from './WorkspaceSplitLayout'
90
+ import { UnavailablePage } from './UnavailablePage'
75
91
 
76
92
  const Scratchpad = lazy(() =>
77
93
  import('@/client/features/scratchpad/Scratchpad').then(module => ({
@@ -79,70 +95,15 @@ const Scratchpad = lazy(() =>
79
95
  }))
80
96
  )
81
97
 
82
- // Tab label for a view: its configured title, or the file-name id as fallback.
83
- const viewLabel = (v: ViewInfo) => v.config.title || v.id
84
-
85
98
  const viewBuilderIcon = (builder: ViewBuilderData) => resolveAppIcon(builder.icon) ?? IconArticle
86
99
 
87
- function viewIcon(view: ViewInfo, builders: ViewBuilderData[]) {
88
- const builder = builders.find(candidate => candidate.viewId === view.id)
89
- return resolveAppIcon(view.config.icon) ?? resolveAppIcon(builder?.icon) ?? IconArticle
90
- }
91
-
92
- type SectionControlsProps = {
93
- onToggleMode: () => void
94
- }
95
-
96
- // Full-screen workspace action: open the chat as a docked split column.
97
- function SectionControls({ onToggleMode }: SectionControlsProps) {
98
- return (
99
- <Tooltip>
100
- <TooltipTrigger
101
- render={
102
- <Button variant="ghost" size="icon-sm" onClick={onToggleMode} aria-label="Dock agent">
103
- <IconLayoutSidebarRight stroke={1.75} />
104
- </Button>
105
- }
106
- />
107
- <TooltipContent>Dock agent</TooltipContent>
108
- </Tooltip>
109
- )
110
- }
111
-
112
- type WorkspaceCustomizeActionProps = {
113
- active: boolean
114
- onToggle: () => void
115
- }
116
-
117
- function WorkspaceCustomizeAction({ active, onToggle }: WorkspaceCustomizeActionProps) {
118
- return (
119
- <Tooltip>
120
- <TooltipTrigger
121
- render={
122
- <Button
123
- variant="ghost"
124
- size="icon-sm"
125
- aria-label="Customize"
126
- aria-pressed={active}
127
- onClick={onToggle}
128
- className={cn(active && 'bg-accent')}
129
- >
130
- <IconLetterCase stroke={1.75} />
131
- </Button>
132
- }
133
- />
134
- <TooltipContent>Customize</TooltipContent>
135
- </Tooltip>
136
- )
137
- }
138
-
139
100
  type WorkspaceScreenProps = {
140
101
  widgets: WidgetInfo[]
141
102
  views: ViewInfo[]
142
103
  builders: ViewBuilderData[]
143
104
  }
144
105
 
145
- type WidgetMode = 'idle' | 'editing' | 'customizing'
106
+ type WidgetMode = 'idle' | 'customizing' | 'theming'
146
107
 
147
108
  function tabItemFor(
148
109
  tab: WorkspaceTabId,
@@ -161,12 +122,13 @@ function tabItemFor(
161
122
  loading: agentRunning
162
123
  }
163
124
  }
164
- if (tab === 'widgets') {
125
+ if (tab === 'overview') {
165
126
  return {
166
127
  key: tab,
167
128
  Icon: IconLayout2,
168
- label: 'Widgets',
169
- closable
129
+ label: 'Overview',
130
+ closable: false,
131
+ reorderable: false
170
132
  }
171
133
  }
172
134
  if (tab === 'scratchpad') {
@@ -193,8 +155,8 @@ function tabItemFor(
193
155
  return view
194
156
  ? {
195
157
  key: tab,
196
- Icon: viewIcon(view, builders),
197
- label: viewLabel(view),
158
+ Icon: getViewIcon(view, builders),
159
+ label: getViewLabel(view),
198
160
  closable
199
161
  }
200
162
  : null
@@ -210,8 +172,54 @@ function applyVisibleTabOrder(
210
172
  return open.map(tab => (visibleSet.has(tab) ? orderedVisible[cursor++] : tab))
211
173
  }
212
174
 
175
+ type WorkspaceMenuProps = {
176
+ onOpenTheme: () => void
177
+ }
178
+
179
+ function WorkspaceMenu({ onOpenTheme }: WorkspaceMenuProps) {
180
+ const { layout, name, provider } = useWorkspaceLayoutCtx()
181
+ const [iconHovered, setIconHovered] = useState(false)
182
+
183
+ return (
184
+ <WorkspaceSettingsDialog>
185
+ <DropdownMenu>
186
+ <DropdownMenuTrigger
187
+ className="flex min-w-0 cursor-pointer items-center gap-2 rounded-sm outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
188
+ aria-label={`${name ?? 'Workspace'} menu`}
189
+ onPointerEnter={() => setIconHovered(true)}
190
+ onPointerLeave={() => setIconHovered(false)}
191
+ >
192
+ <WorkspaceIcon
193
+ icon={iconHovered ? { ...layout.icon, type: 'glyph', value: 'dots' } : layout.icon}
194
+ workspaceType={provider}
195
+ workspaceTheme={layout.theme}
196
+ className="size-5 rounded-sm"
197
+ />
198
+ {name && <span className="truncate text-sm font-medium text-foreground">{name}</span>}
199
+ </DropdownMenuTrigger>
200
+ <DropdownMenuContent align="start" sideOffset={6} className="w-36">
201
+ <DropdownMenuGroup>
202
+ <DropdownMenuItem onClick={onOpenTheme}>
203
+ <IconLetterCase stroke={1.75} />
204
+ Theme
205
+ </DropdownMenuItem>
206
+ <DropdownMenuItem
207
+ nativeButton
208
+ render={<WorkspaceSettingsDialogTrigger />}
209
+ className="w-full"
210
+ >
211
+ <IconSettings stroke={1.75} />
212
+ Settings
213
+ </DropdownMenuItem>
214
+ </DropdownMenuGroup>
215
+ </DropdownMenuContent>
216
+ </DropdownMenu>
217
+ </WorkspaceSettingsDialog>
218
+ )
219
+ }
220
+
213
221
  export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenProps) {
214
- const { layout, setLayout, name, icon, provider, workspaceId } = useWorkspaceLayoutCtx()
222
+ const { layout, setLayout, workspaceId } = useWorkspaceLayoutCtx()
215
223
  const theme = resolveWorkspaceTheme(layout.theme)
216
224
  const builderActions = useViewBuilderActions()
217
225
  const {
@@ -240,7 +248,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
240
248
  const openTabIds = effectiveOpenTabs(normalizeTabsState(layout.tabs), views, builders)
241
249
  const nonAgentOpenTabs = openTabIds.filter(tab => tab !== 'agent')
242
250
  const hasWorkspaceContent = nonAgentOpenTabs.length > 0
243
- const hasWorkspaceApplets = widgets.length > 0 || views.length > 0
251
+ const hasAppletWidgets = widgets.some(widget => !isDefaultWidget(widget.id))
252
+ const hasWorkspaceApplets = hasAppletWidgets || views.length > 0
244
253
 
245
254
  // Effective layout mode. Split is only visible with workspace content and
246
255
  // enough row width; the saved mode remains the user's intent.
@@ -250,7 +259,15 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
250
259
 
251
260
  // The tab address: URL in, active tab + applet params out, plus the persisted
252
261
  // tab state it keeps in sync. See useWorkspaceNavigation for the invariants.
253
- const { tabsState, activeTab, appletParams, navigateToTab, setTabs } = useWorkspaceNavigation({
262
+ const {
263
+ tabsState,
264
+ activeTab,
265
+ appletParams,
266
+ navigateToTab,
267
+ setTabs,
268
+ isUnavailable,
269
+ onNavigationClick
270
+ } = useWorkspaceNavigation({
254
271
  views,
255
272
  builders,
256
273
  split: dockedSplit
@@ -320,8 +337,14 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
320
337
  const activeDraftBuilderId = activeDraftBuilder?.id
321
338
  const canAnnotate =
322
339
  widgetMode === 'idle' &&
323
- ((activeTab === 'widgets' && widgets.length > 0) || activeView !== undefined)
324
- const annotation = useChatAnnotation({
340
+ ((activeTab === 'overview' && hasAppletWidgets) || activeView !== undefined)
341
+ const {
342
+ controls: annotationControls,
343
+ docked: dockedAnnotation,
344
+ layerProps: annotationLayerProps,
345
+ popup: popupAnnotation,
346
+ targetRef: annotationTargetRef
347
+ } = useChatAnnotation({
325
348
  workspaceId,
326
349
  sessionId,
327
350
  activeTab,
@@ -354,7 +377,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
354
377
 
355
378
  // The URL follows a replaced builder tab to the view that took its place.
356
379
  const urlReplacement = replacements.get(activeTab)
357
- if (urlReplacement) navigateToTab(urlReplacement)
380
+ if (urlReplacement) navigateToTab(urlReplacement, { replace: true })
358
381
 
359
382
  const replacementViews = new Set(replacements.values())
360
383
  const sourceForView = new Map(
@@ -375,7 +398,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
375
398
  }
376
399
  if (!changed) return
377
400
  const active = replacements.get(tabsState.active) ?? tabsState.active
378
- setLayout({ tabs: { open: open.length > 0 ? open : ['agent'], active } })
401
+ setLayout({ tabs: { open: open.length > 0 ? open : ['overview'], active } })
379
402
  }, [activeTab, builders, navigateToTab, setLayout, tabsState, views])
380
403
 
381
404
  useEffect(() => {
@@ -392,52 +415,55 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
392
415
 
393
416
  // Tab switching is navigation; the saved default and the open set follow via
394
417
  // the navigation hook. Only the chat side effects belong to the screen.
395
- const openTab = (tab: WorkspaceTabId, params?: Record<string, unknown>) => {
396
- navigateToTab(tab, params)
418
+ const openTab = (tab: WorkspaceTabId) => {
419
+ navigateToTab(tab)
397
420
  if (tab === 'agent') {
398
421
  setFloatingChatOpen(false)
399
422
  setChatFocusRequest(request => request + 1)
400
423
  }
401
424
  }
402
425
 
426
+ const createView = () => {
427
+ // Do NOT select the draft's pre-minted sessionId here: no session exists
428
+ // behind it until submit. Submit selects it once the chat actually starts.
429
+ void builderActions.create().then(builder => openTab(viewBuilderTabId(builder.id)))
430
+ }
431
+
403
432
  const navigateFromWelcome = (destination: WelcomeDestination) => {
404
433
  if (destination === 'views') {
405
434
  const firstView = views[0]
406
435
  if (firstView) openTab(viewTabId(firstView.id))
407
- else void builderActions.create().then(builder => openTab(viewBuilderTabId(builder.id)))
436
+ else createView()
408
437
  } else {
409
438
  openTab(destination)
410
439
  }
411
440
  setFloatingChatOpen(false)
412
441
  }
413
442
 
414
- // Focus requests from applet bridges arrive here already validated — the
415
- // applet runtime narrows the untrusted tab id and params shape at the trust
416
- // boundary (applet-runtime.ts). A well-formed id for a missing view just
417
- // resolves to the default like any dead URL.
418
- useAppletEvent(workspaceId, 'focusTab', openTab)
419
-
420
- // `moi tab focus` — a workspace event, not an applet call: the control
421
- // server validated the target and params before publishing.
422
443
  useWorkspaceEvent(event => {
423
- if (event.type === 'tab:focus' && event.workspaceId === workspaceId) {
424
- openTab(event.tab, event.params)
444
+ if (
445
+ event.type === 'view:deleted' &&
446
+ event.workspaceId === workspaceId &&
447
+ activeTab === viewTabId(event.name)
448
+ ) {
449
+ openTab('overview')
425
450
  }
426
451
  })
427
452
 
428
453
  const closeTab = (tab: WorkspaceTabId) => {
454
+ if (tab === 'overview') return
429
455
  const builderId = viewBuilderIdFromTab(tab)
430
456
  const builder = builderId ? builders.find(candidate => candidate.id === builderId) : undefined
431
457
  if ((!canCloseTabs && !builder) || !openSet.has(tab)) return
432
458
  let open = tabsState.open.filter(t => t !== tab)
433
- if (open.length === 0) open = ['agent']
459
+ if (open.length === 0) open = ['overview']
434
460
  // The neighbor that takes over when the tab on screen closes.
435
461
  const visibleIndex = visibleTabIds.indexOf(tab)
436
462
  const nextTab =
437
463
  visibleTabIds[visibleIndex + 1] ??
438
464
  visibleTabIds[visibleIndex - 1] ??
439
465
  open.find(t => tabAvailable(t, views, builders)) ??
440
- 'agent'
466
+ 'overview'
441
467
  const active =
442
468
  tabsState.active === tab || !open.includes(tabsState.active) ? nextTab : tabsState.active
443
469
  // Persist the open set BEFORE navigating so the sync effect (which reads
@@ -455,7 +481,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
455
481
  const tab = viewBuilderTabId(builder.id)
456
482
  if (openSet.has(tab)) {
457
483
  let open = tabsState.open.filter(item => item !== tab)
458
- if (open.length === 0) open = ['agent']
484
+ if (open.length === 0) open = ['overview']
459
485
  setTabs({ open, active: tabsState.active === tab ? open[0] : tabsState.active })
460
486
  if (activeTab === tab) navigateToTab(open[0])
461
487
  }
@@ -487,7 +513,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
487
513
  // Chat messages fired from applet UI. `openChat` is the reveal: on a view tab
488
514
  // in full-screen mode the chat is a closed popover, and a run the user can't
489
515
  // see is worse than a panel that opens itself.
490
- useAppletChatMessage({ send, revealChat: openChat, agentAvailability })
516
+ useAppletChatMessage({ sessionId, send, revealChat: openChat, agentAvailability })
517
+ useAppletChatAttachment(sessionId, openChat)
491
518
 
492
519
  const createItems: CreateWorkspaceTabItem[] = [
493
520
  ...(!dockedSplit && !openSet.has('agent')
@@ -500,16 +527,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
500
527
  }
501
528
  ] satisfies CreateWorkspaceTabItem[])
502
529
  : []),
503
- ...(!openSet.has('widgets')
504
- ? ([
505
- {
506
- key: 'widgets',
507
- Icon: IconLayout2,
508
- label: 'Widgets',
509
- onClick: () => openTab('widgets')
510
- }
511
- ] satisfies CreateWorkspaceTabItem[])
512
- : []),
513
530
  ...(!openSet.has('scratchpad')
514
531
  ? ([
515
532
  {
@@ -526,8 +543,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
526
543
  .map(
527
544
  ({ view, tab }): CreateWorkspaceTabItem => ({
528
545
  key: tab,
529
- Icon: viewIcon(view, builders),
530
- label: viewLabel(view),
546
+ Icon: getViewIcon(view, builders),
547
+ label: getViewLabel(view),
531
548
  onClick: () => openTab(tab)
532
549
  })
533
550
  ),
@@ -547,32 +564,41 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
547
564
  key: 'create-view',
548
565
  Icon: IconBrowserPlus,
549
566
  label: 'New view',
550
- onClick: () => {
551
- // Do NOT select the draft's pre-minted sessionId here: no session
552
- // exists behind it until submit, so making it the chat selection turns
553
- // the chat into a dead "New chat" whose sends try to resume a session
554
- // that isn't there. Submit selects it once the chat actually starts.
555
- void builderActions.create().then(builder => openTab(viewBuilderTabId(builder.id)))
556
- }
567
+ onClick: createView
557
568
  }
558
569
  ]
559
570
 
571
+ const changeBuilderDraft = useCallback(
572
+ (value: string) => {
573
+ if (activeDraftBuilder) builderDrafts.change(activeDraftBuilder.id, value)
574
+ },
575
+ [activeDraftBuilder, builderDrafts]
576
+ )
577
+ const removeBuilderDrawing = useCallback(() => {
578
+ if (activeDraftBuilder) {
579
+ void builderRefs.current.get(activeDraftBuilder.id)?.resetSketch()
580
+ }
581
+ }, [activeDraftBuilder])
582
+ const submitBuilderDraft = useCallback(
583
+ async (value: string) => {
584
+ if (!activeDraftBuilder) return
585
+ const builderView = builderRefs.current.get(activeDraftBuilder.id)
586
+ await builderView?.prepareSketchForSend()
587
+ await builderActions.submit(activeDraftBuilder, value)
588
+ // Submit clears the sent attachment. Keep the canvas until the built view replaces it.
589
+ builderDrafts.clear(activeDraftBuilder.id)
590
+ },
591
+ [activeDraftBuilder, builderActions, builderDrafts]
592
+ )
593
+
560
594
  const builderChatDraft = activeDraftBuilder
561
595
  ? {
562
596
  sessionId: activeDraftBuilder.sessionId,
563
597
  builderId: activeDraftBuilder.id,
564
598
  initialValue: activeDraftBuilder.input.requirements,
565
- onChange: (value: string) => builderDrafts.change(activeDraftBuilder.id, value),
566
- onRemoveDrawing: () => {
567
- void builderRefs.current.get(activeDraftBuilder.id)?.resetSketch()
568
- },
569
- onSubmit: async (value: string) => {
570
- const builderView = builderRefs.current.get(activeDraftBuilder.id)
571
- await builderView?.prepareSketchForSend()
572
- await builderActions.submit(activeDraftBuilder, value)
573
- // Submit clears the sent attachment. Keep the canvas until the built view replaces it.
574
- builderDrafts.clear(activeDraftBuilder.id)
575
- }
599
+ onChange: changeBuilderDraft,
600
+ onRemoveDrawing: removeBuilderDrawing,
601
+ onSubmit: submitBuilderDraft
576
602
  }
577
603
  : undefined
578
604
 
@@ -588,13 +614,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
588
614
  previewTurn={previewTurn}
589
615
  sessionId={sessionId}
590
616
  processing={processing}
591
- composerBanner={builderChatDraft ? builderComposerBanner : composerBanner}
617
+ composerBanner={activeDraftBuilder ? builderComposerBanner : composerBanner}
592
618
  agentAvailability={agentAvailability}
593
619
  send={send}
594
620
  stop={stop}
595
621
  onNavigateFromWelcome={navigateFromWelcome}
596
622
  onClose={() => setMode('fullscreen')}
597
- annotation={annotation.docked}
623
+ annotation={dockedAnnotation}
598
624
  builderDraft={builderChatDraft}
599
625
  docked
600
626
  />
@@ -627,18 +653,28 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
627
653
  >
628
654
  <div className="relative flex min-h-0 flex-1">
629
655
  <div
630
- ref={annotation.targetRef}
631
- inert={annotation.controls.active || undefined}
632
- aria-hidden={annotation.controls.active || undefined}
656
+ ref={annotationTargetRef}
657
+ inert={annotationControls.active || undefined}
658
+ aria-hidden={annotationControls.active || undefined}
633
659
  className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background transition-colors duration-100 ease-out motion-reduce:transition-none"
634
660
  >
635
- {activeTab === 'agent' ? (
661
+ {isUnavailable ? (
662
+ <UnavailablePage onOpenOverview={() => openTab('overview')} />
663
+ ) : activeTab === 'agent' ? (
636
664
  tabbedChat
637
- ) : activeTab === 'widgets' ? (
638
- <Widgets
639
- editing={widgetMode === 'editing'}
640
- onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
665
+ ) : activeTab === 'overview' ? (
666
+ <Overview
667
+ customizing={widgetMode === 'customizing'}
668
+ theming={widgetMode === 'theming'}
669
+ onThemingChange={theming => setWidgetMode(theming ? 'theming' : 'idle')}
670
+ onCustomizingChange={customizing =>
671
+ setWidgetMode(customizing ? 'customizing' : 'idle')
672
+ }
641
673
  widgets={widgets}
674
+ views={views}
675
+ builders={builders}
676
+ onOpenView={viewId => openTab(viewTabId(viewId))}
677
+ onCreateView={createView}
642
678
  onCreateWidget={() => {
643
679
  selectSession(null)
644
680
  openChat('Create widget')
@@ -659,7 +695,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
659
695
  if (handle) builderRefs.current.set(builder.id, handle)
660
696
  else builderRefs.current.delete(builder.id)
661
697
  }}
662
- active={activeBuilder?.id === builder.id}
698
+ active={!isUnavailable && activeBuilder?.id === builder.id}
663
699
  builder={builder}
664
700
  chatDocked={mode === 'split'}
665
701
  workspaceId={workspaceId}
@@ -679,33 +715,30 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
679
715
  mounted across tab switches (and collapses to nothing while
680
716
  another tab is on screen), which is what makes a switch back
681
717
  instant. */}
682
- <ViewManager views={views} activeViewId={activeView?.id ?? null} params={appletParams} />
718
+ <ViewManager
719
+ views={views}
720
+ activeViewId={isUnavailable ? null : (activeView?.id ?? null)}
721
+ params={appletParams}
722
+ />
683
723
  </div>
684
724
 
685
- <DrawingLayer {...annotation.layerProps}>
725
+ <DrawingLayer {...annotationLayerProps}>
686
726
  <DrawingToolbar
687
- controls={annotation.controls}
727
+ controls={annotationControls}
688
728
  title="Draw annotation"
689
- busy={annotation.controls.finishing}
690
- onComplete={() => void annotation.controls.finish()}
729
+ busy={annotationControls.finishing}
730
+ onComplete={() => void annotationControls.finish()}
691
731
  />
692
732
  </DrawingLayer>
693
733
  </div>
694
734
 
695
735
  <AnimatePresence>
696
- {widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
736
+ {widgetMode === 'theming' && <ThemePanel onClose={() => setWidgetMode('idle')} />}
697
737
  </AnimatePresence>
698
738
 
699
739
  <PanelHeader>
700
740
  <div className="flex min-w-0 flex-1 items-center gap-4">
701
- <div className="flex items-center gap-2">
702
- <img
703
- src={icon ?? workspaceProviderIcon[provider ?? 'claude-code']}
704
- alt=""
705
- className="size-5 shrink-0 rounded-xs"
706
- />
707
- {name && <span className="truncate text-sm font-medium text-foreground">{name}</span>}
708
- </div>
741
+ <WorkspaceMenu onOpenTheme={() => setWidgetMode('theming')} />
709
742
  <WorkspaceTabs
710
743
  tabs={tabItems}
711
744
  active={activeTab}
@@ -715,22 +748,33 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
715
748
  onReorder={reorderTabs}
716
749
  />
717
750
  </div>
718
- <div className="flex shrink-0 items-center gap-1">
719
- <WorkspaceCustomizeAction
720
- active={widgetMode === 'customizing'}
721
- onToggle={() => setWidgetMode(widgetMode === 'customizing' ? 'idle' : 'customizing')}
722
- />
723
- <WorkspaceSettings />
724
- {hasWorkspaceContent && canUseSplit && mode === 'fullscreen' && (
725
- <SectionControls onToggleMode={() => setMode('split')} />
726
- )}
727
- </div>
751
+ {hasWorkspaceContent && canUseSplit && mode === 'fullscreen' && (
752
+ <Tooltip>
753
+ <TooltipTrigger
754
+ render={
755
+ <Button
756
+ variant="ghost"
757
+ size="icon-sm"
758
+ onClick={() => setMode('split')}
759
+ aria-label="Dock agent"
760
+ className="text-muted-foreground"
761
+ >
762
+ <IconLayoutSidebarRight stroke={1.75} />
763
+ </Button>
764
+ }
765
+ />
766
+ <TooltipContent>Dock agent</TooltipContent>
767
+ </Tooltip>
768
+ )}
728
769
  </PanelHeader>
729
770
  </div>
730
771
  )
731
772
 
732
773
  return (
733
- <div className="relative flex h-full min-h-0 flex-col font-sans text-foreground">
774
+ <div
775
+ onClick={onNavigationClick}
776
+ className="relative flex h-full min-h-0 flex-col font-sans text-foreground"
777
+ >
734
778
  <div ref={rowRef} className="flex min-h-0 flex-1">
735
779
  {hasWorkspaceContent && canUseSplit && splitLayoutConstraints ? (
736
780
  <WorkspaceSplitLayout
@@ -770,13 +814,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
770
814
  previewTurn={previewTurn}
771
815
  sessionId={sessionId}
772
816
  processing={processing}
773
- composerBanner={builderChatDraft ? builderComposerBanner : composerBanner}
817
+ composerBanner={activeDraftBuilder ? builderComposerBanner : composerBanner}
774
818
  agentAvailability={agentAvailability}
775
819
  send={send}
776
820
  stop={stop}
777
821
  onNavigateFromWelcome={navigateFromWelcome}
778
822
  onClose={onClose}
779
- annotation={annotation.popup}
823
+ annotation={popupAnnotation}
780
824
  builderDraft={builderChatDraft}
781
825
  />
782
826
  )}
@@ -31,7 +31,7 @@ export function WorkspaceSplitLayout({
31
31
  const transitionFrameRef = useRef<number | null>(null)
32
32
  const [transitionsEnabled, setTransitionsEnabled] = useState(false)
33
33
  const openChatWidth = Math.min(Math.max(chatWidth, chatMinWidth), chatMaxWidth)
34
- const defaultChatSize = useRef(open ? openChatWidth : 0).current
34
+ const [defaultChatSize] = useState(() => (open ? openChatWidth : 0))
35
35
 
36
36
  useLayoutEffect(() => {
37
37
  const chatPanel = chatPanelRef.current
@@ -20,6 +20,7 @@ export type WorkspaceTabItem = {
20
20
  Icon: TabIcon
21
21
  label: string
22
22
  closable?: boolean
23
+ reorderable?: boolean
23
24
  loading?: boolean
24
25
  }
25
26
 
@@ -186,6 +187,7 @@ export function WorkspaceTabs({
186
187
  <ReorderableList
187
188
  items={tabs}
188
189
  getId={tab => tab.key}
190
+ isItemDragDisabled={tab => tab.reorderable === false}
189
191
  className="flex w-max items-center gap-1"
190
192
  onReorder={ordered => onReorder(ordered as WorkspaceTabId[])}
191
193
  renderPlaceholder={() => (