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
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user