moi-computer 0.11.0 → 0.11.1-dev.be1ed10

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 (362) hide show
  1. package/README.md +2 -2
  2. package/client/AGENTS.md +2 -2
  3. package/client/app/AppRouter.tsx +2 -2
  4. package/client/app/routes/WorkspaceRoute.tsx +7 -9
  5. package/client/app/shell/SidebarLayout.tsx +18 -15
  6. package/client/components/shared/BottomPanel.tsx +26 -14
  7. package/client/components/shared/PanelHeader.tsx +1 -1
  8. package/client/components/shared/ReorderableList.tsx +7 -2
  9. package/client/components/shared/WorkspaceIcon.tsx +92 -0
  10. package/client/components/ui/alert-dialog.tsx +1 -0
  11. package/client/components/ui/button.tsx +1 -53
  12. package/client/components/ui/checkbox.tsx +1 -0
  13. package/client/components/ui/collapsible.tsx +1 -15
  14. package/client/components/ui/dialog.tsx +1 -58
  15. package/client/components/ui/dropdown-menu.tsx +1 -254
  16. package/client/components/ui/hover-card.tsx +1 -44
  17. package/client/components/ui/inline-input.tsx +84 -0
  18. package/client/components/ui/input.tsx +1 -21
  19. package/client/components/ui/popover.tsx +1 -88
  20. package/client/components/ui/resizable.tsx +1 -40
  21. package/client/components/ui/skeleton.tsx +1 -13
  22. package/client/components/ui/slider.tsx +1 -70
  23. package/client/components/ui/spinner.tsx +1 -18
  24. package/client/components/ui/switch.tsx +1 -23
  25. package/client/components/ui/tabs.tsx +1 -0
  26. package/client/components/ui/textarea.tsx +1 -18
  27. package/client/components/ui/toast.tsx +2 -2
  28. package/client/components/ui/tooltip.tsx +1 -51
  29. package/client/features/applets/AppletMount.tsx +1 -1
  30. package/client/features/applets/applet-cache.ts +3 -3
  31. package/client/features/applets/applet-runtime.ts +147 -108
  32. package/client/features/applets/applet-styles.ts +2 -2
  33. package/client/features/applets/applet-thumbnail.ts +6 -8
  34. package/client/features/applets/useApplet.ts +10 -9
  35. package/client/features/chat/ChatPanel.tsx +24 -15
  36. package/client/features/chat/ChatPopup.tsx +9 -5
  37. package/client/features/chat/applet-chat-intents.ts +170 -0
  38. package/client/features/chat/chat-send.ts +116 -64
  39. package/client/features/chat/chat-store.ts +51 -62
  40. package/client/features/chat/composer/ChatComposer.tsx +43 -128
  41. package/client/features/chat/composer/ModelPicker.tsx +47 -60
  42. package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
  43. package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
  44. package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
  45. package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
  46. package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
  47. package/client/features/chat/composer/attachments/types.ts +25 -0
  48. package/client/features/chat/composer/attachments/uploads.ts +26 -0
  49. package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
  50. package/client/features/chat/composer/model-order.ts +15 -0
  51. package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
  52. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  53. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
  54. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  55. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  56. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
  57. package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
  58. package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
  59. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  60. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  61. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
  62. package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
  63. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  64. package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
  65. package/client/features/chat/sessions/session-view.ts +53 -0
  66. package/client/features/chat/useChat.ts +42 -24
  67. package/client/features/dev/ChatStatesPage.tsx +8 -7
  68. package/client/features/dev/DevIndexPage.tsx +5 -0
  69. package/client/features/dev/DevRoutes.tsx +2 -0
  70. package/client/features/dev/HarnessDebugPage.tsx +11 -8
  71. package/client/features/dev/ToolCallsPage.tsx +1 -1
  72. package/client/features/dev/UiComponentPreviews.tsx +855 -0
  73. package/client/features/dev/UiComponentsPage.tsx +60 -0
  74. package/client/features/dev/chat-states-fixtures.ts +13 -2
  75. package/client/features/drawings/useChatAnnotation.ts +17 -17
  76. package/client/features/drawings/useDrawingLayer.ts +7 -9
  77. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  78. package/client/features/home/HomePage.tsx +8 -7
  79. package/client/features/home/WorkspacePreview.tsx +2 -2
  80. package/client/features/home/workspace-presentation.tsx +1 -11
  81. package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
  82. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
  83. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  84. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
  85. package/client/features/overview/HiddenPanel.tsx +109 -0
  86. package/client/features/overview/Overview.tsx +302 -0
  87. package/client/features/overview/WidgetCanvas.tsx +164 -0
  88. package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
  89. package/client/features/overview/WorkspaceName.tsx +60 -0
  90. package/client/features/overview/api.ts +30 -0
  91. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  92. package/client/features/overview/default/registry.tsx +36 -0
  93. package/client/features/{widgets → overview}/grid.ts +36 -0
  94. package/client/features/overview/useGridReconcile.ts +94 -0
  95. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  96. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  97. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  98. package/client/features/settings/GeneralSettings.tsx +55 -58
  99. package/client/features/settings/SettingsLayout.tsx +2 -2
  100. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  101. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  102. package/client/features/settings/api.ts +48 -24
  103. package/client/features/views/ViewBuilder.tsx +5 -4
  104. package/client/features/views/ViewManager.tsx +25 -22
  105. package/client/features/views/api.ts +36 -2
  106. package/client/features/views/useViewBuilderActions.ts +8 -5
  107. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  108. package/client/features/views/view-presentation.ts +13 -0
  109. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  110. package/client/features/workspace/UnavailablePage.tsx +21 -0
  111. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  112. package/client/features/workspace/WorkspaceScreen.tsx +210 -162
  113. package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
  114. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  115. package/client/features/workspace/api.ts +2 -30
  116. package/client/features/workspace/moi-context.ts +8 -9
  117. package/client/features/workspace/tab-resolution.ts +10 -33
  118. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  119. package/client/index.css +23 -30
  120. package/client/lib/app-icon-registry.ts +2 -0
  121. package/client/lib/use-latest-ref.ts +11 -0
  122. package/client/main.tsx +1 -1
  123. package/client/runtime/useWorkspaceEvents.ts +59 -14
  124. package/client/theme.css +5 -5
  125. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  126. package/dist/chunk-691pqsj6.js +2 -0
  127. package/dist/chunk-7a5nm4k9.css +1 -0
  128. package/dist/chunk-amb8y04y.js +1 -0
  129. package/dist/chunk-cf3pgy7j.js +546 -0
  130. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  131. package/dist/chunk-mzrgr577.js +5 -0
  132. package/dist/chunk-nf2wkvf9.js +14 -0
  133. package/dist/chunk-q6a0g26x.js +1 -0
  134. package/dist/chunk-twgdemkc.js +74 -0
  135. package/dist/chunk-x90k0f5c.js +2 -0
  136. package/dist/chunk-yq00csvd.js +2 -0
  137. package/dist/index.html +1 -1
  138. package/lib/app-icons.ts +1 -0
  139. package/lib/applet-selector.ts +24 -0
  140. package/lib/chat-title.ts +6 -1
  141. package/lib/default-widgets.ts +32 -0
  142. package/lib/format.ts +67 -7
  143. package/lib/message-attachments.ts +40 -0
  144. package/lib/moi-attachments.ts +204 -0
  145. package/lib/moi-context.ts +20 -35
  146. package/lib/navigation.ts +84 -0
  147. package/lib/themes.ts +6 -6
  148. package/lib/types.ts +91 -34
  149. package/lib/workspace-icon.ts +20 -0
  150. package/lib/workspace-layout.ts +22 -2
  151. package/lib/workspace-tabs.ts +9 -33
  152. package/package.json +42 -32
  153. package/registry.json +656 -0
  154. package/server/AGENTS.md +2 -0
  155. package/server/agent.ts +1 -1
  156. package/server/api.ts +139 -66
  157. package/server/applet-typecheck.ts +95 -0
  158. package/server/applets/applet-css.ts +55 -0
  159. package/server/{bundler → applets}/build-applet.ts +13 -242
  160. package/server/applets/build-worker.ts +178 -0
  161. package/server/applets/config.ts +226 -0
  162. package/server/applets/dependencies.ts +206 -0
  163. package/server/{applets.ts → applets/index.ts} +44 -189
  164. package/server/applets/runtime/base.ts +4 -0
  165. package/server/applets/runtime/moi.ts +42 -0
  166. package/server/applets/runtime/rpc.ts +17 -0
  167. package/server/applets/view-source.ts +67 -0
  168. package/server/attachment-message.ts +95 -0
  169. package/server/cli-ui-components.ts +28 -33
  170. package/server/cli.ts +169 -108
  171. package/server/control.ts +63 -42
  172. package/server/data-dir.ts +1 -1
  173. package/server/harness/README.md +45 -50
  174. package/server/harness/acp/NOTES.md +426 -0
  175. package/server/harness/acp/adapter.ts +7 -21
  176. package/server/harness/acp/discovery.ts +27 -30
  177. package/server/harness/acp/model-state.ts +57 -0
  178. package/server/harness/acp/session.ts +49 -56
  179. package/server/harness/claude-code/NOTES.md +54 -13
  180. package/server/harness/claude-code/adapter.ts +8 -25
  181. package/server/harness/claude-code/cli.ts +40 -0
  182. package/server/harness/claude-code/index.ts +13 -5
  183. package/server/harness/claude-code/models.ts +72 -19
  184. package/server/harness/claude-code/session.ts +447 -343
  185. package/server/harness/claude-code/sessions.ts +9 -4
  186. package/server/harness/codex/NOTES.md +222 -350
  187. package/server/harness/codex/adapter.ts +102 -52
  188. package/server/harness/codex/auth.ts +1 -3
  189. package/server/harness/codex/client.ts +169 -249
  190. package/server/harness/codex/discovery.ts +9 -17
  191. package/server/harness/codex/index.ts +3 -1
  192. package/server/harness/codex/pagination.ts +24 -0
  193. package/server/harness/codex/permissions.ts +32 -8
  194. package/server/harness/codex/probe.ts +10 -13
  195. package/server/harness/codex/session.ts +567 -181
  196. package/server/harness/codex/transport.ts +184 -0
  197. package/server/harness/debug.ts +1 -1
  198. package/server/harness/hermes/NOTES.md +19 -1
  199. package/server/harness/hermes/discovery.ts +20 -0
  200. package/server/harness/hermes/index.ts +13 -0
  201. package/server/harness/hermes/models.ts +28 -8
  202. package/server/harness/openclaw/NOTES.md +1 -1
  203. package/server/harness/openclaw/adapter.ts +22 -4
  204. package/server/harness/openclaw/gateway.ts +5 -3
  205. package/server/harness/openclaw/session.ts +27 -27
  206. package/server/harness/types.ts +9 -5
  207. package/server/layout.ts +9 -14
  208. package/server/moi-scaffold.ts +22 -14
  209. package/server/navigation-relay.ts +110 -0
  210. package/server/preview.ts +3 -1
  211. package/server/registry.ts +71 -41
  212. package/server/scratchpad-executor.ts +79 -56
  213. package/server/scratchpad-shape-defaults.ts +82 -0
  214. package/server/selected-session.ts +24 -4
  215. package/server/skill-update.ts +5 -3
  216. package/server/skill-version.ts +4 -7
  217. package/server/skills-template.ts +48 -9
  218. package/server/tabs.ts +19 -33
  219. package/server/tldraw-package.d.ts +4 -0
  220. package/server/ui-components.ts +101 -434
  221. package/server/uploads.ts +0 -0
  222. package/server/view-builders.ts +20 -2
  223. package/server/views.ts +126 -6
  224. package/server/web.ts +46 -13
  225. package/server/widgets.ts +12 -5
  226. package/server/workspace-config.ts +13 -9
  227. package/server/workspace-env.ts +3 -2
  228. package/tsconfig.json +0 -1
  229. package/ui-components/accordion.tsx +71 -0
  230. package/ui-components/alert-dialog.tsx +165 -0
  231. package/ui-components/alert.tsx +68 -0
  232. package/ui-components/attachment.tsx +195 -0
  233. package/ui-components/avatar.tsx +90 -0
  234. package/ui-components/badge.tsx +49 -0
  235. package/ui-components/button-group.tsx +78 -0
  236. package/ui-components/button.tsx +55 -0
  237. package/ui-components/calendar.tsx +180 -0
  238. package/ui-components/card.tsx +84 -0
  239. package/ui-components/carousel.tsx +235 -0
  240. package/ui-components/chart.tsx +338 -0
  241. package/ui-components/checkbox.tsx +28 -0
  242. package/ui-components/collapsible.tsx +15 -0
  243. package/ui-components/combobox.tsx +267 -0
  244. package/ui-components/context-menu.tsx +244 -0
  245. package/ui-components/dialog.tsx +138 -0
  246. package/ui-components/docs/accordion.md +463 -0
  247. package/ui-components/docs/alert-dialog.md +481 -0
  248. package/ui-components/docs/alert.md +301 -0
  249. package/ui-components/docs/attachment.md +689 -0
  250. package/ui-components/docs/avatar.md +495 -0
  251. package/ui-components/docs/badge.md +258 -0
  252. package/ui-components/docs/button-group.md +879 -0
  253. package/ui-components/docs/button.md +26 -0
  254. package/ui-components/docs/calendar.md +862 -0
  255. package/ui-components/docs/card.md +265 -0
  256. package/ui-components/docs/carousel.md +627 -0
  257. package/ui-components/docs/chart.md +1256 -0
  258. package/ui-components/docs/checkbox.md +477 -0
  259. package/ui-components/docs/collapsible.md +446 -0
  260. package/ui-components/docs/combobox.md +1003 -0
  261. package/ui-components/docs/context-menu.md +860 -0
  262. package/ui-components/docs/data-table.md +1580 -0
  263. package/ui-components/docs/date-picker.md +614 -0
  264. package/ui-components/docs/dialog.md +414 -0
  265. package/ui-components/docs/drawer.md +51 -0
  266. package/ui-components/docs/dropdown-menu.md +1000 -0
  267. package/ui-components/docs/field.md +1192 -0
  268. package/ui-components/docs/hover-card.md +275 -0
  269. package/ui-components/docs/input-group.md +866 -0
  270. package/ui-components/docs/input.md +456 -0
  271. package/ui-components/docs/kbd.md +191 -0
  272. package/ui-components/docs/label.md +295 -0
  273. package/ui-components/docs/pagination.md +416 -0
  274. package/ui-components/docs/popover.md +348 -0
  275. package/ui-components/docs/progress.md +214 -0
  276. package/ui-components/docs/radio-group.md +389 -0
  277. package/ui-components/docs/resizable.md +265 -0
  278. package/ui-components/docs/select.md +616 -0
  279. package/ui-components/docs/separator.md +216 -0
  280. package/ui-components/docs/skeleton.md +205 -0
  281. package/ui-components/docs/slider.md +226 -0
  282. package/ui-components/docs/spinner.md +332 -0
  283. package/ui-components/docs/switch.md +236 -0
  284. package/ui-components/docs/table.md +551 -0
  285. package/ui-components/docs/tabs.md +379 -0
  286. package/ui-components/docs/textarea.md +187 -0
  287. package/ui-components/docs/toggle-group.md +370 -0
  288. package/ui-components/docs/toggle.md +91 -0
  289. package/ui-components/docs/tooltip.md +290 -0
  290. package/ui-components/drawer.tsx +213 -0
  291. package/ui-components/dropdown-menu.tsx +263 -0
  292. package/ui-components/field.tsx +224 -0
  293. package/ui-components/hover-card.tsx +46 -0
  294. package/ui-components/input-group.tsx +146 -0
  295. package/ui-components/input.tsx +20 -0
  296. package/ui-components/kbd.tsx +32 -0
  297. package/ui-components/label.tsx +17 -0
  298. package/ui-components/pagination.tsx +124 -0
  299. package/ui-components/popover.tsx +81 -0
  300. package/ui-components/progress.tsx +63 -0
  301. package/ui-components/radio-group.tsx +38 -0
  302. package/ui-components/resizable.tsx +40 -0
  303. package/ui-components/scoped-portal.tsx +31 -0
  304. package/ui-components/select.tsx +195 -0
  305. package/ui-components/separator.tsx +18 -0
  306. package/ui-components/skeleton.tsx +15 -0
  307. package/ui-components/slider.tsx +75 -0
  308. package/ui-components/spinner.tsx +20 -0
  309. package/ui-components/switch.tsx +27 -0
  310. package/ui-components/table.tsx +86 -0
  311. package/ui-components/tabs.tsx +75 -0
  312. package/ui-components/textarea.tsx +17 -0
  313. package/ui-components/toggle-group.tsx +85 -0
  314. package/ui-components/toggle.tsx +42 -0
  315. package/ui-components/tooltip.tsx +61 -0
  316. package/ui-components/utils.ts +8 -0
  317. package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
  318. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
  319. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  320. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
  321. package/client/features/chat/attachment-staging.ts +0 -153
  322. package/client/features/chat/uploads.ts +0 -18
  323. package/client/features/chat/useAppletChatMessage.ts +0 -68
  324. package/client/features/settings/IconPicker.tsx +0 -442
  325. package/client/features/settings/WorkspaceSettings.tsx +0 -92
  326. package/client/features/settings/render-icon.ts +0 -173
  327. package/client/features/widgets/HiddenPanel.tsx +0 -80
  328. package/client/features/widgets/WidgetGrid.tsx +0 -123
  329. package/client/features/widgets/Widgets.tsx +0 -264
  330. package/client/features/widgets/useGridReconcile.ts +0 -73
  331. package/dist/chunk-104m57qw.js +0 -2
  332. package/dist/chunk-59zf0m6n.js +0 -1
  333. package/dist/chunk-bj3akjs2.js +0 -1
  334. package/dist/chunk-c9pjqx9m.js +0 -14
  335. package/dist/chunk-j2w2vak4.js +0 -546
  336. package/dist/chunk-k2r9c95m.js +0 -10
  337. package/dist/chunk-kmbxhgwv.js +0 -1
  338. package/dist/chunk-p1yqa71k.js +0 -83
  339. package/dist/chunk-pcnahct1.js +0 -5
  340. package/dist/chunk-r5xrenjy.css +0 -1
  341. package/dist/chunk-tny85yt2.js +0 -2
  342. package/dist/chunk-v7wr1df4.js +0 -2
  343. package/server/bundler/applet-css.ts +0 -155
  344. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  345. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  346. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  347. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  348. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  349. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  350. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  351. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  352. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  353. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  354. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  355. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  356. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  357. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  358. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  359. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  360. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  361. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  362. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
