Schedules on a computer: which one, its folder and mode, and "not linked now"
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
`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 <noreply@anthropic.com>
This commit is contained in:
16 files changed
+141
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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<String, String> = 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"
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Hotovo</string>
|
||||
<string name="run_silent">Nic nového</string>
|
||||
<string name="run_unchanged">Beze změny</string>
|
||||
<string name="schedule_computer">Počítač</string>
|
||||
<string name="schedule_computer_away">teď není propojený</string>
|
||||
<string name="schedule_watching">Jen když se tato stránka změní</string>
|
||||
<string name="run_failed">Selhalo</string>
|
||||
<string name="run_missed">Zmeškáno ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Fertig</string>
|
||||
<string name="run_silent">Nichts Neues</string>
|
||||
<string name="run_unchanged">Unverändert</string>
|
||||
<string name="schedule_computer">Computer</string>
|
||||
<string name="schedule_computer_away">gerade nicht verbunden</string>
|
||||
<string name="schedule_watching">Nur wenn sich diese Seite ändert</string>
|
||||
<string name="run_failed">Fehlgeschlagen</string>
|
||||
<string name="run_missed">Verpasst ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Hecho</string>
|
||||
<string name="run_silent">Nada nuevo</string>
|
||||
<string name="run_unchanged">Sin cambios</string>
|
||||
<string name="schedule_computer">Ordenador</string>
|
||||
<string name="schedule_computer_away">no vinculado ahora</string>
|
||||
<string name="schedule_watching">Solo cuando esta página cambie</string>
|
||||
<string name="run_failed">Fallidos</string>
|
||||
<string name="run_missed">Perdida ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Terminé</string>
|
||||
<string name="run_silent">Rien de neuf</string>
|
||||
<string name="run_unchanged">Inchangé</string>
|
||||
<string name="schedule_computer">Ordinateur</string>
|
||||
<string name="schedule_computer_away">non relié pour l’instant</string>
|
||||
<string name="schedule_watching">Seulement quand cette page change</string>
|
||||
<string name="run_failed">Échecs</string>
|
||||
<string name="run_missed">Manquée ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Kész</string>
|
||||
<string name="run_silent">Semmi új</string>
|
||||
<string name="run_unchanged">Változatlan</string>
|
||||
<string name="schedule_computer">Számítógép</string>
|
||||
<string name="schedule_computer_away">most nincs összekapcsolva</string>
|
||||
<string name="schedule_watching">Csak ha ez az oldal megváltozik</string>
|
||||
<string name="run_failed">Sikertelen</string>
|
||||
<string name="run_missed">Kimaradt ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Fatto</string>
|
||||
<string name="run_silent">Niente di nuovo</string>
|
||||
<string name="run_unchanged">Invariato</string>
|
||||
<string name="schedule_computer">Computer</string>
|
||||
<string name="schedule_computer_away">non collegato ora</string>
|
||||
<string name="schedule_watching">Solo quando questa pagina cambia</string>
|
||||
<string name="run_failed">Non riusciti</string>
|
||||
<string name="run_missed">Saltata ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Gotowe</string>
|
||||
<string name="run_silent">Nic nowego</string>
|
||||
<string name="run_unchanged">Bez zmian</string>
|
||||
<string name="schedule_computer">Komputer</string>
|
||||
<string name="schedule_computer_away">teraz niepołączony</string>
|
||||
<string name="schedule_watching">Tylko gdy ta strona się zmieni</string>
|
||||
<string name="run_failed">Nieudane</string>
|
||||
<string name="run_missed">Pominięto ×%1$s</string>
|
||||
|
||||
@@ -219,6 +219,8 @@
|
||||
<string name="run_ok">Hotovo</string>
|
||||
<string name="run_silent">Nič nové</string>
|
||||
<string name="run_unchanged">Bez zmeny</string>
|
||||
<string name="schedule_computer">Počítač</string>
|
||||
<string name="schedule_computer_away">teraz nie je prepojený</string>
|
||||
<string name="schedule_watching">Len keď sa táto stránka zmení</string>
|
||||
<string name="run_failed">Zlyhalo</string>
|
||||
<string name="run_missed">Zmeškané ×%1$s</string>
|
||||
|
||||
@@ -220,6 +220,8 @@
|
||||
<string name="run_ok">Done</string>
|
||||
<string name="run_silent">Nothing new</string>
|
||||
<string name="run_unchanged">Unchanged</string>
|
||||
<string name="schedule_computer">Computer</string>
|
||||
<string name="schedule_computer_away">not linked now</string>
|
||||
<string name="schedule_watching">Only when this page changes</string>
|
||||
<string name="run_failed">Failed</string>
|
||||
<string name="run_missed">Missed ×%1$s</string>
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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) }
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user