@sixb/app 0.2.5 → 0.2.6
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/dist/agent/components/agent-threads.d.ts.map +1 -1
- package/dist/agent/components/composer-place.d.ts.map +1 -1
- package/dist/agent/components/computer-place.d.ts +24 -6
- package/dist/agent/components/computer-place.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts +13 -3
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +13 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +4 -0
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/format.d.ts +7 -0
- package/dist/agent/format.d.ts.map +1 -1
- package/dist/agent/hooks/thread-queries.d.ts +1548 -0
- package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +41 -2
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-place.d.ts +49 -0
- package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
- package/dist/agent/i18n/en.d.ts +39 -6
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +66 -12
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/model-selection.d.ts +3 -2
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/moves.d.ts +40 -0
- package/dist/agent/moves.d.ts.map +1 -0
- package/dist/agent/thread-reader-state.d.ts +30 -0
- package/dist/agent/thread-reader-state.d.ts.map +1 -0
- package/dist/agent/types.d.ts +4 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -1
- package/dist/{chunk-5sgac68y.js → chunk-096d52h2.js} +1 -1
- package/dist/{chunk-4wm09prf.js → chunk-94d7enwc.js} +1 -1
- package/dist/{chunk-69qgh20f.js → chunk-ezntd3yy.js} +1 -1
- package/dist/{chunk-4fex83k2.js → chunk-qjw5r2vk.js} +2233 -732
- package/dist/{chunk-4fex83k2.js.map → chunk-qjw5r2vk.js.map} +28 -25
- package/dist/createCustomApp.d.ts +8 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +3 -3
- package/dist/pages/console/data/accounts.d.ts +94 -0
- package/dist/pages/console/data/accounts.d.ts.map +1 -0
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/live-updates.d.ts.map +1 -1
- package/dist/pages/console/data/messages.d.ts +46 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/sync-button.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/page.d.ts +4 -1
- package/dist/pages/settings/usage/page.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +43 -19
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages.js +23086 -22619
- package/dist/pages.js.map +13 -12
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -3
- package/dist/server.js.map +3 -3
- package/package.json +3 -3
- package/src/agent/agent-chat.tsx +2 -2
- package/src/agent/components/agent-threads.tsx +42 -2
- package/src/agent/components/composer-place.tsx +2 -7
- package/src/agent/components/computer-place.tsx +415 -70
- package/src/agent/components/conversation-panel.tsx +31 -26
- package/src/agent/components/message-view.tsx +418 -9
- package/src/agent/components/pending-messages.tsx +5 -1
- package/src/agent/components/transcript.tsx +136 -5
- package/src/agent/conversation.ts +16 -1
- package/src/agent/format.ts +52 -0
- package/src/agent/hooks/thread-queries.ts +75 -0
- package/src/agent/hooks/use-agent-conversation.ts +454 -112
- package/src/agent/hooks/use-thread-lists.ts +72 -7
- package/src/agent/hooks/use-thread-place.ts +239 -0
- package/src/agent/i18n/en.ts +63 -16
- package/src/agent/i18n/fr.ts +65 -19
- package/src/agent/live-run.ts +38 -0
- package/src/agent/model-selection.ts +3 -2
- package/src/agent/moves.ts +174 -0
- package/src/agent/thread-reader-state.ts +75 -0
- package/src/agent/types.ts +6 -0
- package/src/artifacts/live/session.ts +5 -0
- package/src/createCustomApp.ts +57 -3
- package/src/index.ts +4 -0
- package/src/pages/console/data/accounts.tsx +509 -0
- package/src/pages/console/data/connectors.tsx +7 -15
- package/src/pages/console/data/live-updates.ts +2 -0
- package/src/pages/console/data/messages.ts +73 -0
- package/src/pages/console/data/sync-button.tsx +56 -16
- package/src/pages/console/data/syncs.tsx +66 -41
- package/src/pages/section-ui.tsx +1 -1
- package/src/pages/settings/usage/breakdown.tsx +5 -2
- package/src/pages/settings/usage/filter-menu.tsx +1 -1
- package/src/pages/settings/usage/page.tsx +32 -13
- package/src/pages/settings/usage/spend-chart.tsx +2 -2
- package/src/pages/settings/usage/spend-model.ts +118 -50
- package/src/server.ts +1 -0
- /package/dist/{chunk-5sgac68y.js.map → chunk-096d52h2.js.map} +0 -0
- /package/dist/{chunk-4wm09prf.js.map → chunk-94d7enwc.js.map} +0 -0
- /package/dist/{chunk-69qgh20f.js.map → chunk-ezntd3yy.js.map} +0 -0
|
@@ -8,30 +8,58 @@ import {
|
|
|
8
8
|
Marker,
|
|
9
9
|
MarkerContent,
|
|
10
10
|
MarkerIcon,
|
|
11
|
+
Tooltip,
|
|
12
|
+
TooltipContent,
|
|
13
|
+
TooltipProvider,
|
|
14
|
+
TooltipTrigger,
|
|
11
15
|
} from "@sixb/ui/components"
|
|
16
|
+
import { useLocale } from "@sixb/ui/lib/i18n"
|
|
12
17
|
import { cn } from "@sixb/ui/lib/utils"
|
|
13
18
|
import {
|
|
14
19
|
AlertTriangle,
|
|
15
20
|
ArrowRight,
|
|
21
|
+
Check,
|
|
16
22
|
ChevronRight,
|
|
17
23
|
Clock3,
|
|
24
|
+
Cloud,
|
|
25
|
+
Copy,
|
|
26
|
+
File as FileIcon,
|
|
27
|
+
Folder,
|
|
28
|
+
Info,
|
|
18
29
|
type LucideIcon,
|
|
30
|
+
Pencil,
|
|
19
31
|
Plus,
|
|
20
32
|
RotateCcw,
|
|
21
33
|
Unplug,
|
|
34
|
+
X,
|
|
22
35
|
} from "lucide-react"
|
|
23
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
type KeyboardEvent,
|
|
38
|
+
memo,
|
|
39
|
+
type ReactNode,
|
|
40
|
+
useEffect,
|
|
41
|
+
useLayoutEffect,
|
|
42
|
+
useRef,
|
|
43
|
+
useState,
|
|
44
|
+
} from "react"
|
|
24
45
|
import type { FileSource } from "../../artifacts/file-source"
|
|
25
46
|
import type { AgentConversationMessage } from "../conversation"
|
|
47
|
+
import { formatMessageTimeAgo, formatMessageTimestamp } from "../format"
|
|
48
|
+
import type { AgentMessageEditDraft } from "../hooks/use-agent-conversation"
|
|
26
49
|
import { useAgentMessages } from "../i18n"
|
|
27
50
|
import type { AgentMessages } from "../i18n/en"
|
|
28
51
|
import { riseFromTray } from "../inbox-handoff"
|
|
29
52
|
import { type AuthorLabel, useMessageAuthors } from "../message-authors"
|
|
30
53
|
import { isContinuableDiagnostic } from "../run-presentation"
|
|
31
|
-
import type { AgentFileRef } from "../types"
|
|
54
|
+
import type { AgentContextEntryInput, AgentFileRef } from "../types"
|
|
32
55
|
import { ACTIVITY_STATUS_ROW_CLASS_NAME, ActivityStatusText } from "./activity-status"
|
|
33
56
|
import { AgentMessageBody } from "./agent-message-body"
|
|
34
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
COMPOSER_CHIP_CLASS_NAME,
|
|
59
|
+
COMPOSER_CHIP_REMOVE_CLASS_NAME,
|
|
60
|
+
COMPOSER_CHIP_THUMB_CLASS_NAME,
|
|
61
|
+
ContextChips,
|
|
62
|
+
} from "./context-chips"
|
|
35
63
|
import { FileAttachmentCard } from "./file-attachment-card"
|
|
36
64
|
|
|
37
65
|
/**
|
|
@@ -42,17 +70,44 @@ import { FileAttachmentCard } from "./file-attachment-card"
|
|
|
42
70
|
export const MessageView = memo(function MessageView({
|
|
43
71
|
message,
|
|
44
72
|
continued = false,
|
|
73
|
+
canEdit = false,
|
|
74
|
+
editing = null,
|
|
75
|
+
onStartEdit,
|
|
76
|
+
onCancelEdit,
|
|
77
|
+
onSubmitEdit,
|
|
45
78
|
onContinue,
|
|
46
79
|
continuing = false,
|
|
47
80
|
after,
|
|
48
81
|
}: {
|
|
49
82
|
readonly message: AgentConversationMessage
|
|
50
83
|
readonly continued?: boolean
|
|
84
|
+
readonly canEdit?: boolean
|
|
85
|
+
readonly editing?: AgentMessageEditDraft | null
|
|
86
|
+
readonly onStartEdit?: (messageId: string) => void
|
|
87
|
+
readonly onCancelEdit?: () => void
|
|
88
|
+
readonly onSubmitEdit?: (
|
|
89
|
+
messageId: string,
|
|
90
|
+
text: string,
|
|
91
|
+
attachments: readonly AgentFileRef[],
|
|
92
|
+
context: readonly AgentContextEntryInput[]
|
|
93
|
+
) => void
|
|
51
94
|
readonly onContinue?: () => void
|
|
52
95
|
readonly continuing?: boolean
|
|
53
96
|
readonly after?: ReactNode
|
|
54
97
|
}) {
|
|
55
|
-
if (message.role === "user")
|
|
98
|
+
if (message.role === "user") {
|
|
99
|
+
return (
|
|
100
|
+
<UserMessage
|
|
101
|
+
message={message}
|
|
102
|
+
continued={continued}
|
|
103
|
+
canEdit={canEdit}
|
|
104
|
+
editing={editing}
|
|
105
|
+
onStartEdit={onStartEdit}
|
|
106
|
+
onCancelEdit={onCancelEdit}
|
|
107
|
+
onSubmitEdit={onSubmitEdit}
|
|
108
|
+
/>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
56
111
|
|
|
57
112
|
return (
|
|
58
113
|
<AssistantMessage
|
|
@@ -64,14 +119,41 @@ export const MessageView = memo(function MessageView({
|
|
|
64
119
|
)
|
|
65
120
|
})
|
|
66
121
|
|
|
122
|
+
const USER_ACTION_BUTTON_CLASS_NAME = cn(
|
|
123
|
+
"relative flex size-6 items-center justify-center rounded-md text-muted-foreground/80 outline-none transition-colors",
|
|
124
|
+
"hover:bg-muted/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
125
|
+
// A finger needs more room than the icon: the touch area reaches 40px, the layout stays.
|
|
126
|
+
"[@media(hover:none)]:after:absolute [@media(hover:none)]:after:-inset-2"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
const EDIT_MAX_HEIGHT_PX = 240
|
|
130
|
+
|
|
67
131
|
function UserMessage({
|
|
68
132
|
message,
|
|
69
133
|
continued,
|
|
134
|
+
canEdit,
|
|
135
|
+
editing,
|
|
136
|
+
onStartEdit,
|
|
137
|
+
onCancelEdit,
|
|
138
|
+
onSubmitEdit,
|
|
70
139
|
}: {
|
|
71
140
|
readonly message: AgentConversationMessage
|
|
72
141
|
readonly continued: boolean
|
|
142
|
+
readonly canEdit: boolean
|
|
143
|
+
readonly editing: AgentMessageEditDraft | null
|
|
144
|
+
readonly onStartEdit?: (messageId: string) => void
|
|
145
|
+
readonly onCancelEdit?: () => void
|
|
146
|
+
readonly onSubmitEdit?: (
|
|
147
|
+
messageId: string,
|
|
148
|
+
text: string,
|
|
149
|
+
attachments: readonly AgentFileRef[],
|
|
150
|
+
context: readonly AgentContextEntryInput[]
|
|
151
|
+
) => void
|
|
73
152
|
}) {
|
|
74
153
|
const authors = useMessageAuthors()
|
|
154
|
+
const agentMessages = useAgentMessages()
|
|
155
|
+
const labels = agentMessages.transcript
|
|
156
|
+
const locale = useLocale()
|
|
75
157
|
const text = textOf(message)
|
|
76
158
|
const files = message.parts.flatMap((part) => (part.type === "file" ? [part] : []))
|
|
77
159
|
const pending = message.status === "pending"
|
|
@@ -84,10 +166,71 @@ function UserMessage({
|
|
|
84
166
|
if (message.status === "streaming" && ref.current) riseFromTray(ref.current, message.key)
|
|
85
167
|
}, [])
|
|
86
168
|
|
|
87
|
-
|
|
169
|
+
const [copied, setCopied] = useState(false)
|
|
170
|
+
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if (!copied) return
|
|
173
|
+
const timer = window.setTimeout(() => setCopied(false), 1_600)
|
|
174
|
+
return () => window.clearTimeout(timer)
|
|
175
|
+
}, [copied])
|
|
176
|
+
|
|
177
|
+
// A touch screen has no hover: touching the message shows its time and actions, and touching
|
|
178
|
+
// anywhere else puts them away.
|
|
179
|
+
const [touched, setTouched] = useState(false)
|
|
180
|
+
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (!touched) return
|
|
183
|
+
const away = (event: PointerEvent) => {
|
|
184
|
+
if (!ref.current?.contains(event.target as Node)) setTouched(false)
|
|
185
|
+
}
|
|
186
|
+
document.addEventListener("pointerdown", away)
|
|
187
|
+
return () => document.removeEventListener("pointerdown", away)
|
|
188
|
+
}, [touched])
|
|
189
|
+
|
|
190
|
+
if (!text && files.length === 0 && message.context.length === 0 && !editing) return null
|
|
191
|
+
|
|
192
|
+
if (editing && message.id && onSubmitEdit && onCancelEdit) {
|
|
193
|
+
return (
|
|
194
|
+
<div data-user-message="" className="flex flex-col items-end gap-1.5">
|
|
195
|
+
{continued ? null : <AuthorLine author={authors?.labelOf(message.author)} />}
|
|
196
|
+
<UserMessageEditor
|
|
197
|
+
key={`${editing.messageId}:${editing.nonce}`}
|
|
198
|
+
draft={editing}
|
|
199
|
+
onCancel={onCancelEdit}
|
|
200
|
+
onSubmit={(nextText, nextAttachments, nextContext) =>
|
|
201
|
+
onSubmitEdit(editing.messageId, nextText, nextAttachments, nextContext)
|
|
202
|
+
}
|
|
203
|
+
/>
|
|
204
|
+
</div>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const messageId = message.id
|
|
209
|
+
const showEdit = Boolean(!pending && canEdit && messageId && onStartEdit)
|
|
210
|
+
const showCopy = !pending && text.length > 0
|
|
211
|
+
const age = !pending
|
|
212
|
+
? formatMessageTimeAgo(message.createdAt, locale, agentMessages.contextMeter.justNow)
|
|
213
|
+
: ""
|
|
214
|
+
const timestampTitle = !pending ? formatMessageTimestamp(message.createdAt, locale) : ""
|
|
215
|
+
const showHoverBar = !pending && Boolean(age || showEdit || showCopy)
|
|
216
|
+
|
|
217
|
+
const handleCopy = () => {
|
|
218
|
+
if (!text) return
|
|
219
|
+
void navigator.clipboard?.writeText(text).then(
|
|
220
|
+
() => setCopied(true),
|
|
221
|
+
() => {}
|
|
222
|
+
)
|
|
223
|
+
}
|
|
88
224
|
|
|
89
225
|
return (
|
|
90
|
-
<div
|
|
226
|
+
<div
|
|
227
|
+
ref={ref}
|
|
228
|
+
data-user-message=""
|
|
229
|
+
className="group/user-message flex flex-col items-end gap-1.5"
|
|
230
|
+
onPointerUp={(event) => {
|
|
231
|
+
if (event.pointerType !== "mouse") setTouched(true)
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
91
234
|
{continued ? null : <AuthorLine author={authors?.labelOf(message.author)} />}
|
|
92
235
|
<ContextChips
|
|
93
236
|
entries={message.context}
|
|
@@ -107,6 +250,259 @@ function UserMessage({
|
|
|
107
250
|
</BubbleContent>
|
|
108
251
|
</Bubble>
|
|
109
252
|
) : null}
|
|
253
|
+
{showHoverBar ? (
|
|
254
|
+
<TooltipProvider delayDuration={300}>
|
|
255
|
+
<div
|
|
256
|
+
data-user-message-actions=""
|
|
257
|
+
data-visible={copied || touched || undefined}
|
|
258
|
+
className={cn(
|
|
259
|
+
"-mt-0.5 -mb-4 flex h-6 items-center justify-end gap-0.5 pr-0.5 select-none [@media(hover:none)]:gap-4",
|
|
260
|
+
"pointer-events-none opacity-0 transition-opacity duration-150 ease-out",
|
|
261
|
+
"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100",
|
|
262
|
+
"group-focus-within/user-message:pointer-events-auto group-focus-within/user-message:opacity-100",
|
|
263
|
+
"data-[visible]:pointer-events-auto data-[visible]:opacity-100"
|
|
264
|
+
)}
|
|
265
|
+
>
|
|
266
|
+
{age ? (
|
|
267
|
+
<span
|
|
268
|
+
data-user-message-age=""
|
|
269
|
+
title={timestampTitle || undefined}
|
|
270
|
+
className="mr-1.5 text-xs text-muted-foreground/80 tabular-nums"
|
|
271
|
+
>
|
|
272
|
+
{age}
|
|
273
|
+
</span>
|
|
274
|
+
) : null}
|
|
275
|
+
{showEdit && messageId && onStartEdit ? (
|
|
276
|
+
<Tooltip>
|
|
277
|
+
<TooltipTrigger asChild>
|
|
278
|
+
<button
|
|
279
|
+
type="button"
|
|
280
|
+
onClick={() => onStartEdit(messageId)}
|
|
281
|
+
aria-label={labels.editMessage}
|
|
282
|
+
className={USER_ACTION_BUTTON_CLASS_NAME}
|
|
283
|
+
>
|
|
284
|
+
<Pencil className="size-3.5" strokeWidth={1.75} aria-hidden="true" />
|
|
285
|
+
</button>
|
|
286
|
+
</TooltipTrigger>
|
|
287
|
+
<TooltipContent side="bottom">{labels.editMessage}</TooltipContent>
|
|
288
|
+
</Tooltip>
|
|
289
|
+
) : null}
|
|
290
|
+
{showCopy ? (
|
|
291
|
+
<Tooltip>
|
|
292
|
+
<TooltipTrigger asChild>
|
|
293
|
+
<button
|
|
294
|
+
type="button"
|
|
295
|
+
onClick={handleCopy}
|
|
296
|
+
aria-label={copied ? labels.copiedMessage : labels.copyMessage}
|
|
297
|
+
className={USER_ACTION_BUTTON_CLASS_NAME}
|
|
298
|
+
>
|
|
299
|
+
{copied ? (
|
|
300
|
+
<Check
|
|
301
|
+
className="size-3.5 text-foreground"
|
|
302
|
+
strokeWidth={2}
|
|
303
|
+
aria-hidden="true"
|
|
304
|
+
/>
|
|
305
|
+
) : (
|
|
306
|
+
<Copy className="size-3.5" strokeWidth={1.75} aria-hidden="true" />
|
|
307
|
+
)}
|
|
308
|
+
</button>
|
|
309
|
+
</TooltipTrigger>
|
|
310
|
+
<TooltipContent side="bottom">
|
|
311
|
+
{copied ? labels.copiedMessage : labels.copyMessage}
|
|
312
|
+
</TooltipContent>
|
|
313
|
+
</Tooltip>
|
|
314
|
+
) : null}
|
|
315
|
+
</div>
|
|
316
|
+
</TooltipProvider>
|
|
317
|
+
) : null}
|
|
318
|
+
</div>
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function UserMessageEditor({
|
|
323
|
+
draft,
|
|
324
|
+
onCancel,
|
|
325
|
+
onSubmit,
|
|
326
|
+
}: {
|
|
327
|
+
readonly draft: AgentMessageEditDraft
|
|
328
|
+
readonly onCancel: () => void
|
|
329
|
+
readonly onSubmit: (
|
|
330
|
+
text: string,
|
|
331
|
+
attachments: readonly AgentFileRef[],
|
|
332
|
+
context: readonly AgentContextEntryInput[]
|
|
333
|
+
) => void
|
|
334
|
+
}) {
|
|
335
|
+
const agentMessages = useAgentMessages()
|
|
336
|
+
const labels = agentMessages.transcript
|
|
337
|
+
const [value, setValue] = useState(draft.text)
|
|
338
|
+
const [attachments, setAttachments] = useState<readonly AgentFileRef[]>(draft.attachments)
|
|
339
|
+
const [contextEntries, setContextEntries] = useState<readonly AgentContextEntryInput[]>(
|
|
340
|
+
draft.context
|
|
341
|
+
)
|
|
342
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
343
|
+
|
|
344
|
+
useLayoutEffect(() => {
|
|
345
|
+
const el = textareaRef.current
|
|
346
|
+
if (!el) return
|
|
347
|
+
el.focus({ preventScroll: true })
|
|
348
|
+
el.setSelectionRange(el.value.length, el.value.length)
|
|
349
|
+
|
|
350
|
+
// Reopened after a refused save or a Stop, the editor may sit off screen: once the transcript
|
|
351
|
+
// has settled, it comes into view, clear of the header and the composer, and keeps the focus.
|
|
352
|
+
const frame = requestAnimationFrame(() => {
|
|
353
|
+
el.closest("[data-user-message-editor]")?.scrollIntoView({ block: "nearest" })
|
|
354
|
+
if (document.activeElement !== el) el.focus({ preventScroll: true })
|
|
355
|
+
})
|
|
356
|
+
return () => cancelAnimationFrame(frame)
|
|
357
|
+
}, [])
|
|
358
|
+
|
|
359
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: re-measure height whenever the text changes
|
|
360
|
+
useLayoutEffect(() => {
|
|
361
|
+
const el = textareaRef.current
|
|
362
|
+
if (!el) return
|
|
363
|
+
el.style.height = "auto"
|
|
364
|
+
el.style.overflowY = el.scrollHeight > EDIT_MAX_HEIGHT_PX ? "auto" : "hidden"
|
|
365
|
+
el.style.height = `${Math.min(el.scrollHeight, EDIT_MAX_HEIGHT_PX)}px`
|
|
366
|
+
}, [value])
|
|
367
|
+
|
|
368
|
+
const canSave = value.trim().length > 0 || attachments.length > 0
|
|
369
|
+
|
|
370
|
+
const submit = () => {
|
|
371
|
+
if (!canSave) return
|
|
372
|
+
onSubmit(value.trim(), attachments, contextEntries)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
376
|
+
// Enter and Escape confirm or dismiss the input method's candidate while one is open; Safari
|
|
377
|
+
// reports that keydown with keyCode 229 rather than `isComposing`.
|
|
378
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return
|
|
379
|
+
if (event.key === "Escape") {
|
|
380
|
+
event.preventDefault()
|
|
381
|
+
onCancel()
|
|
382
|
+
return
|
|
383
|
+
}
|
|
384
|
+
if (event.key !== "Enter" || event.shiftKey) return
|
|
385
|
+
event.preventDefault()
|
|
386
|
+
if (event.metaKey || event.ctrlKey) {
|
|
387
|
+
const el = textareaRef.current
|
|
388
|
+
const start = el?.selectionStart ?? value.length
|
|
389
|
+
const end = el?.selectionEnd ?? value.length
|
|
390
|
+
setValue((current) => `${current.slice(0, start)}\n${current.slice(end)}`)
|
|
391
|
+
requestAnimationFrame(() => {
|
|
392
|
+
el?.setSelectionRange(start + 1, start + 1)
|
|
393
|
+
})
|
|
394
|
+
return
|
|
395
|
+
}
|
|
396
|
+
submit()
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<div
|
|
401
|
+
data-user-message-editor=""
|
|
402
|
+
className="flex w-full scroll-mt-20 scroll-mb-48 flex-col items-end gap-2"
|
|
403
|
+
>
|
|
404
|
+
<div
|
|
405
|
+
className={cn(
|
|
406
|
+
"flex w-full max-w-[min(85%,42rem)] flex-col gap-2 rounded-2xl bg-background px-3.5 py-2.5",
|
|
407
|
+
"ring-1 ring-[#007aff] shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:ring-[#0a84ff]"
|
|
408
|
+
)}
|
|
409
|
+
>
|
|
410
|
+
{contextEntries.length > 0 || attachments.length > 0 ? (
|
|
411
|
+
<div className="flex flex-wrap gap-1.5">
|
|
412
|
+
<ContextChips
|
|
413
|
+
entries={contextEntries}
|
|
414
|
+
onRemove={(index) =>
|
|
415
|
+
setContextEntries((current) =>
|
|
416
|
+
current.filter((_, candidateIndex) => candidateIndex !== index)
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
className="contents"
|
|
420
|
+
/>
|
|
421
|
+
{attachments.map((fileRef, index) => (
|
|
422
|
+
<span
|
|
423
|
+
key={`${fileRef.blobId}:${index}`}
|
|
424
|
+
className={cn(COMPOSER_CHIP_CLASS_NAME, "pr-1.5")}
|
|
425
|
+
title={fileRef.fileName}
|
|
426
|
+
>
|
|
427
|
+
<span className={COMPOSER_CHIP_THUMB_CLASS_NAME}>
|
|
428
|
+
<FileIcon className="size-3" strokeWidth={2} aria-hidden="true" />
|
|
429
|
+
</span>
|
|
430
|
+
<span className="min-w-0 flex-1 truncate">
|
|
431
|
+
{fileRef.fileName || agentMessages.files.file}
|
|
432
|
+
</span>
|
|
433
|
+
<button
|
|
434
|
+
type="button"
|
|
435
|
+
onClick={() =>
|
|
436
|
+
setAttachments((current) =>
|
|
437
|
+
current.filter((_, candidateIndex) => candidateIndex !== index)
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
aria-label={
|
|
441
|
+
fileRef.fileName
|
|
442
|
+
? agentMessages.composer.removeAttachment(fileRef.fileName)
|
|
443
|
+
: agentMessages.composer.removeUnnamedAttachment
|
|
444
|
+
}
|
|
445
|
+
className={COMPOSER_CHIP_REMOVE_CLASS_NAME}
|
|
446
|
+
>
|
|
447
|
+
<X className="size-[11px]" strokeWidth={2.6} />
|
|
448
|
+
</button>
|
|
449
|
+
</span>
|
|
450
|
+
))}
|
|
451
|
+
</div>
|
|
452
|
+
) : null}
|
|
453
|
+
<textarea
|
|
454
|
+
ref={textareaRef}
|
|
455
|
+
value={value}
|
|
456
|
+
onChange={(event) => setValue(event.target.value)}
|
|
457
|
+
onKeyDown={handleKeyDown}
|
|
458
|
+
rows={1}
|
|
459
|
+
aria-label={labels.editMessage}
|
|
460
|
+
placeholder={agentMessages.composer.placeholder}
|
|
461
|
+
className="min-h-6 max-h-[240px] w-full resize-none bg-transparent text-[15px] leading-relaxed text-foreground outline-none [field-sizing:content] placeholder:text-muted-foreground"
|
|
462
|
+
/>
|
|
463
|
+
</div>
|
|
464
|
+
{draft.error ? (
|
|
465
|
+
<p role="alert" className="max-w-[min(85%,42rem)] text-right text-xs text-destructive">
|
|
466
|
+
{draft.error}
|
|
467
|
+
</p>
|
|
468
|
+
) : null}
|
|
469
|
+
<div className="flex items-center justify-end gap-1.5">
|
|
470
|
+
<TooltipProvider delayDuration={200}>
|
|
471
|
+
<Tooltip>
|
|
472
|
+
<TooltipTrigger asChild>
|
|
473
|
+
<button
|
|
474
|
+
type="button"
|
|
475
|
+
aria-label={labels.editInfo}
|
|
476
|
+
className="flex size-7 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50"
|
|
477
|
+
>
|
|
478
|
+
<Info className="size-3.5" strokeWidth={1.75} aria-hidden="true" />
|
|
479
|
+
</button>
|
|
480
|
+
</TooltipTrigger>
|
|
481
|
+
<TooltipContent side="bottom" className="max-w-64 text-xs">
|
|
482
|
+
{labels.editInfo}
|
|
483
|
+
</TooltipContent>
|
|
484
|
+
</Tooltip>
|
|
485
|
+
</TooltipProvider>
|
|
486
|
+
<button
|
|
487
|
+
type="button"
|
|
488
|
+
onClick={onCancel}
|
|
489
|
+
className="h-7 rounded-lg px-2.5 text-[13px] font-medium text-foreground/80 outline-none transition-colors hover:bg-muted/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50"
|
|
490
|
+
>
|
|
491
|
+
{labels.cancelEdit}
|
|
492
|
+
</button>
|
|
493
|
+
<button
|
|
494
|
+
type="button"
|
|
495
|
+
onClick={submit}
|
|
496
|
+
disabled={!canSave}
|
|
497
|
+
className={cn(
|
|
498
|
+
"h-7 rounded-lg px-3 text-[13px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
499
|
+
"bg-foreground text-background hover:bg-foreground/85",
|
|
500
|
+
"disabled:pointer-events-none disabled:bg-muted disabled:text-muted-foreground"
|
|
501
|
+
)}
|
|
502
|
+
>
|
|
503
|
+
{labels.saveEdit}
|
|
504
|
+
</button>
|
|
505
|
+
</div>
|
|
110
506
|
</div>
|
|
111
507
|
)
|
|
112
508
|
}
|
|
@@ -242,10 +638,23 @@ export function ThinkingMarker({
|
|
|
242
638
|
)
|
|
243
639
|
}
|
|
244
640
|
|
|
245
|
-
/**
|
|
246
|
-
|
|
641
|
+
/**
|
|
642
|
+
* Where the conversation moved: the files earlier turns worked on stayed behind. Set apart, with
|
|
643
|
+
* where it went as its icon, so it reads as an event of the conversation, not the reply's end.
|
|
644
|
+
*/
|
|
645
|
+
export function MovedMarker({
|
|
646
|
+
label,
|
|
647
|
+
place = "computer",
|
|
648
|
+
}: {
|
|
649
|
+
readonly label: string
|
|
650
|
+
readonly place?: "cloud" | "computer"
|
|
651
|
+
}) {
|
|
652
|
+
const Icon = place === "cloud" ? Cloud : Folder
|
|
247
653
|
return (
|
|
248
|
-
<Marker role="note">
|
|
654
|
+
<Marker role="note" className="mt-2 items-start text-[13px]">
|
|
655
|
+
<MarkerIcon className="mt-px flex size-4 items-center justify-center">
|
|
656
|
+
<Icon className="size-3.5" strokeWidth={1.9} />
|
|
657
|
+
</MarkerIcon>
|
|
249
658
|
<MarkerContent>{label}</MarkerContent>
|
|
250
659
|
</Marker>
|
|
251
660
|
)
|
|
@@ -102,7 +102,11 @@ export function PendingMessages({
|
|
|
102
102
|
// copy the tray last held: the list read again no longer has it.
|
|
103
103
|
const held = useRef(new Map<string, AgentInboxItem>())
|
|
104
104
|
const [folded, setFolded] = useState<ReadonlySet<string>>(NOTHING_READ)
|
|
105
|
-
|
|
105
|
+
// An edit waiting for the turn it stopped shows in place of the message it replaces, not here.
|
|
106
|
+
const fetched =
|
|
107
|
+
threadId === null
|
|
108
|
+
? []
|
|
109
|
+
: (inbox.data?.items ?? []).filter((item) => item.replacesMessageId === undefined)
|
|
106
110
|
for (const item of fetched) held.current.set(item.messageId, item)
|
|
107
111
|
const leaving = [...read].flatMap((messageId) => {
|
|
108
112
|
const item = held.current.get(messageId)
|