@sixb/app 0.2.3 → 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/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.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 +8 -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 +5 -0
- 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/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +16 -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 +114 -5
- 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 +190 -8
- 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/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.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/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.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 +278 -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 +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.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/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- 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-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.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 +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -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 +9 -1
- package/src/agent/agent-chat.tsx +57 -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/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- 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 +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- 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 +92 -45
- package/src/agent/conversation.ts +203 -54
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +64 -61
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- 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 +33 -6
- 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/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -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 +14 -5
- 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 +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- 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/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- 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 +101 -41
- package/src/index.ts +8 -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-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.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"
|
|
@@ -62,6 +70,8 @@ import {
|
|
|
62
70
|
preferenceWithReasoning,
|
|
63
71
|
resolveModelSelection,
|
|
64
72
|
} from "../model-selection"
|
|
73
|
+
import { openQuestion } from "../questions/interpret"
|
|
74
|
+
import type { QuestionComposerProps } from "../questions/question-composer"
|
|
65
75
|
import { type RequesterSettings, sendWithRequesterSettings } from "../requester-settings"
|
|
66
76
|
import {
|
|
67
77
|
CONTEXT_LIMIT_EXCEEDED,
|
|
@@ -87,6 +97,7 @@ import {
|
|
|
87
97
|
import type {
|
|
88
98
|
AgentContextEntryInput,
|
|
89
99
|
AgentFileRef,
|
|
100
|
+
AgentMessageDelivery,
|
|
90
101
|
AgentRun,
|
|
91
102
|
AgentThreadSandboxParams,
|
|
92
103
|
LanguageModel,
|
|
@@ -142,6 +153,7 @@ export type ConversationComposerProps = Pick<
|
|
|
142
153
|
| "disabled"
|
|
143
154
|
| "pending"
|
|
144
155
|
| "running"
|
|
156
|
+
| "steerable"
|
|
145
157
|
| "stopping"
|
|
146
158
|
| "onStop"
|
|
147
159
|
| "hint"
|
|
@@ -156,10 +168,12 @@ export type ConversationComposerProps = Pick<
|
|
|
156
168
|
| "usingDefaultModel"
|
|
157
169
|
| "onResetModelSelection"
|
|
158
170
|
| "modelRouting"
|
|
171
|
+
| "draftKey"
|
|
159
172
|
| "draft"
|
|
160
173
|
| "draftAttachments"
|
|
161
174
|
| "draftContext"
|
|
162
175
|
| "draftNonce"
|
|
176
|
+
| "draftReseedKey"
|
|
163
177
|
| "insertion"
|
|
164
178
|
| "onInserted"
|
|
165
179
|
| "approvalMode"
|
|
@@ -386,7 +400,9 @@ export function useAgentConversation({
|
|
|
386
400
|
attachments: readonly AgentFileRef[]
|
|
387
401
|
context: readonly AgentContextEntryInput[]
|
|
388
402
|
nonce: number
|
|
389
|
-
|
|
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" })
|
|
390
406
|
const [stoppingRunId, setStoppingRunId] = useState<string | null>(null)
|
|
391
407
|
const stopRef = useRef<(approval: AgentApproval) => Promise<void>>(async () => {})
|
|
392
408
|
const decideRef = useRef<NonNullable<TranscriptApprovals["decide"]>>(async () => {
|
|
@@ -400,6 +416,8 @@ export function useAgentConversation({
|
|
|
400
416
|
} | null>(null)
|
|
401
417
|
/** The thread whose answer Continue is asking for, until the API accepts or refuses it. */
|
|
402
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)
|
|
403
421
|
|
|
404
422
|
const pendingRun =
|
|
405
423
|
pendingSend && threadId !== null && pendingSend.run.threadId === threadId
|
|
@@ -410,6 +428,11 @@ export function useAgentConversation({
|
|
|
410
428
|
? selectActiveRunId({ pendingRun, threadActiveRunId: thread?.activeRunId ?? null, latestRun })
|
|
411
429
|
: null
|
|
412
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
|
+
)
|
|
413
436
|
// A compaction that ended changed what the conversation weighs: measure it again.
|
|
414
437
|
const wasCompactingRef = useRef(false)
|
|
415
438
|
useEffect(() => {
|
|
@@ -468,6 +491,7 @@ export function useAgentConversation({
|
|
|
468
491
|
const cancelRun = useMutation(cancelAgentRunMutation())
|
|
469
492
|
const retryRun = useMutation(retryAgentRunMutation())
|
|
470
493
|
const recreateSandbox = useMutation(recreateAgentThreadSandboxMutation())
|
|
494
|
+
const restoreSandbox = useMutation(restoreAgentThreadSandboxMutation())
|
|
471
495
|
const moveToCloud = useMutation(moveAgentThreadToCloudMutation())
|
|
472
496
|
const stopBackgroundCommand = useMutation(stopAgentBackgroundCommandMutation())
|
|
473
497
|
const decideApproval = useMutation(decideAgentApprovalMutation())
|
|
@@ -534,38 +558,58 @@ export function useAgentConversation({
|
|
|
534
558
|
const send = async (
|
|
535
559
|
text: string,
|
|
536
560
|
attachments: readonly AgentFileRef[],
|
|
537
|
-
context: readonly AgentContextEntryInput[]
|
|
561
|
+
context: readonly AgentContextEntryInput[],
|
|
562
|
+
delivery: AgentMessageDelivery = "auto"
|
|
538
563
|
) => {
|
|
539
|
-
|
|
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
|
|
540
574
|
setSendError(null)
|
|
541
575
|
const targetThreadId = threadId
|
|
542
576
|
const key = `sent:${++sentMessageCount}`
|
|
543
577
|
let createdThreadId: string | null = null
|
|
544
578
|
try {
|
|
545
579
|
if (targetThreadId !== null) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
+
}
|
|
554
592
|
const response = await sendWithRequesterSettings((settings) =>
|
|
555
593
|
postMessage.mutateAsync({
|
|
556
594
|
path: { threadId: targetThreadId },
|
|
557
595
|
body: {
|
|
558
596
|
...messageBody(text, attachments, context, modelSelection.request, settings),
|
|
559
597
|
...turnApprovalMode,
|
|
598
|
+
...(where === "auto" ? {} : { delivery: where }),
|
|
560
599
|
},
|
|
561
600
|
})
|
|
562
601
|
)
|
|
563
|
-
recordAcceptedSend(response.run, key)
|
|
602
|
+
if (response.run) recordAcceptedSend(response.run, key)
|
|
564
603
|
await Promise.all([
|
|
565
604
|
queryClient.invalidateQueries({
|
|
566
605
|
queryKey: listAgentThreadMessagesQueryKey({ path: { threadId: targetThreadId } }),
|
|
567
606
|
}),
|
|
568
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
|
+
}),
|
|
569
613
|
])
|
|
570
614
|
return
|
|
571
615
|
}
|
|
@@ -580,7 +624,13 @@ export function useAgentConversation({
|
|
|
580
624
|
}
|
|
581
625
|
if (!place) {
|
|
582
626
|
// They cancelled choosing a folder: nothing was sent, and their message goes back.
|
|
583
|
-
setDraftReseed((current) => ({
|
|
627
|
+
setDraftReseed((current) => ({
|
|
628
|
+
text,
|
|
629
|
+
attachments,
|
|
630
|
+
context,
|
|
631
|
+
nonce: current.nonce + 1,
|
|
632
|
+
draftKey: "draft",
|
|
633
|
+
}))
|
|
584
634
|
return
|
|
585
635
|
}
|
|
586
636
|
const title = deriveTitle(text, attachments)
|
|
@@ -612,7 +662,7 @@ export function useAgentConversation({
|
|
|
612
662
|
},
|
|
613
663
|
})
|
|
614
664
|
)
|
|
615
|
-
recordAcceptedSend(response.run, key)
|
|
665
|
+
if (response.run) recordAcceptedSend(response.run, key)
|
|
616
666
|
// The next new conversation starts from the default again.
|
|
617
667
|
setChosenApprovalMode((current) => (current?.threadId === null ? null : current))
|
|
618
668
|
await queryClient.invalidateQueries({ queryKey: listAgentThreadsQueryKey() })
|
|
@@ -626,6 +676,7 @@ export function useAgentConversation({
|
|
|
626
676
|
attachments,
|
|
627
677
|
context,
|
|
628
678
|
nonce: current.nonce + 1,
|
|
679
|
+
draftKey: createdThreadId ?? targetThreadId ?? "draft",
|
|
629
680
|
}))
|
|
630
681
|
setSendError({
|
|
631
682
|
threadId: createdThreadId ?? targetThreadId,
|
|
@@ -700,6 +751,10 @@ export function useAgentConversation({
|
|
|
700
751
|
queryClient.invalidateQueries({
|
|
701
752
|
queryKey: getAgentThreadContextQueryKey({ path: { threadId } }),
|
|
702
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
|
+
}),
|
|
703
758
|
])
|
|
704
759
|
|
|
705
760
|
const keepThreadApprovalMode = async (threadId: string, mode: AgentApprovalMode) => {
|
|
@@ -805,8 +860,10 @@ export function useAgentConversation({
|
|
|
805
860
|
postMessage.mutateAsync({ path: { threadId }, body: { continue: true, ...settings } })
|
|
806
861
|
)
|
|
807
862
|
setContinuingThreadId(null)
|
|
808
|
-
|
|
809
|
-
|
|
863
|
+
if (response.run) {
|
|
864
|
+
watchRun(response.run)
|
|
865
|
+
setPendingSend({ run: response.run, anchor: true })
|
|
866
|
+
}
|
|
810
867
|
await refreshThread(threadId)
|
|
811
868
|
} catch (error) {
|
|
812
869
|
setContinuingThreadId(null)
|
|
@@ -831,15 +888,18 @@ export function useAgentConversation({
|
|
|
831
888
|
)
|
|
832
889
|
}
|
|
833
890
|
|
|
834
|
-
|
|
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) => {
|
|
835
893
|
if (!thread?.sandboxState || isRunning || access !== "owner") return
|
|
836
|
-
|
|
894
|
+
recovery.mutate(
|
|
837
895
|
{
|
|
838
896
|
path: { threadId: thread.id },
|
|
839
897
|
body: { expectedSandboxName: thread.sandboxState.name },
|
|
840
898
|
},
|
|
841
899
|
{
|
|
842
900
|
onSuccess: () => {
|
|
901
|
+
if (recovery === restoreSandbox) setResumedThreadId(thread.id)
|
|
902
|
+
|
|
843
903
|
void queryClient.invalidateQueries({
|
|
844
904
|
queryKey: getAgentThreadQueryKey({ path: { threadId: thread.id } }),
|
|
845
905
|
})
|
|
@@ -948,6 +1008,22 @@ export function useAgentConversation({
|
|
|
948
1008
|
latestRun,
|
|
949
1009
|
})
|
|
950
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
|
+
|
|
951
1027
|
const reader = user
|
|
952
1028
|
? { type: "user" as const, id: user.id, displayName: user.displayName }
|
|
953
1029
|
: undefined
|
|
@@ -963,7 +1039,22 @@ export function useAgentConversation({
|
|
|
963
1039
|
presentation,
|
|
964
1040
|
})
|
|
965
1041
|
|
|
966
|
-
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({
|
|
967
1058
|
presentation,
|
|
968
1059
|
activeRunId,
|
|
969
1060
|
canStop,
|
|
@@ -971,21 +1062,17 @@ export function useAgentConversation({
|
|
|
971
1062
|
canContinue,
|
|
972
1063
|
stopping,
|
|
973
1064
|
retrying: retryRun.isPending,
|
|
974
|
-
continuing:
|
|
1065
|
+
continuing: continuingHere,
|
|
975
1066
|
waitingLonger,
|
|
976
|
-
waitingFor:
|
|
1067
|
+
waitingFor: waitingForComputer,
|
|
977
1068
|
compacting: live.compacting,
|
|
978
1069
|
contextFull: live.contextFull,
|
|
979
|
-
reconnecting:
|
|
980
|
-
answeringFor:
|
|
981
|
-
? {
|
|
982
|
-
type: answeringFor.type,
|
|
983
|
-
id: answeringFor.id,
|
|
984
|
-
...(answeringForName === undefined ? {} : { displayName: answeringForName }),
|
|
985
|
-
isReader: false,
|
|
986
|
-
}
|
|
987
|
-
: null,
|
|
1070
|
+
reconnecting: streamReconnecting,
|
|
1071
|
+
answeringFor: answeringAuthor,
|
|
988
1072
|
})
|
|
1073
|
+
const prevTurnRef = useRef(nextTurn)
|
|
1074
|
+
if (!sameTurn(prevTurnRef.current, nextTurn)) prevTurnRef.current = nextTurn
|
|
1075
|
+
const turn = prevTurnRef.current
|
|
989
1076
|
|
|
990
1077
|
/**
|
|
991
1078
|
* Stop a turn paused on held calls, as Stop does a running one: its waiting calls are set aside,
|
|
@@ -1098,68 +1185,222 @@ export function useAgentConversation({
|
|
|
1098
1185
|
}
|
|
1099
1186
|
}, [computer, backgroundCommands, runsOnComputer, threadId])
|
|
1100
1187
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1188
|
+
// The Agent's open question takes the composer's place until it is answered or set aside, to
|
|
1189
|
+
// reply in words of one's own.
|
|
1190
|
+
const [questionSetAside, setQuestionSetAside] = useState<string | null>(null)
|
|
1191
|
+
const asked = threadId !== null ? openQuestion(messages, turn) : null
|
|
1192
|
+
const asking = asked !== null && questionSetAside !== asked.messageKey ? asked : null
|
|
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,
|
|
1113
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
|
+
)
|
|
1114
1242
|
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
modelsLoading: modelsQuery.isLoading,
|
|
1120
|
-
modelsError: modelsQuery.isError,
|
|
1121
|
-
onSelectModel: selectModel,
|
|
1122
|
-
onSelectReasoning: selectReasoning,
|
|
1123
|
-
onResetReasoning: resetReasoning,
|
|
1124
|
-
usingDefaultModel: modelSelection.request === undefined,
|
|
1125
|
-
onResetModelSelection: resetModelSelection,
|
|
1126
|
-
modelRouting: modelsQuery.data?.languageRouting,
|
|
1127
|
-
}
|
|
1243
|
+
const askingKey = asking?.messageKey ?? null
|
|
1244
|
+
const dismissQuestion = useCallback(() => {
|
|
1245
|
+
if (askingKey) setQuestionSetAside(askingKey)
|
|
1246
|
+
}, [askingKey])
|
|
1128
1247
|
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
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,
|
|
1160
1307
|
condensing: live.compacting,
|
|
1161
|
-
},
|
|
1162
|
-
|
|
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
|
+
)
|
|
1163
1404
|
|
|
1164
1405
|
const movingThisThread = moveToCloud.variables?.path.threadId === thread?.id
|
|
1165
1406
|
const computerNoticeProps: ComputerOfflineNoticeProps | null = computerOffline
|
|
@@ -1185,9 +1426,19 @@ export function useAgentConversation({
|
|
|
1185
1426
|
|
|
1186
1427
|
const sandboxRecoveryProps: SandboxRecoveryProps | null = sandboxRecovery
|
|
1187
1428
|
? {
|
|
1188
|
-
pending: recreateSandbox.isPending,
|
|
1429
|
+
pending: recreateSandbox.isPending || restoreSandbox.isPending,
|
|
1189
1430
|
error: recreateSandbox.isError,
|
|
1190
|
-
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
|
+
: {}),
|
|
1191
1442
|
canRecreate: access === "owner",
|
|
1192
1443
|
owner: thread ? personName(threadOwner(thread)) : "",
|
|
1193
1444
|
}
|
|
@@ -1261,6 +1512,13 @@ export function useAgentConversation({
|
|
|
1261
1512
|
transcriptProps,
|
|
1262
1513
|
/** Spread into `<Composer>`, then add the page's own props such as `placeholder`. */
|
|
1263
1514
|
composerProps,
|
|
1515
|
+
/**
|
|
1516
|
+
* Spread into `<QuestionComposer>` while set, in the composer's place: the Agent's question,
|
|
1517
|
+
* until the reader answers it or sets it aside.
|
|
1518
|
+
*/
|
|
1519
|
+
questionProps,
|
|
1520
|
+
/** Spread into `<PendingMessages>`, above the composer: what waits beside the running turn. */
|
|
1521
|
+
pendingProps,
|
|
1264
1522
|
/** Spread into `<SandboxRecovery>` while set: the composer stays disabled until it is resolved. */
|
|
1265
1523
|
sandboxRecoveryProps,
|
|
1266
1524
|
/** Where the reader's own conversation runs on their computer, for its badge. */
|
|
@@ -1452,3 +1710,13 @@ function useExtendedWaitingStatus(run: Pick<AgentRun, "status" | "createdAt"> |
|
|
|
1452
1710
|
|
|
1453
1711
|
return visible
|
|
1454
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(() => {
|