@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
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
listAgentComputersQueryKey,
|
|
15
15
|
listAgentThreadApprovalsOptions,
|
|
16
16
|
listAgentThreadApprovalsQueryKey,
|
|
17
|
+
listAgentThreadInboxQueryKey,
|
|
17
18
|
listAgentThreadMessagesOptions,
|
|
18
19
|
listAgentThreadMessagesQueryKey,
|
|
19
20
|
listAgentThreadRunsOptions,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
moveAgentThreadToCloudMutation,
|
|
24
25
|
postAgentThreadMessageMutation,
|
|
25
26
|
recreateAgentThreadSandboxMutation,
|
|
27
|
+
restoreAgentThreadSandboxMutation,
|
|
26
28
|
retryAgentRunMutation,
|
|
27
29
|
setAgentThreadApprovalModeMutation,
|
|
28
30
|
stopAgentBackgroundCommandMutation,
|
|
@@ -32,7 +34,7 @@ import {
|
|
|
32
34
|
} from "@sixb/client/hooks"
|
|
33
35
|
import { MODEL_REASONING_LEVELS, type ModelReasoningLevel } from "@sixb/core/models"
|
|
34
36
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
|
35
|
-
import { useEffect, useMemo, useRef, useState } from "react"
|
|
37
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
36
38
|
import { useCurrentUser } from "../../session"
|
|
37
39
|
import {
|
|
38
40
|
type AgentApproval,
|
|
@@ -48,9 +50,15 @@ import {
|
|
|
48
50
|
import type { TranscriptBackground } from "../background/context"
|
|
49
51
|
import type { ComposerProps } from "../components/composer"
|
|
50
52
|
import { type ComputerOfflineNoticeProps, shownFolder } from "../components/computer-place"
|
|
53
|
+
import type { PendingMessagesProps } from "../components/pending-messages"
|
|
51
54
|
import type { SandboxRecoveryProps } from "../components/sandbox-recovery"
|
|
52
55
|
import type { TranscriptProps } from "../components/transcript"
|
|
53
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
type AgentConversationTurn,
|
|
58
|
+
conversationMessages,
|
|
59
|
+
conversationTurn,
|
|
60
|
+
type PendingUserMessage,
|
|
61
|
+
} from "../conversation"
|
|
54
62
|
import type { TranscriptDelegation } from "../delegation/context"
|
|
55
63
|
import { projectDictation } from "../dictation"
|
|
56
64
|
import { useAgentMessages } from "../i18n"
|
|
@@ -89,6 +97,7 @@ import {
|
|
|
89
97
|
import type {
|
|
90
98
|
AgentContextEntryInput,
|
|
91
99
|
AgentFileRef,
|
|
100
|
+
AgentMessageDelivery,
|
|
92
101
|
AgentRun,
|
|
93
102
|
AgentThreadSandboxParams,
|
|
94
103
|
LanguageModel,
|
|
@@ -144,6 +153,7 @@ export type ConversationComposerProps = Pick<
|
|
|
144
153
|
| "disabled"
|
|
145
154
|
| "pending"
|
|
146
155
|
| "running"
|
|
156
|
+
| "steerable"
|
|
147
157
|
| "stopping"
|
|
148
158
|
| "onStop"
|
|
149
159
|
| "hint"
|
|
@@ -158,10 +168,12 @@ export type ConversationComposerProps = Pick<
|
|
|
158
168
|
| "usingDefaultModel"
|
|
159
169
|
| "onResetModelSelection"
|
|
160
170
|
| "modelRouting"
|
|
171
|
+
| "draftKey"
|
|
161
172
|
| "draft"
|
|
162
173
|
| "draftAttachments"
|
|
163
174
|
| "draftContext"
|
|
164
175
|
| "draftNonce"
|
|
176
|
+
| "draftReseedKey"
|
|
165
177
|
| "insertion"
|
|
166
178
|
| "onInserted"
|
|
167
179
|
| "approvalMode"
|
|
@@ -388,7 +400,9 @@ export function useAgentConversation({
|
|
|
388
400
|
attachments: readonly AgentFileRef[]
|
|
389
401
|
context: readonly AgentContextEntryInput[]
|
|
390
402
|
nonce: number
|
|
391
|
-
|
|
403
|
+
/** The conversation the message was for, whichever one is open when it comes back. */
|
|
404
|
+
draftKey: string
|
|
405
|
+
}>({ text: "", attachments: [], context: [], nonce: 0, draftKey: "draft" })
|
|
392
406
|
const [stoppingRunId, setStoppingRunId] = useState<string | null>(null)
|
|
393
407
|
const stopRef = useRef<(approval: AgentApproval) => Promise<void>>(async () => {})
|
|
394
408
|
const decideRef = useRef<NonNullable<TranscriptApprovals["decide"]>>(async () => {
|
|
@@ -402,6 +416,8 @@ export function useAgentConversation({
|
|
|
402
416
|
} | null>(null)
|
|
403
417
|
/** The thread whose answer Continue is asking for, until the API accepts or refuses it. */
|
|
404
418
|
const [continuingThreadId, setContinuingThreadId] = useState<string | null>(null)
|
|
419
|
+
/** The thread whose sandbox its owner just resumed, until its cut-short turn runs again. */
|
|
420
|
+
const [resumedThreadId, setResumedThreadId] = useState<string | null>(null)
|
|
405
421
|
|
|
406
422
|
const pendingRun =
|
|
407
423
|
pendingSend && threadId !== null && pendingSend.run.threadId === threadId
|
|
@@ -412,6 +428,11 @@ export function useAgentConversation({
|
|
|
412
428
|
? selectActiveRunId({ pendingRun, threadActiveRunId: thread?.activeRunId ?? null, latestRun })
|
|
413
429
|
: null
|
|
414
430
|
const { live, run: streamRun, reconnecting } = useThreadStream({ threadId, runId: activeRunId })
|
|
431
|
+
// What the turn read as it answered leaves the tray: the transcript shows it where it was read.
|
|
432
|
+
const readMessageIds = useMemo(
|
|
433
|
+
() => new Set(live.inboxReads.flatMap((read) => read.messages.map((message) => message.id))),
|
|
434
|
+
[live.inboxReads]
|
|
435
|
+
)
|
|
415
436
|
// A compaction that ended changed what the conversation weighs: measure it again.
|
|
416
437
|
const wasCompactingRef = useRef(false)
|
|
417
438
|
useEffect(() => {
|
|
@@ -470,6 +491,7 @@ export function useAgentConversation({
|
|
|
470
491
|
const cancelRun = useMutation(cancelAgentRunMutation())
|
|
471
492
|
const retryRun = useMutation(retryAgentRunMutation())
|
|
472
493
|
const recreateSandbox = useMutation(recreateAgentThreadSandboxMutation())
|
|
494
|
+
const restoreSandbox = useMutation(restoreAgentThreadSandboxMutation())
|
|
473
495
|
const moveToCloud = useMutation(moveAgentThreadToCloudMutation())
|
|
474
496
|
const stopBackgroundCommand = useMutation(stopAgentBackgroundCommandMutation())
|
|
475
497
|
const decideApproval = useMutation(decideAgentApprovalMutation())
|
|
@@ -536,38 +558,58 @@ export function useAgentConversation({
|
|
|
536
558
|
const send = async (
|
|
537
559
|
text: string,
|
|
538
560
|
attachments: readonly AgentFileRef[],
|
|
539
|
-
context: readonly AgentContextEntryInput[]
|
|
561
|
+
context: readonly AgentContextEntryInput[],
|
|
562
|
+
delivery: AgentMessageDelivery = "auto"
|
|
540
563
|
) => {
|
|
541
|
-
|
|
564
|
+
// A running turn takes the message as a steer, a queued turn, or one that stops it. A chat that
|
|
565
|
+
// does not say where it goes sends it where Enter would: into the reader's own answer, or after
|
|
566
|
+
// the answer in flight when it is someone else's or carries a file, which no step reads.
|
|
567
|
+
// The thread that a message starts is always a turn, whatever the composer said.
|
|
568
|
+
const where: AgentMessageDelivery =
|
|
569
|
+
isRunning && delivery === "auto"
|
|
570
|
+
? attachments.length === 0 && !requestedBySomeoneElse(activeRun, user)
|
|
571
|
+
? "steer"
|
|
572
|
+
: "queue"
|
|
573
|
+
: delivery
|
|
542
574
|
setSendError(null)
|
|
543
575
|
const targetThreadId = threadId
|
|
544
576
|
const key = `sent:${++sentMessageCount}`
|
|
545
577
|
let createdThreadId: string | null = null
|
|
546
578
|
try {
|
|
547
579
|
if (targetThreadId !== null) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
580
|
+
// A message for the running turn waits in the inbox, which the tray shows: only one that
|
|
581
|
+
// starts a turn is the transcript's next message.
|
|
582
|
+
if (where === "auto") {
|
|
583
|
+
setPendingUser({
|
|
584
|
+
key,
|
|
585
|
+
threadId: targetThreadId,
|
|
586
|
+
text,
|
|
587
|
+
attachments,
|
|
588
|
+
context,
|
|
589
|
+
messageId: null,
|
|
590
|
+
})
|
|
591
|
+
}
|
|
556
592
|
const response = await sendWithRequesterSettings((settings) =>
|
|
557
593
|
postMessage.mutateAsync({
|
|
558
594
|
path: { threadId: targetThreadId },
|
|
559
595
|
body: {
|
|
560
596
|
...messageBody(text, attachments, context, modelSelection.request, settings),
|
|
561
597
|
...turnApprovalMode,
|
|
598
|
+
...(where === "auto" ? {} : { delivery: where }),
|
|
562
599
|
},
|
|
563
600
|
})
|
|
564
601
|
)
|
|
565
|
-
recordAcceptedSend(response.run, key)
|
|
602
|
+
if (response.run) recordAcceptedSend(response.run, key)
|
|
566
603
|
await Promise.all([
|
|
567
604
|
queryClient.invalidateQueries({
|
|
568
605
|
queryKey: listAgentThreadMessagesQueryKey({ path: { threadId: targetThreadId } }),
|
|
569
606
|
}),
|
|
570
607
|
queryClient.invalidateQueries({ queryKey: listAgentThreadsQueryKey() }),
|
|
608
|
+
// A message that waits beside the running turn is in the thread's inbox, not its
|
|
609
|
+
// transcript: the tray reads it from there.
|
|
610
|
+
queryClient.invalidateQueries({
|
|
611
|
+
queryKey: listAgentThreadInboxQueryKey({ path: { threadId: targetThreadId } }),
|
|
612
|
+
}),
|
|
571
613
|
])
|
|
572
614
|
return
|
|
573
615
|
}
|
|
@@ -582,7 +624,13 @@ export function useAgentConversation({
|
|
|
582
624
|
}
|
|
583
625
|
if (!place) {
|
|
584
626
|
// They cancelled choosing a folder: nothing was sent, and their message goes back.
|
|
585
|
-
setDraftReseed((current) => ({
|
|
627
|
+
setDraftReseed((current) => ({
|
|
628
|
+
text,
|
|
629
|
+
attachments,
|
|
630
|
+
context,
|
|
631
|
+
nonce: current.nonce + 1,
|
|
632
|
+
draftKey: "draft",
|
|
633
|
+
}))
|
|
586
634
|
return
|
|
587
635
|
}
|
|
588
636
|
const title = deriveTitle(text, attachments)
|
|
@@ -614,7 +662,7 @@ export function useAgentConversation({
|
|
|
614
662
|
},
|
|
615
663
|
})
|
|
616
664
|
)
|
|
617
|
-
recordAcceptedSend(response.run, key)
|
|
665
|
+
if (response.run) recordAcceptedSend(response.run, key)
|
|
618
666
|
// The next new conversation starts from the default again.
|
|
619
667
|
setChosenApprovalMode((current) => (current?.threadId === null ? null : current))
|
|
620
668
|
await queryClient.invalidateQueries({ queryKey: listAgentThreadsQueryKey() })
|
|
@@ -628,6 +676,7 @@ export function useAgentConversation({
|
|
|
628
676
|
attachments,
|
|
629
677
|
context,
|
|
630
678
|
nonce: current.nonce + 1,
|
|
679
|
+
draftKey: createdThreadId ?? targetThreadId ?? "draft",
|
|
631
680
|
}))
|
|
632
681
|
setSendError({
|
|
633
682
|
threadId: createdThreadId ?? targetThreadId,
|
|
@@ -702,6 +751,10 @@ export function useAgentConversation({
|
|
|
702
751
|
queryClient.invalidateQueries({
|
|
703
752
|
queryKey: getAgentThreadContextQueryKey({ path: { threadId } }),
|
|
704
753
|
}),
|
|
754
|
+
// A turn that ended read its steers, or started what was queued behind it.
|
|
755
|
+
queryClient.invalidateQueries({
|
|
756
|
+
queryKey: listAgentThreadInboxQueryKey({ path: { threadId } }),
|
|
757
|
+
}),
|
|
705
758
|
])
|
|
706
759
|
|
|
707
760
|
const keepThreadApprovalMode = async (threadId: string, mode: AgentApprovalMode) => {
|
|
@@ -807,8 +860,10 @@ export function useAgentConversation({
|
|
|
807
860
|
postMessage.mutateAsync({ path: { threadId }, body: { continue: true, ...settings } })
|
|
808
861
|
)
|
|
809
862
|
setContinuingThreadId(null)
|
|
810
|
-
|
|
811
|
-
|
|
863
|
+
if (response.run) {
|
|
864
|
+
watchRun(response.run)
|
|
865
|
+
setPendingSend({ run: response.run, anchor: true })
|
|
866
|
+
}
|
|
812
867
|
await refreshThread(threadId)
|
|
813
868
|
} catch (error) {
|
|
814
869
|
setContinuingThreadId(null)
|
|
@@ -833,15 +888,18 @@ export function useAgentConversation({
|
|
|
833
888
|
)
|
|
834
889
|
}
|
|
835
890
|
|
|
836
|
-
|
|
891
|
+
/** Recover the thread's sandbox as its owner chose: fresh, or as the failed save left it. */
|
|
892
|
+
const recoverSandbox = (recovery: typeof recreateSandbox | typeof restoreSandbox) => {
|
|
837
893
|
if (!thread?.sandboxState || isRunning || access !== "owner") return
|
|
838
|
-
|
|
894
|
+
recovery.mutate(
|
|
839
895
|
{
|
|
840
896
|
path: { threadId: thread.id },
|
|
841
897
|
body: { expectedSandboxName: thread.sandboxState.name },
|
|
842
898
|
},
|
|
843
899
|
{
|
|
844
900
|
onSuccess: () => {
|
|
901
|
+
if (recovery === restoreSandbox) setResumedThreadId(thread.id)
|
|
902
|
+
|
|
845
903
|
void queryClient.invalidateQueries({
|
|
846
904
|
queryKey: getAgentThreadQueryKey({ path: { threadId: thread.id } }),
|
|
847
905
|
})
|
|
@@ -950,6 +1008,22 @@ export function useAgentConversation({
|
|
|
950
1008
|
latestRun,
|
|
951
1009
|
})
|
|
952
1010
|
|
|
1011
|
+
// Resuming the sandbox picks the cut-short turn up again, once the thread reads ready: it goes
|
|
1012
|
+
// on where it stopped, or runs again when it had not got anywhere.
|
|
1013
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Continue and Retry check their own state
|
|
1014
|
+
useEffect(() => {
|
|
1015
|
+
if (resumedThreadId === null) return
|
|
1016
|
+
if (resumedThreadId !== threadId) {
|
|
1017
|
+
setResumedThreadId(null)
|
|
1018
|
+
return
|
|
1019
|
+
}
|
|
1020
|
+
if (sandboxRecovery) return
|
|
1021
|
+
|
|
1022
|
+
setResumedThreadId(null)
|
|
1023
|
+
if (canContinue) void continueTurn()
|
|
1024
|
+
else if (canRetry) retry()
|
|
1025
|
+
}, [resumedThreadId, threadId, sandboxRecovery, canContinue, canRetry])
|
|
1026
|
+
|
|
953
1027
|
const reader = user
|
|
954
1028
|
? { type: "user" as const, id: user.id, displayName: user.displayName }
|
|
955
1029
|
: undefined
|
|
@@ -965,7 +1039,22 @@ export function useAgentConversation({
|
|
|
965
1039
|
presentation,
|
|
966
1040
|
})
|
|
967
1041
|
|
|
968
|
-
const
|
|
1042
|
+
const answeringAuthor = useMemo(
|
|
1043
|
+
() =>
|
|
1044
|
+
answeringFor
|
|
1045
|
+
? {
|
|
1046
|
+
type: answeringFor.type,
|
|
1047
|
+
id: answeringFor.id,
|
|
1048
|
+
...(answeringForName === undefined ? {} : { displayName: answeringForName }),
|
|
1049
|
+
isReader: false,
|
|
1050
|
+
}
|
|
1051
|
+
: null,
|
|
1052
|
+
[answeringFor, answeringForName]
|
|
1053
|
+
)
|
|
1054
|
+
const continuingHere = continuingThreadId !== null && continuingThreadId === threadId
|
|
1055
|
+
const waitingForComputer = computerOffline ? (thread?.computer?.name ?? null) : null
|
|
1056
|
+
const streamReconnecting = live.active && reconnecting
|
|
1057
|
+
const nextTurn = conversationTurn({
|
|
969
1058
|
presentation,
|
|
970
1059
|
activeRunId,
|
|
971
1060
|
canStop,
|
|
@@ -973,21 +1062,17 @@ export function useAgentConversation({
|
|
|
973
1062
|
canContinue,
|
|
974
1063
|
stopping,
|
|
975
1064
|
retrying: retryRun.isPending,
|
|
976
|
-
continuing:
|
|
1065
|
+
continuing: continuingHere,
|
|
977
1066
|
waitingLonger,
|
|
978
|
-
waitingFor:
|
|
1067
|
+
waitingFor: waitingForComputer,
|
|
979
1068
|
compacting: live.compacting,
|
|
980
1069
|
contextFull: live.contextFull,
|
|
981
|
-
reconnecting:
|
|
982
|
-
answeringFor:
|
|
983
|
-
? {
|
|
984
|
-
type: answeringFor.type,
|
|
985
|
-
id: answeringFor.id,
|
|
986
|
-
...(answeringForName === undefined ? {} : { displayName: answeringForName }),
|
|
987
|
-
isReader: false,
|
|
988
|
-
}
|
|
989
|
-
: null,
|
|
1070
|
+
reconnecting: streamReconnecting,
|
|
1071
|
+
answeringFor: answeringAuthor,
|
|
990
1072
|
})
|
|
1073
|
+
const prevTurnRef = useRef(nextTurn)
|
|
1074
|
+
if (!sameTurn(prevTurnRef.current, nextTurn)) prevTurnRef.current = nextTurn
|
|
1075
|
+
const turn = prevTurnRef.current
|
|
991
1076
|
|
|
992
1077
|
/**
|
|
993
1078
|
* Stop a turn paused on held calls, as Stop does a running one: its waiting calls are set aside,
|
|
@@ -1105,76 +1190,217 @@ export function useAgentConversation({
|
|
|
1105
1190
|
const [questionSetAside, setQuestionSetAside] = useState<string | null>(null)
|
|
1106
1191
|
const asked = threadId !== null ? openQuestion(messages, turn) : null
|
|
1107
1192
|
const asking = asked !== null && questionSetAside !== asked.messageKey ? asked : null
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1193
|
+
// Stable callbacks so streaming chunks never invalidate memoized Composer or Transcript controls.
|
|
1194
|
+
const actionsRef = useRef({
|
|
1195
|
+
send,
|
|
1196
|
+
stop,
|
|
1197
|
+
retry,
|
|
1198
|
+
continueTurn,
|
|
1199
|
+
selectModel,
|
|
1200
|
+
selectReasoning,
|
|
1201
|
+
resetReasoning,
|
|
1202
|
+
resetModelSelection,
|
|
1203
|
+
setApprovalMode,
|
|
1204
|
+
})
|
|
1205
|
+
actionsRef.current = {
|
|
1206
|
+
send,
|
|
1207
|
+
stop,
|
|
1208
|
+
retry,
|
|
1209
|
+
continueTurn,
|
|
1210
|
+
selectModel,
|
|
1211
|
+
selectReasoning,
|
|
1212
|
+
resetReasoning,
|
|
1213
|
+
resetModelSelection,
|
|
1214
|
+
setApprovalMode,
|
|
1128
1215
|
}
|
|
1216
|
+
const stableSend = useCallback<ComposerProps["onSend"]>(
|
|
1217
|
+
(text, attachments, context, delivery) =>
|
|
1218
|
+
void actionsRef.current.send(text, attachments, context, delivery),
|
|
1219
|
+
[]
|
|
1220
|
+
)
|
|
1221
|
+
const stableStop = useCallback(() => actionsRef.current.stop(), [])
|
|
1222
|
+
const stableRetry = useCallback(() => actionsRef.current.retry(), [])
|
|
1223
|
+
const stableContinue = useCallback(() => void actionsRef.current.continueTurn(), [])
|
|
1224
|
+
const stableSelectModel = useCallback(
|
|
1225
|
+
(model: LanguageModel) => actionsRef.current.selectModel(model),
|
|
1226
|
+
[]
|
|
1227
|
+
)
|
|
1228
|
+
const stableSelectReasoning = useCallback(
|
|
1229
|
+
(reasoning: ModelReasoningLevel) => actionsRef.current.selectReasoning(reasoning),
|
|
1230
|
+
[]
|
|
1231
|
+
)
|
|
1232
|
+
const stableResetReasoning = useCallback(() => actionsRef.current.resetReasoning(), [])
|
|
1233
|
+
const stableResetModelSelection = useCallback(() => actionsRef.current.resetModelSelection(), [])
|
|
1234
|
+
const stableSetApprovalMode = useCallback(
|
|
1235
|
+
(mode: AgentApprovalMode) => actionsRef.current.setApprovalMode(mode),
|
|
1236
|
+
[]
|
|
1237
|
+
)
|
|
1238
|
+
const stableAnswerQuestion = useCallback(
|
|
1239
|
+
(text: string) => void actionsRef.current.send(text, [], []),
|
|
1240
|
+
[]
|
|
1241
|
+
)
|
|
1129
1242
|
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
modelsLoading: modelsQuery.isLoading,
|
|
1135
|
-
modelsError: modelsQuery.isError,
|
|
1136
|
-
onSelectModel: selectModel,
|
|
1137
|
-
onSelectReasoning: selectReasoning,
|
|
1138
|
-
onResetReasoning: resetReasoning,
|
|
1139
|
-
usingDefaultModel: modelSelection.request === undefined,
|
|
1140
|
-
onResetModelSelection: resetModelSelection,
|
|
1141
|
-
modelRouting: modelsQuery.data?.languageRouting,
|
|
1142
|
-
}
|
|
1243
|
+
const askingKey = asking?.messageKey ?? null
|
|
1244
|
+
const dismissQuestion = useCallback(() => {
|
|
1245
|
+
if (askingKey) setQuestionSetAside(askingKey)
|
|
1246
|
+
}, [askingKey])
|
|
1143
1247
|
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1248
|
+
const questionProps: QuestionComposerProps | null = useMemo(
|
|
1249
|
+
() =>
|
|
1250
|
+
asking
|
|
1251
|
+
? {
|
|
1252
|
+
questions: asking.questions,
|
|
1253
|
+
onAnswer: stableAnswerQuestion,
|
|
1254
|
+
onDismiss: dismissQuestion,
|
|
1255
|
+
}
|
|
1256
|
+
: null,
|
|
1257
|
+
[asking, stableAnswerQuestion, dismissQuestion]
|
|
1258
|
+
)
|
|
1259
|
+
|
|
1260
|
+
const movedAfterMessageId = moved?.afterMessageId ?? null
|
|
1261
|
+
const movedLabel = moved?.label ?? null
|
|
1262
|
+
const stableMoved = useMemo(
|
|
1263
|
+
() =>
|
|
1264
|
+
movedAfterMessageId && movedLabel
|
|
1265
|
+
? { afterMessageId: movedAfterMessageId, label: movedLabel }
|
|
1266
|
+
: null,
|
|
1267
|
+
[movedAfterMessageId, movedLabel]
|
|
1268
|
+
)
|
|
1269
|
+
|
|
1270
|
+
const transcriptProps: TranscriptProps = useMemo(
|
|
1271
|
+
() => ({
|
|
1272
|
+
threadId,
|
|
1273
|
+
messages,
|
|
1274
|
+
moved: stableMoved,
|
|
1275
|
+
turn,
|
|
1276
|
+
anchorCurrentTurn,
|
|
1277
|
+
onRetry: canRetry ? stableRetry : undefined,
|
|
1278
|
+
onContinue: canContinue ? stableContinue : undefined,
|
|
1279
|
+
approvals: transcriptApprovals,
|
|
1280
|
+
approvalOutcomes,
|
|
1281
|
+
delegation: transcriptDelegation,
|
|
1282
|
+
background: transcriptBackground,
|
|
1283
|
+
}),
|
|
1284
|
+
[
|
|
1285
|
+
threadId,
|
|
1286
|
+
messages,
|
|
1287
|
+
stableMoved,
|
|
1288
|
+
turn,
|
|
1289
|
+
anchorCurrentTurn,
|
|
1290
|
+
canRetry,
|
|
1291
|
+
stableRetry,
|
|
1292
|
+
canContinue,
|
|
1293
|
+
stableContinue,
|
|
1294
|
+
transcriptApprovals,
|
|
1295
|
+
approvalOutcomes,
|
|
1296
|
+
transcriptDelegation,
|
|
1297
|
+
transcriptBackground,
|
|
1298
|
+
]
|
|
1299
|
+
)
|
|
1300
|
+
|
|
1301
|
+
const meterContext = threadId !== null ? contextQuery.data : undefined
|
|
1302
|
+
const meterModelName = meteredModelName(models, contextQuery.data?.model)
|
|
1303
|
+
const contextMeter = useMemo(
|
|
1304
|
+
() => ({
|
|
1305
|
+
context: meterContext,
|
|
1306
|
+
modelName: meterModelName,
|
|
1175
1307
|
condensing: live.compacting,
|
|
1176
|
-
},
|
|
1177
|
-
|
|
1308
|
+
}),
|
|
1309
|
+
[meterContext, meterModelName, live.compacting]
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1312
|
+
const composerError = currentSendError
|
|
1313
|
+
? failureMessage(currentSendError, labels, agentMessages.approvalModes.saveFailed)
|
|
1314
|
+
: undefined
|
|
1315
|
+
const composerHint = answeringName
|
|
1316
|
+
? agentMessages.sharing.answering(answeringName)
|
|
1317
|
+
: othersWaiting
|
|
1318
|
+
? agentMessages.approvals.setsAside(transcriptApprovals.requesterName(othersWaiting))
|
|
1319
|
+
: undefined
|
|
1320
|
+
const resolvedNewThreadPlace =
|
|
1321
|
+
threadId === null && !newThreadSandbox && (newThreadPlace || newThreadPlaceWaiting)
|
|
1322
|
+
? (newThreadPlace ?? "waiting")
|
|
1323
|
+
: undefined
|
|
1324
|
+
const usingDefaultModel = modelSelection.request === undefined
|
|
1325
|
+
const modelRouting = modelsQuery.data?.languageRouting
|
|
1326
|
+
const dictationRecognizer = projectDictation(modelsQuery.data)
|
|
1327
|
+
const composerDisabled = Boolean(sandboxRecovery)
|
|
1328
|
+
const steerable = !requestedBySomeoneElse(activeRun, user)
|
|
1329
|
+
|
|
1330
|
+
const composerProps: ConversationComposerProps = useMemo(
|
|
1331
|
+
() => ({
|
|
1332
|
+
onSend: stableSend,
|
|
1333
|
+
...(resolvedNewThreadPlace ? { newThreadPlace: resolvedNewThreadPlace } : {}),
|
|
1334
|
+
error: composerError,
|
|
1335
|
+
// Whoever's answer is in flight, the reader writes the next message.
|
|
1336
|
+
disabled: composerDisabled,
|
|
1337
|
+
hint: composerHint,
|
|
1338
|
+
pending: composerPending,
|
|
1339
|
+
running: isRunning,
|
|
1340
|
+
// Only the turn the reader asked for takes a steer; another person's takes a queued message.
|
|
1341
|
+
steerable,
|
|
1342
|
+
stopping,
|
|
1343
|
+
onStop: canStop ? stableStop : undefined,
|
|
1344
|
+
models,
|
|
1345
|
+
selectedModel,
|
|
1346
|
+
selectedReasoning,
|
|
1347
|
+
modelsLoading: modelsQuery.isLoading,
|
|
1348
|
+
modelsError: modelsQuery.isError,
|
|
1349
|
+
onSelectModel: stableSelectModel,
|
|
1350
|
+
onSelectReasoning: stableSelectReasoning,
|
|
1351
|
+
onResetReasoning: stableResetReasoning,
|
|
1352
|
+
usingDefaultModel,
|
|
1353
|
+
onResetModelSelection: stableResetModelSelection,
|
|
1354
|
+
modelRouting,
|
|
1355
|
+
draftKey: threadId ?? "draft",
|
|
1356
|
+
draft: draftReseed.text,
|
|
1357
|
+
draftAttachments: draftReseed.attachments,
|
|
1358
|
+
draftContext: draftReseed.context,
|
|
1359
|
+
draftNonce: draftReseed.nonce,
|
|
1360
|
+
draftReseedKey: draftReseed.draftKey,
|
|
1361
|
+
approvalMode,
|
|
1362
|
+
onApprovalModeChange: stableSetApprovalMode,
|
|
1363
|
+
awaitingApproval,
|
|
1364
|
+
dictation: dictationRecognizer,
|
|
1365
|
+
contextMeter,
|
|
1366
|
+
}),
|
|
1367
|
+
[
|
|
1368
|
+
stableSend,
|
|
1369
|
+
resolvedNewThreadPlace,
|
|
1370
|
+
composerError,
|
|
1371
|
+
composerDisabled,
|
|
1372
|
+
composerHint,
|
|
1373
|
+
composerPending,
|
|
1374
|
+
isRunning,
|
|
1375
|
+
steerable,
|
|
1376
|
+
stopping,
|
|
1377
|
+
canStop,
|
|
1378
|
+
stableStop,
|
|
1379
|
+
models,
|
|
1380
|
+
selectedModel,
|
|
1381
|
+
selectedReasoning,
|
|
1382
|
+
modelsQuery.isLoading,
|
|
1383
|
+
modelsQuery.isError,
|
|
1384
|
+
stableSelectModel,
|
|
1385
|
+
stableSelectReasoning,
|
|
1386
|
+
stableResetReasoning,
|
|
1387
|
+
usingDefaultModel,
|
|
1388
|
+
stableResetModelSelection,
|
|
1389
|
+
modelRouting,
|
|
1390
|
+
threadId,
|
|
1391
|
+
draftReseed,
|
|
1392
|
+
approvalMode,
|
|
1393
|
+
stableSetApprovalMode,
|
|
1394
|
+
awaitingApproval,
|
|
1395
|
+
dictationRecognizer,
|
|
1396
|
+
contextMeter,
|
|
1397
|
+
]
|
|
1398
|
+
)
|
|
1399
|
+
|
|
1400
|
+
const pendingProps: PendingMessagesProps = useMemo(
|
|
1401
|
+
() => ({ threadId, steerable, read: readMessageIds }),
|
|
1402
|
+
[threadId, steerable, readMessageIds]
|
|
1403
|
+
)
|
|
1178
1404
|
|
|
1179
1405
|
const movingThisThread = moveToCloud.variables?.path.threadId === thread?.id
|
|
1180
1406
|
const computerNoticeProps: ComputerOfflineNoticeProps | null = computerOffline
|
|
@@ -1200,9 +1426,19 @@ export function useAgentConversation({
|
|
|
1200
1426
|
|
|
1201
1427
|
const sandboxRecoveryProps: SandboxRecoveryProps | null = sandboxRecovery
|
|
1202
1428
|
? {
|
|
1203
|
-
pending: recreateSandbox.isPending,
|
|
1429
|
+
pending: recreateSandbox.isPending || restoreSandbox.isPending,
|
|
1204
1430
|
error: recreateSandbox.isError,
|
|
1205
|
-
onRecreate:
|
|
1431
|
+
onRecreate: () => recoverSandbox(recreateSandbox),
|
|
1432
|
+
// Only a workspace its run finished preparing has files to go on from.
|
|
1433
|
+
...(sandboxRecovery.status !== "unavailable" && sandboxRecovery.initialized
|
|
1434
|
+
? {
|
|
1435
|
+
restore: {
|
|
1436
|
+
pending: restoreSandbox.isPending,
|
|
1437
|
+
error: restoreSandbox.isError,
|
|
1438
|
+
onRestore: () => recoverSandbox(restoreSandbox),
|
|
1439
|
+
},
|
|
1440
|
+
}
|
|
1441
|
+
: {}),
|
|
1206
1442
|
canRecreate: access === "owner",
|
|
1207
1443
|
owner: thread ? personName(threadOwner(thread)) : "",
|
|
1208
1444
|
}
|
|
@@ -1281,6 +1517,8 @@ export function useAgentConversation({
|
|
|
1281
1517
|
* until the reader answers it or sets it aside.
|
|
1282
1518
|
*/
|
|
1283
1519
|
questionProps,
|
|
1520
|
+
/** Spread into `<PendingMessages>`, above the composer: what waits beside the running turn. */
|
|
1521
|
+
pendingProps,
|
|
1284
1522
|
/** Spread into `<SandboxRecovery>` while set: the composer stays disabled until it is resolved. */
|
|
1285
1523
|
sandboxRecoveryProps,
|
|
1286
1524
|
/** Where the reader's own conversation runs on their computer, for its badge. */
|
|
@@ -1472,3 +1710,13 @@ function useExtendedWaitingStatus(run: Pick<AgentRun, "status" | "createdAt"> |
|
|
|
1472
1710
|
|
|
1473
1711
|
return visible
|
|
1474
1712
|
}
|
|
1713
|
+
|
|
1714
|
+
function sameTurn(a: AgentConversationTurn, b: AgentConversationTurn): boolean {
|
|
1715
|
+
const keysA = Object.keys(a)
|
|
1716
|
+
const keysB = Object.keys(b)
|
|
1717
|
+
if (keysA.length !== keysB.length) return false
|
|
1718
|
+
for (const key of keysA) {
|
|
1719
|
+
if (!Object.is(Reflect.get(a, key), Reflect.get(b, key))) return false
|
|
1720
|
+
}
|
|
1721
|
+
return true
|
|
1722
|
+
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
getAgentRunQueryKey,
|
|
4
4
|
getAgentThreadContextQueryKey,
|
|
5
5
|
getAgentThreadQueryKey,
|
|
6
|
+
listAgentThreadInboxQueryKey,
|
|
6
7
|
listAgentThreadMessagesQueryKey,
|
|
7
8
|
listAgentThreadRunsQueryKey,
|
|
8
9
|
listAgentThreadsQueryKey,
|
|
@@ -69,6 +70,15 @@ export function useThreadStream(options: UseThreadStreamOptions): UseThreadStrea
|
|
|
69
70
|
})
|
|
70
71
|
}, [live.finalizedMessageId, threadId, queryClient])
|
|
71
72
|
|
|
73
|
+
// A message the turn read is no longer the inbox's: the tray reads what still waits.
|
|
74
|
+
const reads = live.inboxReads.length
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (reads === 0 || !threadId) return
|
|
77
|
+
void queryClient.invalidateQueries({
|
|
78
|
+
queryKey: listAgentThreadInboxQueryKey({ path: { threadId } }),
|
|
79
|
+
})
|
|
80
|
+
}, [reads, threadId, queryClient])
|
|
81
|
+
|
|
72
82
|
// Refresh run/thread state once the run reaches a terminal status.
|
|
73
83
|
const finishHandledRef = useRef<string | null>(null)
|
|
74
84
|
useEffect(() => {
|