Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/artifacts-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@truefoundry/trueforge-assistant-ui-runtime': patch
'@truefoundry/trueforge-ui': patch
---

Add the artifact list, viewer, and publish dialog for published HTML and Markdown pages.
29 changes: 29 additions & 0 deletions docs/artifacts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: 'Artifacts'
sidebarTitle: 'Artifacts'
description: 'Publish an HTML or Markdown page from a chat and share a link that stays readable after the session changes.'
---

**Artifacts** are published pages. From a file preview you can publish an HTML or Markdown file, including the CSS, JavaScript, and images it references, and open it later at a stable link.

## Publishing

Open an HTML or Markdown file from a chat. In the preview header, click **Publish**.

The dialog shows how many files will be included and how large they are. **Show files** lists those paths. It does not let you add or remove files: the server follows references from the page you opened.

- **Title** is the name on the artifacts page.
- **Slug** is the last part of the link. Leave it blank to generate one. A slug cannot be changed later.
- **Note** is stored with that version.

Publishing again from the same file adds a version. If nothing changed, the existing version is kept.

Anyone signed in to the tenant can open an artifact. Only the person who published it, or a tenant admin, can publish another version or delete it.

## Opening an artifact

**Artifacts** in the sidebar lists every published page. Click a row to open it. **Open session** on the row, and on each version, returns to the chat that produced that version.

The page link always opens the latest version. Copy link on an older version adds `?version=` so the link stays on that version.

