@sixb/app 0.2.4 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +5 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +3 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +5 -0
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +68 -0
- 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 +114 -0
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +226 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
- package/dist/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-kymx9y5e.js → chunk-4fex83k2.js} +10874 -4690
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-yrcm1pbg.js → chunk-4wm09prf.js} +491 -2128
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-pxd07kvx.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-970s5nkn.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +3 -0
- package/src/agent/agent-chat.tsx +56 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +69 -29
- package/src/agent/components/message-parts.tsx +367 -59
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +63 -34
- package/src/agent/conversation.ts +203 -54
- package/src/agent/delegation/interpret.ts +31 -7
- package/src/agent/hooks/use-agent-conversation.ts +348 -100
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +87 -11
- package/src/agent/i18n/fr.ts +83 -12
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +16 -0
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/artifacts/artifacts.css +398 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +11 -3
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +138 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- package/src/artifacts/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +87 -41
- package/src/index.ts +6 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-kymx9y5e.js.map +0 -211
- package/dist/chunk-yrcm1pbg.js.map +0 -34
- /package/dist/{chunk-pxd07kvx.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-970s5nkn.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { isSixbApiError } from "@sixb/client"
|
|
2
|
+
import {
|
|
3
|
+
listAgentThreadInboxOptions,
|
|
4
|
+
listAgentThreadInboxQueryKey,
|
|
5
|
+
updateAgentThreadInboxItemMutation,
|
|
6
|
+
withdrawAgentThreadInboxItemMutation,
|
|
7
|
+
} from "@sixb/client/hooks"
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuContent,
|
|
11
|
+
DropdownMenuItem,
|
|
12
|
+
DropdownMenuLabel,
|
|
13
|
+
DropdownMenuTrigger,
|
|
14
|
+
} from "@sixb/ui/components"
|
|
15
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
16
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
|
17
|
+
import {
|
|
18
|
+
CornerDownRight,
|
|
19
|
+
Ellipsis,
|
|
20
|
+
ListEnd,
|
|
21
|
+
type LucideIcon,
|
|
22
|
+
Paperclip,
|
|
23
|
+
Send,
|
|
24
|
+
X,
|
|
25
|
+
} from "lucide-react"
|
|
26
|
+
import { useEffect, useRef, useState } from "react"
|
|
27
|
+
import { useCurrentUser } from "../../session"
|
|
28
|
+
import { useAgentMessages } from "../i18n"
|
|
29
|
+
import { TRAY_MESSAGE_ATTRIBUTE, trayMessageKey } from "../inbox-handoff"
|
|
30
|
+
import { samePrincipal, userPrincipal } from "../sharing"
|
|
31
|
+
import type { AgentInboxItem } from "../types"
|
|
32
|
+
|
|
33
|
+
export interface PendingMessagesProps {
|
|
34
|
+
readonly threadId: string | null
|
|
35
|
+
/**
|
|
36
|
+
* The running turn is the reader's own, as the composer's `steerable` says. Another person's
|
|
37
|
+
* turn takes no steer and no Send now from the reader: their messages wait for their own turn.
|
|
38
|
+
*/
|
|
39
|
+
readonly steerable?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* The messages the running turn read, by id: each leaves the tray as the conversation shows it
|
|
42
|
+
* where the turn read it.
|
|
43
|
+
*/
|
|
44
|
+
readonly read?: ReadonlySet<string>
|
|
45
|
+
readonly className?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const NOTHING_READ: ReadonlySet<string> = new Set()
|
|
49
|
+
|
|
50
|
+
/** How long a line takes to fold away, or to open. */
|
|
51
|
+
const FOLD_MS = 320
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The messages waiting beside a running turn: steers it reads at its next step, and turns queued
|
|
55
|
+
* behind it. Each can be promoted, sent now, or taken back, until a step reads it.
|
|
56
|
+
*/
|
|
57
|
+
export function PendingMessages({
|
|
58
|
+
threadId,
|
|
59
|
+
steerable = true,
|
|
60
|
+
read = NOTHING_READ,
|
|
61
|
+
className,
|
|
62
|
+
}: PendingMessagesProps) {
|
|
63
|
+
const labels = useAgentMessages().composer
|
|
64
|
+
const me = userPrincipal(useCurrentUser())
|
|
65
|
+
const queryClient = useQueryClient()
|
|
66
|
+
// Why the last change did not go through, until the next one is asked for.
|
|
67
|
+
const [failure, setFailure] = useState<string | null>(null)
|
|
68
|
+
const inbox = useQuery({
|
|
69
|
+
...listAgentThreadInboxOptions({ path: { threadId: threadId ?? "" } }),
|
|
70
|
+
enabled: threadId !== null,
|
|
71
|
+
// The turn's stream says when a step reads a steer. While anything waits the tray reads again
|
|
72
|
+
// all the same: a message a turn took, or one that started a turn, leaves it.
|
|
73
|
+
refetchInterval: (query) => ((query.state.data?.items.length ?? 0) > 0 ? 5_000 : false),
|
|
74
|
+
})
|
|
75
|
+
const refresh = () =>
|
|
76
|
+
queryClient.invalidateQueries({
|
|
77
|
+
queryKey: listAgentThreadInboxQueryKey({ path: { threadId: threadId ?? "" } }),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Read again either way. A message a turn already read has left the tray for the conversation,
|
|
81
|
+
// which needs no word; any other refusal says why nothing changed.
|
|
82
|
+
const failed = (message: string) => (error: unknown) => {
|
|
83
|
+
if (isSixbApiError(error) && error.code === "invalid_state") return
|
|
84
|
+
setFailure(
|
|
85
|
+
isSixbApiError(error) && error.code === "not_run_requester" ? labels.notYourAnswer : message
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
const promote = useMutation({
|
|
89
|
+
...updateAgentThreadInboxItemMutation(),
|
|
90
|
+
onMutate: () => setFailure(null),
|
|
91
|
+
onError: failed(labels.changeFailed),
|
|
92
|
+
onSettled: refresh,
|
|
93
|
+
})
|
|
94
|
+
const withdraw = useMutation({
|
|
95
|
+
...withdrawAgentThreadInboxItemMutation(),
|
|
96
|
+
onMutate: () => setFailure(null),
|
|
97
|
+
onError: failed(labels.withdrawFailed),
|
|
98
|
+
onSettled: refresh,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// A line the turn read folds away as its message takes its place in the conversation, from the
|
|
102
|
+
// copy the tray last held: the list read again no longer has it.
|
|
103
|
+
const held = useRef(new Map<string, AgentInboxItem>())
|
|
104
|
+
const [folded, setFolded] = useState<ReadonlySet<string>>(NOTHING_READ)
|
|
105
|
+
const fetched = threadId === null ? [] : (inbox.data?.items ?? [])
|
|
106
|
+
for (const item of fetched) held.current.set(item.messageId, item)
|
|
107
|
+
const leaving = [...read].flatMap((messageId) => {
|
|
108
|
+
const item = held.current.get(messageId)
|
|
109
|
+
return item && !folded.has(messageId) && item.threadId === threadId ? [item] : []
|
|
110
|
+
})
|
|
111
|
+
const items = [...fetched.filter((item) => !read.has(item.messageId)), ...leaving].sort(
|
|
112
|
+
(a, b) => a.seq - b.seq
|
|
113
|
+
)
|
|
114
|
+
const open = useOpened(items.length > 0)
|
|
115
|
+
if (items.length === 0) return null
|
|
116
|
+
|
|
117
|
+
const fold = (messageId: string) => {
|
|
118
|
+
held.current.delete(messageId)
|
|
119
|
+
setFolded((current) => new Set(current).add(messageId))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
// The composer's own column: the tray lines up with the input it waits above. It opens and
|
|
124
|
+
// closes by its height, so the conversation above moves with it instead of jumping.
|
|
125
|
+
<div
|
|
126
|
+
className={cn(
|
|
127
|
+
"grid transition-[grid-template-rows] ease-out motion-reduce:transition-none",
|
|
128
|
+
open && leaving.length < items.length ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
|
|
129
|
+
)}
|
|
130
|
+
style={{ transitionDuration: `${FOLD_MS}ms` }}
|
|
131
|
+
data-pending-messages=""
|
|
132
|
+
>
|
|
133
|
+
<div className="min-h-0 overflow-hidden">
|
|
134
|
+
<div className={cn("px-4", className)}>
|
|
135
|
+
<div className="mx-auto flex w-full max-w-[46rem] flex-col rounded-2xl bg-muted/60 p-1">
|
|
136
|
+
{items.map((item) => (
|
|
137
|
+
<PendingMessage
|
|
138
|
+
key={item.id}
|
|
139
|
+
item={item}
|
|
140
|
+
leaving={read.has(item.messageId)}
|
|
141
|
+
onLeft={() => fold(item.messageId)}
|
|
142
|
+
mine={samePrincipal(item.authorPrincipal, me)}
|
|
143
|
+
steerable={steerable}
|
|
144
|
+
labels={labels}
|
|
145
|
+
busy={promote.isPending || withdraw.isPending}
|
|
146
|
+
onMove={(delivery) =>
|
|
147
|
+
threadId !== null &&
|
|
148
|
+
promote.mutate({ path: { threadId, itemId: item.id }, body: { delivery } })
|
|
149
|
+
}
|
|
150
|
+
onSendNow={() =>
|
|
151
|
+
threadId !== null &&
|
|
152
|
+
promote.mutate({ path: { threadId, itemId: item.id }, body: { immediate: true } })
|
|
153
|
+
}
|
|
154
|
+
onWithdraw={() =>
|
|
155
|
+
threadId !== null && withdraw.mutate({ path: { threadId, itemId: item.id } })
|
|
156
|
+
}
|
|
157
|
+
/>
|
|
158
|
+
))}
|
|
159
|
+
{failure ? (
|
|
160
|
+
<p role="alert" className="px-3 pt-1 pb-1.5 text-[13px] text-destructive">
|
|
161
|
+
{failure}
|
|
162
|
+
</p>
|
|
163
|
+
) : null}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** False on the first frame `shown` is true, then true: what opens by a transition starts closed. */
|
|
172
|
+
function useOpened(shown: boolean): boolean {
|
|
173
|
+
const [opened, setOpened] = useState(false)
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (!shown) {
|
|
176
|
+
setOpened(false)
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
const frame = requestAnimationFrame(() => setOpened(true))
|
|
180
|
+
return () => cancelAnimationFrame(frame)
|
|
181
|
+
}, [shown])
|
|
182
|
+
return shown && opened
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function PendingMessage({
|
|
186
|
+
item,
|
|
187
|
+
leaving,
|
|
188
|
+
onLeft,
|
|
189
|
+
mine,
|
|
190
|
+
steerable: turnSteerable,
|
|
191
|
+
labels,
|
|
192
|
+
busy,
|
|
193
|
+
onMove,
|
|
194
|
+
onSendNow,
|
|
195
|
+
onWithdraw,
|
|
196
|
+
}: {
|
|
197
|
+
readonly item: AgentInboxItem
|
|
198
|
+
/** The turn read it: the line folds away, and its message rises into the conversation. */
|
|
199
|
+
readonly leaving: boolean
|
|
200
|
+
readonly onLeft: () => void
|
|
201
|
+
/** Only the person who sent it may change it: another participant's shows without actions. */
|
|
202
|
+
readonly mine: boolean
|
|
203
|
+
readonly steerable: boolean
|
|
204
|
+
readonly labels: ReturnType<typeof useAgentMessages>["composer"]
|
|
205
|
+
readonly busy: boolean
|
|
206
|
+
/** Into the answer in flight, or after it. */
|
|
207
|
+
readonly onMove: (delivery: "steer" | "queue") => void
|
|
208
|
+
readonly onSendNow: () => void
|
|
209
|
+
readonly onWithdraw: () => void
|
|
210
|
+
}) {
|
|
211
|
+
const text = item.parts
|
|
212
|
+
.flatMap((part) => (part.type === "text" ? [part.text] : []))
|
|
213
|
+
.join(" ")
|
|
214
|
+
.trim()
|
|
215
|
+
const files = item.parts.flatMap((part) => (part.type === "file" ? [part.fileRef] : []))
|
|
216
|
+
const status =
|
|
217
|
+
item.immediate === true
|
|
218
|
+
? labels.sendNowPending
|
|
219
|
+
: item.mode === "steer"
|
|
220
|
+
? labels.steerPending
|
|
221
|
+
: labels.queuePending
|
|
222
|
+
const Status = item.immediate === true ? Send : item.mode === "steer" ? CornerDownRight : ListEnd
|
|
223
|
+
const opened = useOpened(true)
|
|
224
|
+
|
|
225
|
+
// What can still be done with it. A steer is read mid-turn, which prepares no file: one that
|
|
226
|
+
// carries a file stays queued. Only whoever asked for the answer in flight steers it or stops it
|
|
227
|
+
// to send now; anyone takes their own message back.
|
|
228
|
+
const actions: PendingAction[] = []
|
|
229
|
+
if (turnSteerable && item.immediate !== true) {
|
|
230
|
+
if (item.mode === "queue" && files.length === 0) {
|
|
231
|
+
actions.push({ label: labels.steer, Icon: CornerDownRight, run: () => onMove("steer") })
|
|
232
|
+
}
|
|
233
|
+
if (item.mode === "steer") {
|
|
234
|
+
actions.push({ label: labels.queue, Icon: ListEnd, run: () => onMove("queue") })
|
|
235
|
+
}
|
|
236
|
+
actions.push({ label: labels.sendNow, Icon: Send, run: onSendNow })
|
|
237
|
+
}
|
|
238
|
+
actions.push({ label: labels.withdraw, Icon: X, run: onWithdraw })
|
|
239
|
+
|
|
240
|
+
// The chat draws again with every chunk of the answer: the fold's end is not put off by it.
|
|
241
|
+
const left = useRef(onLeft)
|
|
242
|
+
left.current = onLeft
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (!leaving) return
|
|
245
|
+
const timer = setTimeout(() => left.current(), FOLD_MS)
|
|
246
|
+
return () => clearTimeout(timer)
|
|
247
|
+
}, [leaving])
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
// A line opens as it arrives and folds away once read, while its message rises into place.
|
|
251
|
+
<div
|
|
252
|
+
className={cn(
|
|
253
|
+
"grid transition-[grid-template-rows,opacity] ease-out motion-reduce:transition-none",
|
|
254
|
+
opened && !leaving ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
|
255
|
+
leaving && "opacity-0"
|
|
256
|
+
)}
|
|
257
|
+
// Its words leave at once, for the conversation's copy; the space they held closes after.
|
|
258
|
+
style={{ transitionDuration: `${FOLD_MS}ms, ${leaving ? 120 : FOLD_MS}ms` }}
|
|
259
|
+
aria-hidden={leaving || undefined}
|
|
260
|
+
>
|
|
261
|
+
<div className="min-h-0 overflow-hidden">
|
|
262
|
+
{/* One quiet line: where it goes, what it says, and what can still be done with it. */}
|
|
263
|
+
<div
|
|
264
|
+
title={status}
|
|
265
|
+
className="group flex h-9 items-center gap-2.5 rounded-xl pr-1 pl-3 text-[14px] tracking-[-0.006em] transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04] [@media(hover:none)]:h-11"
|
|
266
|
+
>
|
|
267
|
+
<Status aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
|
268
|
+
<span className="sr-only">{status}: </span>
|
|
269
|
+
{files.length > 0 ? (
|
|
270
|
+
<Paperclip aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
|
271
|
+
) : null}
|
|
272
|
+
<p
|
|
273
|
+
className="min-w-0 flex-1 truncate text-foreground/75"
|
|
274
|
+
{...{ [TRAY_MESSAGE_ATTRIBUTE]: trayMessageKey(item.messageId) }}
|
|
275
|
+
>
|
|
276
|
+
{text || files.map((file) => file.fileName ?? labels.waitingFile).join(", ")}
|
|
277
|
+
</p>
|
|
278
|
+
{mine ? (
|
|
279
|
+
<>
|
|
280
|
+
{/* With a pointer: each action as an icon, named on hover. */}
|
|
281
|
+
<div className="flex shrink-0 items-center transition-opacity [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-focus-within:opacity-100 [@media(hover:hover)]:group-hover:opacity-100 [@media(hover:none)]:hidden">
|
|
282
|
+
{actions.map(({ label, Icon, run }) => (
|
|
283
|
+
<button
|
|
284
|
+
key={label}
|
|
285
|
+
type="button"
|
|
286
|
+
onClick={run}
|
|
287
|
+
disabled={busy}
|
|
288
|
+
title={label}
|
|
289
|
+
aria-label={label}
|
|
290
|
+
className={ACTION_CLASS}
|
|
291
|
+
>
|
|
292
|
+
<Icon className="size-3.5" />
|
|
293
|
+
</button>
|
|
294
|
+
))}
|
|
295
|
+
</div>
|
|
296
|
+
{/* By touch, where nothing hovers: one button, and the actions named in a menu. */}
|
|
297
|
+
<DropdownMenu>
|
|
298
|
+
<DropdownMenuTrigger asChild>
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
disabled={busy}
|
|
302
|
+
aria-label={labels.messageActions}
|
|
303
|
+
className={cn(ACTION_CLASS, "size-9 [@media(hover:hover)]:hidden")}
|
|
304
|
+
>
|
|
305
|
+
<Ellipsis className="size-4" />
|
|
306
|
+
</button>
|
|
307
|
+
</DropdownMenuTrigger>
|
|
308
|
+
<DropdownMenuContent align="end" className="min-w-56">
|
|
309
|
+
<DropdownMenuLabel className="text-xs font-normal text-muted-foreground">
|
|
310
|
+
{status}
|
|
311
|
+
</DropdownMenuLabel>
|
|
312
|
+
{actions.map(({ label, Icon, run }) => (
|
|
313
|
+
<DropdownMenuItem key={label} onSelect={run} className="gap-2.5 py-2.5">
|
|
314
|
+
<Icon className="size-4 text-muted-foreground" />
|
|
315
|
+
{label}
|
|
316
|
+
</DropdownMenuItem>
|
|
317
|
+
))}
|
|
318
|
+
</DropdownMenuContent>
|
|
319
|
+
</DropdownMenu>
|
|
320
|
+
</>
|
|
321
|
+
) : null}
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface PendingAction {
|
|
329
|
+
readonly label: string
|
|
330
|
+
readonly Icon: LucideIcon
|
|
331
|
+
readonly run: () => void
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const ACTION_CLASS = cn(
|
|
335
|
+
"flex size-7 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors",
|
|
336
|
+
"hover:bg-black/[0.05] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-50",
|
|
337
|
+
"dark:hover:bg-white/[0.08]"
|
|
338
|
+
)
|
|
@@ -16,17 +16,27 @@ export interface SandboxRecoveryProps {
|
|
|
16
16
|
readonly pending: boolean
|
|
17
17
|
readonly error: boolean
|
|
18
18
|
readonly onRecreate: () => void
|
|
19
|
+
/** Going on in the previous sandbox, offered when its last run finished preparing it. */
|
|
20
|
+
readonly restore?: {
|
|
21
|
+
readonly pending: boolean
|
|
22
|
+
readonly error: boolean
|
|
23
|
+
readonly onRestore: () => void
|
|
24
|
+
}
|
|
19
25
|
/** Only the thread's owner recreates its sandbox; anyone else is told who can. */
|
|
20
26
|
readonly canRecreate: boolean
|
|
21
27
|
/** The thread's owner, by name. */
|
|
22
28
|
readonly owner: string
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Offers to go on in the thread's sandbox, as its failed save left it, or to start fresh when it
|
|
33
|
+
* stops responding; the composer waits for either.
|
|
34
|
+
*/
|
|
26
35
|
export function SandboxRecovery({
|
|
27
36
|
pending,
|
|
28
37
|
error,
|
|
29
38
|
onRecreate,
|
|
39
|
+
restore,
|
|
30
40
|
canRecreate,
|
|
31
41
|
owner,
|
|
32
42
|
}: SandboxRecoveryProps) {
|
|
@@ -45,24 +55,33 @@ export function SandboxRecovery({
|
|
|
45
55
|
<div className="mx-auto w-full max-w-3xl px-4 py-3 text-sm" role="status">
|
|
46
56
|
<p className="font-medium">{messages.title}</p>
|
|
47
57
|
<p className="text-muted-foreground">{messages.description}</p>
|
|
58
|
+
{restore && <p className="text-muted-foreground">{messages.resumeHint}</p>}
|
|
59
|
+
{restore?.error && <p role="alert">{messages.resumeFailed}</p>}
|
|
48
60
|
{error && <p role="alert">{messages.recreateFailed}</p>}
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
<Button
|
|
52
|
-
{pending ? messages.
|
|
61
|
+
<div className="mt-2 flex flex-wrap gap-2">
|
|
62
|
+
{restore && (
|
|
63
|
+
<Button size="sm" disabled={pending} onClick={restore.onRestore}>
|
|
64
|
+
{restore.pending ? messages.resuming : messages.resume}
|
|
53
65
|
</Button>
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
)}
|
|
67
|
+
<AlertDialog>
|
|
68
|
+
<AlertDialogTrigger asChild>
|
|
69
|
+
<Button variant="outline" size="sm" disabled={pending}>
|
|
70
|
+
{pending && !restore?.pending ? messages.recreating : messages.startFresh}
|
|
71
|
+
</Button>
|
|
72
|
+
</AlertDialogTrigger>
|
|
73
|
+
<AlertDialogContent>
|
|
74
|
+
<AlertDialogHeader>
|
|
75
|
+
<AlertDialogTitle>{messages.confirmTitle}</AlertDialogTitle>
|
|
76
|
+
<AlertDialogDescription>{messages.confirmDescription}</AlertDialogDescription>
|
|
77
|
+
</AlertDialogHeader>
|
|
78
|
+
<AlertDialogFooter>
|
|
79
|
+
<AlertDialogCancel>{messages.cancel}</AlertDialogCancel>
|
|
80
|
+
<AlertDialogAction onClick={onRecreate}>{messages.create}</AlertDialogAction>
|
|
81
|
+
</AlertDialogFooter>
|
|
82
|
+
</AlertDialogContent>
|
|
83
|
+
</AlertDialog>
|
|
84
|
+
</div>
|
|
66
85
|
</div>
|
|
67
86
|
)
|
|
68
87
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button } from "@sixb/ui/components"
|
|
2
2
|
import { History } from "lucide-react"
|
|
3
|
+
import { memo } from "react"
|
|
3
4
|
import { useAgentMessages } from "../i18n"
|
|
4
5
|
|
|
5
6
|
const NO_WAITING_THREADS: ReadonlySet<string> = new Set()
|
|
@@ -17,7 +18,7 @@ export interface ThreadsButtonProps {
|
|
|
17
18
|
* The way from a thread to all of them: a button in its header. It counts the other threads
|
|
18
19
|
* waiting for the reader, in amber, or shows a dot while one is at work.
|
|
19
20
|
*/
|
|
20
|
-
export function ThreadsButton({
|
|
21
|
+
export const ThreadsButton = memo(function ThreadsButton({
|
|
21
22
|
currentThreadId,
|
|
22
23
|
runningThreadCount = 0,
|
|
23
24
|
waitingThreadIds = NO_WAITING_THREADS,
|
|
@@ -67,4 +68,4 @@ export function ThreadsButton({
|
|
|
67
68
|
) : null}
|
|
68
69
|
</Button>
|
|
69
70
|
)
|
|
70
|
-
}
|
|
71
|
+
})
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MessageScrollerProvider,
|
|
7
7
|
MessageScrollerViewport,
|
|
8
8
|
} from "@sixb/ui/components"
|
|
9
|
-
import { Fragment, memo, type ReactNode, useMemo } from "react"
|
|
9
|
+
import { Fragment, memo, type ReactNode, useCallback, useMemo, useRef } from "react"
|
|
10
10
|
import {
|
|
11
11
|
ApprovalCardsContext,
|
|
12
12
|
type HeldCall,
|
|
@@ -20,7 +20,8 @@ import { BACKGROUND_TOOLS, readThreadBackground } from "../background/interpret"
|
|
|
20
20
|
import type { AgentConversationMessage, AgentConversationTurn } from "../conversation"
|
|
21
21
|
import { DelegationCardsContext, type TranscriptDelegation } from "../delegation/context"
|
|
22
22
|
import {
|
|
23
|
-
|
|
23
|
+
type DelegationTurn,
|
|
24
|
+
delegationTurnEntry,
|
|
24
25
|
readThreadDelegation,
|
|
25
26
|
type ThreadDelegation,
|
|
26
27
|
} from "../delegation/interpret"
|
|
@@ -87,6 +88,23 @@ const NO_OUTCOMES: ReadonlyMap<string, ReportedApprovalOutcome> = new Map()
|
|
|
87
88
|
|
|
88
89
|
/** A reply whose questions the conversation has moved past. */
|
|
89
90
|
const CLOSED_QUESTION: QuestionTurn = { open: false }
|
|
91
|
+
const OPEN_ANSWERING_QUESTION: QuestionTurn = { open: true, answering: true }
|
|
92
|
+
const OPEN_WAITING_QUESTION: QuestionTurn = { open: true, answering: false }
|
|
93
|
+
|
|
94
|
+
const backgroundSigEntries = new WeakMap<AgentConversationMessage, string>()
|
|
95
|
+
|
|
96
|
+
function messageBackgroundSignature(message: AgentConversationMessage): string {
|
|
97
|
+
const cached = backgroundSigEntries.get(message)
|
|
98
|
+
if (cached !== undefined) return cached
|
|
99
|
+
let sig = ""
|
|
100
|
+
for (const part of message.parts) {
|
|
101
|
+
if (part.type === "tool" && BACKGROUND_TOOLS.has(part.toolName)) {
|
|
102
|
+
sig += `${part.toolCallId ?? ""}@${part.state};`
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
backgroundSigEntries.set(message, sig)
|
|
106
|
+
return sig
|
|
107
|
+
}
|
|
90
108
|
|
|
91
109
|
/** Nothing said of where the commands run: no card claims how one ended that nobody saw. */
|
|
92
110
|
const UNKNOWN_BACKGROUND: TranscriptBackground = {
|
|
@@ -101,10 +119,19 @@ export function Transcript(props: TranscriptProps) {
|
|
|
101
119
|
)
|
|
102
120
|
|
|
103
121
|
// The reply streaming now changes with every chunk; its delegation calls far less often.
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
// Each saved message caches its delegation & background signature by object identity.
|
|
123
|
+
const turns: DelegationTurn[] = []
|
|
124
|
+
let signature = ""
|
|
125
|
+
let backgroundSignature = ""
|
|
126
|
+
for (const message of messages) {
|
|
127
|
+
const entry = delegationTurnEntry(message)
|
|
128
|
+
if (entry) {
|
|
129
|
+
turns.push(entry.turn)
|
|
130
|
+
signature += `${entry.signature}|`
|
|
131
|
+
}
|
|
132
|
+
const bgSig = messageBackgroundSignature(message)
|
|
133
|
+
if (bgSig) backgroundSignature += `${bgSig}|`
|
|
134
|
+
}
|
|
108
135
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the signature stands for the turns
|
|
109
136
|
const delegation = useMemo(() => readThreadDelegation(turns), [signature])
|
|
110
137
|
const liveRunId = turn.kind === "responding" ? turn.runId : null
|
|
@@ -113,16 +140,6 @@ export function Transcript(props: TranscriptProps) {
|
|
|
113
140
|
[threadId, delegation, liveRunId, actions]
|
|
114
141
|
)
|
|
115
142
|
|
|
116
|
-
// Its background commands change as their calls do, not with every chunk of the reply.
|
|
117
|
-
const backgroundSignature = JSON.stringify(
|
|
118
|
-
messages.flatMap((message) =>
|
|
119
|
-
message.parts.flatMap((part) =>
|
|
120
|
-
part.type === "tool" && BACKGROUND_TOOLS.has(part.toolName)
|
|
121
|
-
? [[part.toolCallId, part.state]]
|
|
122
|
-
: []
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
)
|
|
126
143
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the signature stands for the calls
|
|
127
144
|
const thread = useMemo(() => readThreadBackground(messages), [backgroundSignature])
|
|
128
145
|
const { background = UNKNOWN_BACKGROUND } = props
|
|
@@ -162,11 +179,14 @@ function TranscriptView({
|
|
|
162
179
|
const last = messages.at(-1)
|
|
163
180
|
const liveReply = last?.role === "assistant" && last.id === null ? last : undefined
|
|
164
181
|
|
|
165
|
-
// Bridge the gap between sending and the reply's first content with a thinking shimmer
|
|
182
|
+
// Bridge the gap between sending and the reply's first content with a thinking shimmer, and
|
|
183
|
+
// between a message the turn just read and the reply to it.
|
|
184
|
+
const justRead = last?.role === "user" && last.status === "streaming"
|
|
166
185
|
const showThinking =
|
|
167
186
|
turn.kind === "responding" &&
|
|
168
187
|
!liveReply &&
|
|
169
|
-
|
|
188
|
+
(justRead ||
|
|
189
|
+
!messages.some((message) => message.role === "assistant" && message.runId === turn.runId))
|
|
170
190
|
|
|
171
191
|
// A saved thread should open at the newest content, not at the first or last user turn. Only mark
|
|
172
192
|
// a row as a scroll anchor while the current UI-initiated turn is in flight: the pending row
|
|
@@ -179,9 +199,14 @@ function TranscriptView({
|
|
|
179
199
|
? currentTurnAnchor(messages, turn.kind === "responding" ? turn.runId : liveReply?.runId)
|
|
180
200
|
: lastKey(messages, (message) => message.status === "pending")
|
|
181
201
|
const newestSavedKey = lastKey(messages, (message) => message.id !== null)
|
|
202
|
+
const onContinueRef = useRef(onContinue)
|
|
203
|
+
onContinueRef.current = onContinue
|
|
204
|
+
const stableOnContinue = useCallback(() => onContinueRef.current?.(), [])
|
|
205
|
+
const hasOnContinue = onContinue !== undefined
|
|
206
|
+
|
|
182
207
|
// The reply whose questions are the conversation's last word, which its cards answer.
|
|
183
208
|
const openQuestionKey = openQuestion(messages, turn)?.messageKey ?? null
|
|
184
|
-
const asking =
|
|
209
|
+
const asking = onAnswer !== undefined ? OPEN_ANSWERING_QUESTION : OPEN_WAITING_QUESTION
|
|
185
210
|
|
|
186
211
|
// A call is answered on the card under the work that made it. One whose command output does not
|
|
187
212
|
// name it, such as output sent elsewhere, still gets a card, after its turn's saved answer, and
|
|
@@ -255,8 +280,8 @@ function TranscriptView({
|
|
|
255
280
|
continued={continuedKeys.has(message.key)}
|
|
256
281
|
scrollAnchor={message.key === anchoredKey}
|
|
257
282
|
// Only the newest answer can be continued; older ones keep their notice alone.
|
|
258
|
-
{...(message.key === newestSavedKey &&
|
|
259
|
-
? { onContinue, continuing: turn.continuing }
|
|
283
|
+
{...(message.key === newestSavedKey && hasOnContinue
|
|
284
|
+
? { onContinue: stableOnContinue, continuing: turn.continuing }
|
|
260
285
|
: {})}
|
|
261
286
|
{...(message === liveReply
|
|
262
287
|
? {
|
|
@@ -269,18 +294,7 @@ function TranscriptView({
|
|
|
269
294
|
/>
|
|
270
295
|
),
|
|
271
296
|
}
|
|
272
|
-
:
|
|
273
|
-
? {
|
|
274
|
-
after: (
|
|
275
|
-
<UnfinishedMarker
|
|
276
|
-
unfinished={message.unfinished}
|
|
277
|
-
{...(message.key === newestSavedKey && onContinue
|
|
278
|
-
? { onContinue, continuing: turn.continuing }
|
|
279
|
-
: {})}
|
|
280
|
-
/>
|
|
281
|
-
),
|
|
282
|
-
}
|
|
283
|
-
: {})}
|
|
297
|
+
: {})}
|
|
284
298
|
/>
|
|
285
299
|
</QuestionTurnContext.Provider>
|
|
286
300
|
{calls ? (
|
|
@@ -438,6 +452,15 @@ const TranscriptMessage = memo(function TranscriptMessage({
|
|
|
438
452
|
readonly continuing?: boolean
|
|
439
453
|
readonly after?: ReactNode
|
|
440
454
|
}) {
|
|
455
|
+
const trailing =
|
|
456
|
+
after ??
|
|
457
|
+
(message.unfinished ? (
|
|
458
|
+
<UnfinishedMarker
|
|
459
|
+
unfinished={message.unfinished}
|
|
460
|
+
{...(onContinue ? { onContinue, continuing } : {})}
|
|
461
|
+
/>
|
|
462
|
+
) : undefined)
|
|
463
|
+
|
|
441
464
|
return (
|
|
442
465
|
<MessageScrollerItem messageId={message.key} scrollAnchor={scrollAnchor}>
|
|
443
466
|
<MessageView
|
|
@@ -445,7 +468,7 @@ const TranscriptMessage = memo(function TranscriptMessage({
|
|
|
445
468
|
continued={continued}
|
|
446
469
|
onContinue={onContinue}
|
|
447
470
|
continuing={continuing}
|
|
448
|
-
after={
|
|
471
|
+
after={trailing}
|
|
449
472
|
/>
|
|
450
473
|
</MessageScrollerItem>
|
|
451
474
|
)
|
|
@@ -484,9 +507,15 @@ function currentTurnAnchor(
|
|
|
484
507
|
messages: readonly AgentConversationMessage[],
|
|
485
508
|
turnRunId: string | null | undefined
|
|
486
509
|
): string | undefined {
|
|
510
|
+
// A message the turn read as it answered comes after its first reply: the turn still answers the
|
|
511
|
+
// one before, and the view stays where it is.
|
|
512
|
+
const firstReply = messages.findIndex(
|
|
513
|
+
(message) => message.role === "assistant" && message.runId === (turnRunId ?? null)
|
|
514
|
+
)
|
|
487
515
|
for (let index = messages.length - 1; index >= 0; index--) {
|
|
488
516
|
const message = messages[index]
|
|
489
517
|
if (!message) continue
|
|
518
|
+
if (message.role === "user" && firstReply !== -1 && index > firstReply) continue
|
|
490
519
|
if (message.role === "user") return message.key
|
|
491
520
|
|
|
492
521
|
const earlierAnswer = message.id !== null && message.runId !== (turnRunId ?? null)
|