From 14710689010f00ec5522f70dfb69460ba663d8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Thu, 19 Nov 2026 07:38:54 +0000 Subject: [PATCH] Working notes: the lock gate, a share's addresses, kept copies, refs, the PDF renderer Co-Authored-By: Claude Fable 5.2 --- Working-notes.md | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/Working-notes.md b/Working-notes.md index f01f722..b4df7de 100644 --- a/Working-notes.md +++ b/Working-notes.md @@ -36,6 +36,14 @@ Read this before changing anything. Each rule has its reason, because a rule wit 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. 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 @@ -193,7 +201,7 @@ design change, before a phone. - **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`, `ChatState.modelInfo`, `replyModel`, `saidWithConnection`), and by it alone: a ref + (`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 @@ -226,5 +234,37 @@ design change, before a phone. - **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 with `create: true`**; the page does not check its listing for the name - (the listing may be old, and the sentence is the instance's). +- **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.