@sixb/app 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/agent-threads.d.ts.map +1 -1
- package/dist/agent/components/composer-place.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/computer-place.d.ts +24 -6
- package/dist/agent/components/computer-place.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 +13 -3
- 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 +13 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +7 -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/format.d.ts +7 -0
- package/dist/agent/format.d.ts.map +1 -1
- package/dist/agent/hooks/thread-queries.d.ts +1548 -0
- package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +51 -6
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-place.d.ts +49 -0
- package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +107 -6
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +180 -12
- 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/model-selection.d.ts +3 -2
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/moves.d.ts +40 -0
- package/dist/agent/moves.d.ts.map +1 -0
- package/dist/agent/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-reader-state.d.ts +30 -0
- package/dist/agent/thread-reader-state.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 +9 -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-pxd07kvx.js → chunk-096d52h2.js} +1 -1
- package/dist/{chunk-yrcm1pbg.js → chunk-94d7enwc.js} +491 -2128
- package/dist/chunk-94d7enwc.js.map +27 -0
- package/dist/{chunk-970s5nkn.js → chunk-ezntd3yy.js} +1 -1
- package/dist/{chunk-kymx9y5e.js → chunk-qjw5r2vk.js} +12729 -5044
- package/dist/chunk-qjw5r2vk.js.map +242 -0
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/createCustomApp.d.ts +8 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- 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/accounts.d.ts +94 -0
- package/dist/pages/console/data/accounts.d.ts.map +1 -0
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/live-updates.d.ts.map +1 -1
- package/dist/pages/console/data/messages.d.ts +52 -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/console/data/sync-button.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/page.d.ts +4 -1
- package/dist/pages/settings/usage/page.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +43 -19
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages.js +23044 -22570
- package/dist/pages.js.map +17 -16
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -3
- package/dist/server.js.map +3 -3
- package/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 +58 -39
- 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/agent-threads.tsx +42 -2
- package/src/agent/components/composer-place.tsx +2 -7
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/computer-place.tsx +415 -70
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +99 -54
- package/src/agent/components/message-parts.tsx +367 -59
- package/src/agent/components/message-view.tsx +428 -9
- package/src/agent/components/pending-messages.tsx +342 -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 +198 -38
- package/src/agent/conversation.ts +219 -55
- package/src/agent/delegation/interpret.ts +31 -7
- package/src/agent/format.ts +52 -0
- package/src/agent/hooks/thread-queries.ts +75 -0
- package/src/agent/hooks/use-agent-conversation.ts +801 -211
- package/src/agent/hooks/use-thread-lists.ts +72 -7
- package/src/agent/hooks/use-thread-place.ts +239 -0
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +150 -27
- package/src/agent/i18n/fr.ts +148 -31
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +61 -2
- package/src/agent/model-selection.ts +3 -2
- package/src/agent/moves.ts +174 -0
- 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-reader-state.ts +75 -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 +13 -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 +9 -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/createCustomApp.ts +57 -3
- package/src/index.ts +10 -0
- package/src/pages/console/data/accounts.tsx +509 -0
- package/src/pages/console/data/connectors.tsx +7 -15
- package/src/pages/console/data/live-updates.ts +2 -0
- package/src/pages/console/data/messages.ts +79 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/data/sync-button.tsx +56 -16
- package/src/pages/console/data/syncs.tsx +66 -41
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/pages/section-ui.tsx +1 -1
- package/src/pages/settings/usage/breakdown.tsx +5 -2
- package/src/pages/settings/usage/filter-menu.tsx +1 -1
- package/src/pages/settings/usage/page.tsx +32 -13
- package/src/pages/settings/usage/spend-chart.tsx +2 -2
- package/src/pages/settings/usage/spend-model.ts +118 -50
- package/src/server.ts +1 -0
- package/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-096d52h2.js.map} +0 -0
- /package/dist/{chunk-970s5nkn.js.map → chunk-ezntd3yy.js.map} +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
// An edit waiting for the turn it stopped shows in place of the message it replaces, not here.
|
|
106
|
+
const fetched =
|
|
107
|
+
threadId === null
|
|
108
|
+
? []
|
|
109
|
+
: (inbox.data?.items ?? []).filter((item) => item.replacesMessageId === undefined)
|
|
110
|
+
for (const item of fetched) held.current.set(item.messageId, item)
|
|
111
|
+
const leaving = [...read].flatMap((messageId) => {
|
|
112
|
+
const item = held.current.get(messageId)
|
|
113
|
+
return item && !folded.has(messageId) && item.threadId === threadId ? [item] : []
|
|
114
|
+
})
|
|
115
|
+
const items = [...fetched.filter((item) => !read.has(item.messageId)), ...leaving].sort(
|
|
116
|
+
(a, b) => a.seq - b.seq
|
|
117
|
+
)
|
|
118
|
+
const open = useOpened(items.length > 0)
|
|
119
|
+
if (items.length === 0) return null
|
|
120
|
+
|
|
121
|
+
const fold = (messageId: string) => {
|
|
122
|
+
held.current.delete(messageId)
|
|
123
|
+
setFolded((current) => new Set(current).add(messageId))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
// The composer's own column: the tray lines up with the input it waits above. It opens and
|
|
128
|
+
// closes by its height, so the conversation above moves with it instead of jumping.
|
|
129
|
+
<div
|
|
130
|
+
className={cn(
|
|
131
|
+
"grid transition-[grid-template-rows] ease-out motion-reduce:transition-none",
|
|
132
|
+
open && leaving.length < items.length ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
|
|
133
|
+
)}
|
|
134
|
+
style={{ transitionDuration: `${FOLD_MS}ms` }}
|
|
135
|
+
data-pending-messages=""
|
|
136
|
+
>
|
|
137
|
+
<div className="min-h-0 overflow-hidden">
|
|
138
|
+
<div className={cn("px-4", className)}>
|
|
139
|
+
<div className="mx-auto flex w-full max-w-[46rem] flex-col rounded-2xl bg-muted/60 p-1">
|
|
140
|
+
{items.map((item) => (
|
|
141
|
+
<PendingMessage
|
|
142
|
+
key={item.id}
|
|
143
|
+
item={item}
|
|
144
|
+
leaving={read.has(item.messageId)}
|
|
145
|
+
onLeft={() => fold(item.messageId)}
|
|
146
|
+
mine={samePrincipal(item.authorPrincipal, me)}
|
|
147
|
+
steerable={steerable}
|
|
148
|
+
labels={labels}
|
|
149
|
+
busy={promote.isPending || withdraw.isPending}
|
|
150
|
+
onMove={(delivery) =>
|
|
151
|
+
threadId !== null &&
|
|
152
|
+
promote.mutate({ path: { threadId, itemId: item.id }, body: { delivery } })
|
|
153
|
+
}
|
|
154
|
+
onSendNow={() =>
|
|
155
|
+
threadId !== null &&
|
|
156
|
+
promote.mutate({ path: { threadId, itemId: item.id }, body: { immediate: true } })
|
|
157
|
+
}
|
|
158
|
+
onWithdraw={() =>
|
|
159
|
+
threadId !== null && withdraw.mutate({ path: { threadId, itemId: item.id } })
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
162
|
+
))}
|
|
163
|
+
{failure ? (
|
|
164
|
+
<p role="alert" className="px-3 pt-1 pb-1.5 text-[13px] text-destructive">
|
|
165
|
+
{failure}
|
|
166
|
+
</p>
|
|
167
|
+
) : null}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** False on the first frame `shown` is true, then true: what opens by a transition starts closed. */
|
|
176
|
+
function useOpened(shown: boolean): boolean {
|
|
177
|
+
const [opened, setOpened] = useState(false)
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!shown) {
|
|
180
|
+
setOpened(false)
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
const frame = requestAnimationFrame(() => setOpened(true))
|
|
184
|
+
return () => cancelAnimationFrame(frame)
|
|
185
|
+
}, [shown])
|
|
186
|
+
return shown && opened
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function PendingMessage({
|
|
190
|
+
item,
|
|
191
|
+
leaving,
|
|
192
|
+
onLeft,
|
|
193
|
+
mine,
|
|
194
|
+
steerable: turnSteerable,
|
|
195
|
+
labels,
|
|
196
|
+
busy,
|
|
197
|
+
onMove,
|
|
198
|
+
onSendNow,
|
|
199
|
+
onWithdraw,
|
|
200
|
+
}: {
|
|
201
|
+
readonly item: AgentInboxItem
|
|
202
|
+
/** The turn read it: the line folds away, and its message rises into the conversation. */
|
|
203
|
+
readonly leaving: boolean
|
|
204
|
+
readonly onLeft: () => void
|
|
205
|
+
/** Only the person who sent it may change it: another participant's shows without actions. */
|
|
206
|
+
readonly mine: boolean
|
|
207
|
+
readonly steerable: boolean
|
|
208
|
+
readonly labels: ReturnType<typeof useAgentMessages>["composer"]
|
|
209
|
+
readonly busy: boolean
|
|
210
|
+
/** Into the answer in flight, or after it. */
|
|
211
|
+
readonly onMove: (delivery: "steer" | "queue") => void
|
|
212
|
+
readonly onSendNow: () => void
|
|
213
|
+
readonly onWithdraw: () => void
|
|
214
|
+
}) {
|
|
215
|
+
const text = item.parts
|
|
216
|
+
.flatMap((part) => (part.type === "text" ? [part.text] : []))
|
|
217
|
+
.join(" ")
|
|
218
|
+
.trim()
|
|
219
|
+
const files = item.parts.flatMap((part) => (part.type === "file" ? [part.fileRef] : []))
|
|
220
|
+
const status =
|
|
221
|
+
item.immediate === true
|
|
222
|
+
? labels.sendNowPending
|
|
223
|
+
: item.mode === "steer"
|
|
224
|
+
? labels.steerPending
|
|
225
|
+
: labels.queuePending
|
|
226
|
+
const Status = item.immediate === true ? Send : item.mode === "steer" ? CornerDownRight : ListEnd
|
|
227
|
+
const opened = useOpened(true)
|
|
228
|
+
|
|
229
|
+
// What can still be done with it. A steer is read mid-turn, which prepares no file: one that
|
|
230
|
+
// carries a file stays queued. Only whoever asked for the answer in flight steers it or stops it
|
|
231
|
+
// to send now; anyone takes their own message back.
|
|
232
|
+
const actions: PendingAction[] = []
|
|
233
|
+
if (turnSteerable && item.immediate !== true) {
|
|
234
|
+
if (item.mode === "queue" && files.length === 0) {
|
|
235
|
+
actions.push({ label: labels.steer, Icon: CornerDownRight, run: () => onMove("steer") })
|
|
236
|
+
}
|
|
237
|
+
if (item.mode === "steer") {
|
|
238
|
+
actions.push({ label: labels.queue, Icon: ListEnd, run: () => onMove("queue") })
|
|
239
|
+
}
|
|
240
|
+
actions.push({ label: labels.sendNow, Icon: Send, run: onSendNow })
|
|
241
|
+
}
|
|
242
|
+
actions.push({ label: labels.withdraw, Icon: X, run: onWithdraw })
|
|
243
|
+
|
|
244
|
+
// The chat draws again with every chunk of the answer: the fold's end is not put off by it.
|
|
245
|
+
const left = useRef(onLeft)
|
|
246
|
+
left.current = onLeft
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
if (!leaving) return
|
|
249
|
+
const timer = setTimeout(() => left.current(), FOLD_MS)
|
|
250
|
+
return () => clearTimeout(timer)
|
|
251
|
+
}, [leaving])
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
// A line opens as it arrives and folds away once read, while its message rises into place.
|
|
255
|
+
<div
|
|
256
|
+
className={cn(
|
|
257
|
+
"grid transition-[grid-template-rows,opacity] ease-out motion-reduce:transition-none",
|
|
258
|
+
opened && !leaving ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
|
259
|
+
leaving && "opacity-0"
|
|
260
|
+
)}
|
|
261
|
+
// Its words leave at once, for the conversation's copy; the space they held closes after.
|
|
262
|
+
style={{ transitionDuration: `${FOLD_MS}ms, ${leaving ? 120 : FOLD_MS}ms` }}
|
|
263
|
+
aria-hidden={leaving || undefined}
|
|
264
|
+
>
|
|
265
|
+
<div className="min-h-0 overflow-hidden">
|
|
266
|
+
{/* One quiet line: where it goes, what it says, and what can still be done with it. */}
|
|
267
|
+
<div
|
|
268
|
+
title={status}
|
|
269
|
+
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"
|
|
270
|
+
>
|
|
271
|
+
<Status aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
|
272
|
+
<span className="sr-only">{status}: </span>
|
|
273
|
+
{files.length > 0 ? (
|
|
274
|
+
<Paperclip aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
|
275
|
+
) : null}
|
|
276
|
+
<p
|
|
277
|
+
className="min-w-0 flex-1 truncate text-foreground/75"
|
|
278
|
+
{...{ [TRAY_MESSAGE_ATTRIBUTE]: trayMessageKey(item.messageId) }}
|
|
279
|
+
>
|
|
280
|
+
{text || files.map((file) => file.fileName ?? labels.waitingFile).join(", ")}
|
|
281
|
+
</p>
|
|
282
|
+
{mine ? (
|
|
283
|
+
<>
|
|
284
|
+
{/* With a pointer: each action as an icon, named on hover. */}
|
|
285
|
+
<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">
|
|
286
|
+
{actions.map(({ label, Icon, run }) => (
|
|
287
|
+
<button
|
|
288
|
+
key={label}
|
|
289
|
+
type="button"
|
|
290
|
+
onClick={run}
|
|
291
|
+
disabled={busy}
|
|
292
|
+
title={label}
|
|
293
|
+
aria-label={label}
|
|
294
|
+
className={ACTION_CLASS}
|
|
295
|
+
>
|
|
296
|
+
<Icon className="size-3.5" />
|
|
297
|
+
</button>
|
|
298
|
+
))}
|
|
299
|
+
</div>
|
|
300
|
+
{/* By touch, where nothing hovers: one button, and the actions named in a menu. */}
|
|
301
|
+
<DropdownMenu>
|
|
302
|
+
<DropdownMenuTrigger asChild>
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
disabled={busy}
|
|
306
|
+
aria-label={labels.messageActions}
|
|
307
|
+
className={cn(ACTION_CLASS, "size-9 [@media(hover:hover)]:hidden")}
|
|
308
|
+
>
|
|
309
|
+
<Ellipsis className="size-4" />
|
|
310
|
+
</button>
|
|
311
|
+
</DropdownMenuTrigger>
|
|
312
|
+
<DropdownMenuContent align="end" className="min-w-56">
|
|
313
|
+
<DropdownMenuLabel className="text-xs font-normal text-muted-foreground">
|
|
314
|
+
{status}
|
|
315
|
+
</DropdownMenuLabel>
|
|
316
|
+
{actions.map(({ label, Icon, run }) => (
|
|
317
|
+
<DropdownMenuItem key={label} onSelect={run} className="gap-2.5 py-2.5">
|
|
318
|
+
<Icon className="size-4 text-muted-foreground" />
|
|
319
|
+
{label}
|
|
320
|
+
</DropdownMenuItem>
|
|
321
|
+
))}
|
|
322
|
+
</DropdownMenuContent>
|
|
323
|
+
</DropdownMenu>
|
|
324
|
+
</>
|
|
325
|
+
) : null}
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
interface PendingAction {
|
|
333
|
+
readonly label: string
|
|
334
|
+
readonly Icon: LucideIcon
|
|
335
|
+
readonly run: () => void
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const ACTION_CLASS = cn(
|
|
339
|
+
"flex size-7 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors",
|
|
340
|
+
"hover:bg-black/[0.05] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-50",
|
|
341
|
+
"dark:hover:bg-white/[0.08]"
|
|
342
|
+
)
|
|
@@ -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
|
+
})
|