Download saves one file as itself, or a zip when the version has more than one file.
1 change: 1 addition & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"agent-library",
"sessions",
"schedules",
"artifacts",
{
"group": "Harness Capabilities",
"pages": [
Expand Down
12 changes: 12 additions & 0 deletions packages/assistant-ui-runtime/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export type {
AgentUIServer,
AgentUIServerPort,
ApprovalDecision,
Artifact,
ArtifactBundlePreview,
ArtifactContentToken,
ArtifactEntryContentType,
ArtifactFile,
ArtifactServer,
ArtifactVersion,
AuthenticateConnectorRequest,
CatalogServer,
CodeSnippet,
Expand All @@ -48,6 +55,8 @@ export type {
ConnectorConfigBase,
ConnectorSelectorEntry,
ConnectorState,
CreateArtifactRequest,
CreateArtifactVersionRequest,
CreateConnectorRequest,
CreateMemoryProviderRequest,
CreateModelProviderRequest,
Expand All @@ -65,6 +74,7 @@ export type {
DirectoryUser,
GithubSkill,
ImportGithubSkillRequest,
ListArtifactsParams,
ListPermissionsRequest,
ListPermissionsResponse,
ListResult,
Expand Down Expand Up @@ -92,6 +102,7 @@ export type {
PageParams,
PermissionResourceType,
PermissionsServer,
PreviewArtifactBundleRequest,
PreviousTurnIdInput,
ProviderEntry,
ProviderType,
Expand Down Expand Up @@ -158,6 +169,7 @@ export type {
TurnStatePaused,
TurnStateRunning,
TurnStatus,
UpdateArtifactRequest,
UpdateConnectorRequest,
UpdateMemoryProviderRequest,
UpdateModelProviderRequest,
Expand Down
116 changes: 116 additions & 0 deletions packages/assistant-ui-runtime/src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,118 @@ export interface AgentMetricsServer<
getChartData(req: TChartDataRequest): Promise<TChartData>;
}

export type ArtifactEntryContentType = 'html' | 'markdown';

export interface ArtifactFile {
path: string;
sizeBytes: number;
sha256: string;
mediaType: string;
}

export interface ArtifactVersion {
artifactId: string;
version: number;
note: string | null;
entryPath: string;
entryContentType: ArtifactEntryContentType;
fileCount: number;
totalSizeBytes: number;
sessionId: string;
turnId: string;
sourceRoot: string;
storageBackend: 'local' | 's3';
createdBySubject: Subject;
createdAt: string;
files: ArtifactFile[];
}

export interface Artifact {
id: string;
slug: string;
title: string;
description: string | null;
url: string;
latestVersion: ArtifactVersion | null;
createdBySubject: Subject;
createdAt: string;
updatedAt: string;
}

export interface ListArtifactsParams {
limit?: number;
pageToken?: string;
slug?: string;
sessionId?: string;
createdByMe?: boolean;
query?: string;
}

export interface ArtifactBundlePreview {
root: string;
entryPath: string;
entryContentType: ArtifactEntryContentType;
files: { path: string; sizeBytes: number }[];
missing: string[];
totalSizeBytes: number;
changes: { added: number; removed: number; changed: number } | null;
}

export interface PreviewArtifactBundleRequest {
sessionId: string;
turnId: string;
entryPath: string;
artifactId?: string;
}

export interface CreateArtifactRequest {
title: string;
slug?: string;
description?: string | null;
note?: string | null;
sessionId: string;
turnId: string;
entryPath: string;
}

export interface UpdateArtifactRequest {
id: string;
title: string;
description?: string | null;
}

export interface CreateArtifactVersionRequest {
artifactId: string;
note?: string | null;
sessionId: string;
turnId: string;
entryPath: string;
}

export interface ArtifactContentToken {
token: string;
baseUrl: string;
expiresAt: string;
}

/**
* Published HTML and Markdown. Omit the port to hide the sidebar entry,
* the Publish button, and the artifact routes.
*/
export interface ArtifactServer {
listArtifacts(req?: ListArtifactsParams): Promise<ListResult<Artifact>>;
getArtifact(req: { id: string }): Promise<Artifact>;
previewBundle(req: PreviewArtifactBundleRequest): Promise<ArtifactBundlePreview>;
createArtifact(req: CreateArtifactRequest): Promise<Artifact>;
updateArtifact(req: UpdateArtifactRequest): Promise<Artifact>;
deleteArtifact(req: { id: string }): Promise<void>;
listVersions(req: { artifactId: string; limit?: number; pageToken?: string }): Promise<ListResult<ArtifactVersion>>;
getVersion(req: { artifactId: string; version: number }): Promise<ArtifactVersion>;
createVersion(req: CreateArtifactVersionRequest): Promise<ArtifactVersion>;
getContentToken(req: { artifactId: string; version: number }): Promise<ArtifactContentToken>;
downloadVersion(req: { artifactId: string; version: number }): Promise<Blob>;
}

/**
* Composed host port: chat + builder + optional settings catalog + optional
* agent-detail / sessions shell + optional schedules surface + optional metrics.
Expand All @@ -1510,6 +1622,9 @@ export interface AgentMetricsServer<
* `useScheduleServer()` / list and manage schedules; if omitted, that surface
* stays hidden.
*
* `artifacts` is optional — if the host passes it, the artifacts page, viewer,
* and preview Publish button are available; if omitted, that surface stays hidden.
*
* `sandboxEnvironments` is optional — if the host passes it, Environments UI
* can call `useSandboxEnvironmentServer()`; if omitted, that surface stays hidden.
*
Expand All @@ -1536,6 +1651,7 @@ export type AgentUIServerPort<
configuration?: TConfiguration;
sessions?: TSessions;
schedules?: TSchedules;
artifacts?: ArtifactServer;
sandboxEnvironments?: TSandboxEnvironments;
metrics?: TMetrics;
permissions?: TPermissions;
Expand Down
11 changes: 11 additions & 0 deletions packages/trueforge-ui/src/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ export const AnalyticsEvents = {
SessionsBrowser: {
OPENED: 'trueforge.sessions_browser.opened',
},
Artifact: {
PUBLISH_DIALOG_OPENED: 'trueforge.artifact.publish_dialog_opened',
PUBLISHED: 'trueforge.artifact.published',
PAGE_OPENED: 'trueforge.artifact.page_opened',
VIEWER_OPENED: 'trueforge.artifact.viewer_opened',
LINK_COPIED: 'trueforge.artifact.link_copied',
SESSION_OPENED: 'trueforge.artifact.session_opened',
FILE_SELECTED: 'trueforge.artifact.file_selected',
DOWNLOADED: 'trueforge.artifact.downloaded',
DELETED: 'trueforge.artifact.deleted',
},
Schedule: {
PAGE_OPENED: 'trueforge.schedule.page_opened',
CREATED: 'trueforge.schedule.created',
Expand Down
66 changes: 66 additions & 0 deletions packages/trueforge-ui/src/atoms/ArtifactsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use client';

import { useTrackAnalytics } from '../analytics/AnalyticsProvider.js';
import { AnalyticsEvents } from '../analytics/events.js';
import { Icon } from '../icons/Icon.js';
import { useOptionalArtifactServer } from '../server/ServerContext.js';
import { useOptionalShellMode } from '../server/ShellModeContext.js';
import { isArtifactsChromeEnabled } from '../server/serverChrome.js';
import { auiButtonClass, sidebarButtonRadiusClassName, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';

export type ArtifactsButtonProps = {
className?: string;
compact?: boolean;
};

export function ArtifactsButton({ className, compact = false }: ArtifactsButtonProps) {
const shell = useOptionalShellMode();
const artifactServer = useOptionalArtifactServer();

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > does not load more at the top of an overflowing list

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > does not load more before reaching the bottom

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > loads more when scrolled near the bottom

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > loads more when the first page does not fill the viewport

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > rechecks an underflowing viewport after a Strict Mode effect remount

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > remeasures when a hidden viewport becomes visible

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Test (Windows)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > closes Sessions when selecting a thread

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > does not load more at the top of an overflowing list

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > does not load more before reaching the bottom

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > loads more when scrolled near the bottom

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > loads more when the first page does not fill the viewport

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > rechecks an underflowing viewport after a Strict Mode effect remount

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > remeasures when a hidden viewport becomes visible

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41

Check failure on line 19 in packages/trueforge-ui/src/atoms/ArtifactsButton.tsx

View workflow job for this annotation

GitHub Actions / Package (trueforge-ui)

test/containers/ThreadListContainer.pagination.test.tsx > ThreadListContainer pagination > closes Sessions when selecting a thread

Error: [vitest] No "useOptionalArtifactServer" export is defined on the "@/server/ServerContext.js" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("@/server/ServerContext.js"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ ArtifactsButton src/atoms/ArtifactsButton.tsx:19:26 ❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:28571:20 ❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:8030:22 ❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:10569:19 ❯ beginWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:12205:18 ❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:1048:13 ❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19176:22 ❯ workLoopSync ../../node_modules/.pnpm/react-dom@19.3.0_react@19.3.0/node_modules/react-dom/cjs/react-dom-client.development.js:19004:41
const track = useTrackAnalytics();
const enabled = isArtifactsChromeEnabled({ artifacts: artifactServer }) && shell != null;
const open = shell?.artifactsOpen === true || shell?.artifactView != null;

if (!enabled) return null;

return (
<div className={cn('relative min-w-0', compact ? 'flex justify-center' : 'w-full', className)}>
<button
type="button"
aria-label={compact ? 'Artifacts' : undefined}
title={compact ? 'Artifacts' : undefined}
aria-current={open ? 'page' : undefined}
className={auiButtonClass({
variant: 'ghost',
className: cn(
sidebarButtonRadiusClassName,
'font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text',
compact ? sidebarRailButtonClassName : 'h-8 w-full !justify-start px-2.5 text-sm',
open &&
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
if (!shell.artifactsOpen) track(AnalyticsEvents.Artifact.PAGE_OPENED);
shell.setArtifactsOpen(!shell.artifactsOpen);
}}
>
<Icon name="file-code" size={compact ? 14 : undefined} />
{compact ? (
<span className="text-center">Artifacts</span>
) : (
<>
<span className="truncate">Artifacts</span>
<Icon name="chevron-right" className="ml-auto size-3.5 shrink-0 opacity-60" />
</>
)}
</button>
</div>
);
}

declare module '../theme/SlotsProvider.js' {
interface AtomSlots {
ArtifactsButton: typeof ArtifactsButton;
}
}
32 changes: 16 additions & 16 deletions packages/trueforge-ui/src/atoms/FilePreviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { clampPreviewWidth } from '../filePreview/previewPaneWidth.js';
import { FILE_PREVIEW_HIGHLIGHT_CHAR_LIMIT, type ReadFilePreviewResult } from '../filePreview/readFilePreview.js';
import { Icon } from '../icons/Icon.js';
import { useSlot } from '../theme/SlotsProvider.js';
import { RenderedDocument } from './RenderedDocument.js';
import { auiButtonClass } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { Spinner } from './primitives/Spinner.js';
Expand All @@ -22,6 +23,7 @@ export type FilePreviewPanelProps = {
view: FilePreviewView;
onClose: () => void;
onDownload: () => void;
onPublish?: () => void;
onEnterFullPage?: () => void;
onExitFullPage?: () => void;
onRetry?: () => void;
Expand All @@ -33,7 +35,6 @@ export type FilePreviewPanelProps = {

function PreviewBody({ name, view }: { name: string; view: FilePreviewView }) {
const SyntaxHighlighter = useSlot('SyntaxHighlighter');
const Markdown = useSlot('Markdown');

if (view.status === 'loading') {
return (
Expand Down Expand Up @@ -63,24 +64,11 @@ function PreviewBody({ name, view }: { name: string; view: FilePreviewView }) {
}

if (view.status === 'html') {
return (
<iframe
title={name}
// Scripts and forms run only after the page is opened. Popups stay off, and same-origin is omitted so the page cannot read the chat.
sandbox="allow-scripts allow-forms"
referrerPolicy="no-referrer"
srcDoc={view.text}
className="absolute inset-0 h-full w-full border-0 bg-white"
/>
);
return <RenderedDocument name={name} kind="html" text={view.text} />;
}

if (view.status === 'markdown') {
return (
<div className="px-4 py-3">
<Markdown content={view.text} />
</div>
);
return <RenderedDocument name={name} kind="markdown" text={view.text} />;
}

if (view.language != null && view.text.length <= FILE_PREVIEW_HIGHLIGHT_CHAR_LIMIT) {
Expand Down Expand Up @@ -112,6 +100,7 @@ export function FilePreviewPanel({
view,
onClose,
onDownload,
onPublish,
onEnterFullPage,
onExitFullPage,
onRetry,
Expand Down Expand Up @@ -244,6 +233,17 @@ export function FilePreviewPanel({
<Icon name="expand" size={14} />
</button>
) : null}
{onPublish != null ? (
<button
type="button"
onClick={onPublish}
aria-label={`Publish ${name}`}
title="Publish"
className={auiButtonClass({ variant: 'ghost', size: 'small' })}
>
Publish
</button>
) : null}
<button
type="button"
onClick={onDownload}
Expand Down
Loading
Loading