@@ -1,41 +1,8 @@
1
+ import type { StagedAttachment, StagedAttachmentPatch } from './composer/attachments/types'
1
2
  import { useStore } from 'zustand'
2
3
  import { createStore } from 'zustand/vanilla'
3
4
 
4
- import type {
5
- PreviewBlock,
6
- PreviewFrame,
7
- SessionActivity,
8
- UploadInfo,
9
- WorkspaceTabId
10
- } from '@/lib/types'
11
-
12
- // One composer attachment, tracked per session until the message is sent. A
13
- // file uploads as soon as it's added (drop/paste/pick); an annotation stays a
14
- // local `draft` while it's being drawn and uploads once when the drawing
15
- // session ends. `status` reflects that lifecycle, and `upload` holds the server
16
- // handle once ready. `previewUrl` is a local object URL for image thumbnails
17
- // (revoked on remove/clear).
18
- type ChatAttachmentBase = {
19
- localId: string
20
- name: string
21
- mediaType: string
22
- previewUrl?: string
23
- status: 'draft' | 'uploading' | 'ready' | 'error'
24
- upload?: UploadInfo
25
- error?: string
26
- }
27
-
28
- export type DrawingPurpose = 'annotation' | 'sketch'
29
-
30
- export type ChatAttachment = ChatAttachmentBase &
31
- (
32
- | { kind: 'file'; purpose?: never; sourceTab?: never }
33
- | { kind: 'drawing'; purpose: DrawingPurpose; sourceTab: WorkspaceTabId }
34
- )
35
-
36
- type ChatAttachmentPatch = Partial<
37
- Pick<ChatAttachmentBase, 'name' | 'mediaType' | 'previewUrl' | 'status' | 'upload' | 'error'>
38
- >
5
+ import type { PreviewBlock, PreviewFrame, SessionActivity } from '@/lib/types'
39
6
 
