moi-computer 0.11.0 → 0.11.1-dev.1c52199
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.
- package/README.md +2 -2
- package/client/AGENTS.md +2 -2
- package/client/api/app-config.ts +2 -1
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +33 -27
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +5 -2
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +158 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +179 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +64 -20
- package/client/features/chat/useChat.ts +46 -24
- package/client/features/collab/DevCollabIdentity.tsx +170 -0
- package/client/features/collab/DevCollabKit.tsx +501 -0
- package/client/features/collab/DevCollabPage.tsx +25 -0
- package/client/features/collab/WorkspaceCollabControls.tsx +313 -0
- package/client/features/collab/client.ts +146 -0
- package/client/features/collab/components.tsx +307 -0
- package/client/features/collab/dev-persona.ts +66 -0
- package/client/features/collab/engine.ts +96 -0
- package/client/features/collab/entry.tsx +35 -0
- package/client/features/collab/facehash-avatar.ts +132 -0
- package/client/features/collab/fake-engine.ts +130 -0
- package/client/features/collab/hooks.tsx +253 -0
- package/client/features/collab/identity.ts +305 -0
- package/client/features/collab/index.ts +45 -0
- package/client/features/collab/people.ts +102 -0
- package/client/features/collab/personal-state.ts +61 -0
- package/client/features/collab/presence-publisher.ts +29 -0
- package/client/features/collab/presence-target.ts +10 -0
- package/client/features/collab/primitives.tsx +398 -0
- package/client/features/collab/proxy-identity.ts +24 -0
- package/client/features/collab/store.ts +156 -0
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +10 -0
- package/client/features/dev/DevRoutes.tsx +16 -1
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +28 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +11 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +22 -10
- package/client/features/workspace/WorkspaceScreen.tsx +228 -172
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +5 -31
- package/client/features/workspace/layout-save.ts +13 -0
- package/client/features/workspace/moi-context.ts +15 -11
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +173 -101
- package/client/index.css +23 -30
- package/client/index.tsx +4 -3
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/chunk-1ftessc8.js +2 -0
- package/dist/chunk-3802vh2p.js +2 -0
- package/dist/chunk-542a2m9m.js +1 -0
- package/dist/chunk-5745d83v.js +2 -0
- package/dist/chunk-5zxdsjym.js +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-7r4z77ry.js +2 -0
- package/dist/chunk-9cm0wjah.js +79 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-cvgdm1hq.js +2 -0
- package/dist/chunk-gptm4jpd.js +546 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-wnmf38ta.js +5 -0
- package/dist/chunk-xaehhr1j.css +1 -0
- package/dist/chunk-xpt063fx.js +1 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/collab/colors.ts +24 -0
- package/lib/collab/protocol.ts +83 -0
- package/lib/collab/types.ts +63 -0
- package/lib/default-widgets.ts +32 -0
- package/lib/experimental.ts +14 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +27 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +103 -40
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +44 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +162 -68
- package/server/app-config.ts +127 -34
- package/server/applet-typecheck.ts +100 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +21 -240
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/chat-selection.ts +23 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +226 -120
- package/server/collab/applet-module.ts +50 -0
- package/server/collab/cloudflare-access.ts +77 -0
- package/server/collab/config.ts +18 -0
- package/server/collab/ipc.ts +10 -0
- package/server/collab/manager.ts +407 -0
- package/server/collab/service.ts +137 -0
- package/server/collab/skill/collab-env.d.ts +92 -0
- package/server/collab/skill/index.ts +59 -0
- package/server/collab/worker.ts +52 -0
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +24 -16
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +60 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +108 -30
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +91 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +151 -0
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -264
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r5xrenjy.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.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.
|
|
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,
|
|
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:
|
|
137
|
-
updateAttachment: (
|
|
138
|
-
|
|
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
|
-
|
|
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,
|
|
203
|
+
updateAttachment: (workspaceId, localId, patch) =>
|
|
230
204
|
set(s => {
|
|
231
|
-
const
|
|
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 (
|
|
234
|
-
|
|
235
|
-
|
|
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,
|
|
225
|
+
removeAttachment: (workspaceId, localId) =>
|
|
247
226
|
set(s => {
|
|
248
|
-
const
|
|
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 (
|
|
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 =
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
28
|
-
|
|
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 =
|
|
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(
|
|
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:
|
|
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,
|
|
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
|
|
169
|
-
|
|
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:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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 =
|
|
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
|
-
{
|
|
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"
|
|
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]:
|
|
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
|
-
|
|
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={
|
|
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}
|