imsd-messages/AGENTS.md
Jorijn van der Graaf 6eea7228d0
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.

project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-11-18 01:12:27 +01:00

2.8 KiB

AGENTS.md — working on imsd-messages

For coding agents and anyone changing imsd-messages: what the repository contains, how it is built and tested, and the conventions a change follows. The README is for users. Where this file and the code disagree, the code is right and this file has a bug — fix it in the same change.

1. What imsd-messages is

An SMS app for Linux phones (postmarketOS on the Fairphone 6 first; Plasma Mobile and Phosh) whose transport is imsd's D-Bus object /net/catcrafts/IMS1 on the system bus: its net.catcrafts.IMS1.Messaging interface carries the texts, the subscriber's own number and the SIM's operator (GetStatus's ppi and operator), and the frozen net.catcrafts.IMS1 interface gives the registration changes. imsd receives texts over IMS and keeps each one it could store under /var/lib/imsd/sms/ until the app deletes it; the app subscribes to imsd's signals, imports the stored messages into its own database and deletes imsd's copy. The interfaces are documented in imsd's AGENTS.md §8.4 and §7.9 (Messaging) and §8.1 (the frozen one).

2. Repository layout

Path What it is
project.cpp The build description for Crafter.Build: four products (below) and the tests.
interfaces/ImsdMessages*.cppm imsd-messages-core: std + Crafter.DB, no GLib, no window — numbers, time, the model, word wrap, gestures, the store, the sync logic.
interfaces/ImsdMessages.Bus*.cppm imsd-messages-bus: GLib/GDBus — imsd's dictionaries, the client, notifications, the app's own bus name.
interfaces/ImsdMessages.Ui*.cppm imsd-messages-ui: the window on Crafter.Graphics, driven from the GLib main loop.
implementations/main.cpp The executable imsd-messages.
tests/<Name>/main.cpp One test per directory, declared in project.cpp.
assets/ The bundled font (Noto Sans, OFL 1.1).
packaging/ build-libevdev.sh: libevdev into a prefix.

3. Building and testing

crafter-build                 # the executable
crafter-build test            # every test
crafter-build lint            # the house-style rules (Crafter.LintRules)
crafter-build format --check  # what CI gates on

A test is an ordinary int main(): exit 0 passes. Tests link the core (and the bus library where they need GLib) and never need a bus, a phone or a GPU.

4. Making changes

  • Commit messages: subject area: what changes, the body says why; no AI attribution trailers; every commit GPG-signed with the repository's configured identity.
  • format, lint and test green before a push; every push goes through the fp6 project's /prepush gates.
  • Every source file starts with the two SPDX lines and a blank line.