moi-computer 0.11.1-next.1 → 0.11.1-next.3

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 (240) 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 +116 -64
  23. package/client/features/chat/chat-store.ts +51 -62
  24. package/client/features/chat/composer/ChatComposer.tsx +43 -132
  25. package/client/features/chat/composer/ModelPicker.tsx +41 -42
  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/composer/model-order.ts +15 -0
  34. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  35. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +6 -7
  36. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  37. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  38. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
  39. package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +1 -0
  40. package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
  41. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  42. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  43. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
  44. package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
  45. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  46. package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
  47. package/client/features/chat/useChat.ts +37 -23
  48. package/client/features/dev/ChatStatesPage.tsx +5 -6
  49. package/client/features/dev/HarnessDebugPage.tsx +10 -7
  50. package/client/features/dev/ToolCallsPage.tsx +1 -1
  51. package/client/features/dev/UiComponentPreviews.tsx +21 -0
  52. package/client/features/dev/chat-states-fixtures.ts +13 -2
  53. package/client/features/drawings/useChatAnnotation.ts +17 -17
  54. package/client/features/drawings/useDrawingLayer.ts +7 -9
  55. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  56. package/client/features/home/HomePage.tsx +8 -7
  57. package/client/features/home/WorkspacePreview.tsx +1 -1
  58. package/client/features/home/workspace-presentation.tsx +1 -11
  59. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  60. package/client/features/overview/HiddenPanel.tsx +109 -0
  61. package/client/features/overview/Overview.tsx +302 -0
  62. package/client/features/overview/WidgetCanvas.tsx +164 -0
  63. package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
  64. package/client/features/overview/WorkspaceName.tsx +60 -0
  65. package/client/features/overview/api.ts +30 -0
  66. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  67. package/client/features/overview/default/registry.tsx +36 -0
  68. package/client/features/{widgets → overview}/grid.ts +36 -0
  69. package/client/features/overview/useGridReconcile.ts +94 -0
  70. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  71. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  72. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  73. package/client/features/settings/GeneralSettings.tsx +55 -58
  74. package/client/features/settings/SettingsLayout.tsx +2 -2
  75. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  76. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  77. package/client/features/settings/api.ts +48 -24
  78. package/client/features/views/ViewBuilder.tsx +5 -4
  79. package/client/features/views/ViewManager.tsx +11 -13
  80. package/client/features/views/api.ts +36 -2
  81. package/client/features/views/useViewBuilderActions.ts +8 -5
  82. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  83. package/client/features/views/view-presentation.ts +13 -0
  84. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  85. package/client/features/workspace/UnavailablePage.tsx +21 -0
  86. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  87. package/client/features/workspace/WorkspaceScreen.tsx +205 -161
  88. package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
  89. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  90. package/client/features/workspace/api.ts +0 -26
  91. package/client/features/workspace/moi-context.ts +8 -9
  92. package/client/features/workspace/tab-resolution.ts +10 -33
  93. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  94. package/client/index.css +1 -1
  95. package/client/lib/app-icon-registry.ts +2 -0
  96. package/client/lib/use-latest-ref.ts +11 -0
  97. package/client/main.tsx +1 -1
  98. package/client/runtime/useWorkspaceEvents.ts +59 -14
  99. package/client/theme.css +5 -5
  100. package/dist/chunk-1pp135b4.js +1 -0
  101. package/dist/chunk-2gs8jjx4.css +1 -0
  102. package/dist/chunk-94m3q9ce.js +1 -0
  103. package/dist/chunk-azkjzc7a.js +68 -0
  104. package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
  105. package/dist/chunk-m1fvqssh.js +2 -0
  106. package/dist/chunk-p34hvqt3.js +1 -0
  107. package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
  108. package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
  109. package/dist/chunk-xg01f6pn.js +10 -0
  110. package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
  111. package/dist/index.html +1 -1
  112. package/lib/app-icons.ts +1 -0
  113. package/lib/applet-selector.ts +24 -0
  114. package/lib/chat-title.ts +6 -1
  115. package/lib/default-widgets.ts +32 -0
  116. package/lib/format.ts +18 -6
  117. package/lib/message-attachments.ts +40 -0
  118. package/lib/moi-attachments.ts +204 -0
  119. package/lib/moi-context.ts +20 -35
  120. package/lib/navigation.ts +84 -0
  121. package/lib/types.ts +84 -26
  122. package/lib/workspace-icon.ts +20 -0
  123. package/lib/workspace-layout.ts +22 -2
  124. package/lib/workspace-tabs.ts +9 -33
  125. package/package.json +27 -27
  126. package/registry.json +13 -0
  127. package/server/AGENTS.md +1 -0
  128. package/server/api.ts +115 -38
  129. package/server/applet-typecheck.ts +95 -0
  130. package/server/applets/applet-css.ts +55 -0
  131. package/server/{bundler → applets}/build-applet.ts +13 -246
  132. package/server/applets/config.ts +226 -0
  133. package/server/applets/dependencies.ts +206 -0
  134. package/server/{applets.ts → applets/index.ts} +15 -161
  135. package/server/applets/runtime/base.ts +4 -0
  136. package/server/applets/runtime/moi.ts +42 -0
  137. package/server/applets/runtime/rpc.ts +17 -0
  138. package/server/applets/view-source.ts +67 -0
  139. package/server/attachment-message.ts +95 -0
  140. package/server/cli.ts +163 -97
  141. package/server/control.ts +63 -42
  142. package/server/harness/README.md +32 -41
  143. package/server/harness/acp/adapter.ts +7 -21
  144. package/server/harness/acp/session.ts +31 -50
  145. package/server/harness/claude-code/NOTES.md +8 -2
  146. package/server/harness/claude-code/adapter.ts +8 -25
  147. package/server/harness/claude-code/index.ts +2 -0
  148. package/server/harness/claude-code/session.ts +42 -47
  149. package/server/harness/claude-code/sessions.ts +9 -4
  150. package/server/harness/codex/NOTES.md +222 -350
  151. package/server/harness/codex/adapter.ts +102 -52
  152. package/server/harness/codex/auth.ts +1 -3
  153. package/server/harness/codex/client.ts +169 -249
  154. package/server/harness/codex/discovery.ts +9 -17
  155. package/server/harness/codex/index.ts +3 -1
  156. package/server/harness/codex/pagination.ts +24 -0
  157. package/server/harness/codex/permissions.ts +32 -8
  158. package/server/harness/codex/probe.ts +10 -13
  159. package/server/harness/codex/session.ts +567 -181
  160. package/server/harness/codex/transport.ts +184 -0
  161. package/server/harness/debug.ts +1 -1
  162. package/server/harness/hermes/NOTES.md +1 -1
  163. package/server/harness/hermes/index.ts +4 -0
  164. package/server/harness/openclaw/NOTES.md +1 -1
  165. package/server/harness/openclaw/adapter.ts +22 -4
  166. package/server/harness/openclaw/gateway.ts +5 -3
  167. package/server/harness/openclaw/session.ts +27 -27
  168. package/server/harness/types.ts +5 -3
  169. package/server/layout.ts +9 -14
  170. package/server/moi-scaffold.ts +21 -13
  171. package/server/navigation-relay.ts +110 -0
  172. package/server/registry.ts +8 -0
  173. package/server/selected-session.ts +24 -4
  174. package/server/skill-update.ts +5 -3
  175. package/server/skill-version.ts +4 -7
  176. package/server/skills-template.ts +48 -9
  177. package/server/tabs.ts +19 -33
  178. package/server/uploads.ts +0 -0
  179. package/server/view-builders.ts +18 -1
  180. package/server/views.ts +126 -6
  181. package/server/web.ts +38 -9
  182. package/server/widgets.ts +12 -5
  183. package/server/workspace-config.ts +13 -9
  184. package/ui-components/alert-dialog.tsx +1 -1
  185. package/ui-components/alert.tsx +1 -1
  186. package/ui-components/avatar.tsx +1 -1
  187. package/ui-components/button.tsx +2 -2
  188. package/ui-components/checkbox.tsx +2 -1
  189. package/ui-components/combobox.tsx +3 -1
  190. package/ui-components/docs/kbd.md +191 -0
  191. package/ui-components/dropdown-menu.tsx +1 -1
  192. package/ui-components/field.tsx +1 -1
  193. package/ui-components/input-group.tsx +2 -2
  194. package/ui-components/kbd.tsx +32 -0
  195. package/ui-components/radio-group.tsx +2 -1
  196. package/ui-components/slider.tsx +1 -1
  197. package/ui-components/switch.tsx +3 -2
  198. package/ui-components/tabs.tsx +1 -1
  199. package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
  200. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
  201. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  202. package/client/features/chat/attachment-staging.ts +0 -153
  203. package/client/features/chat/uploads.ts +0 -18
  204. package/client/features/chat/useAppletChatMessage.ts +0 -68
  205. package/client/features/settings/IconPicker.tsx +0 -442
  206. package/client/features/settings/WorkspaceSettings.tsx +0 -95
  207. package/client/features/settings/render-icon.ts +0 -173
  208. package/client/features/widgets/HiddenPanel.tsx +0 -80
  209. package/client/features/widgets/WidgetGrid.tsx +0 -123
  210. package/client/features/widgets/Widgets.tsx +0 -262
  211. package/client/features/widgets/useGridReconcile.ts +0 -73
  212. package/dist/chunk-6664vxpk.css +0 -1
  213. package/dist/chunk-87thzbtw.js +0 -2
  214. package/dist/chunk-a6jad1a6.js +0 -1
  215. package/dist/chunk-dghwstd2.js +0 -9
  216. package/dist/chunk-eg120aca.js +0 -1
  217. package/dist/chunk-vwjeezeb.js +0 -1
  218. package/dist/chunk-yc471zah.js +0 -70
  219. package/server/bundler/applet-css.ts +0 -160
  220. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  221. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  222. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  223. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  224. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  225. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  226. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  227. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  228. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  229. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  230. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  231. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  232. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  233. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  234. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  235. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  236. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  237. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  238. /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
  239. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
  240. /package/server/{bundler → applets}/build-worker.ts +0 -0
