Contract at server dev 45c1e0d: the status frame's progress, translated
CI / check (push) Canceled after 0s

The server sends `progress` beside `status` (45c1e0d): event_status.json
carries a running_tool, and the new event_status_person/_stopped/_idle
fixtures are drawn in ProgressTest -- stopped by the person with an empty
status text is "Stopped: by you". A schedule run has `progress` too: the
run row says what a waiting or running run is doing.

Strings regenerated at the same ref: the server's catalogues have the
progress texts in all eight languages, keyed by the spec's English, and
gen-strings numbers their {{fields}} (sk 349/357).

With the tree present, the Tasks section no longer repeats the team's
size line the Subagents list already says. A test that an agent chat
shows the Subagents setting exactly when the server offers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-10 09:40:40 +00:00
1 parent dff3aa67c0
commit 44a102a96f
24 files changed
+306 -7

No files matched your search

@@ -5,6 +5,7 @@ import eu.llembas.android.api.Chat
import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.LinkedDevice
import eu.llembas.android.api.ModelList
import eu.llembas.android.api.SubagentsOffer
import eu.llembas.android.ui.chat.ChatState
import eu.llembas.android.ui.chat.Draft
import eu.llembas.android.ui.chat.agents
@@ -54,6 +55,16 @@ class ChatStateTest {
assertEquals(AgentsSetting(2, 6), ChatState(draft = Draft(agents = AgentsSetting(2, 6))).agents)
}
@Test
fun anAgentChatHasTheSliderWhenTheServerOffersIt() {
// Its subagents run on its device (spec 3.4.0 §14): the chat's own word decides, never a guess.
val agentChat = Chat(id = "a", kind = "agent", model = "qwen")
assertTrue(ChatState(models = models, chat = agentChat.copy(subagents = SubagentsOffer(offered = true, cap = 8))).offersTeam(agent = true))
assertFalse(ChatState(models = models, chat = agentChat.copy(subagents = SubagentsOffer(offered = false, cap = 32))).offersTeam(agent = true))
// A listed chat (`subagents: null`) asks the chat's activity.
assertTrue(ChatState(models = models, chat = agentChat, teamOffered = true).offersTeam(agent = true))
}
@Test
fun aNewAgentChatRunsOnTheChosenDeviceOrTheFirst() {
val devices = listOf(LinkedDevice("d1"), LinkedDevice("d2"))
@@ -4,6 +4,8 @@ import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.LiveReply
import eu.llembas.android.api.Progress
import eu.llembas.android.api.ProgressWords
import eu.llembas.android.api.RunResult
import eu.llembas.android.api.StatusFrame
import eu.llembas.android.api.elapsed
import eu.llembas.android.api.progressLine
import eu.llembas.android.api.progressText
@@ -14,6 +16,7 @@ import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.long
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.File
import java.util.Locale
@@ -94,4 +97,34 @@ class ProgressTest {
val done = LembasJson.parseToJsonElement(File("../contract/event_done.json").readText()).toString()
assertNull(live.apply("done", done).progress)
}
@Test
fun theContractsStatusFrames() {
fun frame(name: String) = LembasJson.decodeFromString(
StatusFrame.serializer(),
requireNotNull(javaClass.classLoader!!.getResource("$name.json")).readText(),
)
val running = frame("event_status")
assertEquals("Running bake --slow", running.text)
val since = running.progress!!.since
assertEquals("Running bash: bake --slow · 5s", progressLine(running.progress!!, english, since + 5_000, Locale.ROOT))
assertEquals("Waiting for you: a question · 0s", progressLine(frame("event_status_person").progress!!, english, since, Locale.ROOT))
// Stopped is its text alone, though the free text is empty: the progress is what is drawn.
val stopped = frame("event_status_stopped")
assertEquals("", stopped.text)
assertEquals("Stopped: by you", progressLine(stopped.progress!!, english, since + 60_000, Locale.ROOT))
assertNull(frame("event_status_idle").progress)
}
@Test
fun aScheduledRunSaysItsProgress() {
val text = requireNotNull(javaClass.classLoader!!.getResource("schedule_run.json")).readText()
// The contract's run has finished: `progress` is there, and null.
assertTrue(text.contains("\"progress\": null"))
assertNull(LembasJson.decodeFromString(RunResult.serializer(), text).run.progress)
val waiting =
"""{"run": {"id": "r", "status": "waiting", "progress": {"phase": "waiting_for_model", "since": 0, "model": "coder", "reason": "slots"}}}"""
val run = LembasJson.decodeFromString(RunResult.serializer(), waiting).run
assertEquals("Waiting for coder: all its slots are in use", progressText(run.progress!!, english, 0, Locale.ROOT))
}
}