moi-computer 0.8.1-next.0 → 0.9.1-next.0
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/client/assets/hermes.png +0 -0
- package/client/components/shared/IconGhost.tsx +15 -18
- package/client/components/ui/button.tsx +2 -2
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +3 -1
- package/client/features/chat/ChatEmptyState.tsx +25 -7
- package/client/features/chat/ChatPanel.tsx +70 -28
- package/client/features/chat/ChatPopup.tsx +3 -2
- package/client/features/chat/ChatPromptBubbles.tsx +1 -1
- package/client/features/chat/MarkdownContent.tsx +1 -1
- package/client/features/chat/attachment-staging.ts +153 -0
- package/client/features/chat/chat-send.ts +55 -0
- package/client/features/chat/chat-store.ts +32 -8
- package/client/features/chat/composer/ChatComposer.tsx +190 -77
- package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
- package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
- package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
- package/client/features/chat/tool-group/format/claude.ts +48 -0
- package/client/features/chat/tool-group/format/codex.ts +126 -0
- package/client/features/chat/tool-group/format/hermes.ts +68 -0
- package/client/features/chat/tool-group/format/index.ts +34 -0
- package/client/features/chat/tool-group/format/mcp.ts +64 -0
- package/client/features/chat/tool-group/format/openclaw.ts +116 -0
- package/client/features/chat/tool-group/format/shared.ts +49 -0
- package/client/features/chat/useChat.ts +5 -10
- package/client/features/dev/ChatStatesPage.tsx +40 -2
- package/client/features/drawings/DrawingLayer.tsx +49 -0
- package/client/features/drawings/DrawingToolbar.tsx +95 -0
- package/client/features/drawings/annotation-availability.ts +10 -0
- package/client/features/drawings/capture-element.ts +45 -0
- package/client/features/drawings/useChatAnnotation.ts +222 -0
- package/client/features/drawings/useDrawingLayer.ts +758 -0
- package/client/features/drawings/useViewBuilderSketch.ts +151 -0
- package/client/features/home/workspace-presentation.tsx +6 -2
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +12 -6
- package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
- package/client/features/views/ViewBuilder.tsx +224 -0
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +24 -3
- package/client/features/views/useViewBuilderDrafts.ts +66 -0
- package/client/features/widgets/Widgets.tsx +23 -39
- package/client/features/workspace/CustomizePanel.tsx +1 -1
- package/client/features/workspace/WorkspaceScreen.tsx +157 -57
- package/client/features/workspace/WorkspaceTabs.tsx +3 -3
- package/client/features/workspace/useFitsSplitLayout.ts +14 -8
- package/client/index.css +8 -0
- package/client/store/ui.ts +19 -0
- package/client/theme.css +33 -8
- package/dist/chunk-3becmq75.js +81 -0
- package/dist/{chunk-kkj86722.js → chunk-6w6j9g4b.js} +78 -78
- package/dist/{chunk-xeyxk7ep.js → chunk-8ew39cvq.js} +4 -4
- package/dist/chunk-c8gtrjwp.js +1 -0
- package/dist/{chunk-2vaafjp4.js → chunk-pp62fnxh.js} +1 -1
- package/dist/{chunk-35fq49qa.js → chunk-sxc24vfp.js} +1 -1
- package/dist/{chunk-xzx7c9hq.js → chunk-v964b5g7.js} +1 -1
- package/dist/chunk-zx33ts9d.css +1 -0
- package/dist/hermes-pznd63x9.png +0 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +21 -7
- package/lib/themes.ts +8 -8
- package/lib/types.ts +8 -1
- package/lib/workspace-types.ts +2 -1
- package/package.json +6 -4
- package/server/api.ts +21 -2
- package/server/bundler/build-applet.ts +35 -44
- package/server/cli-env.ts +2 -2
- package/server/cli.ts +227 -56
- package/server/constants.ts +8 -0
- package/server/control-client.ts +124 -0
- package/server/control.ts +2 -2
- package/server/harness/README.md +74 -23
- package/server/harness/acp/adapter.ts +220 -0
- package/server/harness/acp/archived.ts +88 -0
- package/server/harness/acp/client.ts +328 -0
- package/server/harness/acp/discovery.ts +130 -0
- package/server/harness/acp/run-durations.ts +68 -0
- package/server/harness/acp/session.ts +788 -0
- package/server/harness/acp/wire.ts +132 -0
- package/server/harness/executable.ts +15 -1
- package/server/harness/hermes/NOTES.md +815 -0
- package/server/harness/hermes/discovery.ts +155 -0
- package/server/harness/hermes/index.ts +155 -0
- package/server/harness/hermes/models.ts +79 -0
- package/server/harness/openclaw/NOTES.md +196 -94
- package/server/harness/openclaw/adapter.ts +28 -55
- package/server/harness/openclaw/compat.ts +4 -8
- package/server/harness/openclaw/session.ts +257 -238
- package/server/harness/openclaw/strip.ts +10 -34
- package/server/harness/openclaw/thinking.ts +5 -53
- package/server/harness/registry.ts +3 -1
- package/server/service.ts +2 -2
- package/server/view-builders.ts +4 -2
- package/server/workspace-import.ts +30 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
- package/client/features/chat/tool-group/format.ts +0 -359
- package/client/features/views/ViewBuilderTab.tsx +0 -152
- package/dist/chunk-gny990qx.css +0 -1
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-n7pga5x3.js +0 -80
- /package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +0 -0
- /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
import { useStore } from 'zustand'
|
|
2
2
|
import { createStore } from 'zustand/vanilla'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
PreviewBlock,
|
|
6
|
+
PreviewFrame,
|
|
7
|
+
SessionActivity,
|
|
8
|
+
UploadInfo,
|
|
9
|
+
WorkspaceTabId
|
|
10
|
+
} from '@/lib/types'
|
|
5
11
|
|
|
6
|
-
// One composer attachment, tracked per session until the message is sent.
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
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 = {
|
|
11
19
|
localId: string
|
|
12
20
|
name: string
|
|
13
21
|
mediaType: string
|
|
14
22
|
previewUrl?: string
|
|
15
|
-
status: 'uploading' | 'ready' | 'error'
|
|
23
|
+
status: 'draft' | 'uploading' | 'ready' | 'error'
|
|
16
24
|
upload?: UploadInfo
|
|
17
25
|
error?: string
|
|
18
26
|
}
|
|
19
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
|
+
>
|
|
39
|
+
|
|
20
40
|
// App-level ephemeral chat state — the bits that are *pushed* from the server
|
|
21
41
|
// over the WebSocket and can't be re-fetched as request/response data:
|
|
22
42
|
// - per-session `activity` (spinner) state,
|
|
@@ -114,7 +134,7 @@ export type LiveStore = {
|
|
|
114
134
|
workspaceId: string,
|
|
115
135
|
sessionId: string | null,
|
|
116
136
|
localId: string,
|
|
117
|
-
patch:
|
|
137
|
+
patch: ChatAttachmentPatch
|
|
118
138
|
) => void
|
|
119
139
|
removeAttachment: (workspaceId: string, sessionId: string | null, localId: string) => void
|
|
120
140
|
clearAttachments: (workspaceId: string, sessionId: string | null) => void
|
|
@@ -207,6 +227,10 @@ export const liveStore = createStore<LiveStore>()(set => ({
|
|
|
207
227
|
const k = attachmentKey(workspaceId, sessionId)
|
|
208
228
|
const list = s.attachments[k]
|
|
209
229
|
if (!list) return {}
|
|
230
|
+
const target = list.find(attachment => attachment.localId === localId)
|
|
231
|
+
if (target?.previewUrl && 'previewUrl' in patch && patch.previewUrl !== target.previewUrl) {
|
|
232
|
+
URL.revokeObjectURL(target.previewUrl)
|
|
233
|
+
}
|
|
210
234
|
return {
|
|
211
235
|
attachments: {
|
|
212
236
|
...s.attachments,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
IconLoader2,
|
|
6
6
|
IconPaperclip,
|
|
7
7
|
IconPlayerStopFilled,
|
|
8
|
+
IconScribble,
|
|
8
9
|
IconX
|
|
9
10
|
} from '@tabler/icons-react'
|
|
10
11
|
|
|
@@ -17,10 +18,11 @@ import {
|
|
|
17
18
|
ComposerTextarea
|
|
18
19
|
} from '@/client/components/shared/Composer'
|
|
19
20
|
import { Button } from '@/client/components/ui/button'
|
|
21
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
|
|
20
22
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
23
|
+
import { stageComposerFiles } from '@/client/features/chat/attachment-staging'
|
|
21
24
|
import { cn } from '@/client/lib/cn'
|
|
22
25
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
23
|
-
import { uploadFiles } from '@/client/features/chat/uploads'
|
|
24
26
|
import {
|
|
25
27
|
type ChatAttachment,
|
|
26
28
|
attachmentKey,
|
|
@@ -29,76 +31,110 @@ import {
|
|
|
29
31
|
} from '@/client/features/chat/chat-store'
|
|
30
32
|
import { useUiStore } from '@/client/store/ui'
|
|
31
33
|
|
|
32
|
-
import { ModelPicker } from '
|
|
34
|
+
import { ModelPicker } from './ModelPicker'
|
|
35
|
+
|
|
36
|
+
export type ComposerAnnotationControls = {
|
|
37
|
+
active: boolean
|
|
38
|
+
finish: () => Promise<void>
|
|
39
|
+
onToggle: () => void
|
|
40
|
+
onRemove: (localId: string) => void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type ChatComposerDraft = {
|
|
44
|
+
// The UI-store key the composer subscribes to for live text; `initialValue`
|
|
45
|
+
// is the builder's server-saved requirements, used until a local draft
|
|
46
|
+
// exists.
|
|
47
|
+
id: string
|
|
48
|
+
initialValue: string
|
|
49
|
+
onChange: (value: string) => void
|
|
50
|
+
}
|
|
33
51
|
|
|
34
52
|
type ChatComposerProps = {
|
|
35
53
|
composerRef: RefObject<HTMLTextAreaElement | null>
|
|
36
|
-
onSend: (text: string) => void
|
|
54
|
+
onSend: (text: string) => void | Promise<void>
|
|
37
55
|
onStop: () => void
|
|
38
56
|
processing: boolean
|
|
39
57
|
sessionId: string | null
|
|
58
|
+
modelSessionId: string | null
|
|
40
59
|
availability: ComposerAvailability
|
|
60
|
+
annotation?: ComposerAnnotationControls
|
|
61
|
+
onRemoveDrawing?: (localId: string) => void
|
|
62
|
+
allowFiles?: boolean
|
|
63
|
+
placeholder?: string
|
|
64
|
+
draft?: ChatComposerDraft
|
|
41
65
|
}
|
|
42
66
|
|
|
43
|
-
// Draft text is persisted per workspace
|
|
44
|
-
//
|
|
45
|
-
//
|
|
67
|
+
// Draft text is persisted per workspace (or per view builder, when the
|
|
68
|
+
// composer is fronting one), while attachments remain ephemeral and follow the
|
|
69
|
+
// selected chat. Both stores are subscribed here so a keystroke or upload
|
|
70
|
+
// re-renders only the composer.
|
|
46
71
|
export function ChatComposer({
|
|
47
72
|
composerRef,
|
|
48
73
|
onSend,
|
|
49
74
|
onStop,
|
|
50
75
|
processing,
|
|
51
76
|
sessionId,
|
|
52
|
-
|
|
77
|
+
modelSessionId,
|
|
78
|
+
availability,
|
|
79
|
+
annotation,
|
|
80
|
+
onRemoveDrawing,
|
|
81
|
+
allowFiles = true,
|
|
82
|
+
placeholder,
|
|
83
|
+
draft
|
|
53
84
|
}: ChatComposerProps) {
|
|
54
85
|
const fileRef = useRef<HTMLInputElement>(null)
|
|
55
86
|
const workspaceId = useWorkspaceId()
|
|
56
|
-
const
|
|
87
|
+
const workspaceDraft = useUiStore(s => s.composerDrafts[workspaceId] ?? '')
|
|
88
|
+
const builderDraft = useUiStore(s => (draft ? (s.viewBuilderDrafts ?? {})[draft.id] : undefined))
|
|
89
|
+
const value = draft ? (builderDraft ?? draft.initialValue) : workspaceDraft
|
|
90
|
+
const valueRef = useRef(value)
|
|
91
|
+
valueRef.current = value
|
|
57
92
|
const attachments = useLive(s => s.attachments[attachmentKey(workspaceId, sessionId)] ?? EMPTY)
|
|
58
93
|
const [dragOver, setDragOver] = useState(false)
|
|
59
94
|
|
|
60
95
|
const uploading = attachments.some(a => a.status === 'uploading')
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
// A draft annotation counts as sendable content: send() finishes the drawing
|
|
97
|
+
// first, which uploads it before the message goes out.
|
|
98
|
+
const hasSendable = attachments.some(a => a.status === 'ready' || a.status === 'draft')
|
|
99
|
+
const hasContent = value.trim().length > 0 || hasSendable
|
|
63
100
|
const canSend = canSubmitComposerAction(hasContent, uploading, availability)
|
|
64
101
|
|
|
65
|
-
const onChange = (next: string) =>
|
|
102
|
+
const onChange = (next: string) => {
|
|
103
|
+
valueRef.current = next
|
|
104
|
+
if (draft) draft.onChange(next)
|
|
105
|
+
else useUiStore.getState().setComposerDraft(workspaceId, next)
|
|
106
|
+
}
|
|
66
107
|
|
|
67
|
-
// Upload each picked file immediately, tracking its in-flight status so the
|
|
68
|
-
// thumbnail row can show a spinner / error per file.
|
|
69
108
|
const addFiles = (files: File[]) => {
|
|
70
|
-
if (
|
|
71
|
-
const store = liveStore.getState()
|
|
72
|
-
const items: ChatAttachment[] = files.map(f => ({
|
|
73
|
-
localId: crypto.randomUUID(),
|
|
74
|
-
name: f.name || 'file',
|
|
75
|
-
mediaType: f.type || 'application/octet-stream',
|
|
76
|
-
previewUrl: f.type.startsWith('image/') ? URL.createObjectURL(f) : undefined,
|
|
77
|
-
status: 'uploading'
|
|
78
|
-
}))
|
|
79
|
-
store.addAttachments(workspaceId, sessionId, items)
|
|
80
|
-
items.forEach((item, i) => {
|
|
81
|
-
uploadFiles(workspaceId, [files[i]])
|
|
82
|
-
.then(([info]) =>
|
|
83
|
-
liveStore.getState().updateAttachment(workspaceId, sessionId, item.localId, {
|
|
84
|
-
status: 'ready',
|
|
85
|
-
upload: info,
|
|
86
|
-
mediaType: info.mediaType
|
|
87
|
-
})
|
|
88
|
-
)
|
|
89
|
-
.catch((err: unknown) =>
|
|
90
|
-
liveStore.getState().updateAttachment(workspaceId, sessionId, item.localId, {
|
|
91
|
-
status: 'error',
|
|
92
|
-
error: err instanceof Error ? err.message : 'Upload failed'
|
|
93
|
-
})
|
|
94
|
-
)
|
|
95
|
-
})
|
|
109
|
+
if (allowFiles) stageComposerFiles({ workspaceId, sessionId }, files)
|
|
96
110
|
}
|
|
97
111
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
// Guards the await window while an annotation finishes: no re-entry from a
|
|
113
|
+
// second Enter, and the draft is re-read afterwards so text typed during the
|
|
114
|
+
// upload isn't lost.
|
|
115
|
+
const sendingRef = useRef(false)
|
|
116
|
+
|
|
117
|
+
const removeAttachment = (attachment: ChatAttachment) => {
|
|
118
|
+
if (attachment.kind === 'drawing' && onRemoveDrawing) {
|
|
119
|
+
onRemoveDrawing(attachment.localId)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
liveStore.getState().removeAttachment(workspaceId, sessionId, attachment.localId)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const send = async () => {
|
|
126
|
+
if (!canSend || sendingRef.current) return
|
|
127
|
+
sendingRef.current = true
|
|
128
|
+
try {
|
|
129
|
+
await annotation?.finish()
|
|
130
|
+
await onSend(valueRef.current)
|
|
131
|
+
if (!draft) {
|
|
132
|
+
valueRef.current = ''
|
|
133
|
+
useUiStore.getState().setComposerDraft(workspaceId, '')
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
sendingRef.current = false
|
|
137
|
+
}
|
|
102
138
|
}
|
|
103
139
|
|
|
104
140
|
return (
|
|
@@ -106,14 +142,15 @@ export function ChatComposer({
|
|
|
106
142
|
composerRef={composerRef}
|
|
107
143
|
onSubmit={e => {
|
|
108
144
|
e.preventDefault()
|
|
109
|
-
send()
|
|
145
|
+
void send()
|
|
110
146
|
}}
|
|
111
147
|
onDragOver={e => {
|
|
112
148
|
if (!e.dataTransfer.types.includes('Files')) return
|
|
113
149
|
e.preventDefault()
|
|
114
|
-
setDragOver(true)
|
|
150
|
+
if (allowFiles) setDragOver(true)
|
|
115
151
|
}}
|
|
116
152
|
onDragLeave={e => {
|
|
153
|
+
if (!allowFiles) return
|
|
117
154
|
// Ignore leaves into child elements — only reset when leaving the form.
|
|
118
155
|
if (e.currentTarget.contains(e.relatedTarget as Node | null)) return
|
|
119
156
|
setDragOver(false)
|
|
@@ -127,15 +164,9 @@ export function ChatComposer({
|
|
|
127
164
|
className={cn(dragOver && 'ring-2 ring-ring/60')}
|
|
128
165
|
>
|
|
129
166
|
{attachments.length > 0 && (
|
|
130
|
-
<div className="flex flex-wrap gap-2 px-1 pt-1 pb-
|
|
167
|
+
<div className="flex flex-wrap gap-2 px-1 pt-1 pb-1">
|
|
131
168
|
{attachments.map(a => (
|
|
132
|
-
<AttachmentChip
|
|
133
|
-
key={a.localId}
|
|
134
|
-
attachment={a}
|
|
135
|
-
onRemove={() =>
|
|
136
|
-
liveStore.getState().removeAttachment(workspaceId, sessionId, a.localId)
|
|
137
|
-
}
|
|
138
|
-
/>
|
|
169
|
+
<AttachmentChip key={a.localId} attachment={a} onRemove={() => removeAttachment(a)} />
|
|
139
170
|
))}
|
|
140
171
|
</div>
|
|
141
172
|
)}
|
|
@@ -149,7 +180,7 @@ export function ChatComposer({
|
|
|
149
180
|
onKeyDown={e => {
|
|
150
181
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
151
182
|
e.preventDefault()
|
|
152
|
-
send()
|
|
183
|
+
void send()
|
|
153
184
|
}
|
|
154
185
|
}}
|
|
155
186
|
onPaste={e => {
|
|
@@ -158,31 +189,64 @@ export function ChatComposer({
|
|
|
158
189
|
e.preventDefault()
|
|
159
190
|
addFiles(files)
|
|
160
191
|
}}
|
|
161
|
-
placeholder={processing ? 'Queue a follow-up' : 'Do anything'}
|
|
192
|
+
placeholder={processing ? 'Queue a follow-up' : (placeholder ?? 'Do anything')}
|
|
162
193
|
rows={1}
|
|
163
194
|
/>
|
|
164
195
|
<ComposerFooter>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
{allowFiles && (
|
|
197
|
+
<input
|
|
198
|
+
ref={fileRef}
|
|
199
|
+
type="file"
|
|
200
|
+
multiple
|
|
201
|
+
hidden
|
|
202
|
+
onChange={e => {
|
|
203
|
+
addFiles(Array.from(e.target.files ?? []))
|
|
204
|
+
e.target.value = ''
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
)}
|
|
208
|
+
<div className="mr-auto flex shrink-0 items-center gap-0.5">
|
|
209
|
+
{allowFiles && (
|
|
210
|
+
<Tooltip>
|
|
211
|
+
<TooltipTrigger
|
|
212
|
+
render={
|
|
213
|
+
<Button
|
|
214
|
+
type="button"
|
|
215
|
+
variant="ghost"
|
|
216
|
+
size="icon"
|
|
217
|
+
onClick={() => fileRef.current?.click()}
|
|
218
|
+
aria-label="Attach files"
|
|
219
|
+
>
|
|
220
|
+
{/* Paperclip is too heavy compared to the nearby scribble icon */}
|
|
221
|
+
<IconPaperclip stroke={1.6} className="size-4.5!" />
|
|
222
|
+
</Button>
|
|
223
|
+
}
|
|
224
|
+
/>
|
|
225
|
+
<TooltipContent>Attach files</TooltipContent>
|
|
226
|
+
</Tooltip>
|
|
227
|
+
)}
|
|
228
|
+
{annotation && (
|
|
229
|
+
<Tooltip>
|
|
230
|
+
<TooltipTrigger
|
|
231
|
+
render={
|
|
232
|
+
<Button
|
|
233
|
+
type="button"
|
|
234
|
+
variant="ghost"
|
|
235
|
+
size="icon"
|
|
236
|
+
onClick={annotation.onToggle}
|
|
237
|
+
className={cn(annotation.active && 'bg-accent')}
|
|
238
|
+
aria-label="Draw annotation"
|
|
239
|
+
aria-pressed={annotation.active}
|
|
240
|
+
>
|
|
241
|
+
<IconScribble stroke={1.5} />
|
|
242
|
+
</Button>
|
|
243
|
+
}
|
|
244
|
+
/>
|
|
245
|
+
<TooltipContent>Draw annotation</TooltipContent>
|
|
246
|
+
</Tooltip>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
<ModelPicker sessionId={modelSessionId} />
|
|
186
250
|
{processing ? (
|
|
187
251
|
<Tooltip>
|
|
188
252
|
<TooltipTrigger
|
|
@@ -217,13 +281,17 @@ type AttachmentChipProps = {
|
|
|
217
281
|
// A composer attachment preview: an image thumbnail or a labelled file chip,
|
|
218
282
|
// with an upload spinner / error overlay and a remove button.
|
|
219
283
|
function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {
|
|
284
|
+
if (attachment.kind === 'drawing') {
|
|
285
|
+
return <DrawingAttachmentChip attachment={attachment} onRemove={onRemove} />
|
|
286
|
+
}
|
|
287
|
+
|
|
220
288
|
const { name, previewUrl, status, error } = attachment
|
|
221
289
|
const isImage = !!previewUrl
|
|
222
290
|
|
|
223
291
|
return (
|
|
224
292
|
<div
|
|
225
293
|
className={cn(
|
|
226
|
-
'group relative flex items-center gap-2 overflow-hidden rounded-lg
|
|
294
|
+
'group relative flex items-center gap-2 overflow-hidden rounded-lg bg-accent text-accent-foreground ring-1 ring-border',
|
|
227
295
|
isImage ? 'size-14' : 'h-10 max-w-52 pr-2 pl-2',
|
|
228
296
|
status === 'error' && 'border-destructive/50'
|
|
229
297
|
)}
|
|
@@ -262,3 +330,48 @@ function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {
|
|
|
262
330
|
</div>
|
|
263
331
|
)
|
|
264
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
|
+
)
|
|
377
|
+
}
|
|
@@ -4,9 +4,10 @@ import { AnimatePresence, motion } from 'motion/react'
|
|
|
4
4
|
|
|
5
5
|
import { IconBolt, IconBoltFilled } from '@tabler/icons-react'
|
|
6
6
|
|
|
7
|
-
import { useSaveSessionConfig, useSessionConfig } from '
|
|
7
|
+
import { useSaveSessionConfig, useSessionConfig } from '../api'
|
|
8
8
|
import { useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
9
9
|
import {
|
|
10
|
+
groupModels,
|
|
10
11
|
hasEffortChoice,
|
|
11
12
|
resolveDisplayedEffort,
|
|
12
13
|
resolveEffortIndex,
|
|
@@ -31,7 +32,6 @@ import {
|
|
|
31
32
|
} from '@/client/components/ui/popover'
|
|
32
33
|
import { Slider } from '@/client/components/ui/slider'
|
|
33
34
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
34
|
-
import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
|
|
35
35
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
36
36
|
import { cn } from '@/client/lib/cn'
|
|
37
37
|
import type { Model } from '@/lib/types'
|
|
@@ -42,6 +42,13 @@ function headline(description?: string): string {
|
|
|
42
42
|
return description?.split(/\s*·\s*/)[0] ?? ''
|
|
43
43
|
}
|
|
44
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
|
+
|
|
45
52
|
function capitalize(s: string): string {
|
|
46
53
|
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
47
54
|
}
|
|
@@ -92,24 +99,27 @@ type ModelDropdownProps = {
|
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownProps) {
|
|
95
|
-
const label =
|
|
102
|
+
const label = modelLabel(model)
|
|
103
|
+
const groups = groupModels(models, 'Models')
|
|
96
104
|
|
|
97
105
|
return (
|
|
98
106
|
<DropdownMenu>
|
|
99
107
|
<DropdownMenuTrigger
|
|
100
|
-
render={<PickerTrigger label={label} aria-label={`Model: ${label}`} />}
|
|
108
|
+
render={<PickerTrigger label={label} className="shrink" aria-label={`Model: ${label}`} />}
|
|
101
109
|
/>
|
|
102
110
|
<DropdownMenuContent align="end" side="top" className="w-max max-w-64 min-w-40">
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
<DropdownMenuRadioGroup value={current} onValueChange={onValueChange}>
|
|
112
|
+
{groups.map(group => (
|
|
113
|
+
<DropdownMenuGroup key={group.label}>
|
|
114
|
+
<DropdownMenuLabel>{group.label}</DropdownMenuLabel>
|
|
115
|
+
{group.models.map(item => (
|
|
116
|
+
<DropdownMenuRadioItem key={item.value} value={item.value} closeOnClick>
|
|
117
|
+
{modelLabel(item)}
|
|
118
|
+
</DropdownMenuRadioItem>
|
|
119
|
+
))}
|
|
120
|
+
</DropdownMenuGroup>
|
|
121
|
+
))}
|
|
122
|
+
</DropdownMenuRadioGroup>
|
|
113
123
|
</DropdownMenuContent>
|
|
114
124
|
</DropdownMenu>
|
|
115
125
|
)
|
|
@@ -268,18 +278,15 @@ function EffortPicker({
|
|
|
268
278
|
}
|
|
269
279
|
|
|
270
280
|
type ModelPickerProps = {
|
|
271
|
-
|
|
281
|
+
sessionId: string | null
|
|
272
282
|
}
|
|
273
283
|
|
|
274
284
|
// Model selector for composer surfaces. The workspace's available models come
|
|
275
285
|
// from `/api/workspaces/:id/agent`; effort options follow the selected model.
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
// the same defaults that their submit path reads.
|
|
280
|
-
export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }: ModelPickerProps) {
|
|
286
|
+
// A session id targets that chat's stored config. Null targets the workspace
|
|
287
|
+
// defaults that seed new chats such as the view builder.
|
|
288
|
+
export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerProps) {
|
|
281
289
|
const { workspaceId, layout, setLayout } = useWorkspaceLayoutCtx()
|
|
282
|
-
const [selectedSessionId] = useSelectedSession()
|
|
283
290
|
const { data } = useWorkspaceAgent(workspaceId)
|
|
284
291
|
|
|
285
292
|
// The SDK prepends a synthetic "default" entry ("Use the default model
|
|
@@ -293,9 +300,6 @@ export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }:
|
|
|
293
300
|
)
|
|
294
301
|
: []
|
|
295
302
|
|
|
296
|
-
// The selected chat's stored config is the source of truth. With New chat,
|
|
297
|
-
// the picker reads and edits workspace defaults.
|
|
298
|
-
const sessionId = scope === 'active-chat' ? (selectedSessionId ?? null) : null
|
|
299
303
|
const sessionConfig = useSessionConfig(workspaceId, sessionId).data
|
|
300
304
|
const saveSessionConfig = useSaveSessionConfig(workspaceId)
|
|
301
305
|
|
|
@@ -338,7 +342,7 @@ export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }:
|
|
|
338
342
|
const fastMode = resolveFastMode(model, selectedFastMode)
|
|
339
343
|
|
|
340
344
|
return (
|
|
341
|
-
<div className="flex
|
|
345
|
+
<div className="flex min-w-0 items-center gap-1">
|
|
342
346
|
<ModelDropdown
|
|
343
347
|
current={currentModelValue}
|
|
344
348
|
model={model}
|
|
@@ -2,7 +2,7 @@ import type { ComponentProps, ReactNode } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { cn } from '@/client/lib/cn'
|
|
4
4
|
|
|
5
|
-
export type ComposerBannerTone = '
|
|
5
|
+
export type ComposerBannerTone = 'default' | 'error'
|
|
6
6
|
|
|
7
7
|
export type ComposerBanner = {
|
|
8
8
|
tone: ComposerBannerTone
|
|
@@ -58,26 +58,17 @@ export function WorkspaceAgentAvailabilityBanner({
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
|
-
<ComposerBannerShell
|
|
62
|
-
role="alert"
|
|
63
|
-
className="grid grid-cols-[auto_minmax(0,1fr)] gap-2 @xl:grid-cols-[auto_minmax(0,1fr)_auto] @xl:items-center"
|
|
64
|
-
>
|
|
61
|
+
<ComposerBannerShell role="alert" className="flex items-center gap-2">
|
|
65
62
|
<IconLogin size={20} stroke={1.5} />
|
|
66
|
-
<div className="min-w-0 space-y-1">
|
|
67
|
-
<div className="wrap-break-word">Log in to your agent
|
|
63
|
+
<div className="min-w-0 flex-1 space-y-1">
|
|
64
|
+
<div className="wrap-break-word">Log in to your agent to send messages</div>
|
|
68
65
|
{(error ?? failure) && (
|
|
69
66
|
<div className="wrap-break-word text-destructive">{error ?? failure}</div>
|
|
70
67
|
)}
|
|
71
68
|
</div>
|
|
72
69
|
|
|
73
70
|
{availability.loginCommand && (
|
|
74
|
-
<Button
|
|
75
|
-
type="button"
|
|
76
|
-
size="sm"
|
|
77
|
-
onClick={() => void startLogin()}
|
|
78
|
-
disabled={busy}
|
|
79
|
-
className="col-span-2 w-fit @xl:col-span-1"
|
|
80
|
-
>
|
|
71
|
+
<Button type="button" size="sm" onClick={() => void startLogin()} disabled={busy}>
|
|
81
72
|
{busy && <IconLoader2 stroke={1.75} className="animate-spin" />}
|
|
82
73
|
{phase === 'starting'
|
|
83
74
|
? 'Opening browser to sign in…'
|
|
@@ -73,3 +73,19 @@ export function sortModelsByProviderOrder(models: Model[], provider: WorkspaceTy
|
|
|
73
73
|
const compare = PROVIDER_MODEL_COMPARATORS[provider]
|
|
74
74
|
return compare ? stableSortModels(models, compare) : models
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
export type ModelGroup = { label: string; models: Model[] }
|
|
78
|
+
|
|
79
|
+
// Picker sections. Backends that group their catalog (Hermes, by upstream
|
|
80
|
+
// provider) get one section per `group`, in first-appearance order; everything
|
|
81
|
+
// else stays a single "Models" section.
|
|
82
|
+
export function groupModels(models: readonly Model[], fallbackLabel: string): ModelGroup[] {
|
|
83
|
+
const groups: ModelGroup[] = []
|
|
84
|
+
for (const model of models) {
|
|
85
|
+
const label = model.group ?? fallbackLabel
|
|
86
|
+
const existing = groups.find(group => group.label === label)
|
|
87
|
+
if (existing) existing.models.push(model)
|
|
88
|
+
else groups.push({ label, models: [model] })
|
|
89
|
+
}
|
|
90
|
+
return groups
|
|
91
|
+
}
|
|
@@ -14,6 +14,7 @@ type WorkspaceComposerStateOptions = {
|
|
|
14
14
|
|
|
15
15
|
type WorkspaceComposerState = {
|
|
16
16
|
composerBanner?: ComposerBanner
|
|
17
|
+
builderComposerBanner?: ComposerBanner
|
|
17
18
|
composerAvailability: ComposerAvailability
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -42,7 +43,7 @@ export function useWorkspaceComposerState(
|
|
|
42
43
|
|
|
43
44
|
const agentUnavailableBanner: ComposerBanner | undefined = unavailable
|
|
44
45
|
? {
|
|
45
|
-
tone: '
|
|
46
|
+
tone: 'default',
|
|
46
47
|
content: (
|
|
47
48
|
<WorkspaceAgentAvailabilityBanner
|
|
48
49
|
availability={unavailable}
|
|
@@ -54,13 +55,13 @@ export function useWorkspaceComposerState(
|
|
|
54
55
|
: undefined
|
|
55
56
|
const chatErrorBanner: ComposerBanner | undefined = chatError
|
|
56
57
|
? {
|
|
57
|
-
tone: '
|
|
58
|
+
tone: 'error',
|
|
58
59
|
content: <ChatErrorBanner error={chatError} onDismiss={onDismissChatError} />
|
|
59
60
|
}
|
|
60
61
|
: undefined
|
|
61
62
|
const skillUpdate: ComposerBanner | undefined = skillUpdateBanner
|
|
62
63
|
? {
|
|
63
|
-
tone: '
|
|
64
|
+
tone: 'default',
|
|
64
65
|
content: <WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
|
|
65
66
|
}
|
|
66
67
|
: undefined
|
|
@@ -69,6 +70,10 @@ export function useWorkspaceComposerState(
|
|
|
69
70
|
chatError: chatErrorBanner,
|
|
70
71
|
skillUpdate
|
|
71
72
|
})
|
|
73
|
+
const builderComposerBanner = resolveComposerBanner({
|
|
74
|
+
agentUnavailable: agentUnavailableBanner,
|
|
75
|
+
skillUpdate
|
|
76
|
+
})
|
|
72
77
|
|
|
73
|
-
return { composerAvailability, composerBanner }
|
|
78
|
+
return { composerAvailability, composerBanner, builderComposerBanner }
|
|
74
79
|
}
|