Skip to content

Ariadne: a spinner widget that turns by the host's frame clock - #915

Merged
transfix merged 3 commits into
masterfrom
feat/ariadne-spinner
Oct 31, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/ariadne-spinner

Conversation

@transfix

Copy link
Copy Markdown
Owner

A generic activity indicator for Ariadne documents: spinner:. It shows something is under way (a request, a search) and keeps turning while the document's programs are parked, because the host's frame clock drives it, not state. Asked for by nicotina (show it while ui.busy is set) alongside L4 (#914), which keeps the single-threaded browser pages drawing while a request is out.

- spinner: Signing in...
  visible_when: (= (state-get "ui.busy") "1")
- spinner:                                  # label from state, or a computed expression
  bind: (string.join (list "Loading" (state-get "feed.name")) " ")
- spinner: Working
  glyphs: ascii                             # | / - \ rather than braille dots

Why a spinner kind rather than progress with indeterminate: true

  • progress is a quantity: it requires bind: (the loader warns without one), and its lo / hi / overlay mean nothing with no amount to show.
  • An indeterminate bar is a full-width element, while an activity indicator is one glyph that sits inline beside a label, in a status line or next to a button. In ImGui it is drawn, not a progress bar.
  • A separate kind keeps progress's contract as it is. It also makes the "animates by the host clock, not by state" rule specific to this widget, where it is the whole point.

What it does

  • Frame clock: Runtime::frame_clock() is the steady clock read at the top of each render(). A host that renders frames with no real time between them pins it with set_frame_clock(t):

    • ari snapshot pins frame f at f / fps (default 20);
    • arigl's fixed clock (its snapshots) advances it by frame()'s dt.

    So snapshots are reproducible and still step from frame to frame.

  • Walker (Kind::Spinner): calls Backend::spinner(label, seconds, ascii). The label is the widget's key, or bind: (state path or computed). Disabled, it gets seconds = 0 (stands still), inside the usual disabled scope. visible_when hides it as for any widget.

  • Terminal backends (FTXUI, tvision): the default Backend::spinner draws a text line: ten braille dots a second (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏, spelled as UTF-8 bytes for MSVC), then the label. They fall back to | / - \:

    • with glyphs: ascii;
    • by themselves on the Linux console and on dumb / vt* terminals, which have no braille (Backend::unicode_glyphs(), read from TERM once).

    tvision draws through FtxuiBackend, so it gets the same.

  • ImGui (arigl): a drawn arc (three quarters of a circle a text line high, one turn a second, in the text colour, dimmed when disabled), then the label. It needs no glyph from the font; the browser build's font is ASCII.

  • Browser pages: ari.html (FTXUI over xterm.js) shows the braille; arigl's page uses the ImGui arc.

  • Example: examples/ariadne/terminal/terminal_tour.ari's Status window has one, so the published ari.html and arigl's tour show it.

Docs: ARIADNE.md §4.

Tests

  • ariadne_runtime_test, AriadneSpinner:
    • the glyph cycle (ten braille a second, ASCII, NaN and negative read 0);
    • turning by the pinned and by the real clock;
    • turning every frame while the document's only program is parked on msg-recv;
    • disabled stands still, visible_when hides it, bind: gives the label (state path and computed).
  • ariadne_loader_test, AriadneLoader.Spinner: the key, glyphs: ascii, a bare - spinner, a warning for an unknown glyphs.
  • ariadne_ftxui_test, AriadneFtxui.SpinnerTurnsByTheFrameClock: braille, then the next glyph, in the FTXUI text snapshot.
  • cvcgl_imgui_spinner (bare ImGui context, no GL): the arc turns a quarter second on and comes round after a second; disabled it stands still; the label sits on its line.
  • ari_spinner (src/ari/tests/spinner_test.sh): ari snapshot frame 1 against frame 3 (⠋ → ⠙, | → /). Then ari run in a tmux pane under each terminal backend, its screen taken twice 0.4 s apart while the program is parked. Locally: FTXUI ⠋ → ⠼, tvision ⠋ → ⠼. Without tmux only the snapshots run.
  • Browser, manual: ari.html from a single-threaded wasm build (emsdk 5.0.7) runs the baked tour in Chrome. Pixel comparison of crops 250 ms apart: the glyph cells change (17–29 px differ), the label's don't (0).
    • Not checked visually: arigl's page (ImGui in the browser). Its arc is the same ImDrawList code as native, covered by cvcgl_imgui_spinner, and this PR's arigl-web CI job builds that page with it.
  • Local: Linux GCC Release, cvcGL + ImGui + tvision. The results comment below has the ctest count.

For nicotina

- spinner: Working...
  visible_when: (= (state-get "ui.busy") "1")

Put it next to the status line. It keeps turning while the request is out; in the single-threaded browser pages that needs #914.

`spinner:` shows that something is under way when there is no amount to show (a request, a
search). The host turns it by its own frame clock, not by state, so it keeps moving while the
document's programs are parked: a program waiting on http-get still has a turning spinner
beside it.

- Runtime::frame_clock(): the steady clock read at the top of each render(), or the host's
  pinned time (set_frame_clock). ari snapshot pins frame f at f / fps; arigl's fixed clock
  advances it by frame()'s dt, so snapshots are reproducible and still step.
- Kind::Spinner calls Backend::spinner(label, seconds, ascii): label from the key or from bind:
  (state path or computed), still while disabled, hidden by visible_when as any widget.
- Terminal backends (FTXUI, and tvision through it): ten braille dots a second, then the label;
  | / - \ with glyphs: ascii, and by themselves on the Linux console and dumb / vt* terminals
  (Backend::unicode_glyphs). ImGui: a drawn arc a text line high, one turn a second, so it needs
  no glyph from the font (the browser build's is ASCII).
- A spinner kind rather than progress with indeterminate: progress is a bound quantity over
  [lo, hi]; an activity indicator is one inline glyph with nothing to bind.
- terminal_tour.ari's Status window has one.

Tests: AriadneSpinner (glyph cycle, the frame clock pinned and real, turning while the
document's program is parked, disabled / hidden / bind), AriadneLoader.Spinner,
AriadneFtxui.SpinnerTurnsByTheFrameClock, cvcgl_imgui_spinner (the arc turns, comes round after
a second, stands still disabled), and ari_spinner (tests/spinner_test.sh: ari snapshot frame 1
against frame 3, then ari run under tmux for FTXUI and tvision, the screen taken twice).

Docs: ARIADNE.md 4.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 30, 2026
While ui.busy is set, libcvc's spinner widget (transfix/libcvc#915) turns
beside the status line (Signing in..., Checking the code..., Refreshing...)
and beside Connecting to ... at start-up. It turns by the host's frame clock,
so it keeps moving while the controller is parked on the request. A host
without the widget keeps the text alone: each spinner is gated on
(has? "spinner"), and main.ari lists it as an optional requirement.

The stub's mary takes 3 s to load and slowpoke 12 s. tests/run.sh checks the
spinner in a snapshot, and in tmux under FTXUI and tvision that its glyph
changes while mary signs in; it skips those checks on an ari without the
widget.
@transfix

Copy link
Copy Markdown
Owner Author

Local ctest on this branch, rebased on master 297876c (Linux GCC, Release, cvcGL + ImGui + tvision + arigl; filter Ariadne|ari|imgui|ImGui|arigl): 628/628 passed, including ari_spinner (snapshot + FTXUI and tvision under tmux) and cvcgl_imgui_spinner.

transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…igl, launchers, tests) (#1)

* M0: sign in to a TX.WTF instance, then show the profile and SCRIP balance

share/nicotina/main.ari runs in stock ari (FTXUI or tvision) and arigl. It
signs in with POST /user/login and capture_auth, so the host keeps the token
and the document never sees it; GET /user/ and /billing/scrip/balance name the
credential with auth:. It handles the emailed second factor (/user/login/2fa),
a wrong password, force_password_change (change it in the web app first) and an
expired token (sign in again), and signs out with /user/logout and
net-auth-forget. requires: net and net.auth, so a host without --net refuses it.

The windows (ui/signin.ari, ui/home.ari) are laid out for an 80x24 terminal;
ImGui adds a Details window. The instance comes in as --instance (default
https://tx.wtf); --user fills in the form.

* Launchers: bin/nicotina (POSIX sh) and bin/nicotina.cmd

They find the prefix from their own path and run share/nicotina/main.ari in
arigl, or in ari in a terminal (--terminal, --backend ftxui|tvision, or no
display: no DISPLAY/WAYLAND_DISPLAY, or SSH without X forwarding). The host gets
--net --net-allow <the instance's origin> and a credential store in
$XDG_CONFIG_HOME/nicotina (%APPDATA% on Windows). Other options go to the host,
arguments after -- to the document; --dry-run prints the command.

web/ariadne.config.json is the arigl-web and ari pages' config for an instance
that serves the documents at /apps/nicotina/.

* Tests: a stub TX.WTF instance, snapshots and tmux runs

tests/stub_txwtf.py answers the five endpoints M0 uses with txwtf's shapes.
tests/run.sh checks the launcher's choices, ari check without --net, ari
snapshot in both backends (sign-in form, resumed session, expired session, an
instance that doesn't answer), arigl snapshot, and bin/nicotina in a tmux pane
in both backends typed at like a person: sign in, restart signed in, sign out,
a wrong password, the emailed code, a forced password change. No output may
contain a session token.

* README and roadmap: running M0 from a local libcvc build

How to build ari and arigl from the four open libcvc pull requests, run the
client and its tests, and serve it in the browser; the cvcpkg way once the
packages publish. The roadmap gains L11, a masked text input, which M0 needs.

* tests: remove the tmux socket a killed server leaves

* tests: no bytecode in the tree; the stub follows tx.wtf's live schema

Remove the committed tests/__pycache__, ignore __pycache__/ and *.pyc, and run
Python with -B in tests/run.sh.

The stub's replies now follow https://tx.wtf/openapi.json (txwtf 0.4.0):
ResponseSchema for /user/logout, a validation error's loc/msg/type, the User
fields a login reply requires. Its errors are the ones tx.wtf answers: 401 Not
authenticated without a token (not 403), 401 Invalid token for one it doesn't
know.

* web: --instance {origin}, so one page config serves every instance

transfix/libcvc#887 (0f627c9e) replaces {origin} in a page config's args as
well as its flags.

* tests/live.sh: the client against a live instance, as a test account

tests/live.sh signs in to a live TX.WTF instance (dev.tx.wtf) with a test
account from an owner-only env file outside the repository, in both terminal
backends: a wrong password, the profile and balance, resuming the stored
session in ari and arigl snapshots and on restart, and sign-out. The password
is typed through a tmux buffer, and no output may hold it or the session token.

The helpers both scripts use move to tests/lib.sh.

* tests/local.sh: the client against a real txwtf instance from cvcpkg

tests/local.sh starts txwtf's own server (txwtf-cp312 from a cvcpkg prefix) on a
fresh SQLite database and drives the client against it in both terminal
backends. tests/txwtf_local.py makes the accounts with txwtf's core functions:
SCRIP minted, the emailed second factor on, a forced password change.
tests/smtp_sink.py takes the instance's mail, so grace signs in with the code
from the real email. It also checks that the server refuses a token after
sign-out, the client's answer to txwtf's 429 once its login rate limit is used
up, and a server that has gone away.

The README lists the three suites: the stub (CI), a local txwtf, and a live
test instance.

* tests: run the local txwtf from the work directory, which keeps uploads/ out of the tree

txwtf makes an uploads/ directory wherever it runs, init-db included.
tests/lib.sh makes $out, $ARI and $ARIGL absolute so a script may change
directory.

* README: the browser builds on cyberpcangel.com

In the browser: the pages are public at cyberpcangel.com/nicotina and /nicotina-term, published by the deploy-cyberpcangel workflow (#2). Why that origin needs its own page config and tx.wtf's CORS (atx-crypto-club/txwtf#312), and what the pages do until then. The same-origin /apps/ setup still waits on txwtf T2.

* Home: the full handle, @user@instance, before the display name

The header shows the handle with the instance's host (no scheme, path or
default port), e.g. @[email protected]. A brokered account keeps the
home instance its txwtf username already carries (<user>@<home domain>); GET
/user/ has no other field for it. The display name is cut to fit the
window's 60 columns. ImGui's Details window lists the handle too.

The stub gains a long display name and a brokered account, and tolerates an
instance below a path; tests/run.sh checks the cut, the brokered handle, a
path and a default port, and every suite expects the full handle.

* Home: no placeholder email for a brokered account; a long email cut to fit

txwtf gives a brokered account a local email in .invalid (its real address
belongs to its home instance), so the row shows '-' for one. Others are cut to
the value column's 51 characters.

* A Refreshing... status, and a TODO for the spinner

Refresh now says so while its requests are out, as sign-in and the code check
do, so each request has a status line a spinner can sit beside. The spinner
itself waits on libcvc's widget, which animates from the host's frame clock:
the controller is parked during a request, so no state it writes could drive
one. tests/run.sh presses Refresh in both terminal backends.

* A spinner beside the status line while a request is out

While ui.busy is set, libcvc's spinner widget (transfix/libcvc#915) turns
beside the status line (Signing in..., Checking the code..., Refreshing...)
and beside Connecting to ... at start-up. It turns by the host's frame clock,
so it keeps moving while the controller is parked on the request. A host
without the widget keeps the text alone: each spinner is gated on
(has? "spinner"), and main.ari lists it as an optional requirement.

The stub's mary takes 3 s to load and slowpoke 12 s. tests/run.sh checks the
spinner in a snapshot, and in tmux under FTXUI and tvision that its glyph
changes while mary signs in; it skips those checks on an ari without the
widget.

* README: the tests run in CI; point to ci/README.md
nicotina-ci added 2 commits October 30, 2026 20:13
@transfix
transfix merged commit e8cb3d4 into master Oct 31, 2026
27 checks passed
@transfix
transfix deleted the feat/ariadne-spinner branch October 31, 2026 17:44
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