Skip to content

Ariadne: room chat and direct messages for the conference, text_view and message_input widgets - #972

Merged
transfix merged 10 commits into
masterfrom
feat/ariadne-chat
Nov 3, 2026
Merged

transfix merged 10 commits into
masterfrom
feat/ariadne-chat

Conversation

@transfix

@transfix transfix commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Room chat and direct messages for the Ariadne conference client (the browser page and arigl natively), two new widgets (text_view: and message_input:), and the chat window and users list as reusable components. The design is in docs/roadmap/ARIADNE_CHAT.md.

Design

Why the messages are not plain room-tree writes

The relay sends its whole conf tree to every client: in a joiner's admit snapshot, in the WebSocket re-broadcast, and in its forwarding of each client's participant writes. The S7 filters narrow this only for a participant that has joined and been given a filter. An observer, a connection whose admission hold timed out, or any client under --aoi off gets everything. Kept in the shared tree, history would reach every client in full, and so would a DM.

So the relay keeps the history in memory:

  • Client to relay: a state_message with ttl_hops = 0 on the client's own participants.<pid>.chat path. Bound writes already limit a client to its own path. ttl_hops == 0 stays at the relay; master now has the same rule for Conference: avatar poses as compact per-viewer snapshots at up to 60 Hz #951's lane signaling. The room write gate refuses a chat message with any other ttl_hops.
  • Relay to client: push_snapshot_to_holder, a new variant of push_snapshot_to. It writes only to the connection that holds the pid under bound writes, never to a second connection that claims the same pid.

State layout

What a client holds under conf.rooms.<room>.chat:

path written by reaches
epoch, room.head, room.first relay everyone (replicated)
room.m.<seq> relay (push) present participants as each message is posted; a page to the client that asked
dms, dm.<peer>.{head,first,m.<seq>} relay (push) only the two participants of that conversation
error, rev relay (push) that participant only

A message is one JSON leaf. A client reads rev and room.head once per tick and looks further into the tree only when one of them moves.

Pagination

  • A page is 32 messages. The relay keeps 5000 room messages and 1000 per conversation.
  • The first view of a channel asks for its newest page. When text_view reaches its top, it asks for the page before the oldest message held. One request per channel is in flight at a time, and it is sent again after 3 s.
  • A client shows only the contiguous run that ends at its newest message. If the room's head stays ahead of that run for 2 s, the client asks for the newest page again. The relay re-pushes each participant's conversation heads every 5 s, so a lost DM push is noticed too.

