diff --git a/CHANGELOG.md b/CHANGELOG.md index f540f24..7e5fa3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt b/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt index f045717..4ff13c8 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt @@ -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, edits: Map): Map = 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 diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 9656729..88146d5 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -222,6 +222,10 @@ Vaše odpověď Něco jiného Odeslat + %1$s se ptá: + Model uvádí: %1$s + Upravit to před spuštěním + Povolením se spustí to, co je v poli. Znovu se to neporovnává s pravidly této konverzace — napsali jste to vy. Schválit plán Přepracovat Co by se mělo změnit? diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index cdc5ba0..7dc1ac8 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -222,6 +222,10 @@ Ihre Antwort Etwas anderes Senden + %1$s fragt: + Es sagt: %1$s + Vor dem Ausführen ändern + Erlauben führt aus, was im Feld steht. Es wird nicht erneut gegen die Regeln dieses Chats geprüft — Sie haben es eingegeben. Plan bestätigen Überarbeiten Was soll sich ändern? diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 613d0ff..62f22b6 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -222,6 +222,10 @@ Su respuesta Otra cosa Enviar + %1$s pregunta: + Dice: %1$s + Cambiar esto antes de que se ejecute + Permitir ejecuta lo que hay en el cuadro. No se vuelve a comprobar con las reglas de este chat: lo ha escrito usted. Aprobar el plan Revisar ¿Qué debería cambiar? diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 1bc642a..646f8f8 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -222,6 +222,10 @@ Votre réponse Autre chose Envoyer + %1$s demande : + Il dit : %1$s + Modifier ceci avant l\'exécution + 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. Approuver le plan Réviser Qu\'est-ce qui doit changer ? diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index dd9094f..0276c85 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -222,6 +222,10 @@ Az Ön válasza Valami más Küldés + %1$s kérdezi: + Ezt mondja: %1$s + Módosítás futtatás előtt + 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. Terv jóváhagyása Átdolgozás Mi változzon? diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 3c0b56a..eda7e26 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -222,6 +222,10 @@ La tua risposta Altro Invia + %1$s chiede: + Dice: %1$s + Modificalo prima che venga eseguito + Consenti esegue ciò che c\'è nel campo. Non viene ricontrollato rispetto alle regole di questa chat — l\'hai scritto tu. Approva il piano Rivedi Cosa dovrebbe cambiare? diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 4ac9f93..a445636 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -222,6 +222,10 @@ Twoja odpowiedź Coś innego Wyślij + %1$s pyta: + Mówi: %1$s + Zmień to przed uruchomieniem + Zezwolenie uruchamia to, co jest w polu. Nie jest to ponownie sprawdzane z regułami tego czatu — zostało wpisane ręcznie. Zatwierdź plan Popraw Co powinno się zmienić? diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 5a4e2da..f356eec 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -222,6 +222,10 @@ Vaša odpoveď Niečo iné Poslať + %1$s sa pýta: + Model uvádza: %1$s + Upraviť to pred spustením + Povolením sa spustí to, čo je v poli. Znova sa to neporovnáva s pravidlami tejto konverzácie — napísali ste to vy. Schváliť plán Prepracovať Čo by sa malo zmeniť? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 413f9eb..b37e8e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -223,6 +223,10 @@ Your answer Something else Send + %1$s asks: + It says: %1$s + Change this before it runs + Allow runs what is in the box. It is not checked against this chat\'s rules again — you typed it. Approve the plan Revise What should change? diff --git a/app/src/test/java/eu/llembas/android/ContractTest.kt b/app/src/test/java/eu/llembas/android/ContractTest.kt index 4235af3..7904266 100644 --- a/app/src/test/java/eu/llembas/android/ContractTest.kt +++ b/app/src/test/java/eu/llembas/android/ContractTest.kt @@ -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(), approvalTexts(approval.items, emptyMap())) + assertEquals(emptyMap(), approvalTexts(approval.items, mapOf(item.key to " rm -rf build "))) + assertEquals(emptyMap(), 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(), 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()) diff --git a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt index ac4f781..3d4afa7 100644 --- a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt @@ -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) } } diff --git a/contract/chat_agent.json b/contract/chat_agent.json index df33eb0..c70370e 100644 --- a/contract/chat_agent.json +++ b/contract/chat_agent.json @@ -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" diff --git a/contract/chats_listed.json b/contract/chats_listed.json new file mode 100644 index 0000000..e1e6467 --- /dev/null +++ b/contract/chats_listed.json @@ -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 +} diff --git a/contract/event_ask.json b/contract/event_ask.json index 88faa14..d95979a 100644 --- a/contract/event_ask.json +++ b/contract/event_ask.json @@ -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)" } ] }, diff --git a/contract/lock.json b/contract/lock.json index be01d3c..88d13bf 100644 --- a/contract/lock.json +++ b/contract/lock.json @@ -1,5 +1,5 @@ { - "ref": "v2.0.0-beta.7", - "commit": "e3bd54f4d210cff6adb4586199caed4f41987f5e", - "sha256": "2399f518bbecc30531f840a5b426e782875e6d513fa357684d1cc829fc5273cc" + "ref": "4b28b36fcfe4a2532df2a9ebfa633d6d985063ba", + "commit": "4b28b36fcfe4a2532df2a9ebfa633d6d985063ba", + "sha256": "91bef025589f7680d7cffcbed8822130cce5635d1bfa25658ccc220ebb7764b4" } diff --git a/scripts/strings.py b/scripts/strings.py index 4a9f1ae..91be6ca 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -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",