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
@@ -1,13 +1,9 @@
1
+ import { TextAttachmentChip } from './attachments/TextAttachmentChip'
2
+ import { DrawingAttachmentChip } from './attachments/DrawingAttachmentChip'
3
+ import { FileAttachmentChip } from './attachments/FileAttachmentChip'
1
4
  import { type RefObject, useRef, useState } from 'react'
2
5
 
3
- import {
4
- IconFile,
5
- IconLoader2,
6
- IconPaperclip,
7
- IconPlayerStopFilled,
8
- IconScribble,
9
- IconX
10
- } from '@tabler/icons-react'
6
+ import { IconPaperclip, IconPlayerStopFilled, IconScribble } from '@tabler/icons-react'
11
7
 
12
8
  import {
13
9
  canSubmitComposerAction,
@@ -17,18 +13,14 @@ import {
17
13
  ComposerTextarea
18
14
  } from '@/client/components/shared/Composer'
19
15
  import { Button } from '@/client/components/ui/button'
20
- import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
21
16
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
22
- import { stageComposerFiles } from '@/client/features/chat/attachment-staging'
17
+ import { stageComposerFiles } from '@/client/features/chat/composer/attachments/draft-attachments'
23
18
  import { cn } from '@/client/lib/cn'
24
19
  import type { AgentAvailability } from '@/client/lib/agent-availability'
25
20
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
26
- import {
27
- type ChatAttachment,
28
- attachmentKey,
29
- liveStore,
30
- useLive
31
- } from '@/client/features/chat/chat-store'
21
+ import { useLatestRef } from '@/client/lib/use-latest-ref'
22
+ import { attachmentKey, liveStore, useLive } from '@/client/features/chat/chat-store'
23
+ import type { StagedAttachment } from '@/client/features/chat/composer/attachments/types'
32
24
  import { useUiStore } from '@/client/store/ui'
33
25
 
34
26
  import { ModelPicker } from './ModelPicker'
@@ -87,15 +79,16 @@ export function ChatComposer({
87
79
  const workspaceDraft = useUiStore(s => s.composerDrafts[workspaceId] ?? '')
88
80
  const builderDraft = useUiStore(s => (draft ? (s.viewBuilderDrafts ?? {})[draft.id] : undefined))
89
81
  const value = draft ? (builderDraft ?? draft.initialValue) : workspaceDraft
90
- const valueRef = useRef(value)
91
- valueRef.current = value
82
+ const valueRef = useLatestRef(value)
92
83
  const attachments = useLive(s => s.attachments[attachmentKey(workspaceId, sessionId)] ?? EMPTY)
93
84
  const [dragOver, setDragOver] = useState(false)
94
85
 
95
- const uploading = attachments.some(a => a.status === 'uploading')
86
+ const uploading = attachments.some(a => a.kind !== 'text' && a.status === 'uploading')
96
87
  // A draft annotation counts as sendable content: send() finishes the drawing
97
88
  // first, which uploads it before the message goes out.
98
- const hasSendable = attachments.some(a => a.status === 'ready' || a.status === 'draft')
89
+ const hasSendable = attachments.some(
90
+ a => a.kind === 'text' || a.status === 'ready' || a.status === 'draft'
91
+ )
99
92
  const hasContent = value.trim().length > 0 || hasSendable
100
93
  const canSend = canSubmitComposerAction(hasContent, uploading, availability)
101
94
 
@@ -114,12 +107,12 @@ export function ChatComposer({
114
107
  // upload isn't lost.
115
108
  const sendingRef = useRef(false)
116
109
 
117
- const removeAttachment = (attachment: ChatAttachment) => {
110
+ const removeAttachment = (attachment: StagedAttachment) => {
118
111
  if (attachment.kind === 'drawing' && onRemoveDrawing) {
119
112
  onRemoveDrawing(attachment.localId)
120
113
  return
121
114
  }
122
- liveStore.getState().removeAttachment(workspaceId, sessionId, attachment.localId)
115
+ liveStore.getState().removeAttachment(workspaceId, attachment.localId)
123
116
  }
124
117
 
125
118
  const send = async () => {
@@ -165,9 +158,29 @@ export function ChatComposer({
165
158
  >
166
159
  {attachments.length > 0 && (
167
160
  <div className="flex flex-wrap gap-2 px-1 pt-1 pb-1">
168
- {attachments.map(a => (
169
- <AttachmentChip key={a.localId} attachment={a} onRemove={() => removeAttachment(a)} />
170
- ))}
161
+ {attachments
162
+ .toSorted((a, b) => ATTACHMENT_ORDER[a.kind] - ATTACHMENT_ORDER[b.kind])
163
+ .map(a =>
164
+ a.kind === 'text' ? (
165
+ <TextAttachmentChip
166
+ key={a.localId}
167
+ label={a.label}
168
+ onRemove={() => removeAttachment(a)}
169
+ />
170
+ ) : a.kind === 'drawing' ? (
171
+ <DrawingAttachmentChip
172
+ key={a.localId}
173
+ attachment={a}
174
+ onRemove={() => removeAttachment(a)}
175
+ />
176
+ ) : (
177
+ <FileAttachmentChip
178
+ key={a.localId}
179
+ attachment={a}
180
+ onRemove={() => removeAttachment(a)}
181
+ />
182
+ )
183
+ )}
171
184
  </div>
172
185
  )}
173
186
 
@@ -271,111 +284,9 @@ export function ChatComposer({
271
284
  )
272
285
  }
273
286
 
274
- const EMPTY: ChatAttachment[] = []
275
-
276
- type AttachmentChipProps = {
277
- attachment: ChatAttachment
278
- onRemove: () => void
279
- }
280
-
281
- // A composer attachment preview: an image thumbnail or a labelled file chip,
282
- // with an upload spinner / error overlay and a remove button.
283
- function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {
284
- if (attachment.kind === 'drawing') {
285
- return <DrawingAttachmentChip attachment={attachment} onRemove={onRemove} />
286
- }
287
-
288
- const { name, previewUrl, status, error } = attachment
289
- const isImage = !!previewUrl
290
-
291
- return (
292
- <div
293
- className={cn(
294
- 'group relative flex items-center gap-2 overflow-hidden rounded-lg bg-accent text-accent-foreground ring-1 ring-border',
295
- isImage ? 'size-14' : 'h-10 max-w-52 pr-2 pl-2',
296
- status === 'error' && 'border-destructive/50'
297
- )}
298
- title={error ?? name}
299
- >
300
- {isImage ? (
301
- <img src={previewUrl} alt={name} className="size-full object-cover" />
302
- ) : (
303
- <>
304
- <IconFile size={16} stroke={1.75} className="shrink-0 text-muted-foreground" />
305
- <span className="truncate text-xs">{name}</span>
306
- </>
307
- )}
308
-
309
- {status === 'uploading' && (
310
- <div className="absolute inset-0 flex items-center justify-center bg-background/70">
311
- <IconLoader2 size={16} stroke={1.75} className="animate-spin text-muted-foreground" />
312
- </div>
313
- )}
314
- {status === 'error' && (
315
- <div className="absolute inset-0 flex items-center justify-center bg-destructive/10 text-[10px] text-destructive">
316
- Failed
317
- </div>
318
- )}
319
-
320
- <Button
321
- type="button"
322
- variant="ghost"
323
- size="icon-sm"
324
- onClick={onRemove}
325
- aria-label={`Remove ${name}`}
326
- className="absolute top-0.5 right-0.5 size-4 rounded-full bg-primary/70 text-primary-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-primary/80 [&_svg]:size-3"
327
- >
328
- <IconX stroke={1.75} />
329
- </Button>
330
- </div>
331
- )
332
- }
333
-
334
- type DrawingAttachmentChipProps = {
335
- attachment: Extract<ChatAttachment, { kind: 'drawing' }>
336
- onRemove: () => void
337
- }
338
-
339
- function DrawingAttachmentChip({ attachment, onRemove }: DrawingAttachmentChipProps) {
340
- const { previewUrl, purpose } = attachment
341
- const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
342
-
343
- return (
344
- <HoverCard>
345
- <HoverCardTrigger
346
- render={
347
- <div
348
- tabIndex={0}
349
- className="group flex h-7 cursor-default items-center rounded-md bg-background pr-2 pl-0.5 text-sm whitespace-nowrap text-foreground ring-1 ring-border outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
350
- />
351
- }
352
- >
353
- <Button
354
- type="button"
355
- variant="ghost"
356
- size="icon-sm"
357
- onClick={onRemove}
358
- aria-label={`Remove ${label.toLowerCase()}`}
359
- className="size-6 shrink-0 hover:bg-transparent hover:text-current"
360
- >
361
- <IconScribble stroke={1.75} className="group-focus-within:hidden group-hover:hidden" />
362
- <IconX stroke={1.75} className="hidden group-focus-within:block group-hover:block" />
363
- </Button>
364
- <span>{label}</span>
365
- </HoverCardTrigger>
366
- {previewUrl && (
367
- <HoverCardContent
368
- side="top"
369
- align="start"
370
- className="w-60 max-w-[calc(100vw-2rem)] rounded-xl"
371
- >
372
- <img
373
- src={previewUrl}
374
- alt={`${label} preview`}
375
- className="max-h-72 w-full rounded-md object-contain"
376
- />
377
- </HoverCardContent>
378
- )}
379
- </HoverCard>
380
- )
287
+ const EMPTY: StagedAttachment[] = []
288
+ const ATTACHMENT_ORDER: Record<StagedAttachment['kind'], number> = {
289
+ file: 0,
290
+ drawing: 1,
291
+ text: 2
381
292
  }
@@ -4,7 +4,7 @@ import { AnimatePresence, motion } from 'motion/react'
4
4
 
5
5
  import { IconBolt, IconBoltFilled } from '@tabler/icons-react'
6
6
 
7
- import { useSaveSessionConfig, useSessionConfig } from '../api'
7
+ import { useSaveSessionConfig, useSessionConfig } from '../sessions/api'
8
8
  import { useWorkspaceAgent } from '@/client/features/workspace/api'
9
9
  import {
10
10
  groupModels,
@@ -12,6 +12,7 @@ import {
12
12
  resolveDisplayedEffort,
13
13
  resolveEffortIndex,
14
14
  resolveFastMode,
15
+ resolveSelectedModel,
15
16
  sortModelsByProviderOrder
16
17
  } from './model-order'
17
18
  import { Button } from '@/client/components/ui/button'
@@ -125,6 +126,38 @@ function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownP
125
126
  )
126
127
  }
127
128
 
129
+ type FastModeToggleProps = { fastMode: boolean; onChange: (value: boolean) => void }
130
+
131
+ function FastModeToggle({ fastMode, onChange }: FastModeToggleProps) {
132
+ return (
133
+ <Tooltip>
134
+ <TooltipTrigger
135
+ render={
136
+ <Button
137
+ type="button"
138
+ variant="ghost"
139
+ size="icon-sm"
140
+ aria-label={fastMode ? 'Turn off fast mode' : 'Turn on fast mode'}
141
+ aria-pressed={fastMode}
142
+ onClick={() => onChange(!fastMode)}
143
+ className="-my-1 -mr-1"
144
+ >
145
+ {fastMode ? (
146
+ <IconBoltFilled className="text-primary" stroke={1.75} />
147
+ ) : (
148
+ <IconBolt className="text-muted-foreground" stroke={1.75} />
149
+ )}
150
+ </Button>
151
+ }
152
+ />
153
+ <TooltipContent align="center" className="flex-col gap-0">
154
+ <span>Fast mode</span>
155
+ <span className="font-normal text-muted-foreground">More usage</span>
156
+ </TooltipContent>
157
+ </Tooltip>
158
+ )
159
+ }
160
+
128
161
  type EffortPickerProps = {
129
162
  currentEffort: string
130
163
  effortLevels: readonly string[]
@@ -203,33 +236,7 @@ function EffortPicker({
203
236
  <span className="text-muted-foreground">Effort</span>
204
237
  <output aria-live="polite">{displayedLabel}</output>
205
238
  </div>
206
- {showFastMode && (
207
- <Tooltip>
208
- <TooltipTrigger
209
- render={
210
- <Button
211
- type="button"
212
- variant="ghost"
213
- size="icon-sm"
214
- aria-label={fastMode ? 'Turn off Fast mode' : 'Turn on Fast mode'}
215
- aria-pressed={fastMode}
216
- onClick={() => onFastModeChange(!fastMode)}
217
- className="-my-1 -mr-1"
218
- >
219
- {fastMode ? (
220
- <IconBoltFilled className="text-primary" />
221
- ) : (
222
- <IconBolt className="text-muted-foreground" stroke={1.5} />
223
- )}
224
- </Button>
225
- }
226
- />
227
- <TooltipContent align="center" className="flex-col gap-0">
228
- <span>Fast mode</span>
229
- <span className="font-normal text-muted-foreground">More usage</span>
230
- </TooltipContent>
231
- </Tooltip>
232
- )}
239
+ {showFastMode && <FastModeToggle fastMode={fastMode} onChange={onFastModeChange} />}
233
240
  </motion.div>
234
241
  )}
235
242
  </AnimatePresence>
@@ -324,19 +331,8 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
324
331
  else setLayout({ selectedFastMode: value })
325
332
  }
326
333
 
327
- if (models.length === 0) return null
328
-
329
- // Show a persisted pick when it still exists. Otherwise name the concrete
330
- // model behind the SDK default, or fall back to the first available model.
331
- const persistedModel = models.some(model => model.value === selectedModel)
332
- ? selectedModel
333
- : undefined
334
- const defaultModel =
335
- models.find(
336
- model => defaultEntry?.resolvedModel && model.resolvedModel === defaultEntry.resolvedModel
337
- ) ?? models[0]
338
- const currentModelValue = persistedModel ?? defaultModel.value
339
- const model = models.find(item => item.value === currentModelValue) ?? models[0]
334
+ const model = resolveSelectedModel(models, selectedModel, defaultEntry?.resolvedModel)
335
+ if (!model) return null
340
336
  const effortLevels = model.supportsEffort ? (model.supportedEffortLevels ?? []) : []
341
337
  const currentEffort = resolveDisplayedEffort(effortLevels, selectedEffort, model.defaultEffort)
342
338
  const showEffort = hasEffortChoice(effortLevels) && currentEffort !== undefined
@@ -345,11 +341,14 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
345
341
  return (
346
342
  <div className="flex min-w-0 items-center gap-1">
347
343
  <ModelDropdown
348
- current={currentModelValue}
344
+ current={model.value}
349
345
  model={model}
350
346
  models={models}
351
347
  onValueChange={setSelectedModel}
352
348
  />
349
+ {!showEffort && model.supportsFastMode && (
350
+ <FastModeToggle fastMode={fastMode} onChange={setSelectedFastMode} />
351
+ )}
353
352
  {showEffort && (
354
353
  <EffortPicker
355
354
  key={model.value}
@@ -0,0 +1,99 @@
1
+ import type { ComponentPropsWithRef } from 'react'
2
+ import { IconLoader2, IconX, type Icon } from '@tabler/icons-react'
3
+ import { Button } from '@/client/components/ui/button'
4
+ import { cn } from '@/client/lib/cn'
5
+
6
+ type AttachmentChipProps = ComponentPropsWithRef<'div'> & {
7
+ label: string
8
+ icon: Icon
9
+ onRemove?: () => void
10
+ previewUrl?: string
11
+ loading?: boolean
12
+ }
13
+
14
+ // Two layouts share one frame: a labelled chip or an image thumbnail.
15
+ // Upload status is an overlay; it doesn't introduce another layout.
16
+ export function AttachmentChip({
17
+ label,
18
+ icon,
19
+ onRemove,
20
+ previewUrl,
21
+ loading,
22
+ className,
23
+ children,
24
+ ...props
25
+ }: AttachmentChipProps) {
26
+ return (
27
+ <div
28
+ {...props}
29
+ className={cn(
30
+ 'group relative flex max-w-full min-w-0 cursor-default items-center rounded-md bg-background text-sm whitespace-nowrap text-foreground ring-1 ring-border outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
31
+ previewUrl ? 'size-14 overflow-hidden' : 'h-7 pr-2 pl-0.5',
32
+ className
33
+ )}
34
+ >
35
+ {loading && (
36
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-background/70">
37
+ <IconLoader2 size={16} stroke={1.75} className="animate-spin text-muted-foreground" />
38
+ </div>
39
+ )}
40
+ {previewUrl ? (
41
+ <ImageChipContent label={label} previewUrl={previewUrl} onRemove={onRemove} />
42
+ ) : (
43
+ <LabelChipContent label={label} icon={icon} onRemove={onRemove} />
44
+ )}
45
+ {children}
46
+ </div>
47
+ )
48
+ }
49
+
50
+ type LabelChipContentProps = Pick<AttachmentChipProps, 'label' | 'icon' | 'onRemove'>
51
+
52
+ function LabelChipContent({ label, icon: IconComponent, onRemove }: LabelChipContentProps) {
53
+ return (
54
+ <>
55
+ {onRemove ? (
56
+ <Button
57
+ type="button"
58
+ variant="ghost"
59
+ size="icon-sm"
60
+ onClick={onRemove}
61
+ aria-label={`Remove ${label}`}
62
+ className="size-6 shrink-0 hover:bg-transparent hover:text-current"
63
+ >
64
+ <IconComponent stroke={1.75} className="group-focus-within:hidden group-hover:hidden" />
65
+ <IconX stroke={1.75} className="hidden group-focus-within:block group-hover:block" />
66
+ </Button>
67
+ ) : (
68
+ <span className="flex size-6 shrink-0 items-center justify-center">
69
+ <IconComponent size={16} stroke={1.75} />
70
+ </span>
71
+ )}
72
+ <span className="truncate">{label}</span>
73
+ </>
74
+ )
75
+ }
76
+
77
+ type ImageChipContentProps = Pick<AttachmentChipProps, 'label' | 'onRemove'> & {
78
+ previewUrl: string
79
+ }
80
+
81
+ function ImageChipContent({ label, previewUrl, onRemove }: ImageChipContentProps) {
82
+ return (
83
+ <>
84
+ <img src={previewUrl} alt={label} className="size-full object-cover" />
85
+ {onRemove && (
86
+ <Button
87
+ type="button"
88
+ variant="outline"
89
+ size="icon-sm"
90
+ onClick={onRemove}
91
+ aria-label={`Remove ${label}`}
92
+ className="absolute top-1 right-1 size-4 rounded-xs border-0 opacity-0 shadow-xs transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 [&_svg]:size-3"
93
+ >
94
+ <IconX stroke={1.75} />
95
+ </Button>
96
+ )}
97
+ </>
98
+ )
99
+ }
@@ -0,0 +1,37 @@
1
+ import { IconScribble } from '@tabler/icons-react'
2
+ import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
3
+ import type { StagedAttachment } from './types'
4
+ import { AttachmentChip } from './AttachmentChip'
5
+
6
+ type DrawingAttachmentChipProps = {
7
+ attachment: Extract<StagedAttachment, { kind: 'drawing' }>
8
+ onRemove: () => void
9
+ }
10
+
11
+ export function DrawingAttachmentChip({ attachment, onRemove }: DrawingAttachmentChipProps) {
12
+ const { previewUrl, purpose } = attachment
13
+ const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
14
+
15
+ return (
16
+ <HoverCard>
17
+ <HoverCardTrigger
18
+ render={
19
+ <AttachmentChip tabIndex={0} label={label} icon={IconScribble} onRemove={onRemove} />
20
+ }
21
+ />
22
+ {previewUrl && (
23
+ <HoverCardContent
24
+ side="top"
25
+ align="start"
26
+ className="w-60 max-w-[calc(100vw-2rem)] rounded-xl"
27
+ >
28
+ <img
29
+ src={previewUrl}
30
+ alt={`${label} preview`}
31
+ className="max-h-72 w-full rounded-md object-contain"
32
+ />
33
+ </HoverCardContent>
34
+ )}
35
+ </HoverCard>
36
+ )
37
+ }
@@ -0,0 +1,22 @@
1
+ import { IconFile } from '@tabler/icons-react'
2
+ import type { StagedAttachment } from './types'
3
+ import { AttachmentChip } from './AttachmentChip'
4
+
5
+ type FileAttachmentChipProps = {
6
+ attachment: Extract<StagedAttachment, { kind: 'file' }>
7
+ onRemove: () => void
8
+ }
9
+
10
+ export function FileAttachmentChip({ attachment, onRemove }: FileAttachmentChipProps) {
11
+ return (
12
+ <AttachmentChip
13
+ label={attachment.label}
14
+ icon={IconFile}
15
+ onRemove={onRemove}
16
+ previewUrl={attachment.previewUrl}
17
+ loading={attachment.status === 'uploading'}
18
+ title={attachment.label}
19
+ className="max-w-52"
20
+ />
21
+ )
22
+ }
@@ -0,0 +1,11 @@
1
+ import { IconLibrary } from '@tabler/icons-react'
2
+ import { AttachmentChip } from './AttachmentChip'
3
+
4
+ type TextAttachmentChipProps = {
5
+ label: string
6
+ onRemove?: () => void
7
+ }
8
+
9
+ export function TextAttachmentChip({ label, onRemove }: TextAttachmentChipProps) {
10
+ return <AttachmentChip label={label} icon={IconLibrary} onRemove={onRemove} />
11
+ }