Working notes, Design, Assistant, Release checklist
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed
+199
No files matched your search
+55
@@ -0,0 +1,55 @@
|
||||
# Assistant
|
||||
|
||||
## What the role is
|
||||
|
||||
Android lets one app be the **digital assistant** (Settings › Default apps › Digital assistant
|
||||
app). To be offered there an app must provide a `VoiceInteractionService` with a session service
|
||||
and a recognition service -- Android rejects one without both. LLeMbas provides:
|
||||
|
||||
| Component | Job |
|
||||
|---|---|
|
||||
| `LembasAssistService` | the service the system binds while LLeMbas is the assistant |
|
||||
| `LembasAssistSessionService` / `LembasAssistSession` | one invocation: a sheet over the current app |
|
||||
| `LembasRecognitionService` | speech-to-text through the instance (`/v1/audio/transcriptions`); any app using the system recognizer gets it while LLeMbas is the assistant |
|
||||
| `AssistActivity` | the same sheet as an activity: `ACTION_ASSIST`, the tile, the "Ask" shortcut, and the lock-screen path |
|
||||
|
||||
## How it is opened
|
||||
|
||||
| Way | Notes |
|
||||
|---|---|
|
||||
| Hold the power button | Pixel and most phones on Android 12+, when LLeMbas is the assistant |
|
||||
| Samsung side key | Settings › Advanced features › Side button › Press and hold › **Digital assistant** (Bixby otherwise wins) |
|
||||
| The assist gesture | swipe up from a bottom corner, where the phone has it |
|
||||
| Quick Settings tile | "Ask LLeMbas" -- add it from the tile editor |
|
||||
| Launcher shortcut | long-press the icon › Ask |
|
||||
| Lock screen | the sheet opens; sending asks to unlock first, and nothing from the account is shown before |
|
||||
|
||||
## The screen
|
||||
|
||||
`onHandleAssist` delivers the screen's text and `onHandleScreenshot` a picture -- only if the
|
||||
person allowed it (Settings › Default apps › Assist & voice input › Use text from screen / Use
|
||||
screenshot), and never from an app that marks its window secure. The sheet offers **Include
|
||||
screen**, off every time it opens; when on, the text goes with the question and the screenshot as
|
||||
an attachment.
|
||||
|
||||
## Why there is no wake word
|
||||
|
||||
The platform's always-on hotword -- the low-power detector Gemini uses -- needs
|
||||
`CAPTURE_AUDIO_HOTWORD` and `MANAGE_HOTWORD_DETECTION`, both `signature|privileged`: only an
|
||||
assistant built into the phone can hold them. No app installed from outside has a wake word that
|
||||
way; ChatGPT, Claude and Perplexity have none either.
|
||||
|
||||
## The wake word, later and opt-in
|
||||
|
||||
What is possible is the app listening for itself: a `microphone` foreground service running an
|
||||
on-device keyword spotter.
|
||||
|
||||
- **Engine: sherpa-onnx keyword spotting** -- Apache-2.0, runs on Android, any phrase without
|
||||
training. openWakeWord's pre-trained models are non-commercial (CC BY-NC-SA), and Picovoice's
|
||||
free tier ended in 2026; both are out.
|
||||
- **Android's rules:** a microphone service cannot start from the background, except for the
|
||||
app that is the voice-interaction service -- which LLeMbas is, when chosen. It cannot start at
|
||||
boot, so after a restart the app posts "tap to resume listening". It shows a permanent
|
||||
notification while it listens.
|
||||
- **Cost:** a continuous microphone and CPU inference without the hotword chip. Measured on a real
|
||||
phone before it ships, and off by default.
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
# 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`, `chats`, `chat` (transcript, blocks, cards, composer), `settings`, `theme`, `Markdown.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 self-updater (`full` flavour only) |
|
||||
|
||||
## 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.
|
||||
|
||||
## 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.
|
||||
|
||||
## 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), Reports. An approval's
|
||||
notification carries Allow once and Deny; "always" and a corrected command need the card.
|
||||
|
||||
## Theme and strings
|
||||
|
||||
`Tokens.kt` from `tokens.css` (Moria and Shire); the theme follows the system unless chosen.
|
||||
Strings: see Working notes.
|
||||
|
||||
## Distribution
|
||||
|
||||
`full`: a signed APK on the GitHub and forge Releases, which updates itself from
|
||||
`llembas.eu/android/latest.json` -- SHA-256 checked, signer checked, then Android's installer.
|
||||
`fdroid`: the same app without the updater, for F-Droid (metadata and a reproducible build are
|
||||
later). The release key lives in the CI secrets, never in the repository.
|
||||
|
||||
## Later
|
||||
|
||||
The wake word (see Assistant), agent-chat pickers (device, directory) in the app, the library
|
||||
and `@` mentions, canvas and prototypes, a widget, a tablet layout, an offline cache of the list.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Release checklist
|
||||
|
||||
CI proves the build, the unit tests and the contract. These need a person and a phone, and gate
|
||||
the tag.
|
||||
|
||||
1. **Sign in** by device code to an instance on 1.7.0 or newer; the instance appears in Settings.
|
||||
2. **The list**: Chats and Agents tabs, pull to refresh, swipe to archive (and it is archived on
|
||||
the web too).
|
||||
3. **A reply streams**: thinking, a tool call opened, the metrics. Lock the phone halfway, unlock:
|
||||
the reply is whole.
|
||||
4. **A card**: an agent chat asks to run a command; answer it in the sheet. Then again with the app
|
||||
closed: the notification's Allow once works, and the web page shows the card answered.
|
||||
5. **Notifications**: with ntfy installed, turn them on; a reply finished with the app closed
|
||||
arrives and opens its chat.
|
||||
6. **Share** a picture from the gallery: a chat starts with it attached.
|
||||
7. **Assistant**: choose LLeMbas as the digital assistant; hold the power button over another app;
|
||||
ask by voice; the answer is read aloud; Include screen sends the screen's text.
|
||||
8. **Lock screen**: open the assistant while locked -- nothing from the account shows; sending
|
||||
asks to unlock.
|
||||
9. **The tile and the shortcut** open the sheet.
|
||||
10. **Both themes**, and the narrowest phone at hand: nothing runs off the screen.
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
# 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.
|
||||
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`.
|
||||
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` writes `values*/strings.xml`:
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
||||
## 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.
|
||||
Reference in new issue
Block a user