Skip to content

Ariadne: image: shows a picture by URL (media M1) - #931

Merged
transfix merged 8 commits into
masterfrom
feat/ariadne-media-image-url
Nov 2, 2026
Merged

transfix merged 8 commits into
masterfrom
feat/ariadne-media-image-url

Conversation

@transfix

@transfix transfix commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Media M1 from the design in #929 (docs/roadmap/ARIADNE_MEDIA.md): an image: names a picture by URI, in every host. Reference: docs/ARIADNE.md §5.11.

- image: avatar
  src: https://media.example/u/42.webp   # or bind: feed.items.{i}.avatar, or a computed expression
  auth: example                          # optional: the host's credential, never in state
  size: [48, 48]                         # a box; one number is a width
  fit: cover                             # contain | cover | fill
  shape: circle                          # rect | circle
  status: profile.avatar                 # optional: loading | ready | failed (+ .error)

How it works

  • URIs. http(s)://, file:// (relative to the document), cvc:// and state://. Any other value is still a host-published name.

  • Network and credentials. http(s) goes through the host's network (enable_net): its allowlist, and auth: through host_get, which is the http verbs' perform() with the same terms. The token goes only to origins its credential is bound to, redirects are not followed, and echoes are blanked. The token never reaches state, a cache key, a published name or an error.

  • Off the frame. A per-Runtime media::ImageCache (inc/cvc/ariadne/media.h) runs the fetch, decode, downscale (2048 px) and fit on the app's background pool. In a browser build without threads it runs one step per Runtime::drain, between frames, never in the walk. Boxes of the same URL share one fetch. Idle pictures are evicted after 30 s (64 MiB LRU), and the backends free them through the new Backend::drop_image. Failures retry after 30 s.

  • Decoding. cvc::decode_image (inc/cvc/image/image_decode.h) sniffs the format from the bytes:

    • PNG, JPEG, GIF (first frame) and BMP through stb;
    • WebP through libwebp, now linked directly and optional (it was already a libcvc dependency);
    • TIFF, AVIF and HEIC through ImageMagick, with the coder named from the magic bytes so network input never picks one.

    Size caps (8192 px, 40 Mpx, 64 MiB) are checked from the header before decoding.

  • Fit and placeholders. The core fits the picture to the box (contain pads with transparency, cover crops, fill stretches, circle masks), at twice the box's size where the source allows. The backends draw that raster unchanged. Until it arrives, the widget draws a placeholder raster of the same box, and a darker one with a tooltip on failure.

  • Backends.

    • ImGui: texture, as before.
    • FTXUI and tvision: Kitty, Sixel, iTerm or half-blocks, as before. Half-blocks now honour alpha, so a circle avatar's corners keep the terminal's background.
    • Kitty, Sixel and iTerm composite onto black (documented).
  • Snapshots. ari snapshot, arigl snapshot and ari test wait for the pictures a frame drew (Runtime::media_stale). AppRuntime::idle() counts loading pictures.

Tests

  • ariadne_media_test (21 tests): decoding each format, truncated and oversized input, the fit modes pixel by pixel, the cache (single-flight, retry, eviction, token-free names), and the widget against a local HTTP server with a bound credential. That last test checks the token went only to the bound origin, a 404 fails, a disallowed origin and an unbound credential are refused before any request, and a whole-state-tree and tooltip scan finds no token.
  • ari_media_test: the ari binary. snapshot --ansi shows each picture's own 24-bit colour and the failed placeholder, with a credential from --credential-env. Its output carries no token, and file:// works with the network off.
  • ari_run_media_images_{ftxui,tvision}: ari run in tmux, both backends, three pictures (cover banner, circle avatar, missing file).
  • cvcgl_imgui_media: the ImGui backend receives the fitted RGBA raster at the box width, with placeholders.

Verified locally (GCC 13, Release, GL deps prefix): ctest Ariadne|Ari|ari_|Media|Net|cvcgl_imgui|cvcgl_stream_view|Uri, 641/641 (5 cvcGL binaries built and run separately). arigl --terminal snapshot draws them too. clang-format 18 is clean on changed lines.

Since opening (all merged up the stack):

Not done here

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.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…pictures by URL

The avatar slot is an image: of txwtf's avatar_url (64 px, round, 8 x 4
cells), and the banner an image: of header_image_url cropped to the window
(592 x 32 px, 74 x 2 cells), wherever the host can show a picture from a URL
(transfix/libcvc#931; the optional capability image.url). Elsewhere, and for
an account without a header image, the placeholders stay as they were.

run.sh, on such a host: the pictures draw where the placeholders were, and the
stub saw them fetched without the session token.
Joe Rivera added 2 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.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…ances tabs); no Runway (#12)

The profile laid out as the TX.WTF web app's: the banner, the card (avatar, full handle, badges, description, counts, groups, Refresh and Sign out) and Posts, Replies and Balances tabs, in 76x19 so it fits 80x24 in FTXUI and tvision. The confusing Runway row is gone. The account's avatar and header image show where the host has pictures by URL (image.url, transfix/libcvc#931), and its card and page pictures where it has background: (transfix/libcvc#932, ImGui only for now); placeholders elsewhere. Video avatars keep their placeholder, by the web app's rule. Tests: the stub's profile pictures, emblems, presence and user timeline; local txwtf posts and a reply; tabs, paging, no Runway and the 80x24 fit in tmux in both backends.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…13)

The home feed is the first screen after signing in, as the web app's home is: Show Following (GET /social/timeline/home) or Everyone (/public), ten posts a page with mode=latest, and Load more by before_id. Each post is a bordered card: the author's avatar, name, full handle and time; the text, wrapped, three lines at most; the first picture inline; attachment rows; the counts; Open, which shows the whole post with its reactions (GET /social/posts/{id}). Pictures show where the host has image.url (transfix/libcvc#931); video and audio play with their controls where it has a player (media.player: ari-media and arigl, transfix/libcvc#935), and are rows elsewhere. The launcher prefers ari-media in a terminal; --start profile opens the profile first. Terminal first: 76 columns by 86% of the screen, scrolling by focus. Tests: a stub feed with pictures, a video, a recording, a PDF, a repost, a paid post and two pages; Open, Load more, Everyone and the 80x24 fit in tmux in both backends; players and pictures where the host has them.
Joe Rivera and others added 5 commits October 31, 2026 00:51
…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.
@transfix
transfix merged commit f132d2a into master Nov 2, 2026
24 of 27 checks passed
@transfix
transfix deleted the feat/ariadne-media-image-url branch November 2, 2026 05:34
transfix added a commit that referenced this pull request Nov 2, 2026
#931 took docs/ARIADNE.md §5.11 for pictures by URL, the slot this
branch had used for phones; the phone section is now §5.12, and the
ImGui layout note that points at it follows.
transfix added a commit that referenced this pull request Nov 2, 2026
#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.
transfix added a commit that referenced this pull request Nov 2, 2026
…#932)

Media M2: `background:` on a window or group draws a picture (or a bound
URL) behind its children, with fit, opacity, and a terminal mode: behind
(the default, half-blocks under the text), banner (rows above) or none.
Coloured text no longer paints the backdrop beside it.

Each backdrop test draws from a directory of its own, since ctest runs the
cases as parallel processes and each removes its directory when done.
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