40
7
  // App-level ephemeral chat state — the bits that are *pushed* from the server
41
8
  // over the WebSocket and can't be re-fetched as request/response data:
@@ -112,9 +79,7 @@ export type LivePreview = {
112
79
  }
113
80
 
114
81
  export type LiveStore = {
115
- // Per-session activity mirrored from server `status` frames. Only `running`
116
- // shows the loader/Stop; `requires-action` is tracked but not rendered yet.
117
- // Missing key = idle.
82
+ // Per-session activity mirrored from server `status` frames. Missing key = idle.
118
83
  activity: Record<string, SessionActivity>
119
84
  errors: Record<string, string | null>
120
85
  // Live token-streaming previews, keyed by `messageId` (the API `msg_...` id)
@@ -123,7 +88,7 @@ export type LiveStore = {
123
88
  previews: Record<string, LivePreview>
124
89
  // Composer attachments are per chat, survive composer remounts, and clear on
125
90
  // send. Draft text is workspace-local persisted UI state (client/store/ui).
126
- attachments: Record<string, ChatAttachment[]>
91
+ attachments: Record<string, StagedAttachment[]>
127
92
 
128
93
  setActivity: (workspaceId: string, sessionId: string, value: SessionActivity) => void
129
94
  // Authoritative reconcile from a server `status_snapshot`: exactly the listed
@@ -133,16 +98,12 @@ export type LiveStore = {
133
98
  sessions: { workspaceId: string; sessionId: string; activity: SessionActivity }[]
134
99
  ) => void
135
100
  setError: (workspaceId: string, sessionId: string, message: string | null) => void
136
- addAttachments: (workspaceId: string, sessionId: string | null, items: ChatAttachment[]) => void
137
- updateAttachment: (
138
- workspaceId: string,
139
- sessionId: string | null,
140
- localId: string,
141
- patch: ChatAttachmentPatch
142
- ) => void
143
- removeAttachment: (workspaceId: string, sessionId: string | null, localId: string) => void
101
+ addAttachments: (workspaceId: string, sessionId: string | null, items: StagedAttachment[]) => void
102
+ updateAttachment: (workspaceId: string, localId: string, patch: StagedAttachmentPatch) => void
103
+ removeAttachment: (workspaceId: string, localId: string) => void
144
104
  clearAttachments: (workspaceId: string, sessionId: string | null) => void
145
- renameSession: (workspaceId: string, from: string, to: string) => void
105
+ // `null` assigns the new-chat draft its first session id.
106
+ renameSession: (workspaceId: string, from: string | null, to: string) => void
146
107
 
147
108
  // Upsert a preview snapshot (last write wins — blocks are cumulative).
148
109
  setPreview: (frame: Omit<PreviewFrame, 'type'>) => void
@@ -158,6 +119,19 @@ export type LiveStore = {
158
119
  sweepPreviews: (maxAgeMs: number, now: number) => void
159
120
  }
160
121
 
122
+ // Stable IDs keep asynchronous attachment work attached to a renamed session.
123
+ export function findAttachment(
124
+ attachments: LiveStore['attachments'],
125
+ workspaceId: string,
126
+ localId: string
127
+ ) {
128
+ for (const [key, items] of Object.entries(attachments)) {
129
+ if (!key.startsWith(`${workspaceId}:`)) continue
130
+ const attachment = items.find(item => item.localId === localId)
131
+ if (attachment) return { key, attachment }
132
+ }
133
+ }
134
+
161
135
  export const liveStore = createStore<LiveStore>()(set => ({
162
136
  activity: {},
163
137
  errors: {},
@@ -226,30 +200,35 @@ export const liveStore = createStore<LiveStore>()(set => ({
226
200
  return { attachments: { ...s.attachments, [k]: [...(s.attachments[k] ?? []), ...items] } }
227
201
  }),
228
202
 
229
- updateAttachment: (workspaceId, sessionId, localId, patch) =>
203
+ updateAttachment: (workspaceId, localId, patch) =>
230
204
  set(s => {
231
- const k = attachmentKey(workspaceId, sessionId)
205
+ const found = findAttachment(s.attachments, workspaceId, localId)
206
+ if (!found) return {}
207
+ const { key: k, attachment: target } = found
232
208
  const list = s.attachments[k]
233
- if (!list) return {}
234
- const target = list.find(attachment => attachment.localId === localId)
235
- if (target?.previewUrl && 'previewUrl' in patch && patch.previewUrl !== target.previewUrl) {
209
+ if (
210
+ target.kind !== 'text' &&
211
+ target.previewUrl &&
212
+ 'previewUrl' in patch &&
213
+ patch.previewUrl !== target.previewUrl
214
+ ) {
236
215
  URL.revokeObjectURL(target.previewUrl)
237
216
  }
238
217
  return {
239
218
  attachments: {
240
219
  ...s.attachments,
241
- [k]: list.map(a => (a.localId === localId ? { ...a, ...patch } : a))
220
+ [k]: list.map(a => (a.localId === localId && a.kind !== 'text' ? { ...a, ...patch } : a))
242
221
  }
243
222
  }
244
223
  }),
245
224
 
246
- removeAttachment: (workspaceId, sessionId, localId) =>
225
+ removeAttachment: (workspaceId, localId) =>
247
226
  set(s => {
248
- const k = attachmentKey(workspaceId, sessionId)
227
+ const found = findAttachment(s.attachments, workspaceId, localId)
228
+ if (!found) return {}
229
+ const { key: k, attachment: target } = found
249
230
  const list = s.attachments[k]
250
- if (!list) return {}
251
- const target = list.find(a => a.localId === localId)
252
- if (target?.previewUrl) URL.revokeObjectURL(target.previewUrl)
231
+ if (target.kind !== 'text' && target.previewUrl) URL.revokeObjectURL(target.previewUrl)
253
232
  return { attachments: { ...s.attachments, [k]: list.filter(a => a.localId !== localId) } }
254
233
  }),
255
234
 
@@ -257,7 +236,7 @@ export const liveStore = createStore<LiveStore>()(set => ({
257
236
  set(s => {
258
237
  const k = attachmentKey(workspaceId, sessionId)
259
238
  for (const a of s.attachments[k] ?? []) {
260
- if (a.previewUrl) URL.revokeObjectURL(a.previewUrl)
239
+ if (a.kind !== 'text' && a.previewUrl) URL.revokeObjectURL(a.previewUrl)
261
240
  }
262
241
  const next = { ...s.attachments }
263
242
  delete next[k]
@@ -266,7 +245,7 @@ export const liveStore = createStore<LiveStore>()(set => ({
266
245
 
267
246
  renameSession: (workspaceId, from, to) =>
268
247
  set(s => {
269
- const fromKey = key(workspaceId, from)
248
+ const fromKey = attachmentKey(workspaceId, from)
270
249
  const toKey = key(workspaceId, to)
271
250
  const activity = { ...s.activity }
272
251
  const errors = { ...s.errors }
@@ -291,7 +270,17 @@ export const liveStore = createStore<LiveStore>()(set => ({
291
270
  previews[id] = { ...p, sessionId: to }
292
271
  }
293
272
  }
294
- return { activity, errors, previews }
273
+ // Upload completions use stable attachment IDs, so every draft item can
274
+ // follow the chat through both temporary and provider session IDs.
275
+ let attachments = s.attachments
276
+ if (fromKey !== toKey && attachments[fromKey]) {
277
+ attachments = {
278
+ ...attachments,
279
+ [toKey]: [...(attachments[toKey] ?? []), ...attachments[fromKey]]
280
+ }
281
+ delete attachments[fromKey]
282
+ }
283
+ return { activity, errors, previews, attachments }
295
284
  })
296
285
  }))
297
286
 
@@ -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,107 +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 side="top" align="start" className="w-60 max-w-[calc(100vw-2rem)]">
368
- <img
369
- src={previewUrl}
370
- alt={`${label} preview`}
371
- className="max-h-72 w-full rounded-md object-contain"
372
- />
373
- </HoverCardContent>
374
- )}
375
- </HoverCard>
376
- )
287
+ const EMPTY: StagedAttachment[] = []
288
+ const ATTACHMENT_ORDER: Record<StagedAttachment['kind'], number> = {
289
+ file: 0,
290
+ drawing: 1,
291
+ text: 2
377
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'
@@ -36,19 +37,6 @@ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayo
36
37
  import { cn } from '@/client/lib/cn'
37
38
  import type { Model } from '@/lib/types'
38
39
 
39
- // Models describe themselves with a " · "-joined blurb; we show only the
40
- // headline (e.g. "Opus 4.8 with 1M context · Most capable…" → "Opus 4.8 with 1M context").
41
- function headline(description?: string): string {
42
- return description?.split(/\s*·\s*/)[0] ?? ''
43
- }
44
-
45
- // Row and trigger label. Claude's description headline names the model better
46
- // than its `displayName` ("Sonnet 4.6 with 1M context" vs "Sonnet"); backends
47
- // without one fall back to the name.
48
- function modelLabel(model: Model): string {
49
- return headline(model.description) || model.displayName
50
- }
51
-
52
40
  function capitalize(s: string): string {
53
41
  return s.charAt(0).toUpperCase() + s.slice(1)
54
42
  }
@@ -99,7 +87,7 @@ type ModelDropdownProps = {
99
87
  }
100
88
 
101
89
  function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownProps) {
102
- const label = modelLabel(model)
90
+ const label = model.displayName
103
91
  const groups = groupModels(models, 'Models')
104
92
 
105
93
  return (
@@ -114,7 +102,7 @@ function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownP
114
102
  <DropdownMenuLabel>{group.label}</DropdownMenuLabel>
115
103
  {group.models.map(item => (
116
104
  <DropdownMenuRadioItem key={item.value} value={item.value} closeOnClick>
117
- {modelLabel(item)}
105
+ {item.displayName}
118
106
  </DropdownMenuRadioItem>
119
107
  ))}
120
108
  </DropdownMenuGroup>
@@ -125,6 +113,38 @@ function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownP
125
113
  )
126
114
  }
127
115
 
116
+ type FastModeToggleProps = { fastMode: boolean; onChange: (value: boolean) => void }
117
+
118
+ function FastModeToggle({ fastMode, onChange }: FastModeToggleProps) {
119
+ return (
120
+ <Tooltip>
121
+ <TooltipTrigger
122
+ render={
123
+ <Button
124
+ type="button"
125
+ variant="ghost"
126
+ size="icon-sm"
127
+ aria-label={fastMode ? 'Turn off fast mode' : 'Turn on fast mode'}
128
+ aria-pressed={fastMode}
129
+ onClick={() => onChange(!fastMode)}
130
+ className="-my-1 -mr-1"
131
+ >
132
+ {fastMode ? (
133
+ <IconBoltFilled className="text-primary" stroke={1.75} />
134
+ ) : (
135
+ <IconBolt className="text-muted-foreground" stroke={1.75} />
136
+ )}
137
+ </Button>
138
+ }
139
+ />
140
+ <TooltipContent align="center" className="flex-col gap-0">
141
+ <span>Fast mode</span>
142
+ <span className="font-normal text-muted-foreground">More usage</span>
143
+ </TooltipContent>
144
+ </Tooltip>
145
+ )
146
+ }
147
+
128
148
  type EffortPickerProps = {
129
149
  currentEffort: string
130
150
  effortLevels: readonly string[]
@@ -172,7 +192,7 @@ function EffortPicker({
172
192
  />
173
193
  }
174
194
  />
175
- <PopoverContent align="end" side="top" className="w-64" disableAnchorTracking>
195
+ <PopoverContent align="end" side="top" className="w-64">
176
196
  <PopoverHeader className="relative h-5 flex-row items-center">
177
197
  <AnimatePresence mode="popLayout" initial={false}>
178
198
  {dragging ? (
@@ -203,33 +223,7 @@ function EffortPicker({
203
223
  <span className="text-muted-foreground">Effort</span>
204
224
  <output aria-live="polite">{displayedLabel}</output>
205
225
  </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
- )}
226
+ {showFastMode && <FastModeToggle fastMode={fastMode} onChange={onFastModeChange} />}
233
227
  </motion.div>
234
228
  )}
235
229
  </AnimatePresence>
@@ -237,7 +231,7 @@ function EffortPicker({
237
231
  <label className="block">
238
232
  <span className="sr-only">Reasoning effort</span>
239
233
  <Slider
240
- value={draftIndex}
234
+ value={[draftIndex]}
241
235
  min={0}
242
236
  max={effortLevels.length - 1}
243
237
  step={1}
@@ -252,8 +246,9 @@ function EffortPicker({
252
246
  }}
253
247
  className={cn(
254
248
  '**:data-[slot=slider-track]:h-6 **:data-[slot=slider-track]:rounded-sm',
255
- '**:data-[slot=slider-thumb]:h-6 **:data-[slot=slider-thumb]:w-5 **:data-[slot=slider-thumb]:rounded-sm **:data-[slot=slider-thumb]:border-0 **:data-[slot=slider-thumb]:bg-card **:data-[slot=slider-thumb]:shadow-xs **:data-[slot=slider-thumb]:ring-0'
249
+ '**:data-[slot=slider-thumb]:h-6 **:data-[slot=slider-thumb]:w-5 **:data-[slot=slider-thumb]:rounded-sm **:data-[slot=slider-thumb]:ring-0'
256
250
  )}
251
+ animate
257
252
  >
258
253
  <span
259
254
  data-slot="slider-marks"
@@ -323,19 +318,8 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
323
318
  else setLayout({ selectedFastMode: value })
324
319
  }
325
320
 
326
- if (models.length === 0) return null
327
-
328
- // Show a persisted pick when it still exists. Otherwise name the concrete
329
- // model behind the SDK default, or fall back to the first available model.
330
- const persistedModel = models.some(model => model.value === selectedModel)
331
- ? selectedModel
332
- : undefined
333
- const defaultModel =
334
- models.find(
335
- model => defaultEntry?.resolvedModel && model.resolvedModel === defaultEntry.resolvedModel
336
- ) ?? models[0]
337
- const currentModelValue = persistedModel ?? defaultModel.value
338
- const model = models.find(item => item.value === currentModelValue) ?? models[0]
321
+ const model = resolveSelectedModel(models, selectedModel, defaultEntry?.resolvedModel)
322
+ if (!model) return null
339
323
  const effortLevels = model.supportsEffort ? (model.supportedEffortLevels ?? []) : []
340
324
  const currentEffort = resolveDisplayedEffort(effortLevels, selectedEffort, model.defaultEffort)
341
325
  const showEffort = hasEffortChoice(effortLevels) && currentEffort !== undefined
@@ -344,11 +328,14 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
344
328
  return (
345
329
  <div className="flex min-w-0 items-center gap-1">
346
330
  <ModelDropdown
347
- current={currentModelValue}
331
+ current={model.value}
348
332
  model={model}
349
333
  models={models}
350
334
  onValueChange={setSelectedModel}
351
335
  />
336
+ {!showEffort && model.supportsFastMode && (
337
+ <FastModeToggle fastMode={fastMode} onChange={setSelectedFastMode} />
338
+ )}
352
339
  {showEffort && (
353
340
  <EffortPicker
354
341
  key={model.value}