@@ -0,0 +1,168 @@
1
+ import type {
2
+ AttachmentInput,
3
+ AttachmentOrigin,
4
+ DrawingPurpose,
5
+ TextAttachment,
6
+ WorkspaceTabId
7
+ } from '@/lib/types'
8
+
9
+ import { findAttachment, liveStore } from '../../chat-store'
10
+ import { uploadChatFile } from './uploads'
11
+ import { reportAppletError } from '@/client/features/applets/applet-log'
12
+ import { toast } from '@/client/components/ui/toast'
13
+
14
+ type ComposerTarget = {
15
+ workspaceId: string
16
+ sessionId: string | null
17
+ }
18
+
19
+ export function stageComposerFiles(target: ComposerTarget, files: File[]): void {
20
+ for (const file of files) void stageFile(target, file)
21
+ }
22
+
23
+ // Both file sources enter the same draft lifecycle and become ordinary uploads.
24
+ async function stageFile(
25
+ { workspaceId, sessionId }: ComposerTarget,
26
+ input: File | string,
27
+ onError?: (message: string) => void,
28
+ source?: string
29
+ ): Promise<void> {
30
+ const file = typeof input === 'string' ? null : input
31
+ const label = typeof input === 'string' ? input.split('/').at(-1)! : input.name || 'file'
32
+ const localId = crypto.randomUUID()
33
+ liveStore.getState().addAttachments(workspaceId, sessionId, [
34
+ {
35
+ kind: 'file',
36
+ source,
37
+ localId,
38
+ label,
39
+ mediaType: file?.type || 'application/octet-stream',
40
+ previewUrl: file?.type.startsWith('image/') ? URL.createObjectURL(file) : undefined,
41
+ status: 'uploading'
42
+ }
43
+ ])
44
+ try {
45
+ const upload = await uploadChatFile(workspaceId, input)
46
+ liveStore.getState().updateAttachment(workspaceId, localId, {
47
+ status: 'ready',
48
+ upload,
49
+ label: upload.filename,
50
+ mediaType: upload.mediaType,
51
+ ...(upload.kind === 'image' && !file?.type.startsWith('image/')
52
+ ? { previewUrl: `/api/workspaces/${workspaceId}/uploads/${upload.id}` }
53
+ : {})
54
+ })
55
+ } catch (error: unknown) {
56
+ const message = error instanceof Error ? error.message : 'The file couldn’t be uploaded'
57
+ liveStore.getState().removeAttachment(workspaceId, localId)
58
+ toast.add({ title: `Couldn’t add ${label}`, description: message, type: 'error' })
59
+ onError?.(message)
60
+ }
61
+ }
62
+
63
+ export function stageChatAttachment(
64
+ target: ComposerTarget,
65
+ input: AttachmentInput & AttachmentOrigin
66
+ ): Promise<void> {
67
+ if (input.type === 'text') {
68
+ const { source, label, text } = input
69
+ stageTextAttachment(target, { source, label, text })
70
+ return Promise.resolve()
71
+ }
72
+ return stageFile(
73
+ target,
74
+ input.file ?? input.path,
75
+ message => {
76
+ reportAppletError(target.workspaceId, {
77
+ source: 'runtime',
78
+ message: `addChatAttachment() from ${input.source}: ${message}`
79
+ })
80
+ },
81
+ input.source
82
+ )
83
+ }
84
+
85
+ type StageDrawingDraftInput = ComposerTarget & {
86
+ localId: string
87
+ purpose: DrawingPurpose
88
+ source: WorkspaceTabId
89
+ blob: Blob
90
+ }
91
+
92
+ // Local-only staging while the user is still drawing: the chip shows the
93
+ // latest composite as its preview, but nothing is uploaded until the drawing
94
+ // session ends (stageDrawing).
95
+ export function stageDrawingDraft({
96
+ workspaceId,
97
+ sessionId,
98
+ localId,
99
+ purpose,
100
+ source,
101
+ blob
102
+ }: StageDrawingDraftInput): void {
103
+ const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
104
+ const previewUrl = URL.createObjectURL(blob)
105
+ const store = liveStore.getState()
106
+ const existing = findAttachment(store.attachments, workspaceId, localId)
107
+
108
+ if (existing) {
109
+ store.updateAttachment(workspaceId, localId, {
110
+ previewUrl,
111
+ status: 'draft',
112
+ upload: undefined
113
+ })
114
+ } else {
115
+ store.addAttachments(workspaceId, sessionId, [
116
+ {
117
+ kind: 'drawing',
118
+ purpose,
119
+ localId,
120
+ source,
121
+ label: `${label}.png`,
122
+ mediaType: 'image/png',
123
+ previewUrl,
124
+ status: 'draft'
125
+ }
126
+ ])
127
+ }
128
+ }
129
+
130
+ type StageDrawingInput = StageDrawingDraftInput & {
131
+ isCurrent: () => boolean
132
+ }
133
+
134
+ // Upload a drawing once its editing session ends (finish, send, or an
135
+ // implicit cancel that keeps the attachment). `isCurrent` guards the result:
136
+ // a stale upload must not resurrect an attachment the user has removed.
137
+ export async function stageDrawing(input: StageDrawingInput): Promise<void> {
138
+ const { workspaceId, localId, purpose, blob, isCurrent } = input
139
+ const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
140
+ stageDrawingDraft(input)
141
+ liveStore.getState().updateAttachment(workspaceId, localId, { status: 'uploading' })
142
+
143
+ try {
144
+ const upload = await uploadChatFile(
145
+ workspaceId,
146
+ new File([blob], `${label}.png`, { type: 'image/png' })
147
+ )
148
+ if (!isCurrent()) return
149
+ liveStore.getState().updateAttachment(workspaceId, localId, {
150
+ status: 'ready',
151
+ upload,
152
+ mediaType: upload.mediaType
153
+ })
154
+ } catch {
155
+ if (!isCurrent()) return
156
+ liveStore.getState().removeAttachment(workspaceId, localId)
157
+ }
158
+ }
159
+
160
+ export function stageTextAttachment(
161
+ { workspaceId, sessionId }: ComposerTarget,
162
+ attachment: TextAttachment
163
+ ): void {
164
+ const store = liveStore.getState()
165
+ store.addAttachments(workspaceId, sessionId, [
166
+ { kind: 'text', localId: crypto.randomUUID(), ...attachment }
167
+ ])
168
+ }
@@ -0,0 +1,25 @@
1
+ import type { AttachmentOrigin, DrawingPurpose, TextAttachment, UploadInfo } from '@/lib/types'
2
+
3
+ // One composer attachment, tracked per session until the message is sent. A
4
+ // file uploads as soon as it's added (drop/paste/pick); an annotation stays a
5
+ // local `draft` while it's being drawn and uploads once when the drawing
6
+ // session ends. `status` reflects that lifecycle, and `upload` holds the server
7
+ // handle once ready. `previewUrl` is a local object URL for image thumbnails
8
+ // (revoked on remove/clear).
9
+ type StagedUploadFields = {
10
+ label: string
11
+ mediaType: string
12
+ previewUrl?: string
13
+ status: 'draft' | 'uploading' | 'ready'
14
+ upload?: UploadInfo
15
+ }
16
+
17
+ export type StagedAttachment = { localId: string } & (
18
+ | ({ kind: 'file' } & StagedUploadFields & Partial<AttachmentOrigin>)
19
+ | ({ kind: 'drawing'; purpose: DrawingPurpose } & StagedUploadFields & AttachmentOrigin)
20
+ | ({ kind: 'text' } & TextAttachment)
21
+ )
22
+
23
+ export type StagedAttachmentPatch = Partial<
24
+ Pick<StagedUploadFields, 'label' | 'mediaType' | 'previewUrl' | 'status' | 'upload'>
25
+ >
@@ -0,0 +1,26 @@
1
+ import { jsonRequest, requestJson } from '@/client/api/http'
2
+ import type { UploadInfo } from '@/lib/types'
3
+
4
+ // Shared single-file preparation for drafts, drawings, and immediate sends.
5
+ export async function uploadChatFile(
6
+ workspaceId: string,
7
+ input: File | string
8
+ ): Promise<UploadInfo> {
9
+ const url = `/api/workspaces/${workspaceId}/uploads`
10
+ if (typeof input === 'string') {
11
+ return requestJson<UploadInfo>(
12
+ `${url}/from-path`,
13
+ jsonRequest('POST', { path: input }),
14
+ 'The file couldn’t be uploaded'
15
+ )
16
+ }
17
+ const form = new FormData()
18
+ form.append('files', input)
19
+ const [upload] = await requestJson<UploadInfo[]>(
20
+ url,
21
+ { method: 'POST', body: form },
22
+ 'The file couldn’t be uploaded'
23
+ )
24
+ if (!upload) throw new Error('The upload didn’t finish')
25
+ return upload
26
+ }
@@ -6,6 +6,21 @@ const ANTHROPIC_MODEL_FAMILY_ORDER = ['fable', 'opus', 'sonnet', 'haiku'] as con
6
6
 
