Skip to content

Ariadne: a card component and slots: for units (media M3, stacked on #932) - #933

Merged
transfix merged 34 commits into
masterfrom
feat/ariadne-media-card
Nov 2, 2026
Merged

transfix merged 34 commits into
masterfrom
feat/ariadne-media-card

Conversation

@transfix

@transfix transfix commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Media M3 from the design (#929). Stacked on #932, which is stacked on #931: this branch contains both of their commits. Review only dd9cea4. It targets master so the full CI runs.

card.ari (component library, docs/ARIADNE.md §6.5) is a generic card: a bordered block (a one-column grid with an outer border) with an avatar / title / subtitle / timestamp header, a body text, a media slot and an actions row. The args are state keys, so a repeat: includes one card per item, and a part whose key is empty is not drawn. It uses built-in widgets only, so it draws in every backend.

import: cvc://components/card.ari
...
- type: group
  repeat: (state-get "feed.items")
  children:
    - include: card
      args: {id: post_{i}, avatar: feed.items.{i}.author.avatar, title: feed.items.{i}.author.name,
             subtitle: feed.items.{i}.author.handle, time: feed.items.{i}.when, body: feed.items.{i}.text}
      slots:
        media:   [ {image: "", bind: feed.items.{i}.media.0.url, size: [440, 248], fit: cover} ]
        actions: [ {button: Reply, on: ...}, {button: Like, on: ...} ]

slots: (loader, §6.1) exists because args are strings only, so a component couldn't take widget lists. A - slot: NAME item in a unit's widget list is replaced in place by the include site's slots: {NAME: [...]} (a single map also works). An unfilled slot is dropped, and the unit's args are not substituted into the include site's own widgets.

Tests

  • AriadneModularity.SlotsTakeTheIncludeSitesWidgets.
  • AriadneComponents.ShippedComponentsLoadClean now covers card.ari, an embeddable unit catalogued in INDEX.ari.
  • AriMedia.ACardFromTheComponentLibraryWithAnAvatarAndAMissingAttachment: the ari binary against a local server. It checks the avatar's colour, a 404 attachment's failed placeholder, the byline, the body and the action row, with no warnings.
  • ari_run_media_card_{ftxui,tvision}: two cards under ari run in tmux. One card is full, with a picture that loads and one that fails; the other has only a title and a body.
  • cvcgl_imgui_media: the card in ImGui, its avatar drawn at 40 px.

Verified locally (GCC 13, Release): ctest Ariadne|Ari|ari_|Media|cvcgl_imgui, 634/634 (1 skipped as on master). clang-format 18 is clean.

Since opening:

Joe Rivera added 3 commits October 30, 2026 22:24
An image: whose src (or bound value, or computed expression) is a URI now
loads that picture: http(s) through the host's network policy, with
auth: NAME sending the host's credential on the http verbs' terms; file://
relative to the document. The media cache (media.h) fetches, decodes,
downscales and fits off the frame on the app's background pool (a step per
drain in a browser build without threads), shares one fetch between boxes,
evicts idle pictures and retries failures. Widgets draw a placeholder of
their box until the picture arrives and a darker one on failure, with the
reason in the tooltip and at an optional status: key.

- cvc::decode_image: PNG/JPEG/GIF/BMP via stb, WebP via libwebp (now linked
  directly, optional), TIFF/AVIF/HEIC via ImageMagick with the coder named
  from the magic bytes; size caps checked before decoding.
- fit: contain|cover|fill and shape: circle, made by the core so every
  backend draws the raster unchanged; size: [w, h] is a box.
- FTXUI half-blocks honour alpha (a transparent half keeps the terminal's
  background); Backend::drop_image frees an evicted picture (ImGui deletes
  its texture).
- host_get + net_host_access: a host-side GET on the verbs' terms.
- ari/arigl snapshot (and ari test) wait for the pictures a frame drew.
- Tests: ariadne_media_test (decode, fit, cache, widget over a local server
  with a credential and a token scan), ari_media_test (the ari binary),
  ari_run_media_images_{ftxui,tvision} (tmux), cvcgl_imgui_media.
A window, overlay or group may take background: {src|bind, auth, fit,
opacity, terminal, banner_rows, status} (or a bare URL): a picture by URI
through the media cache, or a published image name, drawn behind the
content. The core brackets the content with the new Backend::begin_backdrop
/ end_backdrop; each backend fits the picture to the area the content takes.

- ImGui: the content goes on a draw-list channel above the picture, which is
  drawn (cover/contain/fill UVs, opacity as tint alpha) once the area is
  known: a window's inner rect, a group's rect, full width unless size: says
  otherwise and at least size:'s height.
- FTXUI and tvision: terminal: behind draws dimmed half-blocks under the
  content and turns each cell the content wrote text into readable (the
  picture's colour as background, dimmed to <= 40%, the terminal's own
  foreground); terminal: banner draws the picture as a row above the
  content, in Kitty/Sixel/iTerm pixels once its width is known; none draws
  nothing. No background in mono.
- Tests: loader, core bracketing (ariadne_media_test), FTXUI behind/banner
  layout, ImGui split/merge and the authored height (cvcgl_imgui_media), and
  the tmux test now checks a window background on both terminal backends.
card.ari in the component library: a bordered card (a one-column grid with
an outer border) with an avatar / title / subtitle / timestamp header, a
body text, a media slot and an action row. Its args are state keys, so a
repeat: includes one per item of a feed; a part whose key is empty is not
drawn. Generic: a post, a message, a search hit.

Args only take strings, so units gain slots: a '- slot: NAME' item in a
unit's widget list is replaced by the include site's slots: {NAME: [...]}
widgets (a single widget map works too; an unfilled slot is dropped; the
unit's args are not substituted into the include site's own widgets).

Tests: AriadneModularity.SlotsTakeTheIncludeSitesWidgets; the shipped
components test checks card.ari (an embeddable unit, not a window);
AriMedia card snapshot over a local server (avatar, a 404 attachment's
failed box, the action row); ari_run_media_card_{ftxui,tvision} in tmux;
the card's avatar in ImGui (cvcgl_imgui_media).
Joe Rivera added 2 commits October 30, 2026 23:39
X11 headers define None, so x11_macro_headers_test failed to compile
widget.h. The YAML value stays terminal: none.
Joe Rivera and others added 22 commits October 31, 2026 00:02
…a reply names

image.url holds in every host that loads a picture by URI, so a document for
older hosts gates its pictures on (has? "image.url") and keeps its own
placeholder elsewhere (an older host prints an unknown URI as text).

A picture whose URL a reply puts in state was drawn as its loading
placeholder by ari snapshot / arigl --terminal snapshot: no frame had asked
for it while the request was out, so the settle loop never waited for it.
AppRuntime::settle_and_render settles, draws, and while that frame drew a
picture still loading, settles and draws again (within the same 10 s).
Test: AriMedia.SnapshotWaitsForAPictureWhoseUrlComesFromAReply.
… the image.background token

A text: with color: wraps its row in a colour decorator, which recoloured
the backdrop's half-blocks after the text (solid bars in the text's colour).
BackdropText now gives a cell that is still the backdrop's own (its
character and background) the picture's foreground back. Test:
MediaBackground.ColouredTextDoesNotPaintTheBackdropBesideIt.
image.background holds where background: draws.
import: entries may be {uri: URI, optional: true}: a library the host may
not have, whose absence is no warning (so ari test passes on older hosts).
A document's own unit with fallback: true stands in only where no import
defines the name, so a document adopts cvc://components/card.ari and keeps
its own card for hosts without it. card.ari gains slots note (above the
header), extra (under the byline) and body (after the body text).
Test: AriadneModularity.OptionalImportsAndFallbackUnits.
…image-url

