Clone
27
Working notes
Jaroslav Beneš edited this page 2026-11-24 13:52:18 +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.

Working notes

Read this before changing anything. Each rule has its reason, because a rule without one gets "simplified" away by the next person who does not know what it prevents.

Hard rules

  1. Never built on a machine that cannot run it. GitHub Actions builds and tests every push (ci.yml) and every tag (release.yml). Locally: the scripts, ktlint, and reading.
  2. No Google Play Services, Firebase or any proprietary SDK. The app must build for F-Droid as it is, and run on a phone without Google. Notifications are UnifiedPush for that reason.
  3. The server's contract is pinned, not assumed. contract/ is the server's tests/fixtures/api_v2/ at a named ref (scripts/fetch-contract.py), and ContractTest parses every file with the app's models. Moving the pin is how the app learns the server changed; a model that drifted fails a test, not a phone.
  4. Model output is untrusted. Markdown is rendered by Markwon with no image loading and no HTML plugin, and a link opens outside the app, in the browser, for http, https and mailto only (ui/Markdown.kt). The server's rule, kept on the phone. The file viewer (ui/viewer/) keeps the same rule for a show card's file and for a file of the person's tree (which a model may have written), and never renders HTML: there is no WebView in the app, so a page a model wrote is shown as its source, and "Open in the browser" hands it to the web UI's sealed frame. A picture the instance generated (image_generate's image {id, width, height}) is drawn by ui/chat/GeneratedPicture.kt alone: fetched by attachment id from /api/v2/attachments/{id} with the token, never from a URL, size-capped and downsampled. Markwon still loads no image. Code is coloured by the app's own scanner (ui/Highlight.kt: comments, strings, numbers, keywords, types, tags), which only reads the text and falls back to plain -- no highlighting library, no WebView.
  5. Nothing from the account shows on the lock screen. The assistant's sheet may open there; sending asks Android to unlock first (AssistActivity), and notifications are VISIBILITY_PRIVATE, with a public version that says only the app's name and a fixed sentence (a scheduled task's names nothing of the task; the server's public is not used). An action that acts on the account from a notification (Allow once, Deny, Run again) needs the phone unlocked. The file manager and its viewers are pages of the main activity, which never shows over the lock screen, and a transfer posts no notification. Generated media's cards and players are drawn only where a chat's own screen provides LocalChatMedia; the assistant's sheet, which may be over the lock screen, must never provide it. The copies of files the phone holds for a viewer or another app are in the private cache and are cleared at sign-out. No new request with the account's files starts while the phone is locked or the app is not in front (InstanceGate, one for the process, LembasApp.gate): a queue of uploads, the copies for Share and Open with, the share sheet's sends, a viewer's or a player's copy each call gate.pass() before every request. The request under way finishes (the person started it); the next waits and goes on by itself, and the dialog says it is waiting (Transfer.waiting). Anything new that sends or fetches in a loop, or from a coroutine that outlives the screen (viewModelScope), asks the gate before each request. A viewModelScope does not stop when the phone locks; that is why the gate exists. A reply nobody asked for from the screen is followed only while the gate is open (ChatViewModel.follow(own = false), InstanceGate.whileOpen): when the gate closes its stream is let go, and on the return one read catches up and follows what is being written then. Only a reply the person started from this screen (own = true: send, edit, regenerate, continue, execute) keeps its stream behind the lock -- the request under way -- and even that one's follow-ups wait at the gate: a broken stream opened again (StreamClient.follow(turn)), the read after done with a next, the read after a close without done. Anything new that chains a request onto a stream's end waits with gate.passLater(), which sleeps until the gate is told of a change; pass() looks at the lock every second and is for waits a person is watching. The events route itself is opened, and opened again, only at the gate (LembasApp.eventFrames), and collected only from repeatOnLifecycle or a resume effect, never from a scope that outlives the screen.
  6. The token is sealed with an AES key in the Android Keystore (auth/Instances.kt) and the app's data is excluded from backups: a copy would be ciphertext nobody can open.
  7. No colour outside the theme. ui/theme/Tokens.kt is generated from the server's tokens.css (scripts/fetch-tokens.py); dynamic colour is off so the app looks like the web UI beside it.
  8. Nothing private in the repository. It is public. scripts/hygiene.sh runs in CI and fails on a private domain, a .lan name, a private address or a machine's name.

The flavour rule

The server's: Middle-earth in the empty states and loading lines, never in a button. "New chat", "Archive", "Allow once".

Strings

scripts/strings.py is the English. scripts/gen-strings.py <server-ref> writes values*/strings.xml from the server's catalogues at that ref -- the same ref the contract and the tokens are pinned to, never the server's shared working tree: a sentence the server's catalogue already has is taken from it, so the phone and the page word "Archive" the same; the app's own sentences come from scripts/strings_own.json. A missing translation falls back to English. Add a string by adding it to strings.py, translating it in strings_own.json, and running the script; --check (CI) fails on a key the code uses that has no English, and on English nobody uses.

A server sentence with placeholders is written %(n)s there and %1$s here, so it does not match by its English. Name the server's own English in strings.py's SERVER_ENGLISH and the script takes its translation, numbering the named placeholders in the order the English names them.

Interfaces line up by construction

The tree's rule holds in Compose as in CSS: a row whose parts have unknown sizes gets a shared track (weight, a Row with one part designated to give), and a tap target is 48 dp. Prove a layout on a real phone at its narrowest; the emulator's default is not a phone.

Every screen is drawn from its state alone, so the screenshot tests can draw it: a new screen gets a …Content(state, actions) composable and a shot in shots/ScreenShots.kt (see Design › Looking at the screens). Look at the shots -- light, dark, 360 dp, large type -- after every design change, before a phone.

Things that will bite

  • /* inside a KDoc opens a nested comment in Kotlin. contract/*.json in a doc comment made the rest of Models.kt a comment; ktlint caught it as "unclosed comment".
  • A UnifiedPush VAPID key must be 87 characters (the uncompressed point, base64url); the connector throws on anything else. The server's key is that shape.
  • TileService.startActivityAndCollapse(Intent) throws on Android 14+; the PendingIntent overload is the one to use.
  • Re-installing the app over adb resets the default assistant on some phones (seen on Android 16): choose it again in Settings.
  • A server is told apart by its device-link protocol, not its version. The app needs protocol 3 (LLeMbas 2.0; api/Compat.kt). The version string is no good for this: the server's dev says 1.7.x until its first beta.
  • show cards come with app API 2. /api/v2 copies only the tool-event fields in serialise.py's TOOL_FIELDS; show is one of them from app API 2, and the contract carries tool_show.json. The file's text is GET /api/v2/chats/{chat}/show?node=&version= or ?shown= (plain text, at most 1 MB; 413 too large, 415 not text, 404 out of reach). The app refuses a server whose app API is not 2.
  • Debug builds are signed with a public test key, app/test-debug.keystore (passwords android, alias androiddebugkey). A runner makes a new debug key each run, so without it no test build installs over the one before. It signs only the .debug application id; it is not a secret and must never sign a release.
  • GitHub release assets can answer 504 for minutes at a time. CI takes ktlint from Maven Central (ktlint-cli-<v>-all.jar), hash-pinned: it is the same jar the signed GitHub binary wraps after a shell header. A ktlint update checks that again before moving the hash.
  • The activity panel follows /activity/events, which closes itself every ten minutes: StreamClient.watch opens it again at once, and only while the chat is on screen (repeatOnLifecycle). A frame carries the strip's counts and a version; the panel reads GET /activity again only when the version moved. Elapsed time is counted on the phone from the read, because version leaves the seconds out on purpose.
  • A model's picture is fetched only from the instance's own /api/v2/models/images/ (ApiClient.modelImageUrl), with the token, at most 2 MB, decoded small. Anything else in the list's image is ignored and the initial is drawn.
  • The system's default speech recogniser is LLeMbas's own while LLeMbas is the digital assistant. Voice input › Phone must therefore never call createSpeechRecognizer(context) without a component: it would hand the audio straight back to the instance. PhoneRecognizer takes the on-device one or another app's.
  • A language is added in gen-strings.py's LANGS and in AppLanguage.LANGUAGES (named in itself); LanguageTest fails until both, the values-* folder and the locale config agree.
  • A failure is shown through ui/Errors.kt's explain(): the server's sentence for a refusal, one "cannot be reached" sentence for a network that is not there. Never e.message straight to the screen.
  • A re-pin breaks tests that hold a fixture's values, not only ContractTest: CI runs 30 and 36 failed on SubagentsTest (the agent chat's facts) and ScheduleContractTest (the schedules frame's version, a hash of the list). Grep app/src/test for the changed fixtures' names and values before pushing a pin.
  • contract/harness_*.json are the harness spec's conformance cases from the server's copy of the spec (src/lembas/harness_spec/conformance/), pinned with the fixtures by fetch-contract.py; ProgressTest draws harness_progress.json with the English resources.
  • -- inside an XML comment fails the resource compiler (aapt: "The string "--" is not permitted within comments"), so no -- dash in a layout's or the manifest's comments. CI run 61.
  • The wake-word engine is not in the repository. scripts/fetch-wakeword.py fetches it (hash-pinned) before Gradle; a local full build without it fails on the missing AAR.
  • Three variants, not two flavours: fullStandard, fullNotifications, fdroidStandard (assembleFullStandardDebug, testFullStandardDebugUnitTest, …). Only src/notifications/ may declare or contain the notification listener; scripts/check-apk.sh fails CI and a release otherwise. See Design › Distribution.
  • An asset the native engine opens must not depend on how the APK stores it. AssetManager.openFd throws on a compressed asset; copy by stream. And never runCatching { … }.getOrNull() around something whose failure a person needs to see: the wake word did not work on any phone for a whole beta because of that pair.
  • The wake phrases' pieces are generated (scripts/gen-wake-phrases.py, needs the sentencepiece pinned in scripts/wake-requirements.txt, in a venv). A piece the model does not know ends the process inside the engine; CI checks the table twice.
  • A number in a keywords line or a duration is formatted with Locale.ROOT; the phone's locale would write a decimal comma. A number a person reads (localeNumber) is the opposite: the phone's format, and Locale.ROOT there means the spec's plain format for the tests.
  • A page in an answer is never drawn and never dumped. No WebView (rule 4); an html-view fence, the server's [page: Title] line and a page step are all PageCard. Anything new that shows or copies a reply's text goes through splitFences / pageProjection.
  • Names in fixtures and fakes are made up. Nothing seen in a screenshot or a message from the owner -- a machine, a host, a path, a task's name -- goes into code, tests, the changelog or a commit; scripts/hygiene.sh runs before every push (a local hook refuses otherwise).
  • A report's notification shows the report only when unlocked. The public version is the app's name and "New report"; ReportNotificationTest reads both faces.
  • Display follows the harness spec (display.md, 3.7.0): api/Display.kt has the title cut, the call states and duration, the end line of a stopped or failed reply, and locale numbers.
  • Phone actions drive OsmAnd through osmand.api:// URIs only. Its AIDL API's classes are GPLv3 (the OsmAnd repository); copying them would change this app's licence.
  • A UI string that names another UI string's words (phone_actions_line says "Do it") must change with it, in every language.
  • A list that is written into follows only for a person at its end (ui/chat/Follow.kt, FollowTest): the chat's transcript and the assistant's sheet. Nothing scrolls to the end without asking movesToEnd -- an unconditional "to the end when the rows change" is what threw a reader down on an older page, a queued turn and a rotation. A finger on the list ends the following; where it comes to rest (within a slack) says whether it is taken up again. Only the person's own scroll can end it (restFollows): a rest is theirs after a finger, or when the list went back towards its start (wentBack: a wheel, a key, a screen reader). The app's own scroll to the end, left short of it by something that arrived meanwhile, must never read as "scrolled away" -- that is the web's clamp bug in Compose's clothes. Every scroll the app makes goes through ownScroll(own) { … }, which counts it: a scroll under way that the app did not start is the person's (personScrolls, scrollWasPersons), whatever moves the list -- a wheel, a key, a screen reader have no DragInteraction. Rows that arrive while the person scrolls do not move the list (movesToEnd(…, personScrolling)); a bare list.scrollToItem outside ownScroll would be taken for the person's and could end the following.
  • A reply's row does not change height when the reply ends: the pulse of a reply being written stands in the finished foot's place (FootTop, FootHeight in Transcript.kt, an icon button's 48 dp). Change one and change the other. A picture's place has its shape from the size the server said before its bytes are there (pictureRatio); a tile is a fixed square.
  • What the list's position rests on, and what was never measured on a phone: rows are keyed by message id, and a reply is one row under one key while it is written and once stored, so the list holds whatever row is first on screen where it is. Inside one tall reply nothing holds a line: a chip that folds or a block that grows above the line being read, in the same reply, moves it. Nobody has measured the transcript per frame on a phone as the web's was.
  • Every request that can start a reply declares client (ApiClient.CAPABILITIES): create, send, edit, regenerate, continue, plan/execute. A new route that starts one declares it too; ClientTest lists them.
  • The system recogniser follows the lock (recogniseWith): unlocked it is the instance's speech-to-text; locked it is the on-device recogniser or ERROR_RECOGNIZER_BUSY, never the instance, and a recording finished on a phone that locked meanwhile is dropped.
  • Every speech request says which chat it is for (MediaFor, server 2.0.0-beta.15): chat_id for a chat that exists, else chat_model with the model the next chat starts on (ChatState.mediaFor, the assistant's mediaFor()), never both; the system recogniser (another app's dictation) says neither. A new caller of transcribe or speech passes one. That the default answered for the chat's own (X-Lembas-Fallback) is said in the chat screen only, once per kind (mediaFellBack) -- never in the assistant's sheet, which may be over the lock.
  • Transcript state is changed by reducers on ChatState (withOlder, closedUnfinished), tested in ChatStateTest: rows are keyed by id, so anything that adds rows adds each once.
  • A reply is drawn by one AssistantMessage call, live or finished, and a thinking chip is keyed by its step's place: two call sites, or a key that holds step.open, fold away what the person opened.
  • /events is followed in three places, on one shared connection that is open while any of them watches: the Scheduled list (schedules), the drawer's model while the app is in front (reports, ChatsState.reported; reply, the list read again), and the chat on screen (reply).
  • A folder on a linked computer is chosen with ui/DirectoryPicker.kt (a new agent chat, the schedule form): a listing with a code is no listing, and the typed path stays -- it is the way in that always works. Anything new that needs a device's folder uses the picker.
  • The folder's usual model is shown, never sent and never kept (ChatState.start, folderModel): model goes on create only when the person picked one; the instance asks the device itself.
  • A schedule's type is runs_on, and a save says it only for what the form knows (whereToSend, as notifyToSend): a form that could not read the schedule must not move it to the server, and a Chat schedule left alone is sent nothing.
  • The composer's @ reads the word the text ends with (ui/chat/Mentions.kt), not the cursor: the field is a plain string shared with dictation.
  • A chat's, a reply's and a schedule's model is looked up by model_ref where there is one (serving, named(name, isRef), ChatState.modelInfo, replyModel, saidWithConnection), and by it alone: a ref the list does not have is no model, never "the first with that id". Anything new that shows such a model goes through these, not through named(id).
  • A file's bytes are asked for with the token in the Authorization header, never in an address. The platform's player reads through RemoteMedia (a MediaDataSource over ApiClient.rawBytes); do not hand MediaPlayer, an intent or another app a URL of the instance. Another app gets a copy from the private cache through the FileProvider.
  • Nothing a file holds is rendered or run. The tree's viewer (TreeViewer.kt) draws text, pixels the app decoded with a size cap, and the platform's own PDF pages. An SVG and an HTML page are their source; a notebook's HTML and picture outputs are dropped (parseNotebook).
  • The text being edited lives in EditViewModel, not in rememberSaveable: a megabyte does not fit what Android saves of a screen, and unsaved words must survive a turn of the phone.
  • Two hosts of one TransferViewModel would each open the other app: the Files page and the viewer each have their own (viewModel(key = "viewer-transfers")).
  • A re-pin's new fixture fields break tests that copy a fixture and change one field (schedule.copy(model = …) kept the fixture's model_ref): change both, or neither.
  • A model's interactive_only is parsed and not drawn: the web's own model pickers do not mark it either. Schedules take their models from /schedules/models, which never lists one.
  • A file's bytes are named by Raw (a path, a version of it, a node id, an attachment) and asked for through ApiClient.raw. A generated file is asked for by its node id, which outlives a rename. An attachment is answered whole (no Range): the player gets a cache copy (MediaBody), never RemoteMedia.
  • An open chat learns of a reply it did not start from the events route's reply frame (ChatViewModel.watchReplies, ChatState.asksFor, ReplyEventTest; contract/event_reply.json). The server says every reply that starts, the app's own too, so the frame is news only for the open chat and a reply that is neither followed nor drawn as finished. News is taken up once nothing of the screen's own is being written (a queued turn comes by the stream's next anyway): the chat is read (rereadAndFollow, one at a time behind a mutex) and what it says is live is followed -- the read's word, not the frame's. follow does nothing for a reply it already follows; without that the frame for the app's own reply would start its drawing over. Each return to the front reads the chat once before listening: a reply that started and ended meanwhile is said by nobody. Both wait at InstanceGate. An instance without the frame costs that one read and nothing else. Reads of the transcript for news go through Reads (rereadAndFollow): whoever learns something takes reads.mark() at that moment, before any wait, and a read that began after the mark and answered stands for it. A burst of frames, or the return read and a let-go reply's catch-up, is one request. The return read runs beside the listening, not before it, so a reply that starts during it is heard; what is heard is checked against what the read found (asksFor, asked again inside the lock) before anything is read again. The frame with live: false is also a reply's end (an instance that says the ends sends the same frame again when a reply ends). For the open chat asksFor already makes it cost nothing when the reply was followed to its done or is drawn as finished.
  • reply is a moment, not a state (EventsHub.MOMENTS): the hub tells a late watcher the last schedules and reports, never the last reply. A new kind of frame on /events is one or the other; decide it there.
  • The drawer's list is merged by id (ChatsState.withNewest): the newest page's rows first, then every row held that the page does not name, in its order. Never by position: a chat that comes up from a later page is not a prefix of the old list, and cutting at "the last row the page names" dropped every chat in between. A held chat that changed after the page's last one did and is not in the page is gone on the server (the list is ordered by updated_at).
  • The list is read by itself only while the drawer is open (ChatsViewModel.shown, readsFor), through Soon: a trailing pause with a longest wait, and a read under way is never cancelled by the next frame. A start in a chat already shown as running reads nothing (every reconnection of /events says all live replies again). A frame with live: false clears the row's running mark and marks it unread, with no read (ended) -- not unread for the chat on screen (ChatsViewModel.open).
  • A message that waits is Message.waiting (api/Display.kt: a person's message with queued true -- Queued behind a reply, Unsure for origin unsure, Carried for carried; an origin the app does not know waits as a queued one). It says how it waits under its bubble (the server's sentences for the two origins, never the queue's progress line) and has Send now and Discard there -- only where UserMessage is given the two callbacks, which the chat's own screen does and nothing that may be over the lock screen ever should. It is never offered Edit (Message.editable): the instance refuses that. The two actions are WaitingActions (ui/chat/Waiting.kt, WaitingMessageTest): one at a time (ChatState.acting); a send reads the chat once and follows the reply it started as the person's own, unless the read no longer holds it (followedAfterSend: a computer that still knew the message does not run it twice and the reply's row is removed); a 409 or a 404 (staleWaiting) is said in the instance's words and the chat read again once nothing is being written on the screen -- never beside a stream, where a stale row could be drawn over a finished one. sendWaiting declares client like every request that starts a reply.
  • Whether an instance says the ends is learned, not assumed (ReplyEnds: a live: false for a reply it had said with live: true). Until then, and for instances that never do, watchRunning reads the list again at a bounded rate (runningPause: 5 s doubling to a minute) while a row shows running and the drawer is open and in front; once proven, never. An end frame missed while /events was down leaves a mark until the drawer opens again.
  • There is still no stream frame for a media job. watchMedia polls while the screen is in front, each request at the gate; a job's told turning true makes the chat read itself again (woke), through the same rereadAndFollow as the reply frame, so the two cannot follow one reply twice. How often a finished job was asked whether it told the chat is kept on the model (toldWaits), not in the loop, or every return to the screen would start it over.
  • A transcript read again goes through ChatState.withNewest, never copy(messages = read.messages): the newest page replaces only itself, and the older pages a person loaded stay above it. Replacing them takes the row being read from under the reader. Only a compaction, which rewrites the transcript, reads it whole (refresh(whole = true)). The kept pages need no reconciling as the server is: it only ever removes a transcript's tail (a rewind, an edit) or a queued prompt, and a page that still joins the rows above it proves they are older than anything removed; the answer carries no count or marker to compare. A server that learns to delete or rewrite a row in the middle must say so in GET /chats/{id}. A transcript left open is held to a size (ChatState.capped: past 600 rows the newest 400 stay and "older" is offered), only under a person at its end (ChatActions.reading).
  • A turn nobody typed is Message.byMachine (machine, or origin harness): a MachineNote, never the person's bubble. An empty finished reply after one, in an agent chat, is the server's one line (replyUnrecorded); a reply still being written is never that -- by the screen's own knowledge of which reply is live, not only by the row's complete, which reads as true when a server leaves it out -- and neither is one that holds a plan.
  • The model lists are narrowed where they are read (ApiClient.modelList, agentModelList: capability chat only). A picker fed from anywhere else narrows with forChat() itself.
  • gen-strings.py --check reads keys as [a-z_]+: a key with a digit (media_model3d) is "used but not in strings.py" under its first letters. No digits in a string's key.
  • Only a page of the instance is opened for a sign-in (signInAddress): the address the list names is taken as it is on the instance's own origin, and as its path on the instance otherwise. Nothing with the app's token in it is ever handed to a browser.
  • A new file is made by ApiClient.newFile: it reads the directory and refuses a name it holds, then sends create: true. Both, on purpose: create is the instance's own check (and its sentence), the reading is for an instance from before create, which ignores the word and would empty the file. Never call saveFile(path, "") for a new file.
  • A share's addresses are the other app's word (share/SharedSource.kt). Only a content: address is taken, never file:; never one of this app's own providers (the FileProvider's .files authority and whatever the libraries declare); and what an address opens is looked at through its descriptor (/proc/self/fd), so one that leads into this app's data is closed unread. Every file of the phone that is uploaded is opened with SharedSource.open -- the pickers' too -- never with contentResolver.openInputStream. The share sheet lists each file by its provider's name and size, and asks the instance nothing (not even where Files opens) before the person has chosen where it goes.
  • A copy another app was handed goes by its age alone (FileCache.SHARED_KEPT_MS, an hour): the other app may still be reading it when the screen closes or the process starts again, so neither deletes it. Sign-out and a switch of instance delete everything. A viewer's own copies (viewing/) are nobody's at a start and go then.
  • FileKinds.safeName caps a name in UTF-8 bytes (200), not characters, and keeps the extension: a file system counts bytes, and a name in another script is three a letter.
  • A name the server said as a model_ref is looked up with named(name, isRef = true): an aggregator's model id may be spelled like another connection's ref, so a ref whose model left the list must not fall through to "the first with that id". The state that keeps such a name keeps how it was said (AssistUiState.modelIsRef, EditState.modelIsRef); the model picker is handed the row in use by its caller and looks nothing up. Plain named(name) is for a name of unknown kind only: a setting, a pick.
  • PdfPages.close() waits for the page being drawn, which cannot be stopped: from the main thread call closeLater(). A renderer made in a coroutine is held in a local too, so one finished after the viewer closed is still closed.
  • ApiClient.download cancels its call when its coroutine is cancelled: a read that waits for the server hears nothing of a cancelled coroutine. Anything new that reads a body in a blocking loop does the same.
  • "Open in Files" asks where the node is now (GET /files/node?id=, whereabouts): its folder today, "in the trash", or -- from an instance without the route (noSuchRoute) -- the folder it was written to. An archive's entries come in its content answer (archive) and are drawn as text (ArchiveBody); nothing is unpacked on the phone.
  • A file an agent showed is media with shown (contract/tool_media_shown.json, ShownMediaTest): no show card, no attachment, drawn by MediaCard where generated media is. kind is then the file's own (image, audio, video, pdf, model3d, archive, binary, text, or a word the app does not know). A shown file is never nothing: every card names the file, says its kind in words (mediaKind(kind, shown): an unknown kind is "File") and has Open in Files, Download, Share and Open with -- also a picture, whose name stands under it, because a picture this phone cannot decode is otherwise an empty box. A new kind gets a word in mediaKindWord, an icon in mediaIcon and, only if the phone can draw it, a MediaView. A PDF is MediaView.Document: Open lays its pages out over the chat (DocumentDialog, PdfBody(Raw, …), by node id). A 3D model has no viewer here.
  • An edit's diff is worked out on the phone (api/Diff.kt, ui/chat/DiffCard.kt) from the card's diffs (contract/event_ask_edit.json): both texts are a model's and a file's words of up to 2 MB, so every bound is applied before the work it bounds, and the work is done off the main thread (diffViews: Dispatchers.Default, one file after another; at once only in a screenshot). A text is cut to DIFF_TEXT_LINES and DIFF_TEXT_CHARS before it is split (textLines; the block then says it was cut); the middles are compared only up to a million line pairs (past that: old removed, new added); one file's diff is one plain Text of at most DIFF_MOST lines of DIFF_LINE_MOST characters, folded to DIFF_FOLD. The lines scroll sideways in their own box; the card (a sheet that scrolls down) never does. Nothing in a diff is rendered or highlighted. The card is where a person decides, so: lines are compared without the \r before their newline and a change of line endings is one sentence; whatever cannot be seen or would move or break a line (bidi controls, zero-width characters, U+2028, controls) is written as its code point in a line and in a path (visibly); and an item's detail gives way to its diffs only when they say something (showsDetail).
  • A picture in a reply waits at the gate (Pictures.load, passLater), like every other fetch of the account's files. The assistant's sheet is no activity: its session tells the gate when it shows and hides (InstanceGate.sessionShown / sessionHidden), or nothing gated would ever load in it. Anything new that draws outside an activity does the same.
  • "Open with" never takes the instance's word for a type (Handover.view, openType): the copy's first bytes (sniffType), else its name's extension, else */*; for a zip a known extension wins, because many documents are one inside.
  • Parsed and drawn nowhere (the editor round's pin): a device's files, files_writable, files_that_run_code; EditorModels (GET /editor); the device_fs_* shapes have no model at all yet. There is no browser for a linked computer's files and no editor settings screen.