The activity sheet as the reference lays it out; Subagents by name
CI / check (push) Canceled after 0s

- ActivityContent(activity, …, actions): the sheet drawn from its facts, for the shots.
  Context with "N until auto-compact" and Compact; Background tasks as cards (running
  with elapsed and a stop square, nested "N under it", Finished folded); Room; Plan.
- A bottom sheet from a top-bar button on every chat, a new one included.
- The strip above the composer: running · queued · waiting · finished, while anything runs.
- Compact through POST /api/v2/chats/{id}/compact (provisional until the server's route).
- "Subagents" wherever a person reads it; 13 new strings in 8 languages.
- Shots 14-16 (activity, unfolded, new chat); ActivityTest for auto-compact and titles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-09 16:53:46 +00:00
1 parent f8a4888984
commit 0be487bf96
21 files changed
+784 -262

No files matched your search

@@ -143,10 +143,30 @@ class ActivityTest {
@Test
fun theStripCountsWhatIsGoing() {
val summary = ActivitySummary(queued = 1, working = 3, waiting = 0, done = 4, finished = 4, active = 4, total = 8)
assertEquals(listOf("working" to 3, "queued" to 1), ActivityLogic.stripCounts(summary))
assertEquals(listOf("working" to 3, "queued" to 1, "finished" to 4), ActivityLogic.stripCounts(summary))
assertTrue(ActivityLogic.stripCounts(ActivitySummary(done = 2, finished = 2)).isEmpty())
}
@Test
fun autoCompactIsCountedOnlyAgainstAKnownWindow() {
val context = read("activity", ActivityEnvelope.serializer()).activity.context!!
// 95 % of 128k is 121.6k; 41k used.
assertEquals(80_600, ActivityLogic.untilAutoCompact(context))
assertEquals(0, ActivityLogic.untilAutoCompact(context.copy(used = 127_000)))
assertNull(ActivityLogic.untilAutoCompact(context.copy(threshold = 0)))
assertNull(ActivityLogic.untilAutoCompact(context.copy(limit = 0)))
}
@Test
fun aTaskIsCalledByWhatItWasAskedToDo() {
val activity = read("activity", ActivityEnvelope.serializer()).activity
val (baker, command) = activity.agents
assertEquals("baker", ActivityLogic.title(baker))
assertEquals("find mallorn leaves", ActivityLogic.title(baker.children[1]))
assertEquals("pytest", ActivityLogic.title(command))
assertEquals(2, ActivityLogic.descendants(baker))
}
@Test
fun numbersAsTheServerWritesThem() {
assertEquals("950", ActivityLogic.compactTokens(950))
@@ -167,10 +187,10 @@ class ActivityTest {
val activity = read("activity", ActivityEnvelope.serializer()).activity
val (baker, _) = activity.agents
val wrapper = baker.children[0]
val helper = baker.children[1]
val subagent = baker.children[1]
assertEquals(105L, ActivityLogic.elapsed(baker, readAtMillis = 1_000, nowMillis = 11_000))
assertEquals(0L, ActivityLogic.elapsed(wrapper, readAtMillis = 1_000, nowMillis = 11_000))
assertEquals(12L, ActivityLogic.elapsed(helper, readAtMillis = 1_000, nowMillis = 11_000))
assertEquals(12L, ActivityLogic.elapsed(subagent, readAtMillis = 1_000, nowMillis = 11_000))
}
@Test
@@ -1,9 +1,13 @@
package eu.llembas.android.shots
import eu.llembas.android.api.ActivityAgent
import eu.llembas.android.api.ActivityEnvelope
import eu.llembas.android.api.ActivitySummary
import eu.llembas.android.api.AgentStep
import eu.llembas.android.api.AgentsSetting
import eu.llembas.android.api.Attachment
import eu.llembas.android.api.Chat
import eu.llembas.android.api.ContextPart
import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.LinkedDevice
import eu.llembas.android.api.LiveReply
@@ -111,7 +115,61 @@ object Fakes {
messages = listOf(question, answer, packing, packingAnswer),
models = models,
teamOffered = true,
summary = ActivitySummary(working = 2, active = 2, total = 2),
summary = ActivitySummary(working = 2, queued = 1, done = 4, finished = 4, active = 3, total = 7),
)
private val fixture = LembasJson.decodeFromString(ActivityEnvelope.serializer(), text("activity")).activity
private fun job(id: String, type: String, role: String, brief: String, state: String, seconds: Int, stoppable: Boolean = true) = ActivityAgent(
kind = "job",
id = id,
type = type,
name = id,
role = role,
brief = brief,
state = state,
seconds = seconds,
model = if (type == "command") "" else "qwen",
agent = if (type == "command") "" else "explore",
manager = "lead",
stoppable = stoppable,
transcript = type != "command",
)
/**
* The activity sheet with everything in it, as the reference has it: a context two thirds
* free with auto-compact ahead, a team with a member under the lead, subagents and commands
* running, four finished, the room and no plan.
*/
val activity = fixture.copy(
summary = ActivitySummary(queued = 1, working = 4, done = 4, finished = 4, active = 5, total = 9),
agents = listOf(
fixture.agents[0].copy(seconds = 1_135, step = AgentStep(tool = "edit", label = "Edit", title = "recipe.md", running = true)),
job("job2", "subagent", "Find where the waybread recipe is used", "Search the notes for every use of the recipe", "working", 97),
job("job3", "command", "Run related test files", "pytest -q tests/test_bake.py", "working", 40),
fixture.agents[1].copy(role = "Relax status, rerun targeted tests", seconds = 39),
) + listOf(
job("job4", "subagent", "Read the old packing list", "", "done", 64, stoppable = false),
job("job5", "command", "Lint the notes", "ruff check", "done", 12, stoppable = false),
job("job6", "subagent", "Check the weather on the pass", "", "error", 8, stoppable = false),
job("job7", "command", "Count the provisions", "wc -l list.md", "stopped", 3, stoppable = false),
),
context = fixture.context!!.copy(
used = 41_200,
limit = 128_000,
percent = 32.2,
categories = listOf(
ContextPart("messages", 26_300, 20.5),
ContextPart("memory", 2_400, 1.9),
ContextPart("mcp_tools", 2_300, 1.8),
ContextPart("tools", 2_000, 1.6),
ContextPart("instructions", 1_300, 1.0),
ContextPart("system", 500, 0.4),
ContextPart("since", 200, 0.1),
ContextPart("buffer", 6_400, 5.0),
ContextPart("free", 80_400, 62.8),
),
),
)
/** The last reply while it is being written: its tools done, its words coming in. */
@@ -16,6 +16,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import eu.llembas.android.ui.chat.ActivityActions
import eu.llembas.android.ui.chat.ActivityContent
import eu.llembas.android.ui.chat.ChatActions
import eu.llembas.android.ui.chat.ChatContent
import eu.llembas.android.ui.chat.ModelPickerContent
@@ -42,6 +44,8 @@ private object NoChatActions : ChatActions
private object NoDrawerActions : DrawerActions
private object NoActivityActions : ActivityActions
private object NoSettingsActions : SettingsActions
/**
@@ -127,6 +131,21 @@ class ScreenShots {
shoot("12-schedule-run", Phone.Small) { RunContent(Fakes.run) }
}
@Test
fun activity() {
val sheet: @Composable () -> Unit = { SheetOver { ActivityContent(Fakes.activity, readAt = 0, now = 0, actions = NoActivityActions) } }
val open: @Composable () -> Unit = {
SheetOver { ActivityContent(Fakes.activity, readAt = 0, now = 0, actions = NoActivityActions, unfolded = true) }
}
shoot("14-activity", content = sheet)
shoot("14-activity", Phone.Small, content = sheet)
shoot("14-activity", Phone.Small, fontScale = 1.5f, content = sheet)
shoot("15-activity-open", content = open)
shoot("16-activity-new-chat") {
SheetOver { ActivityContent(eu.llembas.android.api.Activity(), readAt = 0, now = 0, actions = NoActivityActions, canCompact = false) }
}
}
@Test
fun schedulingModels() = shoot("13-scheduling-models") { SchedulingModelsContent(Fakes.schedulingModels) }
}