13
Design
Jaroslav Beneš edited this page 2026-11-19 07:39:03 +00:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Design

Shape

One module, Kotlin and Jetpack Compose, Material 3 coloured by the server's tokens. minSdk 29 (Android 10: the assist-data API and the Keystore features used here), targetSdk 36.

Package What
api/ Models.kt (the server's shapes), ApiClient (every call, with the token), StreamClient (the reply, reconnecting), LiveReply (applying frames)
auth/ InstanceStore (instances, the active one, preferences; DataStore) and TokenCipher (Keystore)
ui/ signin; home (the drawer and its list); chat (the chat page, transcript, composer, tune sheet, model picker, cards, activity panel); scheduled; files (the file manager); viewer (a show card's file, and a file of the tree by its kind); settings; theme; Markdown.kt and MarkdownSplit.kt
push/ UnifiedPush service, notifications, the approval buttons' receiver
assist/ the voice-interaction service, its session, the recognition service, AssistController and its sheet, the tile, voice in and out
share/ the share target
update/ the update check (ReleaseCheck, both flavours) and the self-updater (full only)

Screens

Shaped like the AI apps people already know, in LLeMbas's own theme:

  • The app opens on a new chat: Chat or Agent chat side by side (one line each, on a shared track), the model's picture and a greeting, four suggestions above the message box. A new agent chat with no computer linked shows the three steps to link one, each command with Copy, and Check again. A chat (or a new chat) is a top-level page -- opening one replaces the last, and Back leaves the app; Files, Scheduled and Settings open over it and Back returns.
  • The drawer (menu button, or a swipe from the edge on a chat page) holds everything else: search over the titles, New chat, New agent chat, Files, Scheduled, Archived (each archived chat opens as it is; Restore chat puts it back), then the chats in three sections -- Today, Earlier, Agent chats (ui/home/ChatGroups.kt, by the phone's day) -- and Settings with the account at the foot. It reads the list again each time it opens.
  • The top bar's title is the model: picture, name and a caret, the chat's title under it. It opens the model picker, a bottom sheet with each model's picture, what it can do and how it thinks. A new chat keeps every choice in its Draft until the first message makes the chat; an open chat changes at once.
  • The transcript: the person's turn is a bubble on the right (plain text, never markdown); the model's is full width with no bubble. Thinking and each round of tools are one chip each that opens; a show card stays in view. Fenced code is cut out of the markdown (splitFences) into its own block with the language and Copy; an unclosed fence is already a block while it streams. Copy, Read aloud (only when /api/v2/me says the instance has text-to-speech; one reply at a time, stopped when the chat is left) and Regenerate sit under a reply with its cost; a long press gives Copy, Select text, Edit or Regenerate (the markdown's TextView then does not select itself; Select text opens the words in a selectable dialog).
  • The composer is one rounded field: attachments as tiles above the words, and a row of +, Options (the tune sheet: Thinking switch or effort levels, the team's size, Plan first or the agent's mode, a new agent chat's device and folder -- only what the model and the chat offer), the microphone and Send, which becomes Stop. The microphone follows Settings › Voice input exactly as the assistant does (usePhoneRecognizer): the instance's speech-to-text (recorded, written down when the person stops) or the phone's recogniser (words into the box as they are said). The Options button sits in the row's one part that gives, so the icons keep their places at any width and type size.
  • Settings are grouped lists: a header, one rounded surface of rows, each row an icon column of fixed width, words that wrap, a control that keeps its size. Language opens a sheet: the account's language (the default), the phone's, then each language named in itself.
  • Spacing is on an 8 dp grid, every touch target is at least 48 dp, and every page is edge-to-edge with the system bars' and keyboard's insets.

Looking at the screens

Every screen is drawn from its state alone (ChatContent, DrawerContent, SettingsContent, ScheduledContent, ScheduleContent, ScheduleEditContent, RunContent, SchedulingModelsContent, and the sheets' contents), with its actions behind an interface whose methods do nothing by default. The screenshot tests (app/src/test/.../shots/) render each with made-up data (Fakes.kt, the server's contract files where they fit) on the JVM -- Robolectric draws, Roborazzi writes the PNG -- in Shire and Moria, at 411×891 dp and 360×640 dp, and the transcript at 1.5× type. CI keeps them as the run's llembas-android-screenshots-<run> artifact. They assert nothing: they are what a design change is reviewed from, by a person or by an agent reading the pictures. Test-only dependencies; nothing of it is in the APK.

A bottom sheet is a window of its own, so its content is shot over a dimmed page rather than as the sheet itself.

Scheduled

The phone's half of the server's scheduled tasks, on its /api/v2/schedules routes (api/Schedules.kt holds the shapes, ScheduleContractTest reads every contract file):

  • The list (GET /schedules): the rule in words (description), the last run's status or Running, the next run, a pause switch (POST …/pause, …/resume). While it is on screen the app follows GET /events, whose schedules frame is the whole list whenever it changes.
  • A task's page: Run now (POST …/run, 202 with the run; the next scheduled run is not used up), Pause, the next five runs, and the history (GET …/runs?before=&limit=): status, when, the model and the one it stood in for (model.switched_from), the first lines of the result (preview, plain text), the error or what it waits for and when it retries.
  • A run (GET …/runs/{run}): its facts and the result in full -- Markdown a model wrote, through Markwon's untrusted rules -- and Open its chat.
  • Create or edit in words: POST /schedules/compile answers a title, the instruction, the rule, the rule in words and the next runs (or ok: false and a reason); nothing is saved until Save sends them (POST /schedules with the words as request, or PATCH). An empty rule cannot be saved. Editing starts from the task's request.
  • Models for scheduled tasks (GET/PUT /schedules/models): the order they are tried, which are free, and a tick per model; all ticked is sent as no narrowing, and the last one cannot be unticked.

A push with kind schedule or schedule_failed carries ids, the run's status, visibility private, actions and ask -- never the result (server services/schedule/notify.py). ScheduledNotice reads it; it goes to the Scheduled results or Scheduled failures channel, VISIBILITY_PRIVATE with a public version that says only that a task finished or failed. A tap and Open go to the run (on the instance the push came from); Pause is there when the payload offers it (a failure; ask: pause after three in a row). A server without the routes answers 404, and the page says scheduling needs a newer server.

Files

The person's tree as a file manager (ui/files/), through the server's /api/v2/files routes and nothing else. FilesScreen.kt is the page and its FilesViewModel (the listing, what is chosen, one write at a time, uploads); FileDialogs.kt the smaller pages (a name, a yes or no, the folder picker, the trash, a file's versions); Transfers.kt and TransferViewModel.kt everything that leaves the instance for the phone.

  • A tap opens, a long press chooses. While anything is chosen a tap chooses too, the top bar counts, and the bottom bar acts on all of it through POST /files/batch -- which answers path by path: what it refused is shown in its own sentences (outcome), and the directory is read again either way. Each row's menu has the same actions for that one thing.
  • No path is typed. Move and copy (and the share sheet's "Save to Files") walk to a folder in FolderPicker; what is being moved is left out of its list.
  • An upload is one request a file, streamed from its content address (StreamBody): a 413 names the file and does not take the others with it.
  • A new file is never written over one: it is made with create: true, and where something has that name the instance writes nothing and its own sentence is shown (409 exists, FileExists). The page checks nothing itself.
  • Which bytes is one type, Raw (api/Media.kt): a path, one version of a path, a node id, or a chat's attachment; ApiClient.raw makes the request for any of them, and a download, a cache copy and the player all take one. A version is saved to the phone that way.
  • Leaving the instance. Download writes into a document the person chose with the system's "Save to" page (CreateFile, the Storage Access Framework); several things, or a folder, are the server's zip. Open with and Share hand another app a copy in the private cache through the FileProvider (cache/shared/, read-only, per grant). A copy goes an hour after it was written -- the other app may still be reading it when the screen closes or the app starts again -- and all of them at sign-out and on a switch of instance (FileCache). There is no storage permission.
  • The viewer goes by file_kind (ui/viewer/TreeViewer.kt, FileKinds.viewer): text kinds as text and editable (a save says the sha it opened; a 409 offers Reload and Save anyway); a picture decoded with capped edge and pixel count (sampleFor); a PDF by the platform's PdfRenderer from a cache copy; sound and video by the platform's MediaPlayer through RemoteMedia, a MediaDataSource that asks the app's own HTTP client for each piece (RangeReader); a table as a grid of fixed columns; a notebook as its cells' text; the rest as its details. An SVG and an HTML page are their source.
  • Nothing is announced. A transfer shows its progress in the app and a short word when it is done; there is no notification, so nothing names a file on the lock screen.

Generated media

What a model made, in the reply (ui/chat/MediaCards.kt, MediaJobs.kt; the shapes in api/Media.kt; the server's App-API, Generated media).

  • A tool call's media is a card, always in view like a show card: a picture drawn (from the call's attachment where it has one, as before; else from the file by its node id), a video or a track as its name with Play, a 3D model or a kind the app does not know as what it is. Under each, four buttons of 48 dp: Open in Files (the Files page at the file's folder, the route files-at/{at}), Download (the "Save to" page), Share and Open with -- the same ways out the file manager has, through the chat's own TransferViewModel.
  • Play opens the player over the chat (PlayerDialog): the platform's MediaPlayer through RemoteMedia, asking /files/raw?node= for each piece. The file is asked for its first byte before the player gets it, so one that is in the trash says so in a sentence.
  • Sound and video the person attached are played from the message: /attachments/{id} answers a file whole, so the player gets a copy in the private cache, deleted when it closes.
  • A media_job is a card with what is made, its state, the time it has taken (counted on the phone between two reads) and Cancel (DELETE /media/jobs/{id}). There is no stream frame for a job. ChatViewModel.watchMedia runs while the chat's screen is in front (repeatOnLifecycle): the chat's jobs once (GET /media/jobs?chat_id=), then the ones under way every three seconds. A job that is done is drawn as its result's card.
  • A finished job wakes the chat with a reply this app did not start. Nothing else tells an open chat of such a reply (/events carries schedules and reports), so the job says it: when a read shows told that the read before did not, the transcript is read again and the reply being written there followed (woke, rereadAndFollow).
  • Only in a chat's own screen. The cards are drawn where LocalChatMedia is provided, which ChatContent does and the assistant's sheet does not: nothing of this is over the lock screen, and nothing here posts a notification.

MCP servers

Settings › MCP servers (ui/settings/McpScreen.kt) lists GET /mcp: each server's name, tools and how it is signed in to. A server in signed_out or needs_signin with a signin_url has a button that opens that page in the browser (a Custom Tab). The sign-in is the instance's own web flow on its cookie door: a browser that is not signed in to the instance is sent to its sign-in page first and then on to the server's. The app starts and finishes nothing, and its token is in no address: signInAddress opens only a page of the instance the app is signed in to. The list is read again when the page comes back to the front.

Reports and "notify when" (harness spec 3.8.0)

From LLeMbas 2.0.0-beta.12 a schedule's run does not answer into a chat: it files a report (the model's report_write), or leaves a line in the task's history. The phone's half (api/Reports.kt, ui/reports/ReportsScreen.kt, push/ReportNotice.kt):

  • Reports in the drawer with a count of the unread (asked for when the drawer opens: GET /reports?unread=1). The list (GET /reports) is sorted by the app -- unread first, then newest (sortedReports); pull reads it again; a swipe marks a row read (POST …/read) or asks once and deletes it (DELETE). A swipe never removes the row by itself.
  • A report (report/{id}, GET /reports/{id}) reads as a page: its Markdown through RichMarkdown, the chat's untrusted rules. Opening it marks it read. Share hands over the title and the text projection (shareText).
  • Reply (POST …/reply answers the chat's id; a report that already has a chat goes straight there) opens the ordinary ChatScreen on the route report-chat/{id} with report = <title>: the bar says Report: …, the navigation icon is Back, and leaving goes back to the report. The server keeps that chat out of the chats list; the app never adds it.
  • Notify when on the schedule form: notify always | when | never and notify_when (the person's words; empty means the default condition). notifyChoice reads what an older server called matters as when. The form shows and sends them only where the instance has the reports route (asked once when the form opens): an older server knows other values.
  • A task's runs show the run's note (else the old preview) and Open its report where report names one; the run's page has the same link, and still Open its chat.
  • The push kind: report: the words are in the payload's notification (title, body, importance); the payload's top says only the app's name and "New report". Channel Reports (reports_filed; the id reports was 0.1's and is deleted at start), VISIBILITY_PRIVATE with a public version of the app's name and "New report" -- nothing from the account. Open, and Mark read (setAuthenticationRequired). schedule and schedule_failed from an older instance go through ScheduledNotice as before.
  • An id that may come as a string or as an object carrying one (a report's chat, a run's report) is read either way (idOf).

A page in an answer is not drawn (pages.md; the owner's decision: no web view in the app). Which fence is a page is the server's to say: a text step with pages carries pages and text (each page the one line [page: Title]), a report likewise; the app draws that text (Step.shownMarkdown, Report.text) and splitFences turns the line into Segment.Page -> PageCard. An html-view fence the server does not list is an ordinary code block. Only the open step of a streaming reply takes the fence for a page (splitFences(pages = true)), so a page being written is not source scrolling by. The chat's settings offer no HTML switch, and a chat the phone has written into is offered no pages by the server anyway.

A report's conversation is a chat of kind report with report {id, title} and controls (what may be done to it). Its first row is the server's (role user, machine): drawn() leaves it out there, and draws any other machine user row as a quiet note (MachineNote), never as the person's bubble.

Ids from outside (a push payload, an intent's extra) pass safeId before they become a route. A push of an unknown kind shows nothing.

Signing in

The CLI's device login: discovery at /.well-known/lembas.json (the app refuses an instance with no app_api, and one with a newer app_api than it reads), a code for the scopes app models, the browser opened on /device in a Custom Tab, polling until approved. The token comes once and is sealed. Several instances are kept; one is in use, and switching it restarts the navigation for it.

The stream

StreamClient.follow reads the JSON server-sent events and, when the connection drops before close, opens it again after 1, 2, 4 … 30 seconds. Nothing is replayed or deduplicated: the server sends whole blocks, so the first pass after a reconnect is the state, and LiveReply.apply replaces fields. A 4xx ends it (the chat went, the token was signed out). done carries the finished row (it replaces the placeholder) and next, the reply the queue started, which the chat follows on.

What the reply is doing is one line under it (ui/ProgressWords.kt, api/Progress.kt): from harness spec 3.4.0 the status frame carries progress {phase, since, ...} beside its text, and the app draws {{text}} · {{elapsed}} with the spec's shared texts (string resources progress_*, the server's translations by the spec's English), the clock ticking each second and kept whole at the end while the text gives way (two lines, then an ellipsis). Stopped and failed are their text alone. A phase the app does not know, or one missing a field its text needs, falls back to the free status text, as an older server's does. ProgressTest runs the spec's own conformance cases against the English resources.

Subagents (spec 3.4.0) are Android's reduced list (ui/chat/SubagentList.kt, api/Tree.kt): the stream's tree frame, kept in ChatState.tree after the reply ends, and GET /chats/{c}/tree when the activity sheet opens. A row: name (id) — position, the state word, the progress text without the clock, context % (floored); the main agent first, ended ones after, dimmed. A subagent's row opens GET /chats/{c}/subagents/{id}/transcript read-only (ConversationDialog, re-read every 3 s while it has not ended). No findings and no Stop on Android, by the spec. With a tree, the Tasks section holds only the background jobs.

Cards

A sheet that cannot be swiped away -- the reply is stopped until it is answered. The answer is the page form in JSON (CardAnswer), so the server reads it through the page's own lines. A 409 is "answered elsewhere first" and is said once, quietly.

An approval's title is its heading (Run a command) and detail the thing itself (the command). An editable item's box starts with detail, and Allow sends it in texts[key] only when it differs (approvalTexts): an untouched or cleared box sends nothing, so the command the model asked for runs. job names a background subagent asking (explore asks:); subagent {id, name, position} a tree subagent asking for what nobody in its tree may allow (Subagent parser (s1), reviews the parser, asks:), said first.

Push

UnifiedPush 3: the app registers with the distributor the person chose (ntfy, or any other), giving it the instance's VAPID key, and hands the endpoint and its keys to /api/v2/push. The server sends Web Push to it with the code it uses for browsers. One registration per instance. Channels: Replies, Questions and approvals (high importance), Scheduled results, Scheduled failures (high importance), Reports; every one private on the lock screen. An approval's notification carries Allow once and Deny, both setAuthenticationRequired (Android 12+ asks for the unlock first); "always" and a corrected command need the card. A fifth channel, App updates (low importance), carries only the update check's notice.

Theme, strings and language

Tokens.kt from tokens.css (Moria and Shire); the theme follows the system unless chosen. Strings: see Working notes.

The app's language is the account's by default (/api/v2/me language, read once per instance in use and kept), so a phone in one language signed in to an account in another shows the account's. Settings › Language chooses the phone's or any the app has (AppLanguage). Android 13+: LocaleManager.setApplicationLocales, and android:localeConfig (res/xml/locales_config.xml, written by gen-strings.py from its LANGS) so the system's own per-app language lists the same set -- a language chosen there is adopted as the person's choice. Older phones: the tag in a small synchronous preferences file, applied in every activity's attachBaseContext and to the assistant's window. No AppCompat. LanguageTest holds the offered list, the values-* folders and the locale config equal.

Distribution

Two flavour dimensions, three APKs of one application id and one key. distribution: full (updates itself, wake-word engine) or fdroid (neither; F-Droid updates it and builds from source). reading: standard (no notification listener in the manifest at all) or notifications (the listener, for notification summaries). The variants are fullStandard (llembas-android-<version>.apk), fullNotifications (…-notifications.apk) and fdroidStandard (…-fdroid.apk); there is no F-Droid build with the listener.

The full builds update themselves from llembas.eu/android/latest.json -- SHA-256 checked, signer checked, then Android's installer -- and only to their own kind: the standard build takes url and sha256, the notifications build the optional notifications: {url, sha256}, and without one it installs nothing and says to take the file from the release page (it would otherwise lose its listener without a word). The release key lives in the CI secrets, never in the repository.

The update check (update/ReleaseCheck.kt, both flavours) reads the repository's public releases from api.github.com over plain HTTPS: no Google service, no account, nothing sent but the request. It runs on start at most once a day while Settings › About › Look for new versions is on, and on Check for an update. Versions sort as their codes do (1.0.0-beta.9 below 1.0.0; a -debug suffix is ignored; any other suffix is not a version and never offered); drafts never count; a pre-release or a -beta.N tag is offered only with Include betas. Both settings default to on in a beta and off in a release (Prefs.updateCheck / updateBetas null until chosen), which keeps a release build quiet for F-Droid. A found release is announced once (updateNotified), by a notification that opens its page; the full build may then install a release itself from Settings. Obtainium: see Installing.

Later

The wake word (see Assistant), browsing a device's folders for an agent chat, the library and @ mentions, canvas and prototypes, a widget, a tablet layout (the drawer as a permanent rail), an offline cache of the list, archived chats.