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.
- package/README.md +2 -2
- package/client/AGENTS.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- 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 +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -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 +170 -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/useChat.ts +42 -24
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- 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 +25 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -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 +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +210 -162
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +2 -30
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +23 -30
- 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-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-mzrgr577.js +5 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -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/default-widgets.ts +32 -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 +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +91 -34
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +42 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +139 -66
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -242
- 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/cli-ui-components.ts +28 -33
- package/server/cli.ts +169 -108
- 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 +9 -14
- 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 +48 -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 +46 -13
- 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 +90 -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/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
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react'
|
|
2
|
+
import { IconLoader2, IconX, type Icon } from '@tabler/icons-react'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { cn } from '@/client/lib/cn'
|
|
5
|
+
|
|
6
|
+
type AttachmentChipProps = ComponentPropsWithRef<'div'> & {
|
|
7
|
+
label: string
|
|
8
|
+
icon: Icon
|
|
9
|
+
onRemove?: () => void
|
|
10
|
+
previewUrl?: string
|
|
11
|
+
loading?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Two layouts share one frame: a labelled chip or an image thumbnail.
|
|
15
|
+
// Upload status is an overlay; it doesn't introduce another layout.
|
|
16
|
+
export function AttachmentChip({
|
|
17
|
+
label,
|
|
18
|
+
icon,
|
|
19
|
+
onRemove,
|
|
20
|
+
previewUrl,
|
|
21
|
+
loading,
|
|
22
|
+
className,
|
|
23
|
+
children,
|
|
24
|
+
...props
|
|
25
|
+
}: AttachmentChipProps) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
{...props}
|
|
29
|
+
className={cn(
|
|
30
|
+
'group relative flex max-w-full min-w-0 cursor-default items-center rounded-md bg-background text-sm whitespace-nowrap text-foreground ring-1 ring-border outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
|
|
31
|
+
previewUrl ? 'size-14 overflow-hidden' : 'h-7 pr-2 pl-0.5',
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
{loading && (
|
|
36
|
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-background/70">
|
|
37
|
+
<IconLoader2 size={16} stroke={1.75} className="animate-spin text-muted-foreground" />
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
{previewUrl ? (
|
|
41
|
+
<ImageChipContent label={label} previewUrl={previewUrl} onRemove={onRemove} />
|
|
42
|
+
) : (
|
|
43
|
+
<LabelChipContent label={label} icon={icon} onRemove={onRemove} />
|
|
44
|
+
)}
|
|
45
|
+
{children}
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type LabelChipContentProps = Pick<AttachmentChipProps, 'label' | 'icon' | 'onRemove'>
|
|
51
|
+
|
|
52
|
+
function LabelChipContent({ label, icon: IconComponent, onRemove }: LabelChipContentProps) {
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
{onRemove ? (
|
|
56
|
+
<Button
|
|
57
|
+
type="button"
|
|
58
|
+
variant="ghost"
|
|
59
|
+
size="icon-sm"
|
|
60
|
+
onClick={onRemove}
|
|
61
|
+
aria-label={`Remove ${label}`}
|
|
62
|
+
className="size-6 shrink-0 hover:bg-transparent hover:text-current"
|
|
63
|
+
>
|
|
64
|
+
<IconComponent stroke={1.75} className="group-focus-within:hidden group-hover:hidden" />
|
|
65
|
+
<IconX stroke={1.75} className="hidden group-focus-within:block group-hover:block" />
|
|
66
|
+
</Button>
|
|
67
|
+
) : (
|
|
68
|
+
<span className="flex size-6 shrink-0 items-center justify-center">
|
|
69
|
+
<IconComponent size={16} stroke={1.75} />
|
|
70
|
+
</span>
|
|
71
|
+
)}
|
|
72
|
+
<span className="truncate">{label}</span>
|
|
73
|
+
</>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type ImageChipContentProps = Pick<AttachmentChipProps, 'label' | 'onRemove'> & {
|
|
78
|
+
previewUrl: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function ImageChipContent({ label, previewUrl, onRemove }: ImageChipContentProps) {
|
|
82
|
+
return (
|
|
83
|
+
<>
|
|
84
|
+
<img src={previewUrl} alt={label} className="size-full object-cover" />
|
|
85
|
+
{onRemove && (
|
|
86
|
+
<Button
|
|
87
|
+
type="button"
|
|
88
|
+
variant="outline"
|
|
89
|
+
size="icon-sm"
|
|
90
|
+
onClick={onRemove}
|
|
91
|
+
aria-label={`Remove ${label}`}
|
|
92
|
+
className="absolute top-1 right-1 size-4 rounded-xs border-0 opacity-0 shadow-xs transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 [&_svg]:size-3"
|
|
93
|
+
>
|
|
94
|
+
<IconX stroke={1.75} />
|
|
95
|
+
</Button>
|
|
96
|
+
)}
|
|
97
|
+
</>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IconScribble } from '@tabler/icons-react'
|
|
2
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
|
|
3
|
+
import type { StagedAttachment } from './types'
|
|
4
|
+
import { AttachmentChip } from './AttachmentChip'
|
|
5
|
+
|
|
6
|
+
type DrawingAttachmentChipProps = {
|
|
7
|
+
attachment: Extract<StagedAttachment, { kind: 'drawing' }>
|
|
8
|
+
onRemove: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function DrawingAttachmentChip({ attachment, onRemove }: DrawingAttachmentChipProps) {
|
|
12
|
+
const { previewUrl, purpose } = attachment
|
|
13
|
+
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<HoverCard>
|
|
17
|
+
<HoverCardTrigger
|
|
18
|
+
render={
|
|
19
|
+
<AttachmentChip tabIndex={0} label={label} icon={IconScribble} onRemove={onRemove} />
|
|
20
|
+
}
|
|
21
|
+
/>
|
|
22
|
+
{previewUrl && (
|
|
23
|
+
<HoverCardContent
|
|
24
|
+
side="top"
|
|
25
|
+
align="start"
|
|
26
|
+
className="w-60 max-w-[calc(100vw-2rem)] rounded-xl"
|
|
27
|
+
>
|
|
28
|
+
<img
|
|
29
|
+
src={previewUrl}
|
|
30
|
+
alt={`${label} preview`}
|
|
31
|
+
className="max-h-72 w-full rounded-md object-contain"
|
|
32
|
+
/>
|
|
33
|
+
</HoverCardContent>
|
|
34
|
+
)}
|
|
35
|
+
</HoverCard>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IconFile } from '@tabler/icons-react'
|
|
2
|
+
import type { StagedAttachment } from './types'
|
|
3
|
+
import { AttachmentChip } from './AttachmentChip'
|
|
4
|
+
|
|
5
|
+
type FileAttachmentChipProps = {
|
|
6
|
+
attachment: Extract<StagedAttachment, { kind: 'file' }>
|
|
7
|
+
onRemove: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function FileAttachmentChip({ attachment, onRemove }: FileAttachmentChipProps) {
|
|
11
|
+
return (
|
|
12
|
+
<AttachmentChip
|
|
13
|
+
label={attachment.label}
|
|
14
|
+
icon={IconFile}
|
|
15
|
+
onRemove={onRemove}
|
|
16
|
+
previewUrl={attachment.previewUrl}
|
|
17
|
+
loading={attachment.status === 'uploading'}
|
|
18
|
+
title={attachment.label}
|
|
19
|
+
className="max-w-52"
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IconLibrary } from '@tabler/icons-react'
|
|
2
|
+
import { AttachmentChip } from './AttachmentChip'
|
|
3
|
+
|
|
4
|
+
type TextAttachmentChipProps = {
|
|
5
|
+
label: string
|
|
6
|
+
onRemove?: () => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function TextAttachmentChip({ label, onRemove }: TextAttachmentChipProps) {
|
|
10
|
+
return <AttachmentChip label={label} icon={IconLibrary} onRemove={onRemove} />
|
|
11
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AttachmentInput,
|
|
3
|
+
AttachmentOrigin,
|
|
4
|
+
DrawingPurpose,
|
|
5
|
+
TextAttachment,
|
|
6
|
+
WorkspaceTabId
|
|
7
|
+
} from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
import { findAttachment, liveStore } from '../../chat-store'
|
|
10
|
+
import { uploadChatFile } from './uploads'
|
|
11
|
+
import { reportAppletError } from '@/client/features/applets/applet-log'
|
|
12
|
+
import { toast } from '@/client/components/ui/toast'
|
|
13
|
+
|
|
14
|
+
type ComposerTarget = {
|
|
15
|
+
workspaceId: string
|
|
16
|
+
sessionId: string | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function stageComposerFiles(target: ComposerTarget, files: File[]): void {
|
|
20
|
+
for (const file of files) void stageFile(target, file)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Both file sources enter the same draft lifecycle and become ordinary uploads.
|
|
24
|
+
async function stageFile(
|
|
25
|
+
{ workspaceId, sessionId }: ComposerTarget,
|
|
26
|
+
input: File | string,
|
|
27
|
+
onError?: (message: string) => void,
|
|
28
|
+
source?: string
|
|
29
|
+
): Promise<void> {
|
|
30
|
+
const file = typeof input === 'string' ? null : input
|
|
31
|
+
const label = typeof input === 'string' ? input.split('/').at(-1)! : input.name || 'file'
|
|
32
|
+
const localId = crypto.randomUUID()
|
|
33
|
+
liveStore.getState().addAttachments(workspaceId, sessionId, [
|
|
34
|
+
{
|
|
35
|
+
kind: 'file',
|
|
36
|
+
source,
|
|
37
|
+
localId,
|
|
38
|
+
label,
|
|
39
|
+
mediaType: file?.type || 'application/octet-stream',
|
|
40
|
+
previewUrl: file?.type.startsWith('image/') ? URL.createObjectURL(file) : undefined,
|
|
41
|
+
status: 'uploading'
|
|
42
|
+
}
|
|
43
|
+
])
|
|
44
|
+
try {
|
|
45
|
+
const upload = await uploadChatFile(workspaceId, input)
|
|
46
|
+
liveStore.getState().updateAttachment(workspaceId, localId, {
|
|
47
|
+
status: 'ready',
|
|
48
|
+
upload,
|
|
49
|
+
label: upload.filename,
|
|
50
|
+
mediaType: upload.mediaType,
|
|
51
|
+
...(upload.kind === 'image' && !file?.type.startsWith('image/')
|
|
52
|
+
? { previewUrl: `/api/workspaces/${workspaceId}/uploads/${upload.id}` }
|
|
53
|
+
: {})
|
|
54
|
+
})
|
|
55
|
+
} catch (error: unknown) {
|
|
56
|
+
const message = error instanceof Error ? error.message : 'The file couldn’t be uploaded'
|
|
57
|
+
liveStore.getState().removeAttachment(workspaceId, localId)
|
|
58
|
+
toast.add({ title: `Couldn’t add ${label}`, description: message, type: 'error' })
|
|
59
|
+
onError?.(message)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function stageChatAttachment(
|
|
64
|
+
target: ComposerTarget,
|
|
65
|
+
input: AttachmentInput & AttachmentOrigin
|
|
66
|
+
): Promise<void> {
|
|
67
|
+
if (input.type === 'text') {
|
|
68
|
+
const { source, label, text } = input
|
|
69
|
+
stageTextAttachment(target, { source, label, text })
|
|
70
|
+
return Promise.resolve()
|
|
71
|
+
}
|
|
72
|
+
return stageFile(
|
|
73
|
+
target,
|
|
74
|
+
input.file ?? input.path,
|
|
75
|
+
message => {
|
|
76
|
+
reportAppletError(target.workspaceId, {
|
|
77
|
+
source: 'runtime',
|
|
78
|
+
message: `addChatAttachment() from ${input.source}: ${message}`
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
input.source
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type StageDrawingDraftInput = ComposerTarget & {
|
|
86
|
+
localId: string
|
|
87
|
+
purpose: DrawingPurpose
|
|
88
|
+
source: WorkspaceTabId
|
|
89
|
+
blob: Blob
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Local-only staging while the user is still drawing: the chip shows the
|
|
93
|
+
// latest composite as its preview, but nothing is uploaded until the drawing
|
|
94
|
+
// session ends (stageDrawing).
|
|
95
|
+
export function stageDrawingDraft({
|
|
96
|
+
workspaceId,
|
|
97
|
+
sessionId,
|
|
98
|
+
localId,
|
|
99
|
+
purpose,
|
|
100
|
+
source,
|
|
101
|
+
blob
|
|
102
|
+
}: StageDrawingDraftInput): void {
|
|
103
|
+
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
104
|
+
const previewUrl = URL.createObjectURL(blob)
|
|
105
|
+
const store = liveStore.getState()
|
|
106
|
+
const existing = findAttachment(store.attachments, workspaceId, localId)
|
|
107
|
+
|
|
108
|
+
if (existing) {
|
|
109
|
+
store.updateAttachment(workspaceId, localId, {
|
|
110
|
+
previewUrl,
|
|
111
|
+
status: 'draft',
|
|
112
|
+
upload: undefined
|
|
113
|
+
})
|
|
114
|
+
} else {
|
|
115
|
+
store.addAttachments(workspaceId, sessionId, [
|
|
116
|
+
{
|
|
117
|
+
kind: 'drawing',
|
|
118
|
+
purpose,
|
|
119
|
+
localId,
|
|
120
|
+
source,
|
|
121
|
+
label: `${label}.png`,
|
|
122
|
+
mediaType: 'image/png',
|
|
123
|
+
previewUrl,
|
|
124
|
+
status: 'draft'
|
|
125
|
+
}
|
|
126
|
+
])
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type StageDrawingInput = StageDrawingDraftInput & {
|
|
131
|
+
isCurrent: () => boolean
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Upload a drawing once its editing session ends (finish, send, or an
|
|
135
|
+
// implicit cancel that keeps the attachment). `isCurrent` guards the result:
|
|
136
|
+
// a stale upload must not resurrect an attachment the user has removed.
|
|
137
|
+
export async function stageDrawing(input: StageDrawingInput): Promise<void> {
|
|
138
|
+
const { workspaceId, localId, purpose, blob, isCurrent } = input
|
|
139
|
+
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
140
|
+
stageDrawingDraft(input)
|
|
141
|
+
liveStore.getState().updateAttachment(workspaceId, localId, { status: 'uploading' })
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const upload = await uploadChatFile(
|
|
145
|
+
workspaceId,
|
|
146
|
+
new File([blob], `${label}.png`, { type: 'image/png' })
|
|
147
|
+
)
|
|
148
|
+
if (!isCurrent()) return
|
|
149
|
+
liveStore.getState().updateAttachment(workspaceId, localId, {
|
|
150
|
+
status: 'ready',
|
|
151
|
+
upload,
|
|
152
|
+
mediaType: upload.mediaType
|
|
153
|
+
})
|
|
154
|
+
} catch {
|
|
155
|
+
if (!isCurrent()) return
|
|
156
|
+
liveStore.getState().removeAttachment(workspaceId, localId)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function stageTextAttachment(
|
|
161
|
+
{ workspaceId, sessionId }: ComposerTarget,
|
|
162
|
+
attachment: TextAttachment
|
|
163
|
+
): void {
|
|
164
|
+
const store = liveStore.getState()
|
|
165
|
+
store.addAttachments(workspaceId, sessionId, [
|
|
166
|
+
{ kind: 'text', localId: crypto.randomUUID(), ...attachment }
|
|
167
|
+
])
|
|
168
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AttachmentOrigin, DrawingPurpose, TextAttachment, UploadInfo } from '@/lib/types'
|
|
2
|
+
|
|
3
|
+
// One composer attachment, tracked per session until the message is sent. A
|
|
4
|
+
// file uploads as soon as it's added (drop/paste/pick); an annotation stays a
|
|
5
|
+
// local `draft` while it's being drawn and uploads once when the drawing
|
|
6
|
+
// session ends. `status` reflects that lifecycle, and `upload` holds the server
|
|
7
|
+
// handle once ready. `previewUrl` is a local object URL for image thumbnails
|
|
8
|
+
// (revoked on remove/clear).
|
|
9
|
+
type StagedUploadFields = {
|
|
10
|
+
label: string
|
|
11
|
+
mediaType: string
|
|
12
|
+
previewUrl?: string
|
|
13
|
+
status: 'draft' | 'uploading' | 'ready'
|
|
14
|
+
upload?: UploadInfo
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type StagedAttachment = { localId: string } & (
|
|
18
|
+
| ({ kind: 'file' } & StagedUploadFields & Partial<AttachmentOrigin>)
|
|
19
|
+
| ({ kind: 'drawing'; purpose: DrawingPurpose } & StagedUploadFields & AttachmentOrigin)
|
|
20
|
+
| ({ kind: 'text' } & TextAttachment)
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
export type StagedAttachmentPatch = Partial<
|
|
24
|
+
Pick<StagedUploadFields, 'label' | 'mediaType' | 'previewUrl' | 'status' | 'upload'>
|
|
25
|
+
>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsonRequest, requestJson } from '@/client/api/http'
|
|
2
|
+
import type { UploadInfo } from '@/lib/types'
|
|
3
|
+
|
|
4
|
+
// Shared single-file preparation for drafts, drawings, and immediate sends.
|
|
5
|
+
export async function uploadChatFile(
|
|
6
|
+
workspaceId: string,
|
|
7
|
+
input: File | string
|
|
8
|
+
): Promise<UploadInfo> {
|
|
9
|
+
const url = `/api/workspaces/${workspaceId}/uploads`
|
|
10
|
+
if (typeof input === 'string') {
|
|
11
|
+
return requestJson<UploadInfo>(
|
|
12
|
+
`${url}/from-path`,
|
|
13
|
+
jsonRequest('POST', { path: input }),
|
|
14
|
+
'The file couldn’t be uploaded'
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
const form = new FormData()
|
|
18
|
+
form.append('files', input)
|
|
19
|
+
const [upload] = await requestJson<UploadInfo[]>(
|
|
20
|
+
url,
|
|
21
|
+
{ method: 'POST', body: form },
|
|
22
|
+
'The file couldn’t be uploaded'
|
|
23
|
+
)
|
|
24
|
+
if (!upload) throw new Error('The upload didn’t finish')
|
|
25
|
+
return upload
|
|
26
|
+
}
|
|
@@ -6,23 +6,31 @@ import { ComposerBannerShell } from './ComposerBanner'
|
|
|
6
6
|
|
|
7
7
|
type ErrorBannerProps = {
|
|
8
8
|
error: string
|
|
9
|
-
onDismiss
|
|
9
|
+
onDismiss?: () => void
|
|
10
|
+
onRetry?: () => void
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export function ErrorBanner({ error, onDismiss }: ErrorBannerProps) {
|
|
13
|
+
export function ErrorBanner({ error, onDismiss, onRetry }: ErrorBannerProps) {
|
|
13
14
|
return (
|
|
14
15
|
<ComposerBannerShell role="alert" className="flex items-center gap-2 text-destructive">
|
|
15
16
|
<span className="flex-1 wrap-break-word">{error}</span>
|
|
16
|
-
|
|
17
|
-
type="button"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
{onRetry && (
|
|
18
|
+
<Button type="button" variant="ghost" size="sm" onClick={onRetry}>
|
|
19
|
+
Retry
|
|
20
|
+
</Button>
|
|
21
|
+
)}
|
|
22
|
+
{onDismiss && (
|
|
23
|
+
<Button
|
|
24
|
+
type="button"
|
|
25
|
+
variant="ghost"
|
|
26
|
+
size="icon-sm"
|
|
27
|
+
onClick={onDismiss}
|
|
28
|
+
className="text-destructive hover:text-destructive"
|
|
29
|
+
aria-label="Dismiss error"
|
|
30
|
+
>
|
|
31
|
+
<IconX stroke={1.75} />
|
|
32
|
+
</Button>
|
|
33
|
+
)}
|
|
26
34
|
</ComposerBannerShell>
|
|
27
35
|
)
|
|
28
36
|
}
|
|
@@ -6,6 +6,21 @@ const ANTHROPIC_MODEL_FAMILY_ORDER = ['fable', 'opus', 'sonnet', 'haiku'] as con
|
|
|
6
6
|
|
|
7
7
|
type ModelComparator = (a: Model, b: Model) => number
|
|
8
8
|
|
|
9
|
+
// Resolve the same concrete row for the picker and the outgoing chat request.
|
|
10
|
+
// Unavailable selections fall back to the resolved default, then the first row.
|
|
11
|
+
export function resolveSelectedModel(
|
|
12
|
+
models: readonly Model[],
|
|
13
|
+
selectedModel: string | undefined,
|
|
14
|
+
defaultModel = models.find(model => model.value === 'default')?.resolvedModel
|
|
15
|
+
): Model | undefined {
|
|
16
|
+
const choices = models.filter(model => model.value !== 'default')
|
|
17
|
+
return (
|
|
18
|
+
choices.find(model => model.value === selectedModel) ??
|
|
19
|
+
choices.find(model => (model.resolvedModel ?? model.value) === defaultModel) ??
|
|
20
|
+
choices[0]
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
function anthropicModelFamilyRank(model: Model): number | undefined {
|
|
10
25
|
const key = model.resolvedModel ?? model.value
|
|
11
26
|
const rank = ANTHROPIC_MODEL_FAMILY_ORDER.findIndex(
|
|
@@ -10,6 +10,8 @@ import { useWorkspaceSkillUpdates } from './useWorkspaceSkillUpdates'
|
|
|
10
10
|
type WorkspaceComposerStateOptions = {
|
|
11
11
|
chatError: string | null
|
|
12
12
|
onDismissChatError: () => void
|
|
13
|
+
chatLoadError?: string | null
|
|
14
|
+
onRetryChatLoad?: () => void
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
type WorkspaceComposerState = {
|
|
@@ -20,7 +22,7 @@ type WorkspaceComposerState = {
|
|
|
20
22
|
|
|
21
23
|
export function useWorkspaceComposerState(
|
|
22
24
|
workspaceId: string,
|
|
23
|
-
{ chatError, onDismissChatError }: WorkspaceComposerStateOptions
|
|
25
|
+
{ chatError, onDismissChatError, chatLoadError, onRetryChatLoad }: WorkspaceComposerStateOptions
|
|
24
26
|
): WorkspaceComposerState {
|
|
25
27
|
const { data: agent, error } = useWorkspaceAgent(workspaceId)
|
|
26
28
|
const availability = agent?.availability
|
|
@@ -43,12 +45,18 @@ export function useWorkspaceComposerState(
|
|
|
43
45
|
)
|
|
44
46
|
}
|
|
45
47
|
: undefined
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
48
|
+
let chatErrorBanner: ComposerBanner | undefined
|
|
49
|
+
if (chatLoadError) {
|
|
50
|
+
chatErrorBanner = {
|
|
51
|
+
tone: 'error',
|
|
52
|
+
content: <ErrorBanner error={chatLoadError} onRetry={onRetryChatLoad} />
|
|
53
|
+
}
|
|
54
|
+
} else if (chatError) {
|
|
55
|
+
chatErrorBanner = {
|
|
56
|
+
tone: 'error',
|
|
57
|
+
content: <ErrorBanner error={chatError} onDismiss={onDismissChatError} />
|
|
58
|
+
}
|
|
59
|
+
}
|
|
52
60
|
const skillUpdate: ComposerBanner | undefined = skillUpdateBanner
|
|
53
61
|
? {
|
|
54
62
|
tone: 'default',
|
|
@@ -2,7 +2,7 @@ import type { QueryClient } from '@tanstack/react-query'
|
|
|
2
2
|
|
|
3
3
|
import { wsUrl } from '@/client/lib/ws-url'
|
|
4
4
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
5
|
-
import { reduceChatFrame } from '@/client/features/chat/chat-frames'
|
|
5
|
+
import { reduceChatFrame } from '@/client/features/chat/connection/chat-frames'
|
|
6
6
|
import type { ClientMessage } from '@/lib/types'
|
|
7
7
|
|
|
8
8
|
// App-wide chat connection: ONE WebSocket for the whole client, opened once at
|
|
@@ -3,7 +3,8 @@ import type { QueryClient } from '@tanstack/react-query'
|
|
|
3
3
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
4
|
import { getScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
|
|
5
5
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
6
|
-
import {
|
|
6
|
+
import { bufferSessionEvent } from '@/client/features/chat/sessions/session-view'
|
|
7
|
+
import { renameSelectedSessionInCache } from '@/client/features/chat/sessions/useSelectedSession'
|
|
7
8
|
import { applyEvent } from '@/lib/format'
|
|
8
9
|
import type {
|
|
9
10
|
ClientMessage,
|
|
@@ -143,11 +144,10 @@ export function reduceChatFrame(data: Record<string, unknown>, context: ChatFram
|
|
|
143
144
|
}
|
|
144
145
|
if (kind === 'error' && typeof data.content === 'string') {
|
|
145
146
|
store.setError(workspaceId, sessionId, data.content)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
store.clearPreviewsForSession(workspaceId, sessionId)
|
|
147
|
+
if (data.terminal !== false) {
|
|
148
|
+
store.setActivity(workspaceId, sessionId, 'idle')
|
|
149
|
+
store.clearPreviewsForSession(workspaceId, sessionId)
|
|
150
|
+
}
|
|
151
151
|
}
|
|
152
152
|
if (kind === 'stopped') {
|
|
153
153
|
store.setActivity(workspaceId, sessionId, 'idle')
|
|
@@ -161,8 +161,10 @@ function patchView(
|
|
|
161
161
|
sessionId: string,
|
|
162
162
|
event: StreamEvent
|
|
163
163
|
) {
|
|
164
|
+
if (!queryClient) return
|
|
165
|
+
bufferSessionEvent(queryClient, workspaceId, sessionId, event)
|
|
164
166
|
const queryKey = workspaceKeys.events(workspaceId, sessionId)
|
|
165
|
-
const existing = queryClient
|
|
167
|
+
const existing = queryClient.getQueryData<ViewState>(queryKey)
|
|
166
168
|
if (existing === undefined) return
|
|
167
|
-
queryClient
|
|
169
|
+
queryClient.setQueryData<ViewState>(queryKey, applyEvent(existing, event))
|
|
168
170
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
IconArticle,
|
|
5
5
|
IconFileSearch,
|
|
6
6
|
IconLayout2,
|
|
7
|
+
IconMessages,
|
|
7
8
|
IconPiano,
|
|
8
9
|
IconSketching,
|
|
9
10
|
IconUmbrella2,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
ChatPromptBubble,
|
|
17
18
|
ChatPromptBubbles,
|
|
18
19
|
type ChatPromptBubble as ChatPrompt
|
|
19
|
-
} from '@/client/features/chat/ChatPromptBubbles'
|
|
20
|
+
} from '@/client/features/chat/messages/ChatPromptBubbles'
|
|
20
21
|
import { cn } from '@/client/lib/cn'
|
|
21
22
|
import type { AgentTheme } from '@/lib/types'
|
|
22
23
|
|
|
@@ -83,7 +84,7 @@ export const WORKSPACE_ANALYSIS_PROMPT = {
|
|
|
83
84
|
} satisfies ChatPrompt
|
|
84
85
|
|
|
85
86
|
export type ChatEmptyStateKind = 'view-builder' | 'welcome' | 'explore-workspace' | 'empty'
|
|
86
|
-
export type WelcomeDestination = 'agent' | '
|
|
87
|
+
export type WelcomeDestination = 'agent' | 'overview' | 'views' | 'scratchpad'
|
|
87
88
|
|
|
88
89
|
type ResolveChatEmptyStateOptions = {
|
|
89
90
|
isViewBuilderDraft: boolean
|
|
@@ -194,19 +195,23 @@ function WelcomeState({
|
|
|
194
195
|
<div className="mt-2 flex flex-col gap-4">
|
|
195
196
|
<div className="prose prose-sm min-w-0 wrap-anywhere prose-inherit">
|
|
196
197
|
<p>
|
|
197
|
-
moi is the
|
|
198
|
-
|
|
198
|
+
moi is the personal workspace built for you by your agent. It grows and adapts to your
|
|
199
|
+
needs.
|
|
199
200
|
</p>
|
|
200
201
|
<p>
|
|
201
|
-
Ask
|
|
202
|
-
<WelcomeTerm Icon={
|
|
203
|
-
|
|
202
|
+
Ask the{' '}
|
|
203
|
+
<WelcomeTerm Icon={IconMessages} destination="agent" onNavigate={onNavigate}>
|
|
204
|
+
Agent
|
|
204
205
|
</WelcomeTerm>{' '}
|
|
205
|
-
|
|
206
|
+
to build widgets on the{' '}
|
|
207
|
+
<WelcomeTerm Icon={IconLayout2} destination="overview" onNavigate={onNavigate}>
|
|
208
|
+
Overview
|
|
209
|
+
</WelcomeTerm>{' '}
|
|
210
|
+
page, or more complex tools as separate{' '}
|
|
206
211
|
<WelcomeTerm Icon={IconArticle} destination="views" onNavigate={onNavigate}>
|
|
207
212
|
Views
|
|
208
|
-
</WelcomeTerm>
|
|
209
|
-
|
|
213
|
+
</WelcomeTerm>
|
|
214
|
+
. Use{' '}
|
|
210
215
|
<WelcomeTerm Icon={IconSketching} destination="scratchpad" onNavigate={onNavigate}>
|
|
211
216
|
Scratchpad
|
|
212
217
|
</WelcomeTerm>{' '}
|
|
@@ -269,7 +274,7 @@ function WelcomeTerm({ Icon, children, destination, onNavigate }: WelcomeTermPro
|
|
|
269
274
|
type="button"
|
|
270
275
|
data-welcome-destination={destination}
|
|
271
276
|
onClick={() => onNavigate(destination)}
|
|
272
|
-
className="
|
|
277
|
+
className="inline-flex cursor-pointer items-center gap-0.5 align-bottom font-medium text-foreground"
|
|
273
278
|
>
|
|
274
279
|
<Icon size={16} stroke={1.75} aria-hidden />
|
|
275
280
|
{children}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react'
|
|
2
|
+
import { useRouter } from 'wouter'
|
|
2
3
|
|
|
3
|
-
import ReactMarkdown, { type ExtraProps } from 'react-markdown'
|
|
4
|
+
import ReactMarkdown, { defaultUrlTransform, type ExtraProps } from 'react-markdown'
|
|
4
5
|
import rehypeHighlight from 'rehype-highlight'
|
|
5
6
|
import remarkGfm from 'remark-gfm'
|
|
6
7
|
|
|
8
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
9
|
+
import { resolveWorkspaceHref } from '@/lib/navigation'
|
|
7
10
|
import { cn } from '@/client/lib/cn'
|
|
8
11
|
|
|
9
12
|
const remarkPlugins = [remarkGfm]
|
|
@@ -44,6 +47,8 @@ type PlainMarkdownTextProps = {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export function MarkdownContent({ size = 'sm', content }: MarkdownContentProps) {
|
|
50
|
+
const workspaceId = useWorkspaceId()
|
|
51
|
+
const { base } = useRouter()
|
|
47
52
|
return (
|
|
48
53
|
<div
|
|
49
54
|
className={cn(
|
|
@@ -55,6 +60,16 @@ export function MarkdownContent({ size = 'sm', content }: MarkdownContentProps)
|
|
|
55
60
|
remarkPlugins={remarkPlugins}
|
|
56
61
|
rehypePlugins={rehypePlugins}
|
|
57
62
|
components={components}
|
|
63
|
+
urlTransform={(url, key, node) => {
|
|
64
|
+
if (node.tagName === 'a' && key === 'href' && url.startsWith('moi:')) {
|
|
65
|
+
try {
|
|
66
|
+
return resolveWorkspaceHref(workspaceId, url, base)
|
|
67
|
+
} catch {
|
|
68
|
+
return ''
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return defaultUrlTransform(url)
|
|
72
|
+
}}
|
|
58
73
|
>
|
|
59
74
|
{content}
|
|
60
75
|
</ReactMarkdown>
|