From d0404f1968039f48dc582572ef02b58912df0286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Tue, 10 Nov 2026 14:15:17 +0000 Subject: [PATCH] Schedules on a computer: which one, its folder and mode, and "not linked now" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `runs_on` (server 57d06ee): the schedule page says Computer: name · folder · mode; each run row names the computer, and a run waiting with error class device_away adds "not linked now" (server's words). The fixtures carry no "does not accept scheduled work" state on /api/v2, so that one is the run's own error text only. ScheduleContractTest reads schedule_on_device.json; shot 10-schedule-on-computer. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 + .../java/eu/llembas/android/api/Schedules.kt | 19 +++++ .../android/ui/scheduled/ScheduledScreens.kt | 75 ++++++++++++++++++- app/src/main/res/values-cs/strings.xml | 2 + app/src/main/res/values-de/strings.xml | 2 + app/src/main/res/values-es/strings.xml | 2 + app/src/main/res/values-fr/strings.xml | 2 + app/src/main/res/values-hu/strings.xml | 2 + app/src/main/res/values-it/strings.xml | 2 + app/src/main/res/values-pl/strings.xml | 2 + app/src/main/res/values-sk/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + .../llembas/android/ScheduleContractTest.kt | 15 ++++ .../java/eu/llembas/android/shots/Fakes.kt | 5 ++ .../eu/llembas/android/shots/ScreenShots.kt | 7 ++ scripts/strings.py | 2 + 16 files changed, 141 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c42b64..a9079c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ is in alpha and releases come off `main`. - **Memory**, in the drawer: what models remember about you, as Settings › Memory on the web. A tap changes or forgets one; **Remember** adds one (in the data group you pick, when you have more than one). What a model wrote is marked, and shown as plain text. +- **A scheduled task that runs on one of your computers** says which, in which folder and mode, + on its page and in each run; a run that found the computer away says *not linked now*. - **A scheduled task that watches a web page** says so on its page (*Only when this page changes*, and the address), and a run that found the page unchanged is shown as *Unchanged*. - **A scheduled task's notification shows its result.** Unlocked, it carries the task's name diff --git a/app/src/main/java/eu/llembas/android/api/Schedules.kt b/app/src/main/java/eu/llembas/android/api/Schedules.kt index 37198d4..9dd1f12 100644 --- a/app/src/main/java/eu/llembas/android/api/Schedules.kt +++ b/app/src/main/java/eu/llembas/android/api/Schedules.kt @@ -102,6 +102,8 @@ data class Schedule( @SerialName("failure_streak") val failureStreak: Int = 0, /** Monitor mode: what the schedule watches; the model runs only when it changed. */ val watch: ScheduleWatch? = null, + /** The linked computer it runs on, as an agent chat there; null: on the server. */ + @SerialName("runs_on") val runsOn: RunsOn? = null, @SerialName("last_error") val lastError: String? = null, @SerialName("last_run") val lastRun: ScheduleRun? = null, val running: Boolean = false, @@ -205,3 +207,20 @@ data class RunNotification( val labels: Map = emptyMap(), val ask: String = "", ) + +/** + * Where a schedule runs when not on the server (harness spec 3.5.0): a linked computer + * ([deviceName]), the folder there, the agent mode (never wider than Edit unless chosen), and how + * long an approval it needs waits on the phone. + */ +@Serializable +data class RunsOn( + val device: String = "", + @SerialName("device_name") val deviceName: String = "", + val cwd: String = "", + val mode: String = "", + @SerialName("approval_wait_minutes") val approvalWaitMinutes: Int? = null, +) + +/** A run that waits because its computer is not linked (`error.class` `device_away`). */ +val ScheduleRun.computerAway: Boolean get() = error?.kind == "device_away" diff --git a/app/src/main/java/eu/llembas/android/ui/scheduled/ScheduledScreens.kt b/app/src/main/java/eu/llembas/android/ui/scheduled/ScheduledScreens.kt index f99b40c..5f23ede 100644 --- a/app/src/main/java/eu/llembas/android/ui/scheduled/ScheduledScreens.kt +++ b/app/src/main/java/eu/llembas/android/ui/scheduled/ScheduledScreens.kt @@ -27,6 +27,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.Computer import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Pause @@ -75,11 +76,13 @@ import eu.llembas.android.R import eu.llembas.android.api.ApiClient import eu.llembas.android.api.ApiException import eu.llembas.android.api.LembasJson +import eu.llembas.android.api.RunsOn import eu.llembas.android.api.Schedule import eu.llembas.android.api.ScheduleCompiled import eu.llembas.android.api.ScheduleRun import eu.llembas.android.api.SchedulesFrame import eu.llembas.android.api.StreamClient +import eu.llembas.android.api.computerAway import eu.llembas.android.lembas import eu.llembas.android.ui.explain import eu.llembas.android.ui.progressLineOf @@ -536,6 +539,7 @@ private fun ScheduleBody( if (facts.isNotEmpty()) { Text(facts.joinToString(" · "), style = MaterialTheme.typography.bodySmall, color = palette.inkFaint) } + schedule.runsOn?.let { on -> ComputerLine(on, away = schedule.lastRun?.computerAway == true) } schedule.watch?.target?.takeIf { it.isNotBlank() }?.let { url -> Text( stringResource(R.string.schedule_watching) + ": " + url, @@ -590,7 +594,7 @@ private fun ScheduleBody( ) } } - items(state.runs, key = { it.id }) { run -> RunRow(run, onOpen = { onOpenRun(run) }) } + items(state.runs, key = { it.id }) { run -> RunRow(run, schedule.runsOn, onOpen = { onOpenRun(run) }) } if (state.more) item { LaunchedEffect(state.runs.size) { onMore() } } } } @@ -610,6 +614,71 @@ private fun modeWords(mode: String): String? = when (mode) { else -> null } +/** + * Where a schedule runs: Computer: its name · the folder there · the mode, and "not linked now" + * in the waiting colour when its last run found it away. The folder gives first. + */ +@Composable +private fun ComputerLine(on: RunsOn, away: Boolean) { + val palette = LocalPalette.current + Row(verticalAlignment = Alignment.CenterVertically) { + Icon(Icons.Filled.Computer, contentDescription = null, tint = palette.inkFaint, modifier = Modifier.size(16.dp)) + Spacer(Modifier.width(6.dp)) + val parts = listOfNotNull( + stringResource(R.string.schedule_computer) + ": " + on.deviceName.ifBlank { on.device }, + on.cwd.takeIf { it.isNotBlank() }, + agentModeWords(on.mode), + ) + Text(parts.joinToString(" · "), style = MaterialTheme.typography.bodySmall, color = palette.inkFaint, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + if (away) { + Text( + on.deviceName.ifBlank { on.device } + ": " + stringResource(R.string.schedule_computer_away), + style = MaterialTheme.typography.bodySmall, + color = palette.warning, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } +} + +/** A run row's line: the computer's name, and "not linked now" when the run found it away. */ +@Composable +private fun ComputerName(on: RunsOn, away: Boolean) { + val palette = LocalPalette.current + Row(verticalAlignment = Alignment.CenterVertically) { + Icon(Icons.Filled.Computer, contentDescription = stringResource(R.string.schedule_computer), tint = palette.inkFaint, modifier = Modifier.size(14.dp)) + Spacer(Modifier.width(4.dp)) + Text( + on.deviceName.ifBlank { + on.device + }, + style = MaterialTheme.typography.bodySmall, + color = palette.inkMuted, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f, fill = false), + ) + if (away) { + Text( + " · " + stringResource(R.string.schedule_computer_away), + style = MaterialTheme.typography.bodySmall, + color = palette.warning, + maxLines = 1, + softWrap = false, + ) + } + } +} + +@Composable +private fun agentModeWords(mode: String): String? = when (mode) { + "manual" -> stringResource(R.string.mode_manual) + "edit" -> stringResource(R.string.mode_edit) + "auto" -> stringResource(R.string.mode_auto) + else -> null +} + @Composable internal fun Header(text: String) { Text( @@ -626,7 +695,7 @@ internal fun Header(text: String) { * whole row opens the run. */ @Composable -private fun RunRow(run: ScheduleRun, onOpen: () -> Unit) { +private fun RunRow(run: ScheduleRun, runsOn: RunsOn?, onOpen: () -> Unit) { val palette = LocalPalette.current Surface( onClick = onOpen, @@ -639,6 +708,8 @@ private fun RunRow(run: ScheduleRun, onOpen: () -> Unit) { Box(Modifier.width(112.dp)) { StatusChip(run.status, run.missed) } Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) { Text(ScheduleLogic.moment(run.startedAt ?: run.dueAt) ?: "—", style = MaterialTheme.typography.bodyMedium) + // Which computer the run was for, and whether it was away. + runsOn?.let { on -> ComputerName(on, away = run.computerAway) } RunFacts(run, maxLines = 2) } } diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 22464a2..8a9a929 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -219,6 +219,8 @@ Hotovo Nic nového Beze změny + Počítač + teď není propojený Jen když se tato stránka změní Selhalo Zmeškáno ×%1$s diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0c58436..2cd0246 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -219,6 +219,8 @@ Fertig Nichts Neues Unverändert + Computer + gerade nicht verbunden Nur wenn sich diese Seite ändert Fehlgeschlagen Verpasst ×%1$s diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c4aa4e3..e957741 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -219,6 +219,8 @@ Hecho Nada nuevo Sin cambios + Ordenador + no vinculado ahora Solo cuando esta página cambie Fallidos Perdida ×%1$s diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b89ac2c..802c3d4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -219,6 +219,8 @@ Terminé Rien de neuf Inchangé + Ordinateur + non relié pour l’instant Seulement quand cette page change Échecs Manquée ×%1$s diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index a4d842f..8531081 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -219,6 +219,8 @@ Kész Semmi új Változatlan + Számítógép + most nincs összekapcsolva Csak ha ez az oldal megváltozik Sikertelen Kimaradt ×%1$s diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index aae840b..39868c7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -219,6 +219,8 @@ Fatto Niente di nuovo Invariato + Computer + non collegato ora Solo quando questa pagina cambia Non riusciti Saltata ×%1$s diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 3e0a1ac..7a7ca83 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -219,6 +219,8 @@ Gotowe Nic nowego Bez zmian + Komputer + teraz niepołączony Tylko gdy ta strona się zmieni Nieudane Pominięto ×%1$s diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 1e50ce7..ac26480 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -219,6 +219,8 @@ Hotovo Nič nové Bez zmeny + Počítač + teraz nie je prepojený Len keď sa táto stránka zmení Zlyhalo Zmeškané ×%1$s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3798f90..022701a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -220,6 +220,8 @@ Done Nothing new Unchanged + Computer + not linked now Only when this page changes Failed Missed ×%1$s diff --git a/app/src/test/java/eu/llembas/android/ScheduleContractTest.kt b/app/src/test/java/eu/llembas/android/ScheduleContractTest.kt index ece8555..f404aa3 100644 --- a/app/src/test/java/eu/llembas/android/ScheduleContractTest.kt +++ b/app/src/test/java/eu/llembas/android/ScheduleContractTest.kt @@ -12,6 +12,7 @@ import eu.llembas.android.api.ScheduleList import eu.llembas.android.api.ScheduleRuns import eu.llembas.android.api.SchedulesFrame import eu.llembas.android.api.SchedulingModels +import eu.llembas.android.api.computerAway import eu.llembas.android.push.ScheduledNotice import eu.llembas.android.ui.scheduled.ScheduleLogic import eu.llembas.android.ui.scheduled.SchedulingLogic @@ -106,6 +107,20 @@ class ScheduleContractTest { assertNull(read("schedule", ScheduleEnvelope.serializer()).schedule.watch) } + @Test + fun aScheduleOnAComputerAndARunThatFoundItAway() { + val on = read("schedule_on_device", ScheduleEnvelope.serializer()).schedule + val where = on.runsOn!! + assertEquals("bag-end", where.deviceName) + assertEquals("/home/frodo/waybread", where.cwd) + assertEquals("edit", where.mode) + assertEquals(30, where.approvalWaitMinutes) + val run = on.lastRun!! + assertEquals("device", run.waitingFor) + assertTrue(run.computerAway) + assertNull(read("schedule", ScheduleEnvelope.serializer()).schedule.runsOn) + } + @Test fun theRunsAWaitingOneAndOneInFull() { val page = read("schedule_runs", ScheduleRuns.serializer()) diff --git a/app/src/test/java/eu/llembas/android/shots/Fakes.kt b/app/src/test/java/eu/llembas/android/shots/Fakes.kt index 99342fe..9ee8e33 100644 --- a/app/src/test/java/eu/llembas/android/shots/Fakes.kt +++ b/app/src/test/java/eu/llembas/android/shots/Fakes.kt @@ -25,6 +25,7 @@ import eu.llembas.android.api.RunResult import eu.llembas.android.api.RunTokens import eu.llembas.android.api.Schedule import eu.llembas.android.api.ScheduleCompiled +import eu.llembas.android.api.ScheduleEnvelope import eu.llembas.android.api.ScheduleRun import eu.llembas.android.api.SchedulingModel import eu.llembas.android.api.SchedulingModels @@ -510,6 +511,10 @@ object Fakes { preview = "Little happened over the weekend: one grid-storage tender in Austria.", ) + private val onComputer = LembasJson.decodeFromString(ScheduleEnvelope.serializer(), text("schedule_on_device")).schedule + + val scheduleOnComputer = ScheduleState(schedule = onComputer, runs = listOfNotNull(onComputer.lastRun)) + val schedule = ScheduleState( schedule = schedules[0], runs = listOf( 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 c849b82..57fed57 100644 --- a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt @@ -184,6 +184,13 @@ class ScreenShots { @Test fun schedule() = shoot("10-schedule") { ScheduleContent(Fakes.schedule) } + @Test + fun scheduleOnAComputer() { + // The server's own fixture: on bag-end, in a folder, Edit, and the computer away. + shoot("10-schedule-on-computer") { ScheduleContent(Fakes.scheduleOnComputer) } + shoot("10-schedule-on-computer", Phone.Small, fontScale = 1.5f) { ScheduleContent(Fakes.scheduleOnComputer) } + } + @Test fun scheduleEdit() = shoot("11-schedule-edit") { ScheduleEditContent(Fakes.editing, editing = false) } diff --git a/scripts/strings.py b/scripts/strings.py index 87fc3d1..1fc1600 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -236,6 +236,8 @@ STRINGS: dict[str, str] = { "run_ok": "Done", "run_silent": "Nothing new", "run_unchanged": "Unchanged", + "schedule_computer": "Computer", + "schedule_computer_away": "not linked now", "schedule_watching": "Only when this page changes", "run_failed": "Failed", "run_missed": "Missed ×%1$s",