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

@@ -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) }
}