7
7
  type ModelComparator = (a: Model, b: Model) => number
8
8
 
9
+ // Resolve the same concrete row for the picker and the outgoing chat request.
10
+ // Unavailable selections fall back to the resolved default, then the first row.
11
+ export function resolveSelectedModel(
12
+ models: readonly Model[],
13
+ selectedModel: string | undefined,
14
+ defaultModel = models.find(model => model.value === 'default')?.resolvedModel
15
+ ): Model | undefined {
16
+ const choices = models.filter(model => model.value !== 'default')
17
+ return (
18
+ choices.find(model => model.value === selectedModel) ??
19
+ choices.find(model => (model.resolvedModel ?? model.value) === defaultModel) ??
20
+ choices[0]
21
+ )
22
+ }
23
+
9
24
  function anthropicModelFamilyRank(model: Model): number | undefined {
10
25
  const key = model.resolvedModel ?? model.value
11
26
  const rank = ANTHROPIC_MODEL_FAMILY_ORDER.findIndex(
@@ -2,7 +2,7 @@ import type { QueryClient } from '@tanstack/react-query'
2
2
 
3
3
  import { wsUrl } from '@/client/lib/ws-url'
4
4
  import { liveStore } from '@/client/features/chat/chat-store'
5
- import { reduceChatFrame } from '@/client/features/chat/chat-frames'
5
+ import { reduceChatFrame } from '@/client/features/chat/connection/chat-frames'
6
6
  import type { ClientMessage } from '@/lib/types'
7
7
 
8
8
  // App-wide chat connection: ONE WebSocket for the whole client, opened once at
@@ -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,
@@ -144,11 +144,10 @@ export function reduceChatFrame(data: Record<string, unknown>, context: ChatFram
144
144
  }
145
145
  if (kind === 'error' && typeof data.content === 'string') {
146
146
  store.setError(workspaceId, sessionId, data.content)
147
- // Servers only emit `error` terminally, so it also ends the busy state —
148
- // relying solely on a separate status frame left the spinner stuck when
149
- // that frame was lost.
150
- store.setActivity(workspaceId, sessionId, 'idle')
151
- store.clearPreviewsForSession(workspaceId, sessionId)
147
+ if (data.terminal !== false) {
148
+ store.setActivity(workspaceId, sessionId, 'idle')
149
+ store.clearPreviewsForSession(workspaceId, sessionId)
150
+ }
152
151
  }
153
152
  if (kind === 'stopped') {
154
153
  store.setActivity(workspaceId, sessionId, 'idle')
@@ -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
  }
@@ -54,6 +54,7 @@ export function groupTurns(turns: Turn[]): Turn[] {
54
54
  const previous = out[index - 1]
55
55
  if (
56
56
  turn.role !== 'assistant' ||
57
+ turn.meta?.durationMs !== undefined ||
57
58
  previous?.role !== 'user' ||
58
59
  previous.origin.kind !== 'user-input' ||
59
60
  !previous.timestamp ||
@@ -1,9 +1,7 @@
1
1
  // Weaves transcript notices (context compaction, mid-session model switches)
2
2
  // into the turn list so each one reads at the moment it happened.
3
3
  //
4
- // Only 'compact' and 'model-change' render today. Every other SystemNotice
5
- // kind is claude-code-specific plumbing with no designed chat treatment yet,
6
- // so `chatNoticeLabel` skips it explicitly.
4
+ // Only notices with a chat label enter the timeline.
7
5
  import type { SystemNotice, Turn } from '@/lib/types'
8
6
 
9
7
  export type ChatTimelineItem =
@@ -13,16 +11,19 @@ export type ChatTimelineItem =
13
11
  // One-line copy for a notice row; null = this kind does not render in chat.
14
12
  export function chatNoticeLabel(notice: SystemNotice): string | null {
15
13
  switch (notice.kind) {
14
+ case 'warning':
15
+ return notice.message
16
16
  case 'compact':
17
17
  return 'Context compacted'
18
18
  case 'model-change':
19
19
  return notice.prev
20
20
  ? `Model changed to ${notice.model} (was ${notice.prev})`
21
21
  : `Model changed to ${notice.model}`
22
+ case 'api-retry':
23
+ return notice.error ? `Retrying: ${notice.error}` : 'Retrying the connection'
22
24
  // Claude-code-specific notices without a designed chat treatment yet —
23
25
  // skipped on purpose. New kinds stay hidden until designed.
24
26
  case 'rate-limit':
25
- case 'api-retry':
26
27
  case 'hook':
27
28
  case 'session-state':
28
29
  case 'files-persisted':
@@ -44,13 +45,8 @@ function parseTime(value: string | undefined): number | undefined {
44
45
  // notices never jump ahead of undated turns. Notices with no parseable `at`
45
46
  // have no comparable anchor and go after the last turn.
46
47
  //
47
- // Known limitation — a transcript whose turns are ALL undated gives nothing to
48
- // compare against, so every dated notice lands after the last turn. That is
49
- // right while a session is live (compaction happens at the current end of the
50
- // conversation) but drifts on replay: the notice follows the new end instead of
51
- // staying where it happened. Codex hits this today — `codexItemToTurn` sets no
52
- // `timestamp` and `codexItemToNotice` stamps `at` with replay-time `new Date()`
53
- // — so fixing it means giving those rows a real anchor, not changing the merge.
48
+ // Entirely undated transcripts cannot anchor notices. Adapters must supply
49
+ // native timestamps when available; otherwise dated notices follow all turns.
54
50
  export function interleaveNotices(turns: Turn[], notices: SystemNotice[]): ChatTimelineItem[] {
55
51
  const shown = notices.filter(notice => chatNoticeLabel(notice) !== null)
56
52
  if (shown.length === 0) return turns.map((turn): ChatTimelineItem => ({ kind: 'turn', turn }))
@@ -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
 
@@ -152,10 +152,7 @@ function ToolRow({ isFirst, isLast, call, leading, marker, name, brief, preview
152
152
  // anything follows it (a text/tool row makes it no longer the last row, so
153
153
  // `inProgress` goes false and it reverts to the user's collapsed default).
154
154
  //
155
- // Some backends report that the model reasoned without handing over the text
156
- // (Anthropic `redacted_thinking`; the OpenClaw codex app-server, which sends a
157
- // Reasoning item with timing only). Those rows have nothing to expand, so they
158
- // render as a bare label — "Thought for 1.2s" — with no chevron.
155
+ // Reasoning without visible text renders as a duration label with no chevron.
159
156
  type ReasoningRowProps = RowPosition & {
160
157
  text: string
161
158
  inProgress?: boolean
@@ -103,7 +103,10 @@ function brief(call: ToolCall, shorten: Shorten): string {
103
103
  if (Array.isArray(queries) && queries.length > 0) {
104
104
  return queries.filter((q): q is string => typeof q === 'string').join(' · ')
105
105
  }
106
- return getInputValue(input, 'query')
106
+ return (
107
+ getInputValue(input, 'query') ||
108
+ [getInputValue(input, 'url'), getInputValue(input, 'pattern')].filter(Boolean).join(' · ')
109
+ )
107
110
  }
108
111
  if (tool === 'update_plan') {
109
112
  const plan = input.plan
@@ -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) {