# Conflicts:
#	src/cvc/ariadne/loader.cpp
…image-url

# Conflicts:
#	src/cvc/ariadne/app_runtime.cpp
…ded wasm (on #914)

With #914's cvc::net::start, the image cache in a browser build without
threads starts a picture's http(s) request (host_get_start: the policy and
auth: on host_get's terms, prepared and completed around cvc::net::start;
else the http handler's resolve_async) and decodes the reply when the
browser hands it over, between frames. host_get_start is host_get,
blocking, where the transport does not start requests.
… clang-format

encode() removed its temporary file while the ifstream reading it was still open. Windows
refuses to delete an open file, so every MediaDecode/MediaCache/MediaWidget case that encodes
a picture threw from std::filesystem::remove there (8 cases in recipe/windows, the same in the
three package-windows builds). The stream now closes first.

Also the changed lines clang-format 18 reformats: ari_media_test.cpp, the two hosts' snapshot
settle calls and two include blocks the master merge touched.
The three MediaBackground cases shared temp/ariadne_media_test_backdrop, and each removed it
when done. ctest runs the cases as separate processes at the same time, so one case removed
(or rewrote) bg.png while another was still loading it; that picture never reached ready and
the case timed out at 5 s. Seen on recipe/ubuntu Debug and Release and on macOS Debug once
the stack above added cases and changed which ones run together. The directory now carries
the running test's name.
#931's changes are already here from its branch, so this keeps this tree
and makes the squash an ancestor, so the branch merges into master.
#932's changes are already here from its branch, so this keeps this tree
and makes the squash an ancestor, so the branch merges into master.
@transfix
transfix merged commit dfa4c25 into master Nov 2, 2026
1 of 27 checks passed
@transfix
transfix deleted the feat/ariadne-media-card branch November 2, 2026 06:18
transfix added a commit that referenced this pull request Nov 2, 2026
…-media-video

Their changes are already here from their branches, so this keeps this tree
and makes the squashes ancestors, so the branch merges into master.
transfix added a commit that referenced this pull request Nov 2, 2026
…media M5, stacked on #933 + #934) (#935)

Media M5: `video:` and `audio:` widgets with poster, autoplay, loop, muted
and state-bound player keys, played natively by cvcMedia's FFmpeg + SDL3
player (`media.player`; ari-media and arigl, `--media-play`). Snapshots wait
for players whose URL a reply puts in state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant