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
@@ -3,8 +3,8 @@ import type { QueryClient } from '@tanstack/react-query'
3
3
  import { workspaceKeys } from '@/client/api/workspace-keys'
4
4
  import { getScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
5
5
  import { liveStore } from '@/client/features/chat/chat-store'
6
- import { bufferSessionEvent } from '@/client/features/chat/session-view'
7
- import { renameSelectedSessionInCache } from '@/client/features/chat/useSelectedSession'
6
+ import { bufferSessionEvent } from '@/client/features/chat/sessions/session-view'
7
+ import { renameSelectedSessionInCache } from '@/client/features/chat/sessions/useSelectedSession'
8
8
  import { applyEvent } from '@/lib/format'
9
9
  import type {
10
10
  ClientMessage,
@@ -4,6 +4,7 @@ import {
4
4
  IconArticle,
5
5
  IconFileSearch,
6
6
  IconLayout2,
7
+ IconMessages,
7
8
  IconPiano,
8
9
  IconSketching,
9
10
  IconUmbrella2,
@@ -16,7 +17,7 @@ import {
16
17
  ChatPromptBubble,
17
18
  ChatPromptBubbles,
18
19
  type ChatPromptBubble as ChatPrompt
19
- } from '@/client/features/chat/ChatPromptBubbles'
20
+ } from '@/client/features/chat/messages/ChatPromptBubbles'
20
21
  import { cn } from '@/client/lib/cn'
21
22
  import type { AgentTheme } from '@/lib/types'
22
23
 
@@ -83,7 +84,7 @@ export const WORKSPACE_ANALYSIS_PROMPT = {
83
84
  } satisfies ChatPrompt
84
85
 
85
86
  export type ChatEmptyStateKind = 'view-builder' | 'welcome' | 'explore-workspace' | 'empty'
86
- export type WelcomeDestination = 'agent' | 'widgets' | 'views' | 'scratchpad'
87
+ export type WelcomeDestination = 'agent' | 'overview' | 'views' | 'scratchpad'
87
88
 
88
89
  type ResolveChatEmptyStateOptions = {
89
90
  isViewBuilderDraft: boolean
@@ -194,19 +195,23 @@ function WelcomeState({
194
195
  <div className="mt-2 flex flex-col gap-4">
195
196
  <div className="prose prose-sm min-w-0 wrap-anywhere prose-inherit">
196
197
  <p>
197
- moi is the visual workspace for you and your agent. It grows and adapts to the work
198
- you're doing.
198
+ moi is the personal workspace built for you by your agent. It grows and adapts to your
199
+ needs.
199
200
  </p>
200
201
  <p>
201
- Ask agent to build{' '}
202
- <WelcomeTerm Icon={IconLayout2} destination="widgets" onNavigate={onNavigate}>
203
- Widgets
202
+ Ask the{' '}
203
+ <WelcomeTerm Icon={IconMessages} destination="agent" onNavigate={onNavigate}>
204
+ Agent
204
205
  </WelcomeTerm>{' '}
205
- that surface information and quick actions, or entire{' '}
206
+ to build widgets on the{' '}
207
+ <WelcomeTerm Icon={IconLayout2} destination="overview" onNavigate={onNavigate}>
208
+ Overview
209
+ </WelcomeTerm>{' '}
210
+ page, or more complex tools as separate{' '}
206
211
  <WelcomeTerm Icon={IconArticle} destination="views" onNavigate={onNavigate}>
207
212
  Views
208
- </WelcomeTerm>{' '}
209
- for more complex tools. Use{' '}
213
+ </WelcomeTerm>
214
+ . Use{' '}
210
215
  <WelcomeTerm Icon={IconSketching} destination="scratchpad" onNavigate={onNavigate}>
211
216
  Scratchpad
212
217
  </WelcomeTerm>{' '}
@@ -269,7 +274,7 @@ function WelcomeTerm({ Icon, children, destination, onNavigate }: WelcomeTermPro
269
274
  type="button"
270
275
  data-welcome-destination={destination}
271
276
  onClick={() => onNavigate(destination)}
272
- className="-mx-0.5 inline-flex cursor-pointer items-center gap-0.5 rounded-xs px-0.5 align-bottom font-medium text-foreground hover:bg-accent focus-visible:bg-accent focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
277
+ className="inline-flex cursor-pointer items-center gap-0.5 align-bottom font-medium text-foreground"
273
278
  >
274
279
  <Icon size={16} stroke={1.75} aria-hidden />
275
280
  {children}
@@ -1,9 +1,12 @@
1
1
  import type { ComponentProps } from 'react'
2
+ import { useRouter } from 'wouter'
2
3
 
3
- import ReactMarkdown, { type ExtraProps } from 'react-markdown'
4
+ import ReactMarkdown, { defaultUrlTransform, type ExtraProps } from 'react-markdown'
4
5
  import rehypeHighlight from 'rehype-highlight'
5
6
  import remarkGfm from 'remark-gfm'
6
7
 
8
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
9
+ import { resolveWorkspaceHref } from '@/lib/navigation'
7
10
  import { cn } from '@/client/lib/cn'
8
11
 
9
12
  const remarkPlugins = [remarkGfm]
@@ -44,6 +47,8 @@ type PlainMarkdownTextProps = {
44
47
  }
45
48
 
46
49
  export function MarkdownContent({ size = 'sm', content }: MarkdownContentProps) {
50
+ const workspaceId = useWorkspaceId()
51
+ const { base } = useRouter()
47
52
  return (
48
53
  <div
49
54
  className={cn(
@@ -55,6 +60,16 @@ export function MarkdownContent({ size = 'sm', content }: MarkdownContentProps)
55
60
  remarkPlugins={remarkPlugins}
56
61
  rehypePlugins={rehypePlugins}
57
62
  components={components}
63
+ urlTransform={(url, key, node) => {
64
+ if (node.tagName === 'a' && key === 'href' && url.startsWith('moi:')) {
65
+ try {
66
+ return resolveWorkspaceHref(workspaceId, url, base)
67
+ } catch {
68
+ return ''
69
+ }
70
+ }
71
+ return defaultUrlTransform(url)
72
+ }}
58
73
  >
59
74
  {content}
60
75
  </ReactMarkdown>
@@ -1,3 +1,4 @@
1
+ import { TextAttachmentChip } from '../composer/attachments/TextAttachmentChip'
1
2
  import { memo } from 'react'
2
3
 
3
4
  import { IconChevronRight, IconFile } from '@tabler/icons-react'
@@ -9,9 +10,9 @@ import {
9
10
  CollapsibleContent,
10
11
  CollapsibleTrigger
11
12
  } from '@/client/components/ui/collapsible'
12
- import { MarkdownContent } from '@/client/features/chat/MarkdownContent'
13
- import { ToolCallGroup } from '@/client/features/chat/tool-group/ToolCallGroup'
14
- import { formatDuration } from '@/client/features/chat/tool-group/format'
13
+ import { MarkdownContent } from '@/client/features/chat/messages/MarkdownContent'
14
+ import { ToolCallGroup } from '@/client/features/chat/messages/tool-group/ToolCallGroup'
15
+ import { formatDuration } from '@/client/features/chat/messages/tool-group/format'
15
16
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
16
17
  import { cn } from '@/client/lib/cn'
17
18
 
@@ -165,17 +166,21 @@ export const TurnView = memo(function TurnView({ turn, processing = false }: Tur
165
166
  // Plain user input — right-aligned. Attachments (images/files) stack above
166
167
  // the text bubble.
167
168
  const fileParts = turn.parts.filter(
168
- (p): p is Extract<Part, { type: 'file' }> => p.type === 'file'
169
+ (p): p is Extract<Part, { type: 'file-attachment' }> => p.type === 'file-attachment'
169
170
  )
171
+ const textAttachmentParts = turn.parts.filter(p => p.type === 'text-attachment')
170
172
  const text = turn.parts
171
173
  .filter(p => p.type === 'text')
172
174
  .map(p => (p.type === 'text' ? p.text : ''))
173
175
  .join('\n')
174
- if (!text && fileParts.length === 0) return null
176
+ if (!text && fileParts.length === 0 && textAttachmentParts.length === 0) return null
175
177
  return (
176
178
  <div className="flex w-full min-w-0 flex-col items-end gap-1.5 pl-8">
179
+ {textAttachmentParts.map((p, i) => (
180
+ <TextAttachmentChip key={`text-attachment:${i}`} label={p.label} />
181
+ ))}
177
182
  {fileParts.map((p, i) => (
178
- <FilePart key={i} mediaType={p.mediaType} url={p.url} filename={p.filename} />
183
+ <FilePart key={i} mediaType={p.mediaType} previewUrl={p.previewUrl} label={p.label} />
179
184
  ))}
180
185
  {text && (
181
186
  <p
@@ -207,14 +212,16 @@ type PartRendererProps = { part: Part }
207
212
  // folded into a <ToolCallGroup> run by buildSegments.
208
213
  function PartRenderer({ part }: PartRendererProps) {
209
214
  switch (part.type) {
215
+ case 'text-attachment':
216
+ return <TextAttachmentChip label={part.label} />
210
217
  case 'text':
211
218
  return <MarkdownContent content={part.text} />
212
219
  case 'tool-call':
213
220
  // Tool calls normally fold into a run; this is a defensive fallback for a
214
221
  // lone tool-call segment, rendered as a one-row group.
215
222
  return <ToolCallGroup parts={[part]} cwd={null} />
216
- case 'file':
217
- return <FilePart mediaType={part.mediaType} url={part.url} filename={part.filename} />
223
+ case 'file-attachment':
224
+ return <FilePart mediaType={part.mediaType} previewUrl={part.previewUrl} label={part.label} />
218
225
  case 'source-url':
219
226
  return <SourceLink url={part.url} title={part.title} />
220
227
  case 'source-document':
@@ -226,16 +233,16 @@ function PartRenderer({ part }: PartRendererProps) {
226
233
  }
227
234
  }
228
235
 
229
- type FilePartProps = { mediaType: string; url: string; filename?: string }
230
- function FilePart({ mediaType, url, filename }: FilePartProps) {
236
+ type FilePartProps = { mediaType: string; previewUrl?: string; label?: string }
237
+ function FilePart({ mediaType, previewUrl, label }: FilePartProps) {
231
238
  // Images (data/object/remote URLs) render as a thumbnail; everything else is a
232
- // labelled chip. A file with no usable url (e.g. a non-image attachment whose
239
+ // labelled chip. A file with no preview URL (e.g. a non-image attachment whose
233
240
  // bytes live only server-side) still shows its name.
234
- if (mediaType.startsWith('image/') && url) {
241
+ if (mediaType.startsWith('image/') && previewUrl) {
235
242
  return (
236
243
  <img
237
- src={url}
238
- alt={filename ?? 'attachment'}
244
+ src={previewUrl}
245
+ alt={label ?? 'attachment'}
239
246
  className="max-h-64 max-w-full rounded-lg border border-border object-contain"
240
247
  />
241
248
  )
@@ -243,7 +250,7 @@ function FilePart({ mediaType, url, filename }: FilePartProps) {
243
250
  return (
244
251
  <div className="flex items-center gap-1.5 rounded-lg border border-border bg-accent px-2.5 py-1.5 text-xs text-accent-foreground">
245
252
  <IconFile size={16} stroke={1.75} />
246
- <span className="truncate">{filename ?? mediaType}</span>
253
+ <span className="truncate">{label ?? mediaType}</span>
247
254
  </div>
248
255
  )
249
256
  }
@@ -10,7 +10,7 @@ import { type ReactNode, useEffect, useState } from 'react'
10
10
 
11
11
  import { IconPlayBasketball, IconPlayFootball, IconPlayVolleyball } from '@tabler/icons-react'
12
12
 
13
- import { ShimmerText } from '@/client/features/chat/ShimmerText'
13
+ import { ShimmerText } from '@/client/features/chat/messages/ShimmerText'
14
14
  import { cn } from '@/client/lib/cn'
15
15
  import type { Part, ToolCall } from '@/lib/types'
16
16
 
@@ -5,7 +5,7 @@
5
5
  // can build on them without a cycle.
6
6
  import type { ReactNode } from 'react'
7
7
 
8
- import { IconChevronRight, IconLoader2, IconPackage } from '@tabler/icons-react'
8
+ import { IconChevronRight, IconLoader2, type TablerIcon } from '@tabler/icons-react'
9
9
  import { motion } from 'motion/react'
10
10
 
11
11
  import { IconMcp } from '@/client/features/connectors/IconMcp'
@@ -131,7 +131,7 @@ export function IconMarker({
131
131
  size = 12,
132
132
  stroke = 1.75
133
133
  }: {
134
- icon: typeof IconPackage
134
+ icon: TablerIcon
135
135
  size?: number
136
136
  stroke?: number
137
137
  }) {
@@ -15,7 +15,7 @@ import { type ReactNode, useState } from 'react'
15
15
  import { IconLoader2, IconPackage } from '@tabler/icons-react'
16
16
 
17
17
  import { cn } from '@/client/lib/cn'
18
- import { PlainMarkdownText } from '@/client/features/chat/MarkdownContent'
18
+ import { PlainMarkdownText } from '@/client/features/chat/messages/MarkdownContent'
19
19
  import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
20
20
  import type { Part, ToolCall } from '@/lib/types'
21
21
 
@@ -4,7 +4,7 @@ import { IconArchive, IconChevronDown, IconEdit } from '@tabler/icons-react'
4
4
  import { useArchiveWorkspaceSession, useWorkspaceSessions } from './api'
5
5
  import { useWorkspaceAgent } from '@/client/features/workspace/api'
6
6
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
7
- import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
7
+ import { useSelectedSession } from '@/client/features/chat/sessions/useSelectedSession'
8
8
  import { cn } from '@/client/lib/cn'
9
9
  import {
10
10
  hasRunningBackgroundSession,
@@ -286,8 +286,8 @@ function SessionSelector() {
286
286
  <DropdownMenu onOpenChange={handleMenuOpenChange}>
287
287
  <DropdownMenuTrigger
288
288
  render={
289
- <Button className="group" variant="ghost" size="sm">
290
- <span className="max-w-64 truncate">{label}</span>
289
+ <Button className="group max-w-full min-w-0 shrink" variant="ghost" size="sm">
290
+ <span className="max-w-64 min-w-0 truncate">{label}</span>
291
291
  {hasRunningBackgroundChat ? (
292
292
  <Spinner className="size-4!" stroke={2} />
293
293
  ) : (
@@ -3,7 +3,7 @@ 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 { sessionViewOptions } from '@/client/features/chat/session-view'
6
+ import { sessionViewOptions } from '@/client/features/chat/sessions/session-view'
7
7
  import type { SessionConfig, SessionInfo } from '@/lib/types'
8
8
 
9
9
  export function useWorkspaceSessions(workspaceId: string) {
@@ -3,27 +3,30 @@ import { useCallback, useEffect, useMemo } from 'react'
3
3
  import { useQueryClient } from '@tanstack/react-query'
4
4
 
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
- import { useSessionConfig, useSessionView, useWorkspaceSessions } from '@/client/features/chat/api'
6
+ import {
7
+ useSessionConfig,
8
+ useSessionView,
9
+ useWorkspaceSessions
10
+ } from '@/client/features/chat/sessions/api'
7
11
  import { useWorkspaceAgent } from '@/client/features/workspace/api'
8
- import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
12
+ import { useSelectedSession } from '@/client/features/chat/sessions/useSelectedSession'
9
13
  import {
10
14
  type WorkspaceTabAddress,
11
15
  useMoiUserMessageContext
12
16
  } from '@/client/features/workspace/moi-context'
13
17
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
14
18
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
15
- import { sendMessage } from '@/client/features/chat/chat-connection'
19
+ import { sendMessage } from '@/client/features/chat/connection/chat-connection'
16
20
  import {
17
21
  type ChatSendOptions,
18
- attachmentPartsForOptimisticTurn,
22
+ prepareDraftAttachments,
19
23
  attachmentsForSend,
20
24
  ownsComposerAttachments,
21
25
  resolveChatRunOptions,
22
26
  startOptimisticSession,
23
- startOptimisticTurn,
24
- withAttachmentDirectives
27
+ startOptimisticTurn
25
28
  } from '@/client/features/chat/chat-send'
26
- import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
29
+ import { buildPreviewTurn } from '@/client/features/chat/messages/preview-turn'
27
30
  import {
28
31
  isRunningActivity,
29
32
  liveStore,
@@ -31,7 +34,9 @@ import {
31
34
  useLive
32
35
  } from '@/client/features/chat/chat-store'
33
36
  import { useUiStore } from '@/client/store/ui'
37
+ import { toast } from '@/client/components/ui/toast'
34
38
  import { emptyViewState } from '@/lib/format'
39
+ import { messageAttachmentLimitError } from '@/lib/message-attachments'
35
40
  import type { Part, ViewState } from '@/lib/types'
36
41
 
37
42
  const EMPTY: ViewState = emptyViewState()
@@ -101,25 +106,36 @@ export function useChat(address: WorkspaceTabAddress) {
101
106
  const text = draft.trim()
102
107
  // Attachments stay with the selected session. Only fully-uploaded ones are
103
108
  // sent; the composer disables send while any are still uploading, so in
104
- // practice they're all ready here. An applet send gets none — the staged
105
- // files are the user's, not the widget's.
109
+ // practice they're all ready here. Applet sends supply their own prepared
110
+ // attachments and leave the user's staged files alone.
106
111
  const ready = attachmentsForSend(workspaceId, selectedSessionId, options)
107
112
  // No `processing` guard: sending while a turn is in flight QUEUES the
108
113
  // message into the same live server session (streaming-input mode).
109
- if (!text && ready.length === 0) return
114
+ if (!text && ready.length === 0 && !options?.preparedAttachments?.attachments.length) return
115
+
116
+ const prepared = options?.preparedAttachments ?? prepareDraftAttachments(ready)
117
+ const limitError = messageAttachmentLimitError(prepared.attachments)
118
+ if (limitError) {
119
+ toast.add({ title: 'Couldn’t send message', description: limitError, type: 'error' })
120
+ return
121
+ }
110
122
 
111
123
  let sid = selectedSessionId
112
124
  let isNew = false
113
125
  if (!sid) {
114
126
  sid = crypto.randomUUID()
115
127
  isNew = true
128
+ // An immediate applet send leaves the user's attachments staged in this chat.
129
+ if (!ownsComposerAttachments(options)) {
130
+ liveStore.getState().renameSession(workspaceId, selectedSessionId, sid)
131
+ }
116
132
  selectSession(sid)
117
133
  startOptimisticSession({
118
134
  queryClient: qc,
119
135
  workspaceId,
120
136
  sessionId: sid,
121
137
  text,
122
- filenames: ready.map(attachment => attachment.name)
138
+ filenames: ready.map(attachment => attachment.label)
123
139
  })
124
140
  }
125
141
 
@@ -128,7 +144,7 @@ export function useChat(address: WorkspaceTabAddress) {
128
144
  // upserts in place rather than duplicating. Image attachments render from
129
145
  // their local object URL until the server's broadcast (with a data URL)
130
146
  // upserts in place.
131
- const parts: Part[] = attachmentPartsForOptimisticTurn(ready)
147
+ const parts: Part[] = [...prepared.parts]
132
148
  if (text) parts.push({ type: 'text', text })
133
149
  const optimisticId = startOptimisticTurn({
134
150
  queryClient: qc,
@@ -150,6 +166,7 @@ export function useChat(address: WorkspaceTabAddress) {
150
166
  pickedEffort,
151
167
  pickedFastMode
152
168
  )
169
+ const { attachments } = prepared
153
170
  sendMessage({
154
171
  type: 'chat',
155
172
  workspaceId,
@@ -161,8 +178,8 @@ export function useChat(address: WorkspaceTabAddress) {
161
178
  effort,
162
179
  fastMode,
163
180
  stream,
164
- context: buildMoiContext(withAttachmentDirectives(options, ready)),
165
- ...(ready.length > 0 ? { attachments: ready.map(a => a.upload!.id) } : {})
181
+ context: buildMoiContext(options),
182
+ ...(attachments.length > 0 ? { attachments } : {})
166
183
  })
167
184
  useUiStore.getState().markMessageSentFromMoi(workspaceId)
168
185
  if (isNew) {
@@ -170,7 +187,7 @@ export function useChat(address: WorkspaceTabAddress) {
170
187
  }
171
188
  // Drop the session's attachments now that they've been sent (revokes the
172
189
  // preview object URLs). Keyed by the pre-mint id, matching where they were
173
- // stored by the composer. Skipped for an applet send, which carried none:
190
+ // stored by the composer. Skipped for an applet send:
174
191
  // clearing here would discard the user's staged (and in-flight) files.
175
192
  if (ownsComposerAttachments(options)) {
176
193
  liveStore.getState().clearAttachments(workspaceId, selectedSessionId)
@@ -24,12 +24,12 @@ import {
24
24
  import { Switch } from '@/client/components/ui/switch'
25
25
  import { ChatNoticeRow } from '@/client/features/chat/ChatPanel'
26
26
  import { ErrorBanner } from '@/client/features/chat/composer/banners/ErrorBanner'
27
- import { ChatSessionItem } from '@/client/features/chat/ChatSelector'
28
- import { TurnView } from '@/client/features/chat/TurnView'
27
+ import { ChatSessionItem } from '@/client/features/chat/sessions/ChatSelector'
28
+ import { TurnView } from '@/client/features/chat/messages/TurnView'
29
29
  import { isSessionRunning, liveStore } from '@/client/features/chat/chat-store'
30
- import { groupTurns } from '@/client/features/chat/group-turns'
31
- import { interleaveNotices } from '@/client/features/chat/interleave-notices'
32
- import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
30
+ import { groupTurns } from '@/client/features/chat/messages/group-turns'
31
+ import { interleaveNotices } from '@/client/features/chat/messages/interleave-notices'
32
+ import { buildPreviewTurn } from '@/client/features/chat/messages/preview-turn'
33
33
  import {
34
34
  WorkspaceLayoutContext,
35
35
  type WorkspaceLayoutContextValue
@@ -58,7 +58,6 @@ const layoutCtxValue: WorkspaceLayoutContextValue = {
58
58
  layout: createDefaultWorkspaceLayout(),
59
59
  setLayout: () => {},
60
60
  name: 'moi',
61
- icon: null,
62
61
  cwd: DEV_CWD,
63
62
  provider: 'openclaw',
64
63
  workspaceId: DEV_WORKSPACE_ID,
@@ -5,6 +5,7 @@ import { useSearchParams } from 'wouter'
5
5
 
6
6
  import { Button } from '@/client/components/ui/button'
7
7
  import { cn } from '@/client/lib/cn'
8
+ import { useLatestRef } from '@/client/lib/use-latest-ref'
8
9
  import { wsUrl } from '@/client/lib/ws-url'
9
10
  import type { Model, WorkspaceAgent, WorkspaceEntry } from '@/lib/types'
10
11
 
@@ -190,6 +191,7 @@ export function HarnessDebugPage() {
190
191
  const [wire, setWire] = useState<WireFrame[]>([])
191
192
  const [clientFrames, setClientFrames] = useState<BroadcastFrame[]>([])
192
193
  const [events, setEvents] = useState<unknown[] | null>(null)
194
+ const [eventsLoadedAt, setEventsLoadedAt] = useState(0)
193
195
  const [hidePreviews, setHidePreviews] = useState(false)
194
196
  const [rightTab, setRightTab] = useState<'frames' | 'events'>('frames')
195
197
  // Split position of the wire pane, as % of the row. Wire frames are the
@@ -201,8 +203,7 @@ export function HarnessDebugPage() {
201
203
  const wireCursor = useRef(0)
202
204
  const wsRef = useRef<WebSocket | null>(null)
203
205
  const localSeq = useRef(0)
204
- const sessionRef = useRef(sessionId)
205
- sessionRef.current = sessionId
206
+ const sessionRef = useLatestRef(sessionId)
206
207
 
207
208
  // Every workspace is drivable — the panes adapt to its harness type.
208
209
  useEffect(() => {
@@ -294,7 +295,7 @@ export function HarnessDebugPage() {
294
295
  wsRef.current = null
295
296
  sock.close()
296
297
  }
297
- }, [workspaceId])
298
+ }, [sessionRef, workspaceId])
298
299
 
299
300
  const send = useCallback(
300
301
  (content: string) => {
@@ -314,25 +315,27 @@ export function HarnessDebugPage() {
314
315
  )
315
316
  setIsNew(false)
316
317
  },
317
- [workspaceId, isNew, model, effort, stream]
318
+ [workspaceId, sessionRef, isNew, model, effort, stream]
318
319
  )
319
320
 
320
321
  const stop = useCallback(() => {
321
322
  wsRef.current?.send(
322
323
  JSON.stringify({ type: 'stop', workspaceId, sessionId: sessionRef.current })
323
324
  )
324
- }, [workspaceId])
325
+ }, [sessionRef, workspaceId])
325
326
 
326
327
  const newThread = useCallback(() => {
327
328
  setSessionId(crypto.randomUUID())
328
329
  setIsNew(true)
329
330
  setEvents(null)
331
+ setEventsLoadedAt(0)
330
332
  }, [])
331
333
 
332
334
  const fetchEvents = useCallback(async () => {
333
335
  const r = await fetch(`/api/workspaces/${workspaceId}/sessions/${sessionRef.current}/events`)
334
336
  setEvents(r.ok ? ((await r.json()) as unknown[]) : [])
335
- }, [workspaceId])
337
+ setEventsLoadedAt(Date.now())
338
+ }, [sessionRef, workspaceId])
336
339
 
337
340
  const effortLevels = useMemo(
338
341
  () => models.find(m => m.value === model)?.supportedEffortLevels ?? [],
@@ -585,7 +588,7 @@ export function HarnessDebugPage() {
585
588
  {events?.map((ev, i) => (
586
589
  <LogRow
587
590
  key={i}
588
- time={Date.now()}
591
+ time={eventsLoadedAt}
589
592
  badge="ev"
590
593
  badgeClass="bg-teal-500/15 text-teal-600"
591
594
  label={frameLabel(ev)}
@@ -9,7 +9,7 @@ import {
9
9
  subagentDoneTrace,
10
10
  subagentTrace,
11
11
  ToolCallGroup
12
- } from '@/client/features/chat/tool-group'
12
+ } from '@/client/features/chat/messages/tool-group'
13
13
 
14
14
  const VARIANTS = [
15
15
  { value: 'single', label: 'Single' },
@@ -126,6 +126,7 @@ import {
126
126
  InputGroupText
127
127
  } from '@/ui-components/input-group'
128
128
  import { Input } from '@/ui-components/input'
129
+ import { Kbd, KbdGroup } from '@/ui-components/kbd'
129
130
  import { Label } from '@/ui-components/label'
130
131
  import {
131
132
  Pagination,
@@ -544,6 +545,25 @@ function InputGroupPreview() {
544
545
  )
545
546
  }
546
547
 
548
+ function KbdPreview() {
549
+ return (
550
+ <div className="flex flex-col items-center gap-4">
551
+ <Kbd>Esc</Kbd>
552
+ <KbdGroup aria-label="Command Shift K">
553
+ <Kbd>⌘</Kbd>
554
+ <Kbd>⇧</Kbd>
555
+ <Kbd>K</Kbd>
556
+ </KbdGroup>
557
+ <Button variant="outline">
558
+ Accept{' '}
559
+ <Kbd data-icon="inline-end" className="translate-x-0.5">
560
+ ⏎
561
+ </Kbd>
562
+ </Button>
563
+ </div>
564
+ )
565
+ }
566
+
547
567
  function LabelPreview() {
548
568
  return (
549
569
  <div className="flex items-center gap-2">
@@ -813,6 +833,7 @@ export const UI_COMPONENT_PREVIEWS = {
813
833
  'hover-card': HoverCardPreview,
814
834
  input: InputPreview,
815
835
  'input-group': InputGroupPreview,
836
+ kbd: KbdPreview,
816
837
  label: LabelPreview,
817
838
  pagination: PaginationPreview,
818
839
  popover: PopoverPreview,
@@ -525,8 +525,19 @@ const moonReplyWithMeta: Turn = {
525
525
 
526
526
  // Beat 12 — attachments: image thumbnail + non-image file chip on one user turn.
527
527
  const attachmentsTurn = turn('user', 23, 26, [
528
- { type: 'file', mediaType: 'image/png', url: CHECKERBOARD_PNG, filename: 'pattern.png' },
529
- { type: 'file', mediaType: 'application/pdf', url: '', filename: 'report.pdf' },
528
+ {
529
+ type: 'text-attachment',
530
+ source: 'view:board',
531
+ label: 'Selected board items',
532
+ text: 'Selected items: item-1, item-2'
533
+ },
534
+ {
535
+ type: 'file-attachment',
536
+ mediaType: 'image/png',
537
+ previewUrl: CHECKERBOARD_PNG,
538
+ label: 'pattern.png'
539
+ },
540
+ { type: 'file-attachment', mediaType: 'application/pdf', label: 'report.pdf' },
530
541
  text(
531
542
  'back to work — mole says the report draft is done. recreate this dither pattern in the scratchpad later, and let him know we got it'
532
543
  )