@sixb/app 0.1.12 → 0.1.13
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/README.md +3 -8
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +9 -8
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts +5 -8
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/agents-page.d.ts +4 -0
- package/dist/agent/agents-page.d.ts.map +1 -0
- package/dist/agent/artifact-card.d.ts +9 -0
- package/dist/agent/artifact-card.d.ts.map +1 -0
- package/dist/agent/artifact-panel-state.d.ts +16 -0
- package/dist/agent/artifact-panel-state.d.ts.map +1 -0
- package/dist/agent/artifact-panel.d.ts +38 -0
- package/dist/agent/artifact-panel.d.ts.map +1 -0
- package/dist/agent/components/file-attachment-card.d.ts +3 -3
- package/dist/agent/components/file-attachment-card.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 +3 -3
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/thread-artifacts-menu.d.ts +8 -0
- package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +3 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +10 -49
- 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 +16 -98
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/parts.d.ts +4 -4
- package/dist/agent/parts.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +32 -0
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -0
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +9 -0
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -0
- package/dist/agent/publish-artifact/use-live-publishes.d.ts +10 -0
- package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -0
- package/dist/agent/react-router.d.ts +1 -2
- package/dist/agent/react-router.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/artifacts/artifact-page.d.ts +7 -0
- package/dist/artifacts/artifact-page.d.ts.map +1 -0
- package/dist/artifacts/card-details.d.ts +15 -0
- package/dist/artifacts/card-details.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts +59 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -0
- package/dist/artifacts/copy-feedback.d.ts +6 -0
- package/dist/artifacts/copy-feedback.d.ts.map +1 -0
- package/dist/artifacts/file-size.d.ts +11 -0
- package/dist/artifacts/file-size.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +45 -0
- package/dist/artifacts/file-source.d.ts.map +1 -0
- package/dist/artifacts/file-view.d.ts +9 -0
- package/dist/artifacts/file-view.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +45 -0
- package/dist/artifacts/frame.d.ts.map +1 -0
- package/dist/artifacts/gallery.d.ts +6 -0
- package/dist/artifacts/gallery.d.ts.map +1 -0
- package/dist/artifacts/kind-icon.d.ts +8 -0
- package/dist/artifacts/kind-icon.d.ts.map +1 -0
- package/dist/artifacts/markdown-tree.d.ts +22 -0
- package/dist/artifacts/markdown-tree.d.ts.map +1 -0
- package/dist/artifacts/messages.d.ts +301 -0
- package/dist/artifacts/messages.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +21 -0
- package/dist/artifacts/queries.d.ts.map +1 -0
- package/dist/artifacts/references/embed-tree.d.ts +17 -0
- package/dist/artifacts/references/embed-tree.d.ts.map +1 -0
- package/dist/artifacts/references/references.d.ts +50 -0
- package/dist/artifacts/references/references.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +11 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -0
- package/dist/artifacts/renderers/document.d.ts +17 -0
- package/dist/artifacts/renderers/document.d.ts.map +1 -0
- package/dist/artifacts/renderers/file.d.ts +10 -0
- package/dist/artifacts/renderers/file.d.ts.map +1 -0
- package/dist/artifacts/renderers/notice.d.ts +12 -0
- package/dist/artifacts/renderers/notice.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/chart-data.d.ts +33 -0
- package/dist/artifacts/renderers/sheet/chart-data.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/chart.d.ts +15 -0
- package/dist/artifacts/renderers/sheet/chart.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/format.d.ts +35 -0
- package/dist/artifacts/renderers/sheet/format.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/grid.d.ts +25 -0
- package/dist/artifacts/renderers/sheet/grid.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/mini-chart.d.ts +7 -0
- package/dist/artifacts/renderers/sheet/mini-chart.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/model.d.ts +29 -0
- package/dist/artifacts/renderers/sheet/model.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/selection.d.ts +42 -0
- package/dist/artifacts/renderers/sheet/selection.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/sheet.d.ts +17 -0
- package/dist/artifacts/renderers/sheet/sheet.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/virtual.d.ts +13 -0
- package/dist/artifacts/renderers/sheet/virtual.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/workbook.d.ts +24 -0
- package/dist/artifacts/renderers/sheet/workbook.d.ts.map +1 -0
- package/dist/artifacts/renderers/slides/navigation.d.ts +17 -0
- package/dist/artifacts/renderers/slides/navigation.d.ts.map +1 -0
- package/dist/artifacts/renderers/slides/slides.d.ts +14 -0
- package/dist/artifacts/renderers/slides/slides.d.ts.map +1 -0
- package/dist/artifacts/target.d.ts +29 -0
- package/dist/artifacts/target.d.ts.map +1 -0
- package/dist/artifacts/theme.d.ts +18 -0
- package/dist/artifacts/theme.d.ts.map +1 -0
- package/dist/artifacts/viewer.d.ts +19 -0
- package/dist/artifacts/viewer.d.ts.map +1 -0
- package/dist/{chunk-shmw3f8t.js → chunk-3schcf10.js} +1 -1
- package/dist/chunk-c7gy61rx.js +276 -0
- package/dist/chunk-c7gy61rx.js.map +10 -0
- package/dist/{chunk-48pkffj6.js → chunk-g3f4cm8x.js} +1 -1
- package/dist/{chunk-zcxrt24m.js → chunk-gn3k23q5.js} +3 -2
- package/dist/{chunk-zcxrt24m.js.map → chunk-gn3k23q5.js.map} +3 -3
- package/dist/{chunk-3a99tmwg.js → chunk-ng0hdnrq.js} +10 -3
- package/dist/chunk-ng0hdnrq.js.map +10 -0
- package/dist/{chunk-j97e06rg.js → chunk-xxpdn63v.js} +7224 -2874
- package/dist/chunk-xxpdn63v.js.map +105 -0
- package/dist/codegen.d.ts +2 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -31
- package/dist/index.js.map +7 -7
- package/dist/locale-messages.d.ts +2 -0
- package/dist/locale-messages.d.ts.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +1 -1
- package/dist/pages/observability/activity/calendar.d.ts +9 -0
- package/dist/pages/observability/activity/calendar.d.ts.map +1 -0
- package/dist/pages/observability/activity/connections.d.ts +7 -0
- package/dist/pages/observability/activity/connections.d.ts.map +1 -0
- package/dist/pages/observability/activity/format.d.ts +11 -0
- package/dist/pages/observability/activity/format.d.ts.map +1 -0
- package/dist/pages/observability/activity/messages.d.ts +231 -0
- package/dist/pages/observability/activity/messages.d.ts.map +1 -0
- package/dist/pages/observability/activity/meta-items.d.ts +10 -0
- package/dist/pages/observability/activity/meta-items.d.ts.map +1 -0
- package/dist/pages/observability/activity/page.d.ts +6 -0
- package/dist/pages/observability/activity/page.d.ts.map +1 -0
- package/dist/pages/observability/activity/period.d.ts +31 -0
- package/dist/pages/observability/activity/period.d.ts.map +1 -0
- package/dist/pages/observability/activity/steps.d.ts +44 -0
- package/dist/pages/observability/activity/steps.d.ts.map +1 -0
- package/dist/pages/observability/activity/timeline.d.ts +36 -0
- package/dist/pages/observability/activity/timeline.d.ts.map +1 -0
- package/dist/pages/observability/activity/users.d.ts +18 -0
- package/dist/pages/observability/activity/users.d.ts.map +1 -0
- package/dist/pages/routes.d.ts +7 -0
- package/dist/pages/routes.d.ts.map +1 -1
- package/dist/pages/section-ui.d.ts +2 -1
- package/dist/pages/section-ui.d.ts.map +1 -1
- package/dist/pages.d.ts +4 -1
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +5852 -3754
- package/dist/pages.js.map +20 -7
- package/dist/sections/catalog.d.ts.map +1 -1
- package/dist/sections/sections.d.ts.map +1 -1
- package/dist/server.js +63 -10
- package/dist/server.js.map +5 -5
- package/dist/shell/search-command.d.ts.map +1 -1
- package/dist/shell/user-menu.d.ts +3 -3
- package/dist/shell/user-menu.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/agent/activity-label.ts +7 -0
- package/src/agent/agent-chat.tsx +29 -18
- package/src/agent/agent-execution-trace.tsx +1 -1
- package/src/agent/agent-panel.tsx +8 -13
- package/src/agent/agent-surface.tsx +4 -4
- package/src/agent/agents-page.ts +7 -0
- package/src/agent/artifact-card.tsx +190 -0
- package/src/agent/artifact-panel-state.ts +38 -0
- package/src/agent/artifact-panel.tsx +320 -0
- package/src/agent/components/file-attachment-card.tsx +13 -14
- package/src/agent/components/message-parts.tsx +30 -5
- package/src/agent/components/message-view.tsx +13 -19
- package/src/agent/components/thread-artifacts-menu.tsx +77 -0
- package/src/agent/i18n/en.ts +16 -58
- package/src/agent/i18n/fr.ts +15 -59
- package/src/agent/parts.ts +6 -6
- package/src/agent/publish-artifact/interpret.ts +110 -0
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +62 -0
- package/src/agent/publish-artifact/use-live-publishes.ts +45 -0
- package/src/agent/react-router.tsx +26 -7
- package/src/agent/view-file/view-file-tool-view.tsx +21 -18
- package/src/artifacts/artifact-page.tsx +61 -0
- package/src/artifacts/artifacts.css +172 -0
- package/src/artifacts/card-details.ts +92 -0
- package/src/artifacts/card-preview.tsx +612 -0
- package/src/artifacts/copy-feedback.ts +25 -0
- package/src/artifacts/file-size.ts +24 -0
- package/src/artifacts/file-source.ts +109 -0
- package/src/artifacts/file-view.ts +57 -0
- package/src/artifacts/frame.tsx +288 -0
- package/src/artifacts/gallery.tsx +405 -0
- package/src/artifacts/kind-icon.tsx +23 -0
- package/src/artifacts/markdown-tree.ts +32 -0
- package/src/artifacts/messages.ts +317 -0
- package/src/artifacts/queries.ts +85 -0
- package/src/artifacts/references/embed-tree.ts +86 -0
- package/src/artifacts/references/references.tsx +739 -0
- package/src/artifacts/renderers/document-tree.ts +157 -0
- package/src/artifacts/renderers/document.tsx +334 -0
- package/src/artifacts/renderers/file.tsx +160 -0
- package/src/artifacts/renderers/notice.tsx +38 -0
- package/src/artifacts/renderers/sheet/chart-data.ts +73 -0
- package/src/artifacts/renderers/sheet/chart.tsx +288 -0
- package/src/artifacts/renderers/sheet/format.ts +142 -0
- package/src/artifacts/renderers/sheet/grid.tsx +709 -0
- package/src/artifacts/renderers/sheet/mini-chart.tsx +241 -0
- package/src/artifacts/renderers/sheet/model.ts +136 -0
- package/src/artifacts/renderers/sheet/selection.ts +152 -0
- package/src/artifacts/renderers/sheet/sheet.tsx +471 -0
- package/src/artifacts/renderers/sheet/virtual.ts +49 -0
- package/src/artifacts/renderers/sheet/workbook.ts +57 -0
- package/src/artifacts/renderers/slides/navigation.ts +38 -0
- package/src/artifacts/renderers/slides/slides.tsx +441 -0
- package/src/artifacts/target.ts +76 -0
- package/src/artifacts/theme.ts +29 -0
- package/src/artifacts/viewer.tsx +476 -0
- package/src/build.ts +13 -2
- package/src/codegen.ts +38 -2
- package/src/createCustomApp.ts +21 -1
- package/src/index.ts +0 -5
- package/src/locale-messages.ts +9 -2
- package/src/pages/observability/activity/calendar.tsx +239 -0
- package/src/pages/observability/activity/connections.tsx +144 -0
- package/src/pages/observability/activity/format.ts +49 -0
- package/src/pages/observability/activity/messages.ts +255 -0
- package/src/pages/observability/activity/meta-items.tsx +23 -0
- package/src/pages/observability/activity/page.tsx +605 -0
- package/src/pages/observability/activity/period.ts +63 -0
- package/src/pages/observability/activity/steps.ts +102 -0
- package/src/pages/observability/activity/timeline.tsx +411 -0
- package/src/pages/observability/activity/users.tsx +133 -0
- package/src/pages/observability/messages.ts +2 -2
- package/src/pages/routes.ts +15 -0
- package/src/pages/section-ui.tsx +3 -1
- package/src/pages.ts +4 -1
- package/src/sections/catalog.ts +1 -0
- package/src/sections/sections.tsx +2 -0
- package/src/shell/search-command.tsx +8 -6
- package/src/shell/user-menu.tsx +22 -22
- package/dist/agent/document-preview/classify.d.ts +0 -4
- package/dist/agent/document-preview/classify.d.ts.map +0 -1
- package/dist/agent/document-preview/content-policy.d.ts +0 -10
- package/dist/agent/document-preview/content-policy.d.ts.map +0 -1
- package/dist/agent/document-preview/content.d.ts +0 -26
- package/dist/agent/document-preview/content.d.ts.map +0 -1
- package/dist/agent/document-preview/delimited.d.ts +0 -19
- package/dist/agent/document-preview/delimited.d.ts.map +0 -1
- package/dist/agent/document-preview/document-preview-root.d.ts +0 -24
- package/dist/agent/document-preview/document-preview-root.d.ts.map +0 -1
- package/dist/agent/document-preview/file-size.d.ts +0 -3
- package/dist/agent/document-preview/file-size.d.ts.map +0 -1
- package/dist/agent/document-preview/html.d.ts +0 -9
- package/dist/agent/document-preview/html.d.ts.map +0 -1
- package/dist/agent/document-preview/persistence.d.ts +0 -6
- package/dist/agent/document-preview/persistence.d.ts.map +0 -1
- package/dist/agent/document-preview/presentation.d.ts +0 -3
- package/dist/agent/document-preview/presentation.d.ts.map +0 -1
- package/dist/agent/document-preview/rendering.d.ts +0 -14
- package/dist/agent/document-preview/rendering.d.ts.map +0 -1
- package/dist/agent/document-preview/source.d.ts +0 -13
- package/dist/agent/document-preview/source.d.ts.map +0 -1
- package/dist/agent/document-preview/state.d.ts +0 -27
- package/dist/agent/document-preview/state.d.ts.map +0 -1
- package/dist/agent/document-preview/types.d.ts +0 -33
- package/dist/agent/document-preview/types.d.ts.map +0 -1
- package/dist/agent/workspace.d.ts +0 -11
- package/dist/agent/workspace.d.ts.map +0 -1
- package/dist/chunk-3a99tmwg.js.map +0 -10
- package/dist/chunk-j97e06rg.js.map +0 -80
- package/src/agent/document-preview/classify.ts +0 -55
- package/src/agent/document-preview/content-policy.ts +0 -37
- package/src/agent/document-preview/content.ts +0 -82
- package/src/agent/document-preview/delimited.ts +0 -118
- package/src/agent/document-preview/document-preview-root.tsx +0 -1017
- package/src/agent/document-preview/file-size.ts +0 -26
- package/src/agent/document-preview/html.ts +0 -67
- package/src/agent/document-preview/persistence.ts +0 -115
- package/src/agent/document-preview/presentation.ts +0 -13
- package/src/agent/document-preview/rendering.ts +0 -48
- package/src/agent/document-preview/source.ts +0 -48
- package/src/agent/document-preview/state.ts +0 -77
- package/src/agent/document-preview/types.ts +0 -36
- package/src/agent/workspace.ts +0 -33
- /package/dist/{chunk-shmw3f8t.js.map → chunk-3schcf10.js.map} +0 -0
- /package/dist/{chunk-48pkffj6.js.map → chunk-g3f4cm8x.js.map} +0 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dialog,
|
|
3
|
+
DialogContent,
|
|
4
|
+
DialogDescription,
|
|
5
|
+
DialogTitle,
|
|
6
|
+
ResizableHandle,
|
|
7
|
+
ResizablePanel,
|
|
8
|
+
ResizablePanelGroup,
|
|
9
|
+
} from "@sixb/ui/components"
|
|
10
|
+
import { useIsMobile } from "@sixb/ui/hooks"
|
|
11
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
12
|
+
import {
|
|
13
|
+
createContext,
|
|
14
|
+
memo,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
useCallback,
|
|
17
|
+
useContext,
|
|
18
|
+
useEffect,
|
|
19
|
+
useId,
|
|
20
|
+
useLayoutEffect,
|
|
21
|
+
useMemo,
|
|
22
|
+
useReducer,
|
|
23
|
+
useRef,
|
|
24
|
+
useState,
|
|
25
|
+
} from "react"
|
|
26
|
+
import { createPortal } from "react-dom"
|
|
27
|
+
import { ArtifactReferencesProvider } from "../artifacts/references/references"
|
|
28
|
+
import {
|
|
29
|
+
type ArtifactTarget,
|
|
30
|
+
artifactTargetHref,
|
|
31
|
+
type ViewerTarget,
|
|
32
|
+
viewerTargetKey,
|
|
33
|
+
} from "../artifacts/target"
|
|
34
|
+
import { Viewer } from "../artifacts/viewer"
|
|
35
|
+
import {
|
|
36
|
+
type ArtifactPanelPresentation,
|
|
37
|
+
artifactPanelPresentation,
|
|
38
|
+
readArtifactPanelWidth,
|
|
39
|
+
writeArtifactPanelWidth,
|
|
40
|
+
} from "./artifact-panel-state"
|
|
41
|
+
import { useAgentMessages } from "./i18n"
|
|
42
|
+
|
|
43
|
+
export interface ArtifactPanelValue {
|
|
44
|
+
/** What is open, or null when nothing is. */
|
|
45
|
+
readonly openTarget: ViewerTarget | null
|
|
46
|
+
/** The open target's identity, or null when nothing is open. */
|
|
47
|
+
readonly openKey: string | null
|
|
48
|
+
readonly open: (target: ViewerTarget) => void
|
|
49
|
+
readonly close: () => void
|
|
50
|
+
/** Where the panel opens: beside the conversation, over the app, or as a dialog. */
|
|
51
|
+
readonly presentation: ArtifactPanelPresentation
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface PanelHandle {
|
|
55
|
+
collapse(): void
|
|
56
|
+
expand(): void
|
|
57
|
+
getSize(): { readonly asPercentage: number; readonly inPixels: number }
|
|
58
|
+
isCollapsed(): boolean
|
|
59
|
+
resize(size: number | string): void
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const ArtifactPanelContext = createContext<ArtifactPanelValue | null>(null)
|
|
63
|
+
|
|
64
|
+
/** The artifact panel of the conversation around it, when there is one. */
|
|
65
|
+
export function useArtifactPanel(): ArtifactPanelValue | null {
|
|
66
|
+
return useContext(ArtifactPanelContext)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Shows one artifact or file beside the conversation. With `onRouteTargetChange`, an open artifact
|
|
71
|
+
* lives in the page's URL so reloads and shared links land on it; a file stays local, since a
|
|
72
|
+
* message file has no address of its own.
|
|
73
|
+
*/
|
|
74
|
+
export function ArtifactPanelRoot({
|
|
75
|
+
children,
|
|
76
|
+
compact = false,
|
|
77
|
+
split = false,
|
|
78
|
+
overlayHost,
|
|
79
|
+
scopeKey,
|
|
80
|
+
routeTarget = null,
|
|
81
|
+
onRouteTargetChange,
|
|
82
|
+
}: {
|
|
83
|
+
readonly children: ReactNode
|
|
84
|
+
readonly compact?: boolean
|
|
85
|
+
/** Use the resizable panel beside the conversation even when compact. */
|
|
86
|
+
readonly split?: boolean
|
|
87
|
+
/** Where the dock's canvas goes, beside it over the app. */
|
|
88
|
+
readonly overlayHost?: HTMLElement | null
|
|
89
|
+
/** The conversation; a different one starts with nothing open. */
|
|
90
|
+
readonly scopeKey: string
|
|
91
|
+
readonly routeTarget?: ArtifactTarget | null
|
|
92
|
+
readonly onRouteTargetChange?: (target: ArtifactTarget | null) => void
|
|
93
|
+
}) {
|
|
94
|
+
const messages = useAgentMessages().artifacts
|
|
95
|
+
const idPrefix = useId()
|
|
96
|
+
const [localTarget, setLocalTarget] = useState<ViewerTarget | null>(null)
|
|
97
|
+
const target: ViewerTarget | null = routeTarget ?? localTarget
|
|
98
|
+
// What the reader followed a reference from, so the panel can take them back.
|
|
99
|
+
const [trail, setTrail] = useState<readonly ViewerTarget[]>([])
|
|
100
|
+
const presentation = artifactPanelPresentation({
|
|
101
|
+
compact,
|
|
102
|
+
isMobile: useIsMobile(),
|
|
103
|
+
hasCanvas: Boolean(overlayHost),
|
|
104
|
+
split,
|
|
105
|
+
})
|
|
106
|
+
const [revealCount, reveal] = useReducer((count: number) => count + 1, 0)
|
|
107
|
+
const openerRef = useRef<HTMLElement | null>(null)
|
|
108
|
+
const scopeRef = useRef(scopeKey)
|
|
109
|
+
|
|
110
|
+
useLayoutEffect(() => {
|
|
111
|
+
if (scopeRef.current === scopeKey) return
|
|
112
|
+
scopeRef.current = scopeKey
|
|
113
|
+
setLocalTarget(null)
|
|
114
|
+
setTrail([])
|
|
115
|
+
openerRef.current = null
|
|
116
|
+
}, [scopeKey])
|
|
117
|
+
|
|
118
|
+
const show = useCallback(
|
|
119
|
+
(next: ViewerTarget) => {
|
|
120
|
+
if (onRouteTargetChange && next.type === "artifact") {
|
|
121
|
+
setLocalTarget(null)
|
|
122
|
+
onRouteTargetChange(next)
|
|
123
|
+
} else {
|
|
124
|
+
setLocalTarget(next)
|
|
125
|
+
if (onRouteTargetChange && routeTarget) onRouteTargetChange(null)
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
[onRouteTargetChange, routeTarget]
|
|
129
|
+
)
|
|
130
|
+
const open = useCallback(
|
|
131
|
+
(next: ViewerTarget) => {
|
|
132
|
+
const active = typeof document === "undefined" ? null : document.activeElement
|
|
133
|
+
openerRef.current = active instanceof HTMLElement ? active : null
|
|
134
|
+
setTrail([])
|
|
135
|
+
show(next)
|
|
136
|
+
reveal()
|
|
137
|
+
},
|
|
138
|
+
[show]
|
|
139
|
+
)
|
|
140
|
+
const close = useCallback(() => {
|
|
141
|
+
setLocalTarget(null)
|
|
142
|
+
setTrail([])
|
|
143
|
+
if (onRouteTargetChange && routeTarget) onRouteTargetChange(null)
|
|
144
|
+
const opener = openerRef.current
|
|
145
|
+
openerRef.current = null
|
|
146
|
+
if (opener?.isConnected) queueMicrotask(() => opener.focus())
|
|
147
|
+
}, [onRouteTargetChange, routeTarget])
|
|
148
|
+
|
|
149
|
+
const value = useMemo<ArtifactPanelValue>(
|
|
150
|
+
() => ({
|
|
151
|
+
openTarget: target,
|
|
152
|
+
openKey: target ? viewerTargetKey(target) : null,
|
|
153
|
+
open,
|
|
154
|
+
close,
|
|
155
|
+
presentation,
|
|
156
|
+
}),
|
|
157
|
+
[target, open, close, presentation]
|
|
158
|
+
)
|
|
159
|
+
const viewer = target ? (
|
|
160
|
+
<Viewer
|
|
161
|
+
target={target}
|
|
162
|
+
onTargetChange={show}
|
|
163
|
+
onOpenReference={(next) => {
|
|
164
|
+
setTrail((current) => [...current, target])
|
|
165
|
+
show(next)
|
|
166
|
+
}}
|
|
167
|
+
chrome={{
|
|
168
|
+
onClose: close,
|
|
169
|
+
...(trail.length > 0
|
|
170
|
+
? {
|
|
171
|
+
onBack: () => {
|
|
172
|
+
const previous = trail.at(-1)
|
|
173
|
+
setTrail((current) => current.slice(0, -1))
|
|
174
|
+
if (previous) show(previous)
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
: {}),
|
|
178
|
+
...(target.type === "artifact" ? { fullPageHref: artifactTargetHref(target) } : {}),
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
) : null
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<ArtifactPanelContext.Provider value={value}>
|
|
185
|
+
{/* A stable parent keeps composer drafts and scroll position across dock and page. */}
|
|
186
|
+
<ArtifactWorkspace
|
|
187
|
+
idPrefix={idPrefix}
|
|
188
|
+
revealKey={
|
|
189
|
+
presentation === "panel" && target ? `${viewerTargetKey(target)}:${revealCount}` : null
|
|
190
|
+
}
|
|
191
|
+
viewer={presentation === "panel" ? viewer : null}
|
|
192
|
+
>
|
|
193
|
+
{/* An artifact a reply shows or links to opens here, beside the conversation. */}
|
|
194
|
+
<ArtifactReferencesProvider open={open}>{children}</ArtifactReferencesProvider>
|
|
195
|
+
</ArtifactWorkspace>
|
|
196
|
+
<Dialog
|
|
197
|
+
open={presentation === "dialog" && target !== null}
|
|
198
|
+
onOpenChange={(nextOpen) => {
|
|
199
|
+
if (!nextOpen) close()
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<DialogContent
|
|
203
|
+
showCloseButton={false}
|
|
204
|
+
onEscapeKeyDown={leaveEscapeToDeck}
|
|
205
|
+
className="flex h-[calc(100dvh-1rem)] max-h-none w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl p-0 sm:h-[min(88vh,56rem)] sm:w-[min(92vw,72rem)] sm:max-w-[min(92vw,72rem)]"
|
|
206
|
+
>
|
|
207
|
+
<DialogTitle className="sr-only">{messages.dialogTitle}</DialogTitle>
|
|
208
|
+
<DialogDescription className="sr-only">{messages.dialogDescription}</DialogDescription>
|
|
209
|
+
{presentation === "dialog" ? viewer : null}
|
|
210
|
+
</DialogContent>
|
|
211
|
+
</Dialog>
|
|
212
|
+
{presentation === "canvas" && overlayHost && viewer
|
|
213
|
+
? createPortal(
|
|
214
|
+
<section
|
|
215
|
+
role="dialog"
|
|
216
|
+
aria-modal="false"
|
|
217
|
+
aria-label={messages.dialogTitle}
|
|
218
|
+
aria-describedby={`${idPrefix}-canvas-description`}
|
|
219
|
+
className="pointer-events-auto flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden rounded-xl border border-border bg-background shadow-2xl motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-right-2 motion-safe:duration-200"
|
|
220
|
+
>
|
|
221
|
+
<p id={`${idPrefix}-canvas-description`} className="sr-only">
|
|
222
|
+
{messages.canvasDescription}
|
|
223
|
+
</p>
|
|
224
|
+
{viewer}
|
|
225
|
+
</section>,
|
|
226
|
+
overlayHost
|
|
227
|
+
)
|
|
228
|
+
: null}
|
|
229
|
+
</ArtifactPanelContext.Provider>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Escape in a deck's overview or presentation takes the deck back to its slide; only then does it
|
|
235
|
+
* close the dialog. The dialog hears Escape first, on the document, before the deck does.
|
|
236
|
+
*/
|
|
237
|
+
export function leaveEscapeToDeck(event: KeyboardEvent): void {
|
|
238
|
+
const target = event.target instanceof Element ? event.target : null
|
|
239
|
+
if (target?.closest('[data-deck-mode]:not([data-deck-mode="slide"])')) event.preventDefault()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Keep the conversation wrapper stable while the panel opens, closes, or changes target.
|
|
243
|
+
const ConversationPane = memo(function ConversationPane({ children }: { children: ReactNode }) {
|
|
244
|
+
return <div className="h-full min-h-0 min-w-0">{children}</div>
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
function ArtifactWorkspace({
|
|
248
|
+
idPrefix,
|
|
249
|
+
revealKey,
|
|
250
|
+
viewer,
|
|
251
|
+
children,
|
|
252
|
+
}: {
|
|
253
|
+
readonly idPrefix: string
|
|
254
|
+
/** Changes whenever the panel should show itself: a new target, or the same one asked again. */
|
|
255
|
+
readonly revealKey: string | null
|
|
256
|
+
readonly viewer: ReactNode
|
|
257
|
+
readonly children: ReactNode
|
|
258
|
+
}) {
|
|
259
|
+
const open = revealKey !== null
|
|
260
|
+
const panelRef = useRef<PanelHandle | null>(null)
|
|
261
|
+
const sizedRef = useRef(false)
|
|
262
|
+
|
|
263
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: each new reveal key reruns this.
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
const panel = panelRef.current
|
|
266
|
+
if (!panel) return
|
|
267
|
+
if (!open) {
|
|
268
|
+
panel.collapse()
|
|
269
|
+
sizedRef.current = false
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
if (!sizedRef.current) {
|
|
273
|
+
sizedRef.current = true
|
|
274
|
+
panel.resize(readArtifactPanelWidth() ?? "50%")
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
// Asking for a target again brings back a panel the reader collapsed by dragging the handle.
|
|
278
|
+
if (panel.isCollapsed()) panel.expand()
|
|
279
|
+
}, [open, revealKey])
|
|
280
|
+
|
|
281
|
+
const rememberWidth = useCallback(() => {
|
|
282
|
+
const size = panelRef.current?.getSize()
|
|
283
|
+
if (open && size && size.inPixels > 0) writeArtifactPanelWidth(size.inPixels)
|
|
284
|
+
}, [open])
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<ResizablePanelGroup
|
|
288
|
+
id={`${idPrefix}-workspace`}
|
|
289
|
+
orientation="horizontal"
|
|
290
|
+
onLayoutChanged={rememberWidth}
|
|
291
|
+
className="min-h-0"
|
|
292
|
+
>
|
|
293
|
+
<ResizablePanel id={`${idPrefix}-conversation`} defaultSize="100%" minSize="30%">
|
|
294
|
+
<ConversationPane>{children}</ConversationPane>
|
|
295
|
+
</ResizablePanel>
|
|
296
|
+
<ResizableHandle
|
|
297
|
+
className={cn(
|
|
298
|
+
"bg-transparent transition-opacity before:pointer-events-none before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border/70 before:transition-[width,background-color] before:duration-150 hover:before:w-0.5 hover:before:bg-foreground/25 focus-visible:before:w-0.5 focus-visible:before:bg-ring active:before:w-[3px] active:before:bg-foreground/35",
|
|
299
|
+
!open && "pointer-events-none invisible opacity-0"
|
|
300
|
+
)}
|
|
301
|
+
/>
|
|
302
|
+
<ResizablePanel
|
|
303
|
+
id={`${idPrefix}-artifact`}
|
|
304
|
+
defaultSize="0%"
|
|
305
|
+
minSize="20rem"
|
|
306
|
+
maxSize="70%"
|
|
307
|
+
groupResizeBehavior="preserve-pixel-size"
|
|
308
|
+
collapsedSize="0%"
|
|
309
|
+
collapsible
|
|
310
|
+
panelRef={(panel) => {
|
|
311
|
+
panelRef.current = panel
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
<div className="flex h-full min-h-0 min-w-0 flex-col bg-background">
|
|
315
|
+
{open ? viewer : null}
|
|
316
|
+
</div>
|
|
317
|
+
</ResizablePanel>
|
|
318
|
+
</ResizablePanelGroup>
|
|
319
|
+
)
|
|
320
|
+
}
|
|
@@ -9,28 +9,29 @@ import {
|
|
|
9
9
|
import { useLocale } from "@sixb/ui/lib/i18n"
|
|
10
10
|
import { cn } from "@sixb/ui/lib/utils"
|
|
11
11
|
import { File as FileIcon, FileImage, FileText, Table2, X } from "lucide-react"
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
12
|
+
import { formatFileSize } from "../../artifacts/file-size"
|
|
13
|
+
import type { FileSource } from "../../artifacts/file-source"
|
|
14
|
+
import { viewerTargetKey } from "../../artifacts/target"
|
|
15
|
+
import { useArtifactPanel } from "../artifact-panel"
|
|
15
16
|
import { useAgentMessages } from "../i18n"
|
|
16
17
|
import type { AgentMessages } from "../i18n/en"
|
|
17
18
|
import type { AgentFileRef } from "../types"
|
|
18
19
|
|
|
19
20
|
export function FileAttachmentCard({
|
|
20
21
|
fileRef,
|
|
21
|
-
|
|
22
|
+
source,
|
|
22
23
|
className,
|
|
23
24
|
}: {
|
|
24
25
|
readonly fileRef: AgentFileRef
|
|
25
|
-
readonly
|
|
26
|
+
readonly source?: FileSource
|
|
26
27
|
readonly className?: string
|
|
27
28
|
}) {
|
|
28
|
-
const
|
|
29
|
+
const panel = useArtifactPanel()
|
|
29
30
|
const messages = useAgentMessages().files
|
|
30
31
|
const locale = useLocale()
|
|
31
32
|
const fileName = fileRef.fileName?.trim() || messages.file
|
|
32
|
-
const
|
|
33
|
-
const selected = Boolean(
|
|
33
|
+
const target = source ? ({ type: "file", source } as const) : null
|
|
34
|
+
const selected = Boolean(target && panel?.openKey === viewerTargetKey(target))
|
|
34
35
|
const mediaLabel = fileMediaLabel(fileRef.mediaType, fileName, messages)
|
|
35
36
|
const { Icon, className: iconClassName } = fileIconPresentation(fileRef.mediaType, fileName)
|
|
36
37
|
|
|
@@ -46,21 +47,19 @@ export function FileAttachmentCard({
|
|
|
46
47
|
className
|
|
47
48
|
)}
|
|
48
49
|
>
|
|
49
|
-
{
|
|
50
|
+
{target && panel ? (
|
|
50
51
|
<AttachmentTrigger asChild>
|
|
51
52
|
<button
|
|
52
53
|
type="button"
|
|
53
|
-
onClick={() =>
|
|
54
|
-
selected ? preview.closeDocument(document.id) : preview.openDocument(document)
|
|
55
|
-
}
|
|
54
|
+
onClick={() => (selected ? panel.close() : panel.open(target))}
|
|
56
55
|
aria-label={selected ? messages.closePreview(fileName) : messages.preview(fileName)}
|
|
57
56
|
aria-pressed={selected}
|
|
58
57
|
/>
|
|
59
58
|
</AttachmentTrigger>
|
|
60
|
-
) :
|
|
59
|
+
) : source ? (
|
|
61
60
|
<AttachmentTrigger asChild>
|
|
62
61
|
<a
|
|
63
|
-
href={
|
|
62
|
+
href={source.inlineUrl}
|
|
64
63
|
target="_blank"
|
|
65
64
|
rel="noreferrer"
|
|
66
65
|
aria-label={messages.open(fileName)}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Collapsible, CollapsibleContent, CollapsibleTrigger
|
|
1
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
|
|
2
2
|
import { cn } from "@sixb/ui/lib/utils"
|
|
3
|
-
import { ChevronRight, Wrench } from "lucide-react"
|
|
3
|
+
import { ChevronRight, FileX, Wrench } from "lucide-react"
|
|
4
4
|
import { memo, useState } from "react"
|
|
5
|
+
import { ReferencingMarkdown } from "../../artifacts/references/references"
|
|
5
6
|
import { latestWorkLabel } from "../activity-label"
|
|
7
|
+
import { ArtifactCards } from "../artifact-card"
|
|
6
8
|
import { BashToolView } from "../bash/bash-tool-view"
|
|
7
9
|
import { useAgentMessages } from "../i18n"
|
|
8
10
|
import type { NormalizedPart, NormalizedTool } from "../parts"
|
|
11
|
+
import { isPublishTool, turnArtifacts, unpublishedTitles } from "../publish-artifact/interpret"
|
|
12
|
+
import { PublishArtifactToolView } from "../publish-artifact/publish-artifact-tool-view"
|
|
9
13
|
import { ReadToolView } from "../read/read-tool-view"
|
|
10
14
|
import { coerceWebFetchOutput } from "../utils/web-fetch"
|
|
11
15
|
import { coerceWebSearchOutput, collectWebSources } from "../utils/web-search"
|
|
@@ -20,7 +24,8 @@ import { WebSources } from "./web-sources"
|
|
|
20
24
|
* Render an assistant body from normalized parts. Narration text stays on the main reading path;
|
|
21
25
|
* every run of consecutive reasoning + tool parts collapses into a single "work" disclosure, so a
|
|
22
26
|
* long chain of thinking and tool calls reads as one quiet line above the answer instead of a stack
|
|
23
|
-
* of separate dropdowns.
|
|
27
|
+
* of separate dropdowns. What the turn published closes the body as one row of cards, while each
|
|
28
|
+
* publish keeps its row in the work. `step-start` markers are intentionally skipped.
|
|
24
29
|
*/
|
|
25
30
|
export function AssistantBody({
|
|
26
31
|
parts,
|
|
@@ -74,12 +79,31 @@ export function AssistantBody({
|
|
|
74
79
|
flushText()
|
|
75
80
|
// The final work run is the only one that can still be receiving steps.
|
|
76
81
|
flushWork(live)
|
|
82
|
+
const artifacts = turnArtifacts(parts)
|
|
83
|
+
if (artifacts.length > 0) blocks.push(<ArtifactCards key="artifacts" artifacts={artifacts} />)
|
|
84
|
+
// Said where the card would be, whatever the answer claims. A live turn may still retry.
|
|
85
|
+
if (!live) {
|
|
86
|
+
for (const title of unpublishedTitles(parts)) {
|
|
87
|
+
blocks.push(<NotPublished key={`unpublished:${title}`} title={title} />)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
77
90
|
|
|
78
91
|
return <div className="flex flex-col gap-3">{blocks}</div>
|
|
79
92
|
}
|
|
80
93
|
|
|
94
|
+
function NotPublished({ title }: { title: string }) {
|
|
95
|
+
const messages = useAgentMessages().artifacts
|
|
96
|
+
return (
|
|
97
|
+
<p className="flex items-center gap-1.5 text-[13px] text-muted-foreground" role="status">
|
|
98
|
+
<FileX className="size-3.5 shrink-0" aria-hidden="true" />
|
|
99
|
+
{messages.publishFailed(title)}
|
|
100
|
+
</p>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// A reply can show or link to an artifact; the panel around the conversation says where it opens.
|
|
81
105
|
const TextBlock = memo(function TextBlock({ text }: { text: string }) {
|
|
82
|
-
return <
|
|
106
|
+
return <ReferencingMarkdown className="prose-chat">{text}</ReferencingMarkdown>
|
|
83
107
|
})
|
|
84
108
|
|
|
85
109
|
const FileBlock = memo(function FileBlock({
|
|
@@ -87,7 +111,7 @@ const FileBlock = memo(function FileBlock({
|
|
|
87
111
|
}: {
|
|
88
112
|
part: Extract<NormalizedPart, { kind: "file" }>
|
|
89
113
|
}) {
|
|
90
|
-
return <FileAttachmentCard fileRef={part.fileRef}
|
|
114
|
+
return <FileAttachmentCard fileRef={part.fileRef} source={part.source} />
|
|
91
115
|
})
|
|
92
116
|
|
|
93
117
|
/**
|
|
@@ -196,6 +220,7 @@ function ToolCallRow({ tool }: { tool: NormalizedTool }) {
|
|
|
196
220
|
}
|
|
197
221
|
if (tool.toolName === "read") return <ReadToolView tool={tool} />
|
|
198
222
|
if (tool.toolName === "view_file") return <ViewFileToolView tool={tool} />
|
|
223
|
+
if (isPublishTool(tool.toolName)) return <PublishArtifactToolView tool={tool} />
|
|
199
224
|
if (
|
|
200
225
|
tool.toolName === "web_fetch" &&
|
|
201
226
|
(tool.state !== "output-available" || coerceWebFetchOutput(tool.output) !== null)
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
} from "@sixb/ui/components"
|
|
12
12
|
import { AlertTriangle, ArrowRight, ChevronRight, Clock3, RotateCcw, Unplug } from "lucide-react"
|
|
13
13
|
import { memo } from "react"
|
|
14
|
-
import {
|
|
15
|
-
import type { AgentDocumentSource } from "../document-preview/types"
|
|
14
|
+
import { type FileSource, messageFileSource } from "../../artifacts/file-source"
|
|
16
15
|
import { useAgentMessages } from "../i18n"
|
|
17
16
|
import type { AgentMessages } from "../i18n/en"
|
|
18
17
|
import { isAwaitingFirstToken, type LiveRunState } from "../live-run"
|
|
19
18
|
import { normalizeDurableParts } from "../parts"
|
|
19
|
+
import { useLivePublishes } from "../publish-artifact/use-live-publishes"
|
|
20
20
|
import type {
|
|
21
21
|
AgentContextEntryInput,
|
|
22
22
|
AgentContextInput,
|
|
@@ -49,11 +49,7 @@ function UserMessage({ message }: { message: AgentMessage }) {
|
|
|
49
49
|
<UserFileAttachment
|
|
50
50
|
key={index}
|
|
51
51
|
fileRef={part.fileRef}
|
|
52
|
-
|
|
53
|
-
message,
|
|
54
|
-
part.fileRef,
|
|
55
|
-
`/parts/${index}/fileRef`
|
|
56
|
-
)}
|
|
52
|
+
source={agentMessageFileSource(message, part.fileRef, `/parts/${index}/fileRef`)}
|
|
57
53
|
/>
|
|
58
54
|
))}
|
|
59
55
|
</div>
|
|
@@ -74,12 +70,12 @@ function AssistantMessage({ message }: { message: AgentMessage }) {
|
|
|
74
70
|
{message.compaction ? <CompactionResult summary={message.compaction.summary} /> : null}
|
|
75
71
|
<AssistantBody
|
|
76
72
|
parts={normalizeDurableParts(message.parts, {
|
|
77
|
-
fileSource: (fileRef, path) =>
|
|
73
|
+
fileSource: (fileRef, path) => agentMessageFileSource(message, fileRef, path),
|
|
78
74
|
})}
|
|
79
75
|
/>
|
|
80
76
|
{message.annotations.map((annotation, index) => (
|
|
81
77
|
<Marker
|
|
82
|
-
key={`${annotation.code}:${
|
|
78
|
+
key={`${annotation.code}:${index}`}
|
|
83
79
|
className={
|
|
84
80
|
annotation.severity === "error"
|
|
85
81
|
? "text-destructive"
|
|
@@ -96,10 +92,7 @@ function AssistantMessage({ message }: { message: AgentMessage }) {
|
|
|
96
92
|
}
|
|
97
93
|
/>
|
|
98
94
|
</MarkerIcon>
|
|
99
|
-
<MarkerContent>
|
|
100
|
-
{annotation.path ? `${annotation.path}: ` : ""}
|
|
101
|
-
{diagnosticMessage(annotation.code, messages.diagnostics)}
|
|
102
|
-
</MarkerContent>
|
|
95
|
+
<MarkerContent>{diagnosticMessage(annotation.code, messages.diagnostics)}</MarkerContent>
|
|
103
96
|
</Marker>
|
|
104
97
|
))}
|
|
105
98
|
</div>
|
|
@@ -146,6 +139,7 @@ export function LiveAssistant({
|
|
|
146
139
|
continuing?: boolean
|
|
147
140
|
}) {
|
|
148
141
|
const messages = useAgentMessages().transcript
|
|
142
|
+
useLivePublishes(live)
|
|
149
143
|
if (live.compacting && live.parts.length === 0) {
|
|
150
144
|
return <CompactionMarker />
|
|
151
145
|
}
|
|
@@ -350,12 +344,12 @@ export function ReconnectingMarker() {
|
|
|
350
344
|
|
|
351
345
|
export function UserFileAttachment({
|
|
352
346
|
fileRef,
|
|
353
|
-
|
|
347
|
+
source,
|
|
354
348
|
}: {
|
|
355
349
|
fileRef: AgentFileRef
|
|
356
|
-
|
|
350
|
+
source?: FileSource
|
|
357
351
|
}) {
|
|
358
|
-
return <FileAttachmentCard fileRef={fileRef}
|
|
352
|
+
return <FileAttachmentCard fileRef={fileRef} source={source} />
|
|
359
353
|
}
|
|
360
354
|
|
|
361
355
|
export function RunErrorMarker({ message }: { message: string }) {
|
|
@@ -414,12 +408,12 @@ function contextPartsOf(message: AgentMessage): AgentContextEntryInput[] {
|
|
|
414
408
|
)
|
|
415
409
|
}
|
|
416
410
|
|
|
417
|
-
function
|
|
411
|
+
function agentMessageFileSource(
|
|
418
412
|
message: AgentMessage,
|
|
419
413
|
fileRef: AgentFileRef,
|
|
420
414
|
path: string
|
|
421
|
-
):
|
|
422
|
-
return
|
|
415
|
+
): FileSource {
|
|
416
|
+
return messageFileSource({
|
|
423
417
|
threadId: message.threadId,
|
|
424
418
|
messageId: message.id,
|
|
425
419
|
path,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { listArtifactsOptions } from "@sixb/client/hooks"
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuLabel,
|
|
8
|
+
DropdownMenuSeparator,
|
|
9
|
+
DropdownMenuTrigger,
|
|
10
|
+
} from "@sixb/ui/components"
|
|
11
|
+
import { useQuery } from "@tanstack/react-query"
|
|
12
|
+
import { ArrowUpRight, Layers } from "lucide-react"
|
|
13
|
+
import { Link } from "react-router-dom"
|
|
14
|
+
import { ArtifactKindIcon } from "../../artifacts/kind-icon"
|
|
15
|
+
import { useArtifactMessages } from "../../artifacts/messages"
|
|
16
|
+
import { ARTIFACTS_HREF } from "../../pages/routes"
|
|
17
|
+
import { useArtifactPanel } from "../artifact-panel"
|
|
18
|
+
import { useAgentMessages } from "../i18n"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The artifacts the Agent published in this conversation, each one opening in the panel, and the
|
|
22
|
+
* way to every artifact in the gallery.
|
|
23
|
+
*/
|
|
24
|
+
export function ThreadArtifactsMenu({ threadId }: { readonly threadId: string }) {
|
|
25
|
+
const panel = useArtifactPanel()
|
|
26
|
+
const messages = useAgentMessages().artifacts
|
|
27
|
+
const artifactMessages = useArtifactMessages()
|
|
28
|
+
const { data } = useQuery({
|
|
29
|
+
...listArtifactsOptions({ query: { thread: threadId } }),
|
|
30
|
+
retry: false,
|
|
31
|
+
})
|
|
32
|
+
const artifacts = data?.artifacts ?? []
|
|
33
|
+
if (!panel || artifacts.length === 0) return null
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<DropdownMenu>
|
|
37
|
+
<DropdownMenuTrigger asChild>
|
|
38
|
+
<Button
|
|
39
|
+
type="button"
|
|
40
|
+
variant="ghost"
|
|
41
|
+
size="sm"
|
|
42
|
+
aria-label={messages.list(artifacts.length)}
|
|
43
|
+
title={messages.list(artifacts.length)}
|
|
44
|
+
className="gap-1.5 text-muted-foreground"
|
|
45
|
+
>
|
|
46
|
+
<Layers />
|
|
47
|
+
<span className="tabular-nums">{artifacts.length}</span>
|
|
48
|
+
</Button>
|
|
49
|
+
</DropdownMenuTrigger>
|
|
50
|
+
<DropdownMenuContent align="end" className="w-72">
|
|
51
|
+
<DropdownMenuLabel>{messages.list(artifacts.length)}</DropdownMenuLabel>
|
|
52
|
+
{artifacts.map((artifact) => (
|
|
53
|
+
<DropdownMenuItem
|
|
54
|
+
key={artifact.id}
|
|
55
|
+
onSelect={() => panel.open({ type: "artifact", artifactId: artifact.id })}
|
|
56
|
+
className="gap-2.5"
|
|
57
|
+
>
|
|
58
|
+
<ArtifactKindIcon kind={artifact.kind} className="size-4 text-muted-foreground" />
|
|
59
|
+
<span className="min-w-0 flex-1 truncate">{artifact.title}</span>
|
|
60
|
+
<span className="shrink-0 text-xs text-muted-foreground tabular-nums">
|
|
61
|
+
{artifactMessages.kinds[artifact.kind]} ·{" "}
|
|
62
|
+
{artifactMessages.viewer.version(artifact.latestVersion)}
|
|
63
|
+
</span>
|
|
64
|
+
</DropdownMenuItem>
|
|
65
|
+
))}
|
|
66
|
+
<DropdownMenuSeparator />
|
|
67
|
+
<DropdownMenuItem asChild className="gap-2.5 text-muted-foreground">
|
|
68
|
+
<Link to={ARTIFACTS_HREF}>
|
|
69
|
+
<Layers className="size-4" />
|
|
70
|
+
<span className="flex-1">{messages.all}</span>
|
|
71
|
+
<ArrowUpRight className="size-3.5" />
|
|
72
|
+
</Link>
|
|
73
|
+
</DropdownMenuItem>
|
|
74
|
+
</DropdownMenuContent>
|
|
75
|
+
</DropdownMenu>
|
|
76
|
+
)
|
|
77
|
+
}
|