From 37574292cdcba033fa7b6d8770c533893e1c1aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Mon, 23 Nov 2026 17:39:25 +0000 Subject: [PATCH] Pinned to the server's dev at 69f4800: a reply's end on the events route; a message whose arrival is unknown says so The end frame is the one this app was built against: `reply` with `live` false, once per reply (event_reply_end.json, read in SecondReviewTest with what an end does to the list and to an open chat). Nothing in the handling changed. Tokens and strings are read at the same commit. A person's message with origin `unsure` (queued, never sent by itself: it was handed to the linked computer and nobody heard whether it arrived) carries the server's sentence in place of the queued line. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 3 ++ .../java/eu/llembas/android/api/Display.kt | 11 +++++ .../java/eu/llembas/android/api/Models.kt | 7 +-- .../eu/llembas/android/ui/chat/Transcript.kt | 5 ++- .../eu/llembas/android/ui/theme/Tokens.kt | 2 +- app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-night/tokens.xml | 2 +- app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/tokens.xml | 2 +- .../eu/llembas/android/SecondReviewTest.kt | 43 +++++++++++++++++++ contract/event_reply_end.json | 5 +++ contract/lock.json | 6 +-- scripts/strings.py | 2 + tokens.lock.json | 10 ++--- 21 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 contract/event_reply_end.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b68820..2f40624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ What is said here of replies that start by themselves needs an instance newer th ### Changed +- **A message of which it is not known whether it reached the linked computer says so**, in + the instance's words, instead of looking queued: the instance does not send it by itself. + Sending it again or discarding it is done on the web page for now. - **A turn the linked computer started is a quiet note**, as a schedule's line is: it never looks like something you typed. - In an agent chat, a finished reply that holds nothing, after such a turn, says "The reply to diff --git a/app/src/main/java/eu/llembas/android/api/Display.kt b/app/src/main/java/eu/llembas/android/api/Display.kt index 1a26c5d..ad26584 100644 --- a/app/src/main/java/eu/llembas/android/api/Display.kt +++ b/app/src/main/java/eu/llembas/android/api/Display.kt @@ -150,6 +150,17 @@ fun drawn(message: Message, first: Boolean, reportChat: Boolean): Drawn = when { /** The `origin` of a turn the linked computer's harness started by itself. */ const val ORIGIN_HARNESS = "harness" +/** The `origin` of a message handed to the linked computer whose arrival there was never heard. */ +const val ORIGIN_UNSURE = "unsure" + +/** + * Whether this is the person's message of which nobody knows whether it reached the linked + * computer (`origin` `unsure`, waiting): the instance never sends it by itself, so it is not + * "queued, two ahead" -- it says what it is, in the instance's sentence. Any other origin this + * app does not know is drawn as none. + */ +val Message.fateUnknown: Boolean get() = isUser && queued && origin == ORIGIN_UNSURE + /** Whether nobody typed this row: the server wrote it (`machine`), or a device's harness did. */ val Message.byMachine: Boolean get() = machine || origin == ORIGIN_HARNESS diff --git a/app/src/main/java/eu/llembas/android/api/Models.kt b/app/src/main/java/eu/llembas/android/api/Models.kt index e8ab3dd..2d3010d 100644 --- a/app/src/main/java/eu/llembas/android/api/Models.kt +++ b/app/src/main/java/eu/llembas/android/api/Models.kt @@ -455,9 +455,10 @@ data class ChatDetail(val chat: Chat, val messages: List = emptyList(), /** * `GET /events`, frame `reply`: a reply started in the chat [chatId] -- whoever started it, this - * app's own too. [messageId] is the reply's row; [live] false says it had already ended when the - * frame was sent. An event, not a state: it is said once (and, on a connection just opened, for - * every reply being written then). + * app's own too -- and, with [live] false, that it is over (`event_reply_end.json`): once per + * reply, however it ended; a reply shorter than the news of its start is said by that one frame + * alone. [messageId] is the reply's row. An event, not a state: a start is said once (and, on a + * connection just opened, for every reply being written then), an end once and never again. */ @Serializable data class ReplyFrame(@SerialName("chat_id") val chatId: String = "", @SerialName("message_id") val messageId: String = "", val live: Boolean = false) diff --git a/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt b/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt index 210f1b1..a5f7e2b 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt @@ -171,10 +171,11 @@ 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. + // Not one whose arrival at the computer is unknown: that one waits for the person, not for its turn. Text( - progressLineOf(message.progress) ?: stringResource(R.string.queued), + if (message.fateUnknown) stringResource(R.string.fate_unknown) else progressLineOf(message.progress) ?: stringResource(R.string.queued), style = MaterialTheme.typography.labelSmall, - color = palette.inkFaint, + color = if (message.fateUnknown) palette.warning else palette.inkFaint, modifier = Modifier.padding(top = 4.dp, end = 4.dp), ) } diff --git a/app/src/main/java/eu/llembas/android/ui/theme/Tokens.kt b/app/src/main/java/eu/llembas/android/ui/theme/Tokens.kt index 1a5e053..c76091b 100644 --- a/app/src/main/java/eu/llembas/android/ui/theme/Tokens.kt +++ b/app/src/main/java/eu/llembas/android/ui/theme/Tokens.kt @@ -1,4 +1,4 @@ -// Generated by scripts/fetch-tokens.py from the LLeMbas server's tokens.css at 37a09bb6ee2f248ff23ab49df344e7ae0143b1ef. Do not edit. +// Generated by scripts/fetch-tokens.py from the LLeMbas server's tokens.css at 69f480095cfa77b5d25debf560aab3d26783e197. Do not edit. package eu.llembas.android.ui.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 1e57ac3..91a960b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -51,6 +51,7 @@ Pokračovat Starší zprávy Čeká na odeslání + Není známo, zda se tato zpráva dostala do počítače. Odešlete ji znovu, nebo ji zahoďte. Odpověď na toto nebyla zaznamenána. Přemýšlí Přemýšlel diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index b69e977..703312f 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -51,6 +51,7 @@ Fortsetzen Frühere Nachrichten Wartet auf das Senden + Es ist nicht bekannt, ob dies den Computer erreicht hat. Senden Sie es erneut oder verwerfen Sie es. Die Antwort darauf wurde nicht aufgezeichnet. Denkt nach Nachgedacht diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 0a4db6f..b94a8b2 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -51,6 +51,7 @@ Continuar Mensajes anteriores Esperando para enviarse + No se sabe si esto llegó al ordenador. Envíalo de nuevo o descártalo. La respuesta a esto no se registró. Pensando Pensamiento diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6cad397..2ae1290 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -51,6 +51,7 @@ Continuer Messages précédents En attente d\'envoi + On ne sait pas si ce message est parvenu à l’ordinateur. Renvoyez-le ou supprimez-le. La réponse à ceci n’a pas été enregistrée. Réflexion Réflexion diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 4a94e9b..5c4875b 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -51,6 +51,7 @@ Folytatás Korábbi üzenetek Küldésre vár + Nem tudni, hogy ez eljutott-e a számítógéphez. Küldje el újra, vagy vesse el. Az erre adott válasz nem lett rögzítve. Gondolkodás Gondolkodott diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 72bcae7..f5df297 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -51,6 +51,7 @@ Continua Messaggi precedenti In attesa di invio + Non si sa se questo messaggio abbia raggiunto il computer. Invialo di nuovo o scartalo. La risposta a questo non è stata registrata. Ragionamento Ha ragionato diff --git a/app/src/main/res/values-night/tokens.xml b/app/src/main/res/values-night/tokens.xml index 25cc6cc..84cacea 100644 --- a/app/src/main/res/values-night/tokens.xml +++ b/app/src/main/res/values-night/tokens.xml @@ -1,5 +1,5 @@ - + #FF0B0D10 #FF11151A diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 49263fe..f49a45a 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -51,6 +51,7 @@ Kontynuuj Wcześniejsze wiadomości Czeka na wysłanie + Nie wiadomo, czy ta wiadomość dotarła do komputera. Wyślij ją ponownie albo odrzuć. Odpowiedź na to nie została zapisana. Rozumowanie Rozumowanie diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index aa3becc..708dd99 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -51,6 +51,7 @@ Pokračovať Staršie správy Čaká na odoslanie + Nie je známe, či sa táto správa dostala do počítača. Odošlite ju znova alebo ju zahoďte. Odpoveď na toto nebola zaznamenaná. Premýšľa Premýšľal diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9d96ac4..59de0c8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,6 +52,7 @@ Continue Earlier messages Waiting to be sent + It is not known whether this reached the computer. Send it again, or discard it. The reply to this was not recorded. Thinking Thought diff --git a/app/src/main/res/values/tokens.xml b/app/src/main/res/values/tokens.xml index 06d9120..850b4d6 100644 --- a/app/src/main/res/values/tokens.xml +++ b/app/src/main/res/values/tokens.xml @@ -1,5 +1,5 @@ - + #FFF1EAD6 #FFF8F3E5 diff --git a/app/src/test/java/eu/llembas/android/SecondReviewTest.kt b/app/src/test/java/eu/llembas/android/SecondReviewTest.kt index 72b794c..f9929d8 100644 --- a/app/src/test/java/eu/llembas/android/SecondReviewTest.kt +++ b/app/src/test/java/eu/llembas/android/SecondReviewTest.kt @@ -3,12 +3,16 @@ package eu.llembas.android import eu.llembas.android.api.Chat import eu.llembas.android.api.ChatDetail import eu.llembas.android.api.ChatPage +import eu.llembas.android.api.Drawn import eu.llembas.android.api.Frame +import eu.llembas.android.api.LembasJson import eu.llembas.android.api.LiveReply import eu.llembas.android.api.Message import eu.llembas.android.api.Outcome import eu.llembas.android.api.ReplyFrame import eu.llembas.android.api.Step +import eu.llembas.android.api.drawn +import eu.llembas.android.api.fateUnknown import eu.llembas.android.api.reopened import eu.llembas.android.api.replyUnrecorded import eu.llembas.android.api.unrecordedReplies @@ -378,6 +382,45 @@ class SecondReviewTest { assertSame(list, list.ended(said("c9", live = false), open = null)) } + private fun fixture(name: String): String = requireNotNull(javaClass.classLoader!!.getResource("$name.json")) { + "contract/$name.json is missing" + }.readText() + + @Test + fun theEndFrameIsReadAsTheServerWritesItAndDoesWhatAnEndDoes() { + val start = LembasJson.decodeFromString(ReplyFrame.serializer(), fixture("event_reply")) + val end = LembasJson.decodeFromString(ReplyFrame.serializer(), fixture("event_reply_end")) + // The same reply, said twice: once being written, once over. + assertEquals(ReplyFrame(chatId = start.chatId, messageId = start.messageId, live = false), end) + assertTrue(start.live) + val list = ChatsState(chats = listOf(Chat(id = end.chatId, running = true)), more = false) + // No read for it, the mark gone, something new. + assertFalse(list.readsFor(end, shown = true)) + assertEquals(listOf(Chat(id = end.chatId, running = false, unread = true)), list.ended(end, open = null).chats) + // The pair is the proof that this instance says the ends. + val ends = ReplyEnds() + ends.hear(start) + ends.hear(end) + assertTrue(ends.said) + // For the chat on screen that followed the reply, it is no news. + val open = ChatState(chat = Chat(id = end.chatId), messages = listOf(reply(end.messageId, complete = false)), live = LiveReply(end.messageId)) + assertFalse(open.asksFor(end)) + } + + @Test + fun aMessageWhoseArrivalIsUnknownSaysSoAndNotThatItWaitsItsTurn() { + val unsure = Message(id = "q1", role = "user", text = "And the bread?", queued = true, origin = "unsure") + assertTrue(unsure.fateUnknown) + // Still the person's own bubble. + assertEquals(Drawn.Person, drawn(unsure, first = false, reportChat = false)) + // Once sent it is a turn like any other; a queued prompt is only queued; a reply is never this. + assertFalse(unsure.copy(queued = false, origin = "").fateUnknown) + assertFalse(unsure.copy(origin = "").fateUnknown) + assertFalse(unsure.copy(role = "assistant").fateUnknown) + // An origin this app does not know is drawn as none. + assertEquals(Drawn.Person, drawn(unsure.copy(queued = false, origin = "somewhere"), first = false, reportChat = false)) + } + @Test fun anInstanceProvesItSaysTheEndsWithOneEndOfAReplyItSaidStarted() { val ends = ReplyEnds() diff --git a/contract/event_reply_end.json b/contract/event_reply_end.json new file mode 100644 index 0000000..8838156 --- /dev/null +++ b/contract/event_reply_end.json @@ -0,0 +1,5 @@ +{ + "chat_id": "chat1", + "message_id": "msg2", + "live": false +} diff --git a/contract/lock.json b/contract/lock.json index a92c0f6..7c7355a 100644 --- a/contract/lock.json +++ b/contract/lock.json @@ -1,5 +1,5 @@ { - "ref": "37a09bb6ee2f248ff23ab49df344e7ae0143b1ef", - "commit": "37a09bb6ee2f248ff23ab49df344e7ae0143b1ef", - "sha256": "f133b407c1fcfa0106c35ca0edfea3b150a5c1faafbe6652c7e47b5d40ff4178" + "ref": "69f480095cfa77b5d25debf560aab3d26783e197", + "commit": "69f480095cfa77b5d25debf560aab3d26783e197", + "sha256": "8431c8a0214c699ef591b4fcbb96e4262834cf154aaf731896c282d7f453b4b8" } diff --git a/scripts/strings.py b/scripts/strings.py index 02ca4ef..29a8736 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -64,6 +64,8 @@ STRINGS: dict[str, str] = { "continue_reply": "Continue", "older": "Earlier messages", "queued": "Waiting to be sent", + # A message handed to the linked computer whose arrival was never heard (`origin` `unsure`): the server's sentence. + "fate_unknown": "It is not known whether this reached the computer. Send it again, or discard it.", # In place of a finished reply that holds nothing, after a turn nobody typed (the server's sentence). "reply_unrecorded": "The reply to this was not recorded.", "thinking": "Thinking", diff --git a/tokens.lock.json b/tokens.lock.json index a0f86d5..3128a03 100644 --- a/tokens.lock.json +++ b/tokens.lock.json @@ -1,9 +1,9 @@ { - "tag": "37a09bb6ee2f248ff23ab49df344e7ae0143b1ef", - "commit": "37a09bb6ee2f248ff23ab49df344e7ae0143b1ef", - "sha256": "d6db24a6e64b211bc93917d3e8ce66fdbdb3d944fb2d6a4e4610ab261e4bf1fd", + "tag": "69f480095cfa77b5d25debf560aab3d26783e197", + "commit": "69f480095cfa77b5d25debf560aab3d26783e197", + "sha256": "c2045c57039da6573e9efc5aa99753f0238301a139cbf75932c81e8058cdbff0", "res": { - "values": "cb1d1a1c12e2f286b4abcd45aa5048cb4c43612c3b64e099b4effb2d0c524c92", - "values-night": "db1b33a4bcdff43bdcc96d83e5378aed184457fedf69e26edb23a68adbbb6e5e" + "values": "167f908b373da57d383f5ccd032ee42beb0153cd62991ef3f60a9c1d77cc25e2", + "values-night": "060a0ca61bfa4cbe7bd7283e44b1324a35ef463c209c4f363f574b5454db4153" } }