DMs and permissions

  • Who can post: a participant, only as the pid its connection holds. The relay stamps the sender's pid and name.
  • Who can read a DM: only the connections that hold its two pids. Nothing about a conversation is in the shared tree.
  • What the relay refuses (reported in the sender's chat.error): empty or over-long text, a DM to someone absent or to yourself, more than 64 conversations, and posts over the rate limit (a burst of 10, refilled at 2/s). With --bind-writes off, DMs are off.
  • Limits: DMs are not end-to-end encrypted, conversations last only as long as the pid's session, and history does not survive a relay restart.

What changed

  • Relay and model: room_chat.h/.cpp, with room_chat_relay (in arisrv, with stats in the room-debug log) and room_chat_client. The new DSL verbs are chat-post, chat-info, chat-messages, chat-more, chat-conversations and chat-rev. arigl and the example host set the shard's transport, so the chat messages leave.
  • Transports and gate: push_snapshot_to_holder on WS and gRPC, and the gate's chat rule.
  • Widgets: text_view: and message_input: in the core, ImGui and FTXUI. tvision draws FTXUI's widgets. In ImGui, text_view draws only the lines in view. It follows new lines, keeps its place when older lines are added above, and with height 0 fills the window less what is under it. message_input sends on Enter, takes Shift+Enter for a new line, keeps focus, and grows to max_lines. In a terminal, a new line is Alt+Enter or Ctrl+J. arigl on a phone: UI size, windows in view, the system keyboard #967's phone keyboard covers message_input too, since it keys off ImGui's IME data.
  • Components: components/chat.ari (units chat and chat_panel, plus chat-ui-* functions) and components/room_users.ari (the conference's Users window, now with a message button, plus room_users_compact and room-users-step). Both are listed in INDEX.ari. conference_roster.ari is built from them, and Ariadne: a closed peer camera window comes back from the View menu #962's camera-window state still follows the person. The browser page embeds the component library.
  • Docs: ARIADNE.md §5.15 (the widgets), §5.16 (the chat verbs and components) and §6.5. arigl snapshot now stops at the frame where the document quits, as ari's does.

Testing (Windows: native, and the browser page in Chrome)

  • New tests:

    • room_chat_test (14): relay rules, privacy, pagination, a late joiner paging back, lost-push recovery, epochs, the DSL verbs.
    • WS and gRPC *PushToHolder* and *TtlZero* tests.
    • Loader, runtime and FTXUI widget tests.
    • cvcgl_imgui_chat_widgets: keys, Shift+Enter, focus, the wheel to the top, prepend anchoring, the fill height.
    • ari test src/ari/tests/chat_component.ari (10), as ctest ari_chat_component: the components' DSL with the room verbs stubbed.
  • Existing suites on merged master: ariadne_loader 214, ariadne_runtime 250, ariadne_ftxui 79, room_intrinsics 15, state_transport_ws 42, state_transport_grpc 48, room_relay_integration 16. All pass.

  • End to end: src/arigl/tests/chat_two_clients.sh runs a local arisrv and scripted arigl clients over gRPC, each drawing the shipped Chat and Users windows offscreen:

    • alice posts 40 messages;
    • bob joins after them all and pages back through all 40 (the first view, then one request);
    • alice and bob exchange direct messages;
    • carol, who joined with bob, checks she was pushed none of them.

    All three report OK, and a fourth client on the real conference_roster.ari shows the Chat window with the history.

  • In the browser: the conference page built for wasm from this branch, a local arisrv over WebSocket, and headless Chrome clients driven through DevTools (trusted mouse and wheel events; text through the page's system-keyboard queue), on the real conference document:

    • alice typed into the Chat window: one message, then 40 numbered ones. Each came back from the relay and showed, and the field cleared and kept focus.
    • bob joined after them. His first view showed the newest page (to message 40). Wheeling to the top fetched the older page, back to "the start of the room's chat": two page requests in all.
    • bob opened a conversation from alice's "msg" button and sent a DM. alice's Users window showed "1 new" by bob. She opened it and replied, and both see both messages.
    • carol, who joined after the DMs, had only "Room" in her channel list.
    • The relay counted 43 posts (2 direct), 3 pages, nothing refused or dropped. No console errors.
  • Fixed from the browser run: in a 1600x900 browser window the canvas is 729 px tall, and the 420-px Chat window put its message field below it. It is 320 px now, and the Users window's message column no longer clips "1 new". Both were checked again in a relinked browser build.

  • Not fixed here: the browser page lays its windows out against arigl's starting 1024x768 render window, before the canvas takes the page's size, so on a smaller canvas the "opens inside the view" rule (§5.8) never moves them in. That holds for every window in the document (the Avatar window is cut off too), and it is a separate fix.

@transfix
transfix marked this pull request as ready for review November 2, 2026 07:14
# Conflicts:
#	docs/ARIADNE.md
#	examples/ariadne/documents/conference_roster.ari
#	inc/cvc/ariadne/widget.h
#	inc/cvc/state/state_transport_grpc.h
#	inc/cvc/state/state_transport_ws.h
#	src/arigl/main.cpp
#	src/arisrv/main.cpp
#	src/cvc/CMakeLists.txt
#	src/cvc/ariadne/components/INDEX.ari
#	src/cvc/ariadne/loader.cpp
Tried in cyprty (headless Chrome, two and three clients through a local
arisrv): at a 1600x900 browser window the canvas is 729 px tall, and the
420-px Chat window put its message field below it. 320 px keeps it on
screen. The Users window clipped "1 new" beside a person's message
button; the message column takes 12 px from the down and up columns.
@transfix
transfix merged commit dded8e5 into master Nov 3, 2026
29 checks passed
@transfix
transfix deleted the feat/ariadne-chat branch November 3, 2026 01:39
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