Contract at server dev 4b28b36: a device approval corrects its detail
CI / check (push) Canceled after 0s

The server's contract moved (2198eda, 94e5243): a device's approval has
the heading "Run a command" in `title` and the command in `detail`, which
is what an `editable` item corrects; it offers no free text and names the
asking subagent in `job`. The agent chat carries its real subagent facts,
and the chats list (`chats_listed.json`, new) says `subagents: null` --
read the chat.

The approval card draws the asker, the heading, "It says:" for the
model's purpose, the command in the box and the server's reason, with the
page's own sentences (from the server's catalogue). `approvalTexts` sends
a box only when its text differs from `detail`; an untouched or cleared
box sends nothing. ContractTest covers both fixtures; a screenshot of the
contract's approval and question cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-10 08:53:55 +00:00
1 parent 6a7d129d09
commit 490568a980
18 files changed
+176 -18

No files matched your search

+7
View File
@@ -41,6 +41,13 @@ is in alpha and releases come off `main`.
and the recording goes wherever that recogniser sends it. No Google library is in the app: it
uses whichever recogniser the phone has, and says so when it has none.
### Fixed
- **A corrected command on an approval runs as corrected.** A linked computer's approval card
now shows its heading (*Run a command*), the command itself in the box you can change, and
the server's reason; Allow sends your correction only when you changed it. The card names the
subagent asking, when one does. (Pinned to the server's current `dev` contract.)
## [1.0.0-beta.4] — 2026-11-09
For LLeMbas server 2.0 (2.0.0-beta.7 or later for the Subagents setting and the panel's compaction).
@@ -72,21 +72,33 @@ private fun Approval(card: Card, onAnswer: (CardAnswer) -> Unit) {
var refusing by remember { mutableStateOf(false) }
Text(stringResource(R.string.card_approval), style = MaterialTheme.typography.titleMedium)
card.items.forEach { item ->
// A subagent asks, not the chat's own turn: said first, as the page says it.
if (item.job.isNotBlank()) {
Text(stringResource(R.string.card_asker, item.job), style = MaterialTheme.typography.labelLarge, color = palette.accent)
}
// `title` is the heading ("Run a command"); `detail` is the thing itself, the command.
if (item.title.isNotBlank()) Text(item.title, style = MaterialTheme.typography.titleSmall)
if (item.purpose.isNotBlank()) {
Text(stringResource(R.string.card_it_says, item.purpose), style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
}
if (item.editable) {
OutlinedTextField(
value = edits[item.key] ?: item.title,
value = edits[item.key] ?: item.detail,
onValueChange = { edits[item.key] = it },
textStyle = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
label = { Text(stringResource(R.string.card_change_before)) },
modifier = Modifier.fillMaxWidth(),
)
} else {
Text(item.title, fontFamily = FontFamily.Monospace)
if (approvalTexts(listOf(item), edits).isNotEmpty()) {
Text(stringResource(R.string.card_edit_runs), style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
}
} else if (item.detail.isNotBlank()) {
Text(item.detail, fontFamily = FontFamily.Monospace)
}
if (item.detail.isNotBlank()) Text(item.detail, style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
if (item.purpose.isNotBlank()) Text(item.purpose, style = MaterialTheme.typography.bodySmall, color = palette.inkFaint)
if (item.reason.isNotBlank()) Text(item.reason, style = MaterialTheme.typography.bodySmall, color = palette.inkFaint)
}
// A corrected command goes with an allow, never with a refusal.
val texts = edits.filter { (key, value) -> card.items.firstOrNull { it.key == key }?.title != value }
// A corrected command goes with an allow, never with a refusal, and only when it was corrected.
val texts = approvalTexts(card.items, edits)
if (refusing) {
OutlinedTextField(
value = reason,
@@ -109,6 +121,19 @@ private fun Approval(card: Card, onAnswer: (CardAnswer) -> Unit) {
}
}
/**
* What an approval's allow sends in `texts`: the box of each `editable` item whose text differs
* from the item's `detail` (the command it was offered with). An untouched box sends nothing, so
* the server runs what the model asked for; a cleared box is no correction either.
*/
fun approvalTexts(items: List<CardItem>, edits: Map<String, String>): Map<String, String> = items
.filter { it.editable }
.mapNotNull { item ->
val edited = edits[item.key]?.trim() ?: return@mapNotNull null
if (edited.isEmpty() || edited == item.detail.trim()) null else item.key to edited
}
.toMap()
@Composable
private fun Questions(card: Card, onAnswer: (CardAnswer) -> Unit) {
val palette = LocalPalette.current
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Vaše odpověď</string>
<string name="card_something_else">Něco jiného</string>
<string name="card_send">Odeslat</string>
<string name="card_asker">%1$s se ptá:</string>
<string name="card_it_says">Model uvádí: %1$s</string>
<string name="card_change_before">Upravit to před spuštěním</string>
<string name="card_edit_runs">Povolením se spustí to, co je v poli. Znovu se to neporovnává s pravidly této konverzace — napsali jste to vy.</string>
<string name="plan_approve">Schválit plán</string>
<string name="plan_revise">Přepracovat</string>
<string name="plan_what_to_change">Co by se mělo změnit?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Ihre Antwort</string>
<string name="card_something_else">Etwas anderes</string>
<string name="card_send">Senden</string>
<string name="card_asker">%1$s fragt:</string>
<string name="card_it_says">Es sagt: %1$s</string>
<string name="card_change_before">Vor dem Ausführen ändern</string>
<string name="card_edit_runs">Erlauben führt aus, was im Feld steht. Es wird nicht erneut gegen die Regeln dieses Chats geprüft — Sie haben es eingegeben.</string>
<string name="plan_approve">Plan bestätigen</string>
<string name="plan_revise">Überarbeiten</string>
<string name="plan_what_to_change">Was soll sich ändern?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Su respuesta</string>
<string name="card_something_else">Otra cosa</string>
<string name="card_send">Enviar</string>
<string name="card_asker">%1$s pregunta:</string>
<string name="card_it_says">Dice: %1$s</string>
<string name="card_change_before">Cambiar esto antes de que se ejecute</string>
<string name="card_edit_runs">Permitir ejecuta lo que hay en el cuadro. No se vuelve a comprobar con las reglas de este chat: lo ha escrito usted.</string>
<string name="plan_approve">Aprobar el plan</string>
<string name="plan_revise">Revisar</string>
<string name="plan_what_to_change">¿Qué debería cambiar?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Votre réponse</string>
<string name="card_something_else">Autre chose</string>
<string name="card_send">Envoyer</string>
<string name="card_asker">%1$s demande :</string>
<string name="card_it_says">Il dit : %1$s</string>
<string name="card_change_before">Modifier ceci avant l\'exécution</string>
<string name="card_edit_runs">Autoriser exécute ce qui se trouve dans le champ. Ce n\'est pas revérifié par rapport aux règles de cette conversation — c\'est vous qui l\'avez saisi.</string>
<string name="plan_approve">Approuver le plan</string>
<string name="plan_revise">Réviser</string>
<string name="plan_what_to_change">Qu\'est-ce qui doit changer ?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Az Ön válasza</string>
<string name="card_something_else">Valami más</string>
<string name="card_send">Küldés</string>
<string name="card_asker">%1$s kérdezi:</string>
<string name="card_it_says">Ezt mondja: %1$s</string>
<string name="card_change_before">Módosítás futtatás előtt</string>
<string name="card_edit_runs">Az Engedélyezés azt futtatja, ami a mezőben van. Nem ellenőrizzük újra a csevegés szabályai szerint – ezt Ön írta be.</string>
<string name="plan_approve">Terv jóváhagyása</string>
<string name="plan_revise">Átdolgozás</string>
<string name="plan_what_to_change">Mi változzon?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">La tua risposta</string>
<string name="card_something_else">Altro</string>
<string name="card_send">Invia</string>
<string name="card_asker">%1$s chiede:</string>
<string name="card_it_says">Dice: %1$s</string>
<string name="card_change_before">Modificalo prima che venga eseguito</string>
<string name="card_edit_runs">Consenti esegue ciò che c\'è nel campo. Non viene ricontrollato rispetto alle regole di questa chat — l\'hai scritto tu.</string>
<string name="plan_approve">Approva il piano</string>
<string name="plan_revise">Rivedi</string>
<string name="plan_what_to_change">Cosa dovrebbe cambiare?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Twoja odpowiedź</string>
<string name="card_something_else">Coś innego</string>
<string name="card_send">Wyślij</string>
<string name="card_asker">%1$s pyta:</string>
<string name="card_it_says">Mówi: %1$s</string>
<string name="card_change_before">Zmień to przed uruchomieniem</string>
<string name="card_edit_runs">Zezwolenie uruchamia to, co jest w polu. Nie jest to ponownie sprawdzane z regułami tego czatu — zostało wpisane ręcznie.</string>
<string name="plan_approve">Zatwierdź plan</string>
<string name="plan_revise">Popraw</string>
<string name="plan_what_to_change">Co powinno się zmienić?</string>
+4
View File
@@ -222,6 +222,10 @@
<string name="card_answer">Vaša odpoveď</string>
<string name="card_something_else">Niečo iné</string>
<string name="card_send">Poslať</string>
<string name="card_asker">%1$s sa pýta:</string>
<string name="card_it_says">Model uvádza: %1$s</string>
<string name="card_change_before">Upraviť to pred spustením</string>
<string name="card_edit_runs">Povolením sa spustí to, čo je v poli. Znova sa to neporovnáva s pravidlami tejto konverzácie — napísali ste to vy.</string>
<string name="plan_approve">Schváliť plán</string>
<string name="plan_revise">Prepracovať</string>
<string name="plan_what_to_change">Čo by sa malo zmeniť?</string>
+4
View File
@@ -223,6 +223,10 @@
<string name="card_answer">Your answer</string>
<string name="card_something_else">Something else</string>
<string name="card_send">Send</string>
<string name="card_asker">%1$s asks:</string>
<string name="card_it_says">It says: %1$s</string>
<string name="card_change_before">Change this before it runs</string>
<string name="card_edit_runs">Allow runs what is in the box. It is not checked against this chat\'s rules again — you typed it.</string>
<string name="plan_approve">Approve the plan</string>
<string name="plan_revise">Revise</string>
<string name="plan_what_to_change">What should change?</string>
@@ -3,6 +3,7 @@ package eu.llembas.android
import eu.llembas.android.api.APP_API
import eu.llembas.android.api.AskFrame
import eu.llembas.android.api.Chat
import eu.llembas.android.api.ChatPage
import eu.llembas.android.api.DoneFrame
import eu.llembas.android.api.FileContent
import eu.llembas.android.api.FileListing
@@ -17,6 +18,7 @@ import eu.llembas.android.api.SteeredFrame
import eu.llembas.android.api.StepsFrame
import eu.llembas.android.api.Tail
import eu.llembas.android.api.ToolCall
import eu.llembas.android.ui.chat.approvalTexts
import kotlinx.serialization.KSerializer
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.json.jsonObject
@@ -131,6 +133,42 @@ class ContractTest {
assertEquals(40, reply.metrics!!.completionTokens)
}
@Test
fun aDeviceApprovalCorrectsItsDetail() {
// A device's approval: the heading in `title`, the command in `detail` -- the text an
// `editable` item corrects -- no "Something else", and the subagent asking in `job`.
val approval = read("event_ask", AskFrame.serializer()).cards.single { it.kind == "approval" }
val item = approval.items.single()
assertEquals("Run a command", item.title)
assertEquals("rm -rf build", item.detail)
assertTrue(item.editable)
assertFalse(item.freeText)
assertEquals("explore (job1)", item.job)
assertTrue(item.reason.isNotBlank())
// Untouched, the same, blank: nothing sent. Corrected: the item's key with the new command.
assertEquals(emptyMap<String, String>(), approvalTexts(approval.items, emptyMap()))
assertEquals(emptyMap<String, String>(), approvalTexts(approval.items, mapOf(item.key to " rm -rf build ")))
assertEquals(emptyMap<String, String>(), approvalTexts(approval.items, mapOf(item.key to " ")))
assertEquals(mapOf(item.key to "rm -rf build/tmp"), approvalTexts(approval.items, mapOf(item.key to "rm -rf build/tmp\n")))
// An item that is not editable never sends a correction.
assertEquals(emptyMap<String, String>(), approvalTexts(listOf(item.copy(editable = false)), mapOf(item.key to "ls")))
}
@Test
fun aListedChatLeavesTheSubagentFactsToTheChat() {
// The list does not work the facts out: null means "read the chat", never "not offered".
val page = read("chats_listed", ChatPage.serializer())
val chat = page.chats.single()
assertEquals("Waybread", chat.title)
assertNull(chat.subagents)
assertEquals(4, chat.agents?.max)
assertFalse(page.more)
// The agent chat's own facts: not offered (its subagents run on its device), the cap said.
val agent = read("chat_agent", Chat.serializer())
assertEquals(false, agent.subagents?.offered)
assertEquals(32, agent.subagents?.cap)
}
@Test
fun everyFrameParses() {
assertTrue(read("event_steps", StepsFrame.serializer()).steps.isNotEmpty())
@@ -22,6 +22,7 @@ import eu.llembas.android.assist.AssistSheetFrame
import eu.llembas.android.assist.AssistUiState
import eu.llembas.android.ui.chat.ActivityActions
import eu.llembas.android.ui.chat.ActivityContent
import eu.llembas.android.ui.chat.CardSheet
import eu.llembas.android.ui.chat.ChatActions
import eu.llembas.android.ui.chat.ChatContent
import eu.llembas.android.ui.chat.ModelPickerContent
@@ -198,6 +199,22 @@ class ScreenShots {
shoot("23-assistant-offline", Phone.Small, content = over(Fakes.assistOffline, false))
}
/**
* The cards a reply waits on, as the server's contract (`event_ask.json`) has them: a device's
* approval (the subagent asking, the heading, the command in its box, the server's reason),
* and a question.
*/
@Test
fun cards() {
val frame = requireNotNull(javaClass.classLoader!!.getResource("event_ask.json")).readText()
val cards = eu.llembas.android.api.LembasJson.decodeFromString(eu.llembas.android.api.AskFrame.serializer(), frame).cards
val approval = cards.single { it.kind == "approval" }
val question = cards.first { it.kind == "question" }
shoot("24-approval") { SheetOver { CardSheet(approval, onAnswer = {}) } }
shoot("24-approval", Phone.Small, fontScale = 1.5f) { SheetOver { CardSheet(approval, onAnswer = {}) } }
shoot("25-question") { SheetOver { CardSheet(question, onAnswer = {}) } }
}
@Test
fun schedulingModels() = shoot("13-scheduling-models") { SchedulingModelsContent(Fakes.schedulingModels) }
}
+1 -1
View File
@@ -24,7 +24,7 @@
"subagents": {
"offered": false,
"named_only": false,
"cap": null
"cap": 32
},
"created_at": "2026-01-02T03:04:05+00:00",
"updated_at": "2026-01-02T03:04:05+00:00"
+29
View File
@@ -0,0 +1,29 @@
{
"chats": [
{
"id": "chat1",
"kind": "chat",
"title": "Waybread",
"model": "qwen",
"folder_id": null,
"pinned": false,
"archived": false,
"temporary": false,
"unread": true,
"running": false,
"mode": "",
"effort": "low",
"device": null,
"device_session_id": null,
"parent_chat_id": null,
"agents": {
"min": 1,
"max": 4
},
"subagents": null,
"created_at": "2026-01-02T03:04:05+00:00",
"updated_at": "2026-01-02T03:04:05+00:00"
}
],
"more": false
}
+7 -7
View File
@@ -41,27 +41,27 @@
{
"id": "card2",
"kind": "approval",
"why": "explore (job1) asks",
"why": "",
"dismissable": false,
"expires_in": null,
"items": [
{
"index": 0,
"key": "a0",
"key": "0",
"kind": "approval",
"tool": "bash",
"title": "rm -rf build",
"title": "Run a command",
"header": "",
"detail": "Removes the build directory.",
"reason": "",
"detail": "rm -rf build",
"reason": "Edit mode asks before anything that runs a command.",
"purpose": "Start clean",
"options": [],
"multiple": false,
"free_text": true,
"free_text": false,
"editable": true,
"plan": null,
"mode_choice": true,
"job": ""
"job": "explore (job1)"
}
]
},
+3 -3
View File
@@ -1,5 +1,5 @@
{
"ref": "v2.0.0-beta.7",
"commit": "e3bd54f4d210cff6adb4586199caed4f41987f5e",
"sha256": "2399f518bbecc30531f840a5b426e782875e6d513fa357684d1cc829fc5273cc"
"ref": "4b28b36fcfe4a2532df2a9ebfa633d6d985063ba",
"commit": "4b28b36fcfe4a2532df2a9ebfa633d6d985063ba",
"sha256": "91bef025589f7680d7cffcbed8822130cce5635d1bfa25658ccc220ebb7764b4"
}
+6
View File
@@ -240,6 +240,10 @@ STRINGS: dict[str, str] = {
"card_answer": "Your answer",
"card_something_else": "Something else",
"card_send": "Send",
"card_asker": "%1$s asks:",
"card_it_says": "It says: %1$s",
"card_change_before": "Change this before it runs",
"card_edit_runs": "Allow runs what is in the box. It is not checked against this chat's rules again — you typed it.",
"plan_approve": "Approve the plan",
"plan_revise": "Revise",
"plan_what_to_change": "What should change?",
@@ -347,6 +351,8 @@ STRINGS: dict[str, str] = {
# taken from the server's catalogue and its named placeholders numbered in the order the
# English names them -- so "%(steps)s steps, %(tools)s tools" becomes `%1$s`, `%2$s`.
SERVER_ENGLISH: dict[str, str] = {
"card_asker": "%(job)s asks:",
"card_it_says": "It says: %(purpose)s",
"activity_used": "%(percent)s%% used",
"activity_tools_offered": "%(n)s tools offered.",
"agents_n_queued": "%(n)s queued",