Artifact

A file, document or code an agent made, as a card that opens a viewer.

Forge: Done. The retry fix and its test are ready to review.

src/payments · 16 linesSession: checkout retries
Summary · 2 min readSession: checkout retries

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/artifact

Usage

import { ArtifactCard } from "./ui/uicontext/components/kit/Artifact.ts"
const Message = UiSchema.TaggedEnum({ OpenedArtifact: { id: Schema.String } })export const PatchCard = (h: Html.H<typeof Message.Type>) =>	ArtifactCard(h, {		props: { id: "patch-412", kind: "code", title: "retry.ts", detail: "src/payments · 16 lines" },		// without `href`, opening asks the app: show an ArtifactViewer in a Sheet or a page		onEmit: { Opened: ({ id }) => Message.OpenedArtifact({ id }), RequestedAction: () => undefined },	})

Examples

While it's made, and after

A card says when the work is still running, a draft, failed with the reason, or gone.

Migration plan
Generating…Reading 38 tables✦
DraftEdited 4 minutes ago
Load test report
The staging cluster stopped answering after 6 minutes. Run it again once it's back.
orders_schema_v1.sql
DeletedDeleted yesterday

API reference

ArtifactCardComponent

Props

ArtifactCard props
NameTypeDefaultDescription
agentIdstring—The id agents see this card by; artifact:<id> when left out
idrequiredstring—Identifies the artifact in the events it sends
kindrequiredstring—Document, deck, spreadsheet, chart, dashboard, image, video, page, report, pull-request, code, file, or the app's word
titlerequiredstring—The artifact's name: "Q3 planning deck"
hrefstring—Where it opens: a real link. Without one, opening asks the app (Opened).
statusArtifactStatus"ready"Generating, ready, draft, failed, blocked, deleted or unavailable; "ready" by default
detailstring—"Version 3 · edited 2 minutes ago", "12 slides"
noticestring—For failed and blocked: why, as a sentence
progressnumber—0 to 1, while generating
preview{ src, alt }—A thumbnail for the tile
attributionAttributionData—Who made it, for whom, and how
originArtifactOrigin—Where it was made: a thread, a task, a run
actionsArtifactAction[]—What the menu offers: Download, Share, Delete
layout"card" | "tile" | "row""card"A card, a tile with a preview, or a compact row; "card" by default
pinnedboolean—Marks the artifact as pinned

Events

ArtifactCard events
EventPayloadDescription
Opened{ id: string }The person opened an artifact that has no href
RequestedAction{ id: string; action: string }The person picked one of actions

ArtifactViewerComponent

Props

ArtifactViewer props
NameTypeDefaultDescription
agentIdstring—The id agents see this viewer by; derived from id when left out
idrequiredstring—Identifies the artifact in the events it sends
kindrequiredstring—Document, deck, spreadsheet, image, page, code, or the app's word
titlerequiredstring—The artifact's name, as the viewer's heading
statusArtifactStatus"ready"Generating, ready, draft, failed, blocked, deleted or unavailable; "ready" by default
detailstring—A line under the title: "Version 3 · edited 2 minutes ago"
versions{ id, label }[]—Earlier versions to switch between, newest first
versionstring—The id of the version shown
actionsArtifactAction[]—What the toolbar offers: Download, Share, Delete
noticeArtifactNotice—A banner above the content, with its own actions: "Someone else edited this"
contentArtifactContent—What to show; leave out and fill the body slot instead (an editor, a table)
pendingEditsnumber—Unsaved edits: Save and Discard show, sent as RequestedAction "save" and "discard"
attributionAttributionData—Who made it, for whom, and how
originArtifactOrigin—Where it was made: a thread, a task, a run

Events

ArtifactViewer events
EventPayloadDescription
RequestedAction{ id: string; action: string }The person picked an action, a notice's action, Save or Discard
ChoseVersion{ id: string; version: string }The person picked another version from versions

Slots

body

Accessibility

  • Each card is an article named by its title; its status is announced, and a failure is read as an alert.
  • Its actions sit behind a button named for the artifact, in a popover that closes with Escape.
  • The viewer's version picker is a labelled select, and unsaved edits are announced. Agents can open, switch versions and run actions, and a destructive action waits for a person to confirm.

Source