GPUI Deck

Attachment

Named file-metadata group with a filename, supplied media type and size, and optional existing actions.

Rendered by GPUI’s web backend from the real component. Requires a browser with WebGPU.

attachment.rs presents a file's name, media type, and size as application-supplied text, with an optional existing action. It describes metadata; the content itself remains with the application.

Attachment::new(
    "configuration-attachment",
    "session-configuration.json",
    "application/json",
    format!("{} bytes (UTF-8)", configuration.len()),
    palette,
)
.action(inspect_json_button)

The native Group's accessible name is the complete filename. Its description is the same media_type · size_label text shown below the filename. The visible filename and metadata children have no separate native role or name, so each value is exposed once through the group. Supplied action Buttons retain their own names and roles. The attachment frame adds no Tab stop, whole-row click, selection state, link destination, or live announcement.

All three metadata values are supplied strings. The application chooses units, localization, and how to describe unavailable metadata; the recipe does not parse filenames, infer types, inspect files, format byte quantities, or validate the claimed size. Zero bytes can be displayed literally. An ordinary Group is used because metadata does not itself supply a document viewer or a file link. Unlike Item's generic title/description row, Attachment has explicit file metadata. Unlike Message's authored Comment and body, it identifies a separate content resource without claiming authorship or delivery.

The frame fills a bounded parent. Filename and metadata wrap without truncation, and the frame grows vertically; an action sits below the text so it does not compete with the filename's width. Styled customizes the frame and inherited text presentation. Long collections belong in the application's existing ScrollArea. .action(...) accepts one element, including an existing Button or an application-owned container whose controls fit the available width. Button continues to own enabled state, pointer/Enter/Space activation, focus, and Tab/Shift+Tab traversal. The application owns focus policy if it removes a focused action; Attachment has no new focus controller.

Both appearances use Attachment in Help's State ownership panel above the existing CodeBlock. The consumer serializes the current settings once, uses the same string for the code and metadata, and displays session-configuration.json, application/json, and its UTF-8 byte count. Editing a name or note changes that metadata with the displayed JSON. Inspect JSON focuses the existing code viewport and uses its existing scrolling and keyboard behavior. The explanatory text identifies this content as in memory and not saved. No file is created or opened, and no upload or download occurs. The existing CodeBlock Copy action remains independent; Attachment adds no clipboard operation, preview renderer, progress state, transport, or storage mechanism.