@opengeni/react 7.4.0 → 7.5.0-canary.36927100590001
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 +124 -27
- package/dist/artifacts-document.js +3 -2
- package/dist/artifacts-presentation.js +3 -2
- package/dist/artifacts-spreadsheet.js +2 -2
- package/dist/artifacts.d.ts +1 -0
- package/dist/artifacts.js +516 -1413
- package/dist/artifacts.js.map +1 -1
- package/dist/{browser-viewer-2E6R2Y4W.js → browser-viewer-Z7S7QEJL.js} +6 -5
- package/dist/chat-interactive-block-UGBTNB3L.js +11 -0
- package/dist/{chunk-Y3QTZN2F.js → chunk-2VFNCX4E.js} +6 -6
- package/dist/{chunk-UDD6DLLT.js → chunk-3IJJEYW4.js} +15 -3
- package/dist/chunk-3IJJEYW4.js.map +1 -0
- package/dist/chunk-4RVYOY4O.js +379 -0
- package/dist/chunk-4RVYOY4O.js.map +1 -0
- package/dist/chunk-5CVXZA3Y.js +292 -0
- package/dist/chunk-5CVXZA3Y.js.map +1 -0
- package/dist/{chunk-5YK2ZDIG.js → chunk-5J4FOW6Q.js} +2 -10
- package/dist/chunk-5J4FOW6Q.js.map +1 -0
- package/dist/{chunk-KVERXCFY.js → chunk-5KYZIQFY.js} +40 -3
- package/dist/chunk-5KYZIQFY.js.map +1 -0
- package/dist/{chunk-KNDIXZN6.js → chunk-7UAMYXJY.js} +25 -18
- package/dist/{chunk-KNDIXZN6.js.map → chunk-7UAMYXJY.js.map} +1 -1
- package/dist/{chunk-SEEVCT36.js → chunk-A4UJB2MM.js} +2 -2
- package/dist/{chunk-X4HIN6TV.js → chunk-AFLPWUQ7.js} +71 -162
- package/dist/chunk-AFLPWUQ7.js.map +1 -0
- package/dist/chunk-B3V6TG77.js +41 -0
- package/dist/chunk-B3V6TG77.js.map +1 -0
- package/dist/{chunk-XEJEOAOV.js → chunk-B7WMS3CS.js} +51 -40
- package/dist/chunk-B7WMS3CS.js.map +1 -0
- package/dist/{chunk-S5JQ4R22.js → chunk-BDKR6BAR.js} +54 -24
- package/dist/chunk-BDKR6BAR.js.map +1 -0
- package/dist/{chunk-4MDLEHXL.js → chunk-DYWBUX5Q.js} +24 -12
- package/dist/chunk-DYWBUX5Q.js.map +1 -0
- package/dist/{chunk-YZ3YYMOM.js → chunk-E3G7SAYZ.js} +252 -624
- package/dist/chunk-E3G7SAYZ.js.map +1 -0
- package/dist/chunk-JT4JW7BC.js +54 -0
- package/dist/chunk-JT4JW7BC.js.map +1 -0
- package/dist/{chunk-5AZSK6MV.js → chunk-LWNLETQT.js} +5 -5
- package/dist/{chunk-USXVQACU.js → chunk-M7LBYP63.js} +5 -4
- package/dist/{chunk-USXVQACU.js.map → chunk-M7LBYP63.js.map} +1 -1
- package/dist/{chunk-L4OSXQ6H.js → chunk-NBOHNRLJ.js} +1289 -1060
- package/dist/chunk-NBOHNRLJ.js.map +1 -0
- package/dist/chunk-RHREZ7BO.js +11 -0
- package/dist/chunk-RHREZ7BO.js.map +1 -0
- package/dist/chunk-SCOTPE2I.js +589 -0
- package/dist/chunk-SCOTPE2I.js.map +1 -0
- package/dist/chunk-WEHMPOXK.js +39 -0
- package/dist/chunk-WEHMPOXK.js.map +1 -0
- package/dist/chunk-WRHIZYZF.js +988 -0
- package/dist/chunk-WRHIZYZF.js.map +1 -0
- package/dist/{chunk-3E2AITTZ.js → chunk-WUISZ3WU.js} +32 -28
- package/dist/{chunk-3E2AITTZ.js.map → chunk-WUISZ3WU.js.map} +1 -1
- package/dist/chunk-XCHWDJ22.js +107 -0
- package/dist/chunk-XCHWDJ22.js.map +1 -0
- package/dist/{chunk-DUEBTL3N.js → chunk-Y2PRMYLC.js} +4 -3
- package/dist/{chunk-DUEBTL3N.js.map → chunk-Y2PRMYLC.js.map} +1 -1
- package/dist/chunk-YBXQDQFX.js +1772 -0
- package/dist/chunk-YBXQDQFX.js.map +1 -0
- package/dist/chunk-YV4L3ILF.js +9 -0
- package/dist/chunk-YV4L3ILF.js.map +1 -0
- package/dist/{chunk-V2ABIVYJ.js → chunk-ZXSEDZP7.js} +70 -6
- package/dist/chunk-ZXSEDZP7.js.map +1 -0
- package/dist/components/artifacts/artifact-chrome.d.ts +120 -0
- package/dist/components/artifacts/artifact-sandbox.d.ts +27 -0
- package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
- package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
- package/dist/components/artifacts/editable-artifact-ui.d.ts +2 -1
- package/dist/components/artifacts/editable-artifact-view.d.ts +46 -0
- package/dist/components/artifacts/index.d.ts +7 -0
- package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
- package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
- package/dist/components/artifacts/site-view.d.ts +23 -0
- package/dist/components/browser-select-control.d.ts +3 -1
- package/dist/components/code-editor.d.ts +1 -4
- package/dist/components/desktop-viewer.d.ts +1 -1
- package/dist/components/message-timeline.d.ts +20 -3
- package/dist/components/open-geni-links.d.ts +16 -0
- package/dist/components/session-conversation.d.ts +20 -1
- package/dist/components/timeline-pill-geometry.d.ts +8 -0
- package/dist/components/timeline-pill-placement.d.ts +24 -0
- package/dist/components/usage-limit-notice.d.ts +49 -0
- package/dist/components/usage-member-list.d.ts +91 -0
- package/dist/components/usage-meter.d.ts +73 -0
- package/dist/composer.js +5 -5
- package/dist/{computer-viewer-WMJE6OA3.js → computer-viewer-KJWLH3GI.js} +7 -5
- package/dist/connect.js +7 -6
- package/dist/connect.js.map +1 -1
- package/dist/conversation-timeline.d.ts +1 -1
- package/dist/desktop.d.ts +7 -0
- package/dist/desktop.js +26 -0
- package/dist/desktop.js.map +1 -0
- package/dist/editor.d.ts +7 -0
- package/dist/editor.js +21 -0
- package/dist/editor.js.map +1 -0
- package/dist/hooks/latest-question.d.ts +1 -1
- package/dist/hooks/use-composer.d.ts +4 -0
- package/dist/hooks/use-desktop-stream.d.ts +1 -1
- package/dist/hooks/use-usage.d.ts +40 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +460 -1386
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +8 -6
- package/dist/interaction.js.map +1 -1
- package/dist/{latest-question-QB4EUCW5.js → latest-question-IS445HOW.js} +3 -3
- package/dist/lib/format.d.ts +6 -1
- package/dist/lib/workbench-peers.d.ts +36 -0
- package/dist/machines.js +2 -2
- package/dist/{markdown-table-layout-PFUEZ2U4.js → markdown-table-layout-QXSLK4BY.js} +37 -5
- package/dist/markdown-table-layout-QXSLK4BY.js.map +1 -0
- package/dist/{queue-surface-implementation-IM2HD3SK.js → queue-surface-implementation-2CAQAIHM.js} +2 -2
- package/dist/realtime.js +3 -3
- package/dist/{sandbox-files-PXPIZAFG.js → sandbox-files-AEJTWGT4.js} +8 -5
- package/dist/sandbox-files-AEJTWGT4.js.map +1 -0
- package/dist/session-ui.d.ts +9 -2
- package/dist/session-ui.js +39 -20
- package/dist/session-ui.js.map +1 -1
- package/dist/session.js +4 -4
- package/dist/sites.js +4 -289
- package/dist/sites.js.map +1 -1
- package/dist/terminal.d.ts +8 -0
- package/dist/terminal.js +31 -0
- package/dist/terminal.js.map +1 -0
- package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
- package/dist/timeline/genie-loading.d.ts +3 -1
- package/dist/timeline/types.d.ts +8 -1
- package/dist/{timeline-annotation-selection-ODLVF4OI.js → timeline-annotation-selection-DMLMM2TX.js} +6 -1
- package/dist/timeline-annotation-selection-DMLMM2TX.js.map +1 -0
- package/dist/timeline-pill-geometry-Z23V243M.js +110 -0
- package/dist/timeline-pill-geometry-Z23V243M.js.map +1 -0
- package/dist/usage/allowance-copy.d.ts +25 -0
- package/dist/usage/summary.d.ts +35 -0
- package/dist/usage.d.ts +13 -0
- package/dist/usage.js +1073 -0
- package/dist/usage.js.map +1 -0
- package/package.json +19 -3
- package/src/artifacts.ts +37 -0
- package/src/components/artifacts/artifact-chrome.tsx +413 -0
- package/src/components/artifacts/artifact-sandbox.tsx +185 -0
- package/src/components/artifacts/chat-interactive-block.tsx +260 -0
- package/src/components/artifacts/deferred-chat-media.tsx +67 -0
- package/src/components/artifacts/editable-artifact-ui.tsx +3 -1
- package/src/components/artifacts/editable-artifact-view.tsx +187 -0
- package/src/components/artifacts/editable-artifact-workbench.tsx +5 -2
- package/src/components/artifacts/editable-document.tsx +34 -36
- package/src/components/artifacts/editable-presentation.tsx +21 -16
- package/src/components/artifacts/index.ts +41 -0
- package/src/components/artifacts/latest-task-runner.ts +49 -0
- package/src/components/artifacts/session-artifact-viewer.tsx +376 -0
- package/src/components/artifacts/site-view.tsx +116 -0
- package/src/components/browser-select-control.tsx +4 -1
- package/src/components/browser-viewer.tsx +81 -22
- package/src/components/code-editor.tsx +13 -16
- package/src/components/computer-viewer.tsx +51 -23
- package/src/components/desktop-viewer.tsx +1 -1
- package/src/components/markdown-table-layout.ts +49 -5
- package/src/components/markdown.tsx +5 -2
- package/src/components/message-timeline.tsx +557 -516
- package/src/components/open-geni-links.tsx +24 -0
- package/src/components/sandbox-terminal.tsx +48 -11
- package/src/components/session-chrome.tsx +22 -3
- package/src/components/session-conversation.tsx +195 -102
- package/src/components/timeline-annotation-selection.tsx +7 -0
- package/src/components/timeline-pill-geometry.ts +169 -0
- package/src/components/timeline-pill-placement.ts +99 -0
- package/src/components/usage-limit-notice.tsx +179 -0
- package/src/components/usage-member-list.tsx +792 -0
- package/src/components/usage-meter.tsx +382 -0
- package/src/conversation-timeline.ts +10 -2
- package/src/desktop.ts +24 -0
- package/src/editor.ts +13 -0
- package/src/hooks/use-available-models.ts +1 -1
- package/src/hooks/use-composer.ts +57 -2
- package/src/hooks/use-desktop-stream.ts +19 -28
- package/src/hooks/use-usage.ts +100 -0
- package/src/index.ts +22 -0
- package/src/lib/format.ts +32 -6
- package/src/lib/workbench-peers.ts +62 -0
- package/src/session-ui.ts +22 -0
- package/src/terminal.ts +26 -0
- package/src/timeline/activity-rail.tsx +5 -3
- package/src/timeline/allowance-exhausted-row.tsx +86 -0
- package/src/timeline/genie-loading.tsx +16 -6
- package/src/timeline/projection.ts +78 -4
- package/src/timeline/types.ts +8 -0
- package/src/usage/allowance-copy.ts +64 -0
- package/src/usage/summary.ts +93 -0
- package/src/usage.ts +50 -0
- package/styles/compiled.css +325 -0
- package/dist/chunk-4MDLEHXL.js.map +0 -1
- package/dist/chunk-5YK2ZDIG.js.map +0 -1
- package/dist/chunk-KVERXCFY.js.map +0 -1
- package/dist/chunk-L4OSXQ6H.js.map +0 -1
- package/dist/chunk-S5JQ4R22.js.map +0 -1
- package/dist/chunk-UDD6DLLT.js.map +0 -1
- package/dist/chunk-UGMKPUEM.js +0 -299
- package/dist/chunk-UGMKPUEM.js.map +0 -1
- package/dist/chunk-V2ABIVYJ.js.map +0 -1
- package/dist/chunk-X4HIN6TV.js.map +0 -1
- package/dist/chunk-XEJEOAOV.js.map +0 -1
- package/dist/chunk-YZ3YYMOM.js.map +0 -1
- package/dist/markdown-table-layout-PFUEZ2U4.js.map +0 -1
- package/dist/timeline-annotation-selection-ODLVF4OI.js.map +0 -1
- /package/dist/{browser-viewer-2E6R2Y4W.js.map → browser-viewer-Z7S7QEJL.js.map} +0 -0
- /package/dist/{computer-viewer-WMJE6OA3.js.map → chat-interactive-block-UGBTNB3L.js.map} +0 -0
- /package/dist/{chunk-Y3QTZN2F.js.map → chunk-2VFNCX4E.js.map} +0 -0
- /package/dist/{chunk-SEEVCT36.js.map → chunk-A4UJB2MM.js.map} +0 -0
- /package/dist/{chunk-5AZSK6MV.js.map → chunk-LWNLETQT.js.map} +0 -0
- /package/dist/{sandbox-files-PXPIZAFG.js.map → computer-viewer-KJWLH3GI.js.map} +0 -0
- /package/dist/{latest-question-QB4EUCW5.js.map → latest-question-IS445HOW.js.map} +0 -0
- /package/dist/{queue-surface-implementation-IM2HD3SK.js.map → queue-surface-implementation-2CAQAIHM.js.map} +0 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { OpenGeniApiError } from "@opengeni/sdk";
|
|
2
|
+
import {
|
|
3
|
+
AlertTriangleIcon,
|
|
4
|
+
ArrowLeftIcon,
|
|
5
|
+
ChevronDownIcon,
|
|
6
|
+
FileIcon,
|
|
7
|
+
FilePenLineIcon,
|
|
8
|
+
GalleryHorizontalEndIcon,
|
|
9
|
+
ImageIcon,
|
|
10
|
+
Loader2Icon,
|
|
11
|
+
PanelsTopLeftIcon,
|
|
12
|
+
RotateCcwIcon,
|
|
13
|
+
Table2Icon,
|
|
14
|
+
XIcon,
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import {
|
|
17
|
+
createContext,
|
|
18
|
+
forwardRef,
|
|
19
|
+
useContext,
|
|
20
|
+
useMemo,
|
|
21
|
+
type ComponentProps,
|
|
22
|
+
type ReactNode,
|
|
23
|
+
} from "react";
|
|
24
|
+
|
|
25
|
+
import { cn } from "../../lib/cn";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Shared chrome for artifact surfaces: the OpenGeni console and embedding hosts
|
|
29
|
+
* render the same header, controls, and load states. Class names use the
|
|
30
|
+
* package theme aliases, so the console's own Tailwind build and the compiled
|
|
31
|
+
* `.og-root` stylesheet resolve them identically.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export type ArtifactKind = "document" | "spreadsheet" | "presentation" | "site" | "image" | "file";
|
|
35
|
+
|
|
36
|
+
const BUTTON_BASE =
|
|
37
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-hidden focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-bg disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
|
|
38
|
+
const BUTTON_VARIANT = {
|
|
39
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
40
|
+
outline:
|
|
41
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-border dark:bg-input/30 dark:hover:bg-input/50",
|
|
42
|
+
} as const;
|
|
43
|
+
const BUTTON_SIZE = {
|
|
44
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
45
|
+
icon: "size-9",
|
|
46
|
+
"icon-sm": "size-8",
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export function ArtifactButton({
|
|
50
|
+
variant = "ghost",
|
|
51
|
+
size = "sm",
|
|
52
|
+
className,
|
|
53
|
+
type = "button",
|
|
54
|
+
...props
|
|
55
|
+
}: ComponentProps<"button"> & {
|
|
56
|
+
variant?: keyof typeof BUTTON_VARIANT;
|
|
57
|
+
size?: keyof typeof BUTTON_SIZE;
|
|
58
|
+
}) {
|
|
59
|
+
return (
|
|
60
|
+
<button
|
|
61
|
+
type={type}
|
|
62
|
+
className={cn(BUTTON_BASE, BUTTON_VARIANT[variant], BUTTON_SIZE[size], className)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function ArtifactBadge({ className, ...props }: ComponentProps<"span">) {
|
|
69
|
+
return (
|
|
70
|
+
<span
|
|
71
|
+
className={cn(
|
|
72
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-border px-2 py-0.5 text-xs font-medium whitespace-nowrap text-foreground [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
73
|
+
className,
|
|
74
|
+
)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const ArtifactSelect = forwardRef<HTMLSelectElement, ComponentProps<"select">>(
|
|
81
|
+
({ className, children, ...props }, ref) => (
|
|
82
|
+
<span className="relative inline-block max-w-full">
|
|
83
|
+
<select
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(
|
|
86
|
+
"peer h-9 w-full appearance-none rounded-md border border-border bg-bg px-2.5 pr-8 text-sm text-fg transition-colors hover:border-border-strong focus-visible:border-ring focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
>
|
|
91
|
+
{children}
|
|
92
|
+
</select>
|
|
93
|
+
<ChevronDownIcon
|
|
94
|
+
aria-hidden="true"
|
|
95
|
+
className="pointer-events-none absolute right-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle"
|
|
96
|
+
/>
|
|
97
|
+
</span>
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
ArtifactSelect.displayName = "ArtifactSelect";
|
|
101
|
+
|
|
102
|
+
export function artifactKindIcon(kind: ArtifactKind): ReactNode {
|
|
103
|
+
if (kind === "image") return <ImageIcon className="size-4" />;
|
|
104
|
+
if (kind === "file") return <FileIcon className="size-4" />;
|
|
105
|
+
if (kind === "site") return <PanelsTopLeftIcon className="size-4" />;
|
|
106
|
+
if (kind === "document") return <FilePenLineIcon className="size-4" />;
|
|
107
|
+
if (kind === "spreadsheet") return <Table2Icon className="size-4" />;
|
|
108
|
+
return <GalleryHorizontalEndIcon className="size-4" />;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function artifactKindSubtitle(kind: ArtifactKind): string {
|
|
112
|
+
if (kind === "site") return "Site · published preview";
|
|
113
|
+
if (kind === "image") return "Image · retained file";
|
|
114
|
+
if (kind === "file") return "File · retained file";
|
|
115
|
+
return `${kind[0]!.toUpperCase()}${kind.slice(1)} · shared editor`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type LoadErrorCopy = Readonly<
|
|
119
|
+
Record<
|
|
120
|
+
"unavailable" | "invalid" | "transient",
|
|
121
|
+
{
|
|
122
|
+
title: string;
|
|
123
|
+
message: string;
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Every user-facing string in the artifact surfaces (inline Site preview, Site
|
|
130
|
+
* frame, viewer header and states). Hosts translate by passing a partial
|
|
131
|
+
* `labels` object; unspecified keys keep the English defaults.
|
|
132
|
+
*/
|
|
133
|
+
export type ArtifactLabels = Readonly<{
|
|
134
|
+
back: string;
|
|
135
|
+
close: string;
|
|
136
|
+
/** Header title and loading copy until an artifact's title is known. */
|
|
137
|
+
opening: string;
|
|
138
|
+
/** Header title when an artifact cannot be opened. */
|
|
139
|
+
artifact: string;
|
|
140
|
+
startingEditor: string;
|
|
141
|
+
kindSubtitle: (kind: ArtifactKind) => string;
|
|
142
|
+
live: string;
|
|
143
|
+
reloadSite: string;
|
|
144
|
+
openFullScreen: string;
|
|
145
|
+
editWithAgent: string;
|
|
146
|
+
editShort: string;
|
|
147
|
+
preview: string;
|
|
148
|
+
loadPreview: string;
|
|
149
|
+
loadSitePreview: string;
|
|
150
|
+
siteVersion: string;
|
|
151
|
+
savedVersion: string;
|
|
152
|
+
version: (revision: number) => string;
|
|
153
|
+
openSite: string;
|
|
154
|
+
loadingSite: string;
|
|
155
|
+
siteArchived: string;
|
|
156
|
+
siteUnpublished: string;
|
|
157
|
+
siteReferenceInvalid: string;
|
|
158
|
+
siteLoadFailed: string;
|
|
159
|
+
retry: string;
|
|
160
|
+
tryAgain: string;
|
|
161
|
+
toolCount: (count: number) => string;
|
|
162
|
+
toolsAvailable: (count: number) => string;
|
|
163
|
+
sourceFileCount: (count: number) => string;
|
|
164
|
+
viewingDisabled: { title: string; message: string };
|
|
165
|
+
editorsMissing: { title: string; message: string };
|
|
166
|
+
siteErrors: LoadErrorCopy;
|
|
167
|
+
editableErrors: LoadErrorCopy;
|
|
168
|
+
reference: (id: string) => string;
|
|
169
|
+
}>;
|
|
170
|
+
|
|
171
|
+
export const DEFAULT_ARTIFACT_LABELS: ArtifactLabels = Object.freeze({
|
|
172
|
+
back: "Back",
|
|
173
|
+
close: "Close",
|
|
174
|
+
opening: "Opening artifact…",
|
|
175
|
+
artifact: "Artifact",
|
|
176
|
+
startingEditor: "Starting the secure editing session…",
|
|
177
|
+
kindSubtitle: (kind: ArtifactKind) => artifactKindSubtitle(kind),
|
|
178
|
+
live: "Live",
|
|
179
|
+
reloadSite: "Reload Site",
|
|
180
|
+
openFullScreen: "Open Site full screen",
|
|
181
|
+
editWithAgent: "Edit with Opengeni",
|
|
182
|
+
editShort: "Edit",
|
|
183
|
+
preview: "Preview",
|
|
184
|
+
loadPreview: "Load preview",
|
|
185
|
+
loadSitePreview: "Load Site preview",
|
|
186
|
+
siteVersion: "Site version",
|
|
187
|
+
savedVersion: "Saved version",
|
|
188
|
+
version: (revision: number) => `Version ${revision}`,
|
|
189
|
+
openSite: "Open Site",
|
|
190
|
+
loadingSite: "Loading Site…",
|
|
191
|
+
siteArchived: "This Site is archived.",
|
|
192
|
+
siteUnpublished: "This Site is archived or unpublished.",
|
|
193
|
+
siteReferenceInvalid: "This Site reference is invalid.",
|
|
194
|
+
siteLoadFailed: "Couldn’t load this Site.",
|
|
195
|
+
retry: "Retry",
|
|
196
|
+
tryAgain: "Try again",
|
|
197
|
+
toolCount: (count: number) => `${count} ${count === 1 ? "tool" : "tools"}`,
|
|
198
|
+
toolsAvailable: (count: number) => `${count} workspace tools available to this Site`,
|
|
199
|
+
sourceFileCount: (count: number) => `${count} source ${count === 1 ? "file" : "files"}`,
|
|
200
|
+
viewingDisabled: {
|
|
201
|
+
title: "Artifact viewing isn't enabled",
|
|
202
|
+
message: "This app doesn't serve editable artifacts yet.",
|
|
203
|
+
},
|
|
204
|
+
editorsMissing: {
|
|
205
|
+
title: "This artifact can't open here",
|
|
206
|
+
message: "This app hasn't installed the document, spreadsheet, and presentation editors.",
|
|
207
|
+
},
|
|
208
|
+
siteErrors: {
|
|
209
|
+
unavailable: {
|
|
210
|
+
title: "This Site isn't available",
|
|
211
|
+
message: "It may have been removed, or you may not have access.",
|
|
212
|
+
},
|
|
213
|
+
invalid: {
|
|
214
|
+
title: "This Site link isn't valid",
|
|
215
|
+
message: "Check the address and open a Site from your workspace library.",
|
|
216
|
+
},
|
|
217
|
+
transient: {
|
|
218
|
+
title: "Couldn't load this Site",
|
|
219
|
+
message: "A temporary problem prevented this Site from loading. Try again.",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
editableErrors: {
|
|
223
|
+
unavailable: {
|
|
224
|
+
title: "This artifact isn't available",
|
|
225
|
+
message: "It may have been removed, or you may not have access.",
|
|
226
|
+
},
|
|
227
|
+
invalid: {
|
|
228
|
+
title: "This artifact link isn't valid",
|
|
229
|
+
message: "Check the address and open the artifact from your workspace library.",
|
|
230
|
+
},
|
|
231
|
+
transient: {
|
|
232
|
+
title: "Could not open this artifact",
|
|
233
|
+
message: "A temporary problem prevented this artifact from opening. Try again.",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
reference: (id: string) => `Reference: ${id}`,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const ArtifactLabelsContext = createContext<ArtifactLabels>(DEFAULT_ARTIFACT_LABELS);
|
|
240
|
+
|
|
241
|
+
/** Translate every artifact surface below; nested providers override outer ones. */
|
|
242
|
+
export function ArtifactLabelsProvider({
|
|
243
|
+
labels,
|
|
244
|
+
children,
|
|
245
|
+
}: {
|
|
246
|
+
labels: Partial<ArtifactLabels> | undefined;
|
|
247
|
+
children: ReactNode;
|
|
248
|
+
}) {
|
|
249
|
+
const parent = useContext(ArtifactLabelsContext);
|
|
250
|
+
const value = useMemo(() => (labels ? { ...parent, ...labels } : parent), [labels, parent]);
|
|
251
|
+
return <ArtifactLabelsContext.Provider value={value}>{children}</ArtifactLabelsContext.Provider>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function useArtifactLabels(): ArtifactLabels {
|
|
255
|
+
return useContext(ArtifactLabelsContext);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* One artifact header: optional Back, the kind tile, title (or a host-supplied
|
|
260
|
+
* title control), trailing actions, and optional Close. The console dock and
|
|
261
|
+
* embedded viewers share it.
|
|
262
|
+
*/
|
|
263
|
+
export function ArtifactViewerHeader({
|
|
264
|
+
kind,
|
|
265
|
+
title,
|
|
266
|
+
subtitle,
|
|
267
|
+
titleSlot,
|
|
268
|
+
onBack,
|
|
269
|
+
backLabel,
|
|
270
|
+
actions,
|
|
271
|
+
onClose,
|
|
272
|
+
closeLabel,
|
|
273
|
+
}: Readonly<{
|
|
274
|
+
/** `null` while the host does not know the modality yet. */
|
|
275
|
+
kind: ArtifactKind | null;
|
|
276
|
+
title: string;
|
|
277
|
+
subtitle?: string | undefined;
|
|
278
|
+
/** Replaces the title text, for example with a picker. */
|
|
279
|
+
titleSlot?: ReactNode;
|
|
280
|
+
onBack?: (() => void) | undefined;
|
|
281
|
+
backLabel?: string | undefined;
|
|
282
|
+
actions?: ReactNode;
|
|
283
|
+
onClose?: (() => void) | undefined;
|
|
284
|
+
closeLabel?: string | undefined;
|
|
285
|
+
}>) {
|
|
286
|
+
const labels = useArtifactLabels();
|
|
287
|
+
backLabel ??= labels.back;
|
|
288
|
+
closeLabel ??= labels.close;
|
|
289
|
+
return (
|
|
290
|
+
<div
|
|
291
|
+
data-og-artifact-header=""
|
|
292
|
+
className="flex min-h-11 shrink-0 items-center gap-2 border-b border-border px-2"
|
|
293
|
+
>
|
|
294
|
+
{onBack ? (
|
|
295
|
+
<ArtifactButton size="icon-sm" aria-label={backLabel} title={backLabel} onClick={onBack}>
|
|
296
|
+
<ArrowLeftIcon className="size-4" />
|
|
297
|
+
</ArtifactButton>
|
|
298
|
+
) : null}
|
|
299
|
+
<span className="flex size-7 shrink-0 items-center justify-center rounded-md bg-accent text-accent-foreground">
|
|
300
|
+
{kind ? artifactKindIcon(kind) : <FileIcon className="size-4" />}
|
|
301
|
+
</span>
|
|
302
|
+
{titleSlot ?? (
|
|
303
|
+
<div className="min-w-0 flex-1">
|
|
304
|
+
<p className="m-0 truncate text-sm font-medium">{title}</p>
|
|
305
|
+
{(subtitle ?? (kind ? labels.kindSubtitle(kind) : "")) ? (
|
|
306
|
+
<p className="m-0 truncate text-xs text-fg-subtle">
|
|
307
|
+
{subtitle ?? (kind ? labels.kindSubtitle(kind) : "")}
|
|
308
|
+
</p>
|
|
309
|
+
) : null}
|
|
310
|
+
</div>
|
|
311
|
+
)}
|
|
312
|
+
{actions}
|
|
313
|
+
{onClose ? (
|
|
314
|
+
<ArtifactButton
|
|
315
|
+
size="icon-sm"
|
|
316
|
+
className="shrink-0"
|
|
317
|
+
aria-label={closeLabel}
|
|
318
|
+
title={closeLabel}
|
|
319
|
+
onClick={onClose}
|
|
320
|
+
>
|
|
321
|
+
<XIcon className="size-4" />
|
|
322
|
+
</ArtifactButton>
|
|
323
|
+
) : null}
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function ArtifactLoading({ label }: { label: string }) {
|
|
329
|
+
return (
|
|
330
|
+
<section
|
|
331
|
+
role="status"
|
|
332
|
+
className="grid h-full min-h-0 flex-1 grid-cols-[minmax(0,1fr)] place-items-center px-4 text-center"
|
|
333
|
+
>
|
|
334
|
+
<div className="max-w-sm rounded-lg border border-border bg-surface p-5 text-sm text-fg-muted">
|
|
335
|
+
<Loader2Icon aria-hidden className="mx-auto mb-3 size-5 animate-spin text-fg" />
|
|
336
|
+
{label}
|
|
337
|
+
</div>
|
|
338
|
+
</section>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function ArtifactProblem({
|
|
343
|
+
view,
|
|
344
|
+
onRetry,
|
|
345
|
+
}: {
|
|
346
|
+
view: ArtifactLoadErrorView;
|
|
347
|
+
onRetry?: (() => void) | undefined;
|
|
348
|
+
}) {
|
|
349
|
+
const labels = useArtifactLabels();
|
|
350
|
+
return (
|
|
351
|
+
<section
|
|
352
|
+
role="alert"
|
|
353
|
+
className="grid h-full min-h-0 flex-1 grid-cols-[minmax(0,1fr)] place-items-center px-4 text-center"
|
|
354
|
+
>
|
|
355
|
+
<div className="w-full max-w-md rounded-lg border border-border bg-surface p-5">
|
|
356
|
+
<AlertTriangleIcon aria-hidden className="mx-auto mb-3 size-5 text-status-waiting" />
|
|
357
|
+
<h2 className="m-0 text-base font-semibold">{view.title}</h2>
|
|
358
|
+
<p className="mb-0 mt-2 text-sm leading-5 text-fg-muted">
|
|
359
|
+
{artifactLoadErrorMessage(view, labels)}
|
|
360
|
+
</p>
|
|
361
|
+
{view.retryable && onRetry ? (
|
|
362
|
+
<div className="mt-4 flex justify-center">
|
|
363
|
+
<ArtifactButton variant="outline" onClick={onRetry}>
|
|
364
|
+
<RotateCcwIcon aria-hidden="true" />
|
|
365
|
+
{labels.tryAgain}
|
|
366
|
+
</ArtifactButton>
|
|
367
|
+
</div>
|
|
368
|
+
) : null}
|
|
369
|
+
</div>
|
|
370
|
+
</section>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export type ArtifactLoadErrorKind = "site" | "editable";
|
|
375
|
+
|
|
376
|
+
export type ArtifactLoadErrorView = Readonly<{
|
|
377
|
+
title: string;
|
|
378
|
+
message: string;
|
|
379
|
+
retryable: boolean;
|
|
380
|
+
correlationId?: string;
|
|
381
|
+
}>;
|
|
382
|
+
|
|
383
|
+
/** Site/editor load copy. Never surfaces raw OpenGeni API status text. */
|
|
384
|
+
export function artifactLoadErrorView(
|
|
385
|
+
error: unknown,
|
|
386
|
+
kind: ArtifactLoadErrorKind,
|
|
387
|
+
labels: ArtifactLabels = DEFAULT_ARTIFACT_LABELS,
|
|
388
|
+
): ArtifactLoadErrorView {
|
|
389
|
+
const copy = kind === "site" ? labels.siteErrors : labels.editableErrors;
|
|
390
|
+
const correlationId = error instanceof OpenGeniApiError ? error.correlationId : undefined;
|
|
391
|
+
const withSupport = (view: {
|
|
392
|
+
title: string;
|
|
393
|
+
message: string;
|
|
394
|
+
retryable: boolean;
|
|
395
|
+
}): ArtifactLoadErrorView => (correlationId ? { ...view, correlationId } : view);
|
|
396
|
+
if (error instanceof OpenGeniApiError) {
|
|
397
|
+
if (error.status === 401 || error.status === 403 || error.status === 404) {
|
|
398
|
+
return withSupport({ ...copy.unavailable, retryable: false });
|
|
399
|
+
}
|
|
400
|
+
if (error.status === 422) return withSupport({ ...copy.invalid, retryable: false });
|
|
401
|
+
return withSupport({ ...copy.transient, retryable: error.retryable });
|
|
402
|
+
}
|
|
403
|
+
return { ...copy.transient, retryable: true };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export function artifactLoadErrorMessage(
|
|
407
|
+
view: ArtifactLoadErrorView,
|
|
408
|
+
labels: ArtifactLabels = DEFAULT_ARTIFACT_LABELS,
|
|
409
|
+
): string {
|
|
410
|
+
return view.correlationId
|
|
411
|
+
? `${view.message} ${labels.reference(view.correlationId)}`
|
|
412
|
+
: view.message;
|
|
413
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowLeftIcon,
|
|
3
|
+
Globe2Icon,
|
|
4
|
+
Maximize2Icon,
|
|
5
|
+
PlugZapIcon,
|
|
6
|
+
RefreshCwIcon,
|
|
7
|
+
SparklesIcon,
|
|
8
|
+
} from "lucide-react";
|
|
9
|
+
import { useLayoutEffect, useRef, useState, type ReactNode } from "react";
|
|
10
|
+
|
|
11
|
+
import { cn } from "../../lib/cn";
|
|
12
|
+
import { ArtifactBadge, ArtifactButton, useArtifactLabels } from "./artifact-chrome";
|
|
13
|
+
import {
|
|
14
|
+
PublishedHtmlArtifactFrame,
|
|
15
|
+
type PublishedHtmlArtifactToolBridge,
|
|
16
|
+
} from "./published-html-artifact-frame";
|
|
17
|
+
|
|
18
|
+
export type ArtifactSandboxProps = {
|
|
19
|
+
html: string;
|
|
20
|
+
height?: number | undefined;
|
|
21
|
+
autoHeight?: boolean | undefined;
|
|
22
|
+
theme?: "light" | "dark" | undefined;
|
|
23
|
+
headerControls?: ReactNode | undefined;
|
|
24
|
+
title: string;
|
|
25
|
+
/** Hide the visible title/icon while retaining the accessible iframe title. */
|
|
26
|
+
showTitle?: boolean | undefined;
|
|
27
|
+
showLiveStatus?: boolean | undefined;
|
|
28
|
+
versionLabel?: string | undefined;
|
|
29
|
+
className?: string | undefined;
|
|
30
|
+
editDisabled?: boolean | undefined;
|
|
31
|
+
onEdit?: (() => void) | undefined;
|
|
32
|
+
toolBridge?: PublishedHtmlArtifactToolBridge | undefined;
|
|
33
|
+
connectedToolCount?: number | undefined;
|
|
34
|
+
sourceFileCount?: number | undefined;
|
|
35
|
+
fill?: boolean | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The Site/preview frame chrome shared by the console and embedding hosts:
|
|
40
|
+
* title, version and tool badges, live status, reload, and a full-screen mode
|
|
41
|
+
* that escapes the host's scroll containers through the modal top layer.
|
|
42
|
+
*/
|
|
43
|
+
export function ArtifactSandbox(props: ArtifactSandboxProps) {
|
|
44
|
+
const labels = useArtifactLabels();
|
|
45
|
+
const [reloadKey, setReloadKey] = useState(0);
|
|
46
|
+
const [focused, setFocused] = useState(false);
|
|
47
|
+
const frameRef = useRef<HTMLDialogElement>(null);
|
|
48
|
+
const modalRef = useRef(false);
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
const frame = frameRef.current;
|
|
51
|
+
if (!frame) return;
|
|
52
|
+
if (focused) {
|
|
53
|
+
// A fixed child of the chat timeline is still clipped and layered by its
|
|
54
|
+
// scroll pane and the sibling workspace dock. The modal top layer escapes
|
|
55
|
+
// both while keeping the live Site iframe mounted in the same DOM node.
|
|
56
|
+
frame.close();
|
|
57
|
+
frame.showModal();
|
|
58
|
+
modalRef.current = true;
|
|
59
|
+
} else if (modalRef.current) {
|
|
60
|
+
frame.close();
|
|
61
|
+
frame.show();
|
|
62
|
+
modalRef.current = false;
|
|
63
|
+
}
|
|
64
|
+
}, [focused]);
|
|
65
|
+
const reload = () => {
|
|
66
|
+
setReloadKey((value) => value + 1);
|
|
67
|
+
};
|
|
68
|
+
return (
|
|
69
|
+
<dialog
|
|
70
|
+
ref={frameRef}
|
|
71
|
+
open
|
|
72
|
+
aria-label={props.title}
|
|
73
|
+
onCancel={(event) => {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
setFocused(false);
|
|
76
|
+
}}
|
|
77
|
+
className={cn(
|
|
78
|
+
"og-root static m-0 w-full max-h-none max-w-none overflow-hidden rounded-2xl border border-border/80 bg-white p-0 text-left shadow-sm",
|
|
79
|
+
props.className,
|
|
80
|
+
props.fill && "flex min-h-0 flex-col",
|
|
81
|
+
focused &&
|
|
82
|
+
"fixed inset-0 z-50 flex h-dvh w-dvw flex-col rounded-none border-0 bg-surface shadow-none",
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<div className="flex min-h-12 shrink-0 items-center justify-between gap-3 border-b border-border/80 bg-surface/95 px-3 sm:px-4">
|
|
86
|
+
<div className="flex min-w-0 items-center gap-2.5">
|
|
87
|
+
{focused ? (
|
|
88
|
+
<ArtifactButton
|
|
89
|
+
variant="ghost"
|
|
90
|
+
size="sm"
|
|
91
|
+
className="h-8 shrink-0 px-2"
|
|
92
|
+
onClick={() => setFocused(false)}
|
|
93
|
+
>
|
|
94
|
+
<ArrowLeftIcon className="mr-2 size-3.5" />
|
|
95
|
+
{labels.back}
|
|
96
|
+
</ArtifactButton>
|
|
97
|
+
) : null}
|
|
98
|
+
{!focused && props.showTitle !== false ? (
|
|
99
|
+
<span className="grid size-6 shrink-0 place-items-center rounded-md bg-surface-2 text-fg-muted">
|
|
100
|
+
<Globe2Icon className="size-3.5" />
|
|
101
|
+
</span>
|
|
102
|
+
) : null}
|
|
103
|
+
{props.showTitle !== false && (
|
|
104
|
+
<span className="truncate text-xs font-semibold text-fg">{props.title}</span>
|
|
105
|
+
)}
|
|
106
|
+
{props.headerControls}
|
|
107
|
+
{props.versionLabel ? (
|
|
108
|
+
<ArtifactBadge className="hidden h-5 rounded-md border-border/80 px-1.5 text-2xs font-normal text-fg-muted sm:inline-flex">
|
|
109
|
+
{props.versionLabel}
|
|
110
|
+
</ArtifactBadge>
|
|
111
|
+
) : null}
|
|
112
|
+
{props.connectedToolCount ? (
|
|
113
|
+
<ArtifactBadge
|
|
114
|
+
className="hidden h-5 max-w-40 gap-1 rounded-md border-border/80 px-1.5 text-2xs font-normal text-fg-muted sm:inline-flex"
|
|
115
|
+
title={labels.toolsAvailable(props.connectedToolCount)}
|
|
116
|
+
>
|
|
117
|
+
<PlugZapIcon className="size-3" />
|
|
118
|
+
{labels.toolCount(props.connectedToolCount)}
|
|
119
|
+
</ArtifactBadge>
|
|
120
|
+
) : null}
|
|
121
|
+
{props.sourceFileCount ? (
|
|
122
|
+
<span className="hidden text-2xs text-fg-subtle xl:inline">
|
|
123
|
+
{labels.sourceFileCount(props.sourceFileCount)}
|
|
124
|
+
</span>
|
|
125
|
+
) : null}
|
|
126
|
+
</div>
|
|
127
|
+
<div className="flex shrink-0 items-center gap-1">
|
|
128
|
+
{focused && props.onEdit ? (
|
|
129
|
+
<ArtifactButton
|
|
130
|
+
variant="ghost"
|
|
131
|
+
size="sm"
|
|
132
|
+
className="h-8 px-2"
|
|
133
|
+
disabled={props.editDisabled}
|
|
134
|
+
onClick={props.onEdit}
|
|
135
|
+
>
|
|
136
|
+
<SparklesIcon className="mr-2 size-3.5" />
|
|
137
|
+
<span className="hidden sm:inline">{labels.editWithAgent}</span>
|
|
138
|
+
<span className="sm:hidden">{labels.editShort}</span>
|
|
139
|
+
</ArtifactButton>
|
|
140
|
+
) : null}
|
|
141
|
+
{props.showLiveStatus !== false && (
|
|
142
|
+
<span className="mr-1 hidden items-center gap-1.5 text-2xs font-medium text-fg-muted sm:inline-flex">
|
|
143
|
+
<span className="size-1.5 rounded-full bg-status-success ring-4 ring-status-success/10" />
|
|
144
|
+
{labels.live}
|
|
145
|
+
</span>
|
|
146
|
+
)}
|
|
147
|
+
<ArtifactButton
|
|
148
|
+
variant="ghost"
|
|
149
|
+
size="icon"
|
|
150
|
+
className="size-8 rounded-md text-fg-muted hover:text-fg"
|
|
151
|
+
aria-label={labels.reloadSite}
|
|
152
|
+
onClick={reload}
|
|
153
|
+
>
|
|
154
|
+
<RefreshCwIcon className="size-3.5" />
|
|
155
|
+
</ArtifactButton>
|
|
156
|
+
{!focused ? (
|
|
157
|
+
<ArtifactButton
|
|
158
|
+
variant="ghost"
|
|
159
|
+
size="icon"
|
|
160
|
+
className="size-8 rounded-md text-fg-muted hover:text-fg"
|
|
161
|
+
aria-label={labels.openFullScreen}
|
|
162
|
+
onClick={() => setFocused(true)}
|
|
163
|
+
>
|
|
164
|
+
<Maximize2Icon className="size-3.5" />
|
|
165
|
+
</ArtifactButton>
|
|
166
|
+
) : null}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
<PublishedHtmlArtifactFrame
|
|
170
|
+
key={reloadKey}
|
|
171
|
+
title={props.title}
|
|
172
|
+
html={props.html}
|
|
173
|
+
autoHeight={Boolean(props.autoHeight && !focused)}
|
|
174
|
+
{...(props.theme ? { theme: props.theme } : {})}
|
|
175
|
+
{...(!focused && props.height ? { style: { height: props.height } } : {})}
|
|
176
|
+
{...(props.toolBridge ? { toolBridge: props.toolBridge } : {})}
|
|
177
|
+
className={cn(
|
|
178
|
+
"block h-[clamp(30rem,62vh,48rem)] w-full border-0 bg-white",
|
|
179
|
+
props.fill && "h-0 min-h-0 flex-1",
|
|
180
|
+
focused && "min-h-0 flex-1",
|
|
181
|
+
)}
|
|
182
|
+
/>
|
|
183
|
+
</dialog>
|
|
184
|
+
);
|
|
185
|
+
}
|