Contract at server dev 3e6f6da: notifications, monitor mode, pinning, parity routes, queued
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
Re-pinned contract/ and the strings at the server's dev 3e6f6da (after f7f2ff2 parity routes,
96240be pinning, 00c209a monitor mode, fd0a386 scheduled-result notifications, a8a3733
progress gaps).
- Message.progress: a queued prompt draws the server's queued line ("2 ahead · 12s").
loading_model and reading_prompt's tokens were already drawn (Progress.kt).
- Schedule.watch / ScheduleRun.watch: a watching schedule names its address on its page;
`unchanged` runs are drawn quiet, as Unchanged.
- ScheduleRun.notification parsed (title, body, public, actions, labels) for the push work.
- The schedules frame's version hash moved (ScheduleContractTest).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
36 files changed
+571
-15
No files matched your search
@@ -412,6 +412,8 @@ data class Message(
|
||||
val steps: List<Step> = emptyList(),
|
||||
val plan: JsonObject? = null,
|
||||
val metrics: Metrics? = null,
|
||||
/** A prompt queued behind a running reply: `{phase: queued, since, ahead}`; null otherwise. */
|
||||
val progress: Progress? = null,
|
||||
) {
|
||||
val isUser: Boolean get() = role == "user"
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ data class ScheduleRun(
|
||||
val preview: String = "",
|
||||
val error: RunError? = null,
|
||||
val notified: Boolean = false,
|
||||
/** The notification the server made for this run, when it made one (see [RunNotification]). */
|
||||
val notification: RunNotification? = null,
|
||||
/** A watching schedule's look at its address on this run (`unchanged` when nothing moved). */
|
||||
val watch: RunWatch? = null,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -96,6 +100,8 @@ data class Schedule(
|
||||
@SerialName("chat_id") val chatId: String? = null,
|
||||
@SerialName("fired_count") val firedCount: Int = 0,
|
||||
@SerialName("failure_streak") val failureStreak: Int = 0,
|
||||
/** Monitor mode: what the schedule watches; the model runs only when it changed. */
|
||||
val watch: ScheduleWatch? = null,
|
||||
@SerialName("last_error") val lastError: String? = null,
|
||||
@SerialName("last_run") val lastRun: ScheduleRun? = null,
|
||||
val running: Boolean = false,
|
||||
@@ -171,3 +177,31 @@ data class SchedulingModel(
|
||||
/** `GET`/`PUT /schedules/models`: the models, the instance's order, and the person's narrowing. */
|
||||
@Serializable
|
||||
data class SchedulingModels(val models: List<SchedulingModel> = emptyList(), val instance: List<String> = emptyList(), val mine: List<String> = emptyList())
|
||||
|
||||
/** What a watching schedule looks at before each run: [kind] `url` and the address. */
|
||||
@Serializable
|
||||
data class ScheduleWatch(val kind: String = "", val target: String = "", @SerialName("changed_at") val changedAt: String? = null)
|
||||
|
||||
/** One run's look: whether the address [changed] since the last one, or why the look failed. */
|
||||
@Serializable
|
||||
data class RunWatch(val kind: String = "", val changed: Boolean = false, val first: Boolean = false, val bytes: Long = 0, val error: String? = null)
|
||||
|
||||
/** The lock-screen half of a [RunNotification]: the task's name and Finished / Failed only. */
|
||||
@Serializable
|
||||
data class PublicNotice(val title: String = "", val body: String = "")
|
||||
|
||||
/**
|
||||
* A scheduled run's notification as the server wrote it, in the owner's language: [title] (the
|
||||
* task's name) and [body] (the result's first lines) for an unlocked phone, [public] for the
|
||||
* lock screen, and [actions] (`open`, `run_again`, `pause`) with their [labels]. [ask] names the
|
||||
* action the body asks about (`pause` after failures).
|
||||
*/
|
||||
@Serializable
|
||||
data class RunNotification(
|
||||
val title: String = "",
|
||||
val body: String = "",
|
||||
val public: PublicNotice = PublicNotice(),
|
||||
val actions: List<String> = emptyList(),
|
||||
val labels: Map<String, String> = emptyMap(),
|
||||
val ask: String = "",
|
||||
)
|
||||
@@ -88,6 +88,7 @@ import eu.llembas.android.api.ToolCall
|
||||
import eu.llembas.android.lembas
|
||||
import eu.llembas.android.ui.MarkdownText
|
||||
import eu.llembas.android.ui.Segment
|
||||
import eu.llembas.android.ui.progressLineOf
|
||||
import eu.llembas.android.ui.splitFences
|
||||
import eu.llembas.android.ui.theme.LocalPalette
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -154,8 +155,9 @@ fun UserMessage(message: Message, canEdit: Boolean, onEdit: () -> Unit, modifier
|
||||
}
|
||||
}
|
||||
if (message.queued) {
|
||||
// The server's queued progress ("Queued, 2 ahead · 12s") where it sends one.
|
||||
Text(
|
||||
stringResource(R.string.queued),
|
||||
progressLineOf(message.progress) ?: stringResource(R.string.queued),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = palette.inkFaint,
|
||||
modifier = Modifier.padding(top = 4.dp, end = 4.dp),
|
||||
|
||||
@@ -11,7 +11,7 @@ enum class Tone { Good, Quiet, Bad, Waiting, Neutral }
|
||||
object ScheduleLogic {
|
||||
fun tone(status: String): Tone = when (status) {
|
||||
"ok" -> Tone.Good
|
||||
"silent" -> Tone.Quiet
|
||||
"silent", "unchanged" -> Tone.Quiet
|
||||
"failed", "missed" -> Tone.Bad
|
||||
"waiting", "running" -> Tone.Waiting
|
||||
else -> Tone.Neutral
|
||||
|
||||
@@ -301,6 +301,7 @@ fun StatusChip(status: String, missed: Int = 0) {
|
||||
val words = when (status) {
|
||||
"ok" -> stringResource(R.string.run_ok)
|
||||
"silent" -> stringResource(R.string.run_silent)
|
||||
"unchanged" -> stringResource(R.string.run_unchanged)
|
||||
"failed" -> stringResource(R.string.run_failed)
|
||||
"missed" -> stringResource(R.string.run_missed, maxOf(missed, 1).toString())
|
||||
"skipped" -> stringResource(R.string.run_skipped)
|
||||
@@ -535,6 +536,15 @@ private fun ScheduleBody(
|
||||
if (facts.isNotEmpty()) {
|
||||
Text(facts.joinToString(" · "), style = MaterialTheme.typography.bodySmall, color = palette.inkFaint)
|
||||
}
|
||||
schedule.watch?.target?.takeIf { it.isNotBlank() }?.let { url ->
|
||||
Text(
|
||||
stringResource(R.string.schedule_watching) + ": " + url,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.inkFaint,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Nedá vědět nikdy</string>
|
||||
<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_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>
|
||||
<string name="run_skipped">Vynecháno</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Meldet sich nie</string>
|
||||
<string name="run_ok">Fertig</string>
|
||||
<string name="run_silent">Nichts Neues</string>
|
||||
<string name="run_unchanged">Unverändert</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>
|
||||
<string name="run_skipped">Übersprungen</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">No avisa nunca</string>
|
||||
<string name="run_ok">Hecho</string>
|
||||
<string name="run_silent">Nada nuevo</string>
|
||||
<string name="run_unchanged">Sin cambios</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>
|
||||
<string name="run_skipped">Omitida</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Ne prévient jamais</string>
|
||||
<string name="run_ok">Terminé</string>
|
||||
<string name="run_silent">Rien de neuf</string>
|
||||
<string name="run_unchanged">Inchangé</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>
|
||||
<string name="run_skipped">Sautée</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Soha nem szól</string>
|
||||
<string name="run_ok">Kész</string>
|
||||
<string name="run_silent">Semmi új</string>
|
||||
<string name="run_unchanged">Változatlan</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>
|
||||
<string name="run_skipped">Kihagyva</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Non avvisa mai</string>
|
||||
<string name="run_ok">Fatto</string>
|
||||
<string name="run_silent">Niente di nuovo</string>
|
||||
<string name="run_unchanged">Invariato</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>
|
||||
<string name="run_skipped">Ignorata</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Nigdy nie powiadamia</string>
|
||||
<string name="run_ok">Gotowe</string>
|
||||
<string name="run_silent">Nic nowego</string>
|
||||
<string name="run_unchanged">Bez zmian</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>
|
||||
<string name="run_skipped">Pominięto</string>
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
<string name="notify_never">Nedá vedieť nikdy</string>
|
||||
<string name="run_ok">Hotovo</string>
|
||||
<string name="run_silent">Nič nové</string>
|
||||
<string name="run_unchanged">Bez zmeny</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>
|
||||
<string name="run_skipped">Vynechané</string>
|
||||
|
||||
@@ -197,6 +197,8 @@
|
||||
<string name="notify_never">Never tells you</string>
|
||||
<string name="run_ok">Done</string>
|
||||
<string name="run_silent">Nothing new</string>
|
||||
<string name="run_unchanged">Unchanged</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>
|
||||
<string name="run_skipped">Skipped</string>
|
||||
|
||||
@@ -130,6 +130,13 @@ class ContractTest {
|
||||
val user = read("message_user", Message.serializer())
|
||||
assertTrue(user.isUser)
|
||||
assertEquals("How is lembas made?", user.text)
|
||||
assertNull(user.progress)
|
||||
|
||||
// A prompt waiting behind a running reply says so, and how many are ahead of it.
|
||||
val queued = read("message_queued", Message.serializer())
|
||||
assertTrue(queued.queued)
|
||||
assertEquals("queued", queued.progress!!.phase)
|
||||
assertEquals(2, queued.progress!!.ahead)
|
||||
|
||||
val reply = read("message_assistant", Message.serializer())
|
||||
assertEquals(listOf("thinking", "text", "tools", "steer", "text"), reply.steps.map { it.kind })
|
||||
|
||||
@@ -13,7 +13,9 @@ import eu.llembas.android.api.ScheduleRuns
|
||||
import eu.llembas.android.api.SchedulesFrame
|
||||
import eu.llembas.android.api.SchedulingModels
|
||||
import eu.llembas.android.push.ScheduledNotice
|
||||
import eu.llembas.android.ui.scheduled.ScheduleLogic
|
||||
import eu.llembas.android.ui.scheduled.SchedulingLogic
|
||||
import eu.llembas.android.ui.scheduled.Tone
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
@@ -84,10 +86,26 @@ class ScheduleContractTest {
|
||||
assertWaybread(read("schedules", ScheduleList.serializer()).schedules.single())
|
||||
assertWaybread(read("schedule", ScheduleEnvelope.serializer()).schedule)
|
||||
val frame = read("event_schedules", SchedulesFrame.serializer())
|
||||
assertEquals("6852d52c0c9575b0", frame.version)
|
||||
assertEquals("d2f307bf1c7b8d6b", frame.version)
|
||||
assertWaybread(frame.schedules.single())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aWatchingScheduleAndItsUnchangedRun() {
|
||||
// Monitor mode (`schedule_watching.json`): the address it looks at, and a run that found
|
||||
// nothing changed -- no model, no notification.
|
||||
val watching = read("schedule_watching", ScheduleEnvelope.serializer()).schedule
|
||||
assertEquals("url", watching.watch!!.kind)
|
||||
assertEquals("https://shop.example/mallorn", watching.watch!!.target)
|
||||
val run = watching.lastRun!!
|
||||
assertEquals("unchanged", run.status)
|
||||
assertFalse(run.watch!!.changed)
|
||||
assertNull(run.notification)
|
||||
assertEquals(Tone.Quiet, ScheduleLogic.tone(run.status))
|
||||
// A schedule that watches nothing says null.
|
||||
assertNull(read("schedule", ScheduleEnvelope.serializer()).schedule.watch)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theRunsAWaitingOneAndOneInFull() {
|
||||
val page = read("schedule_runs", ScheduleRuns.serializer())
|
||||
|
||||
Reference in new issue
Block a user