Which fence is a page is the server's to say; the build's missing constant
CI / check (push) Canceled after 0s

- A closed step and a report are drawn from the server's text, where a page
  is the one line "[page: Title]" (the card). An `html-view` fence the
  server does not list -- written while pages were not offered -- is the
  code block it is. Only the open step of a reply as it streams takes the
  fence for a page, so that a page being written is not source scrolling by.
- The events' reports frame carries latest_created; a report its pages.
- FEATURE_VOICE_RECOGNIZERS is not in the SDK for apps: the feature is
  asked for by its name (CI run 88 failed to compile on it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-11-13 11:42:48 +00:00
1 parent af290cd7d5
commit f9cca74af5
7 files changed
+57 -31

No files matched your search

@@ -41,8 +41,10 @@ data class Report(
@JsonNames("created_at") val created: String? = null,
val unread: Boolean = false,
val body: String? = null,
/** The body as text: every page in it replaced by its one line, `[page: Title]`. */
/** The body as text: every page in it replaced by its one line, `[page: Title]`; the body itself where it has none. */
val text: String? = null,
/** The pages the body has: only these are pages -- an `html-view` fence the server does not list is a code block. */
val pages: List<StepPage> = emptyList(),
val model: String? = null,
val chat: JsonElement? = null,
) {
@@ -63,7 +65,7 @@ data class ReportList(val reports: List<Report> = emptyList(), val unread: Int?
/** `GET /events`, frame `reports`: the count of the unread, and the newest report. */
@Serializable
data class ReportsFrame(val unread: Int = 0, val newest: Report? = null)
data class ReportsFrame(val unread: Int = 0, val newest: Report? = null, @SerialName("latest_created") val latestCreated: String? = null)
/** `POST /reports/{id}/reply`: the chat the conversation about the report is in. */
@Serializable
@@ -10,9 +10,13 @@ package eu.llembas.android.ui
* is in the middle of is already a code block, not markdown that changes shape when it closes.
*
* **A page** (harness spec 3.8.0, `pages.md`: a whole HTML document in an `html-view` fence) is
* not drawn on a phone and its source is never shown: the fence becomes [Segment.Page] with its
* title, and so does the line the server puts in a page's place where a reply is read as text,
* `[page: Title]`. One still being written is a page already ([Segment.Page.closed] false).
* not drawn on a phone and its source is never shown as the answer. Which fence is a page is the
* server's to say: a block is one only in a reply written while pages were offered, and the
* server then puts the one line `[page: Title]` in its place in the text it gives a client that
* draws no pages. That line is what becomes [Segment.Page]. A fence is taken for a page here
* only where the caller says pages are being written ([splitFences]' `pages`: the open step of
* a reply as it streams, which the server has not turned into text yet); anywhere else an
* `html-view` fence is the code block it is.
*/
sealed interface Segment {
data class Prose(val markdown: String) : Segment
@@ -41,7 +45,7 @@ private fun pageTitle(raw: String?): String = raw.orEmpty().trim().replace(Regex
* Share and read-aloud take, so a page's source never leaves as "the answer". [untitled] names
* a page without a title.
*/
fun pageProjection(markdown: String, untitled: String): String = splitFences(markdown).joinToString("\n\n") { segment ->
fun pageProjection(markdown: String, untitled: String, pages: Boolean = false): String = splitFences(markdown, pages).joinToString("\n\n") { segment ->
when (segment) {
is Segment.Prose -> segment.markdown
is Segment.Code -> "```${segment.language}\n${segment.code}\n```"
@@ -51,7 +55,7 @@ fun pageProjection(markdown: String, untitled: String): String = splitFences(mar
private val OPENING = Regex("^ {0,3}(`{3,}|~{3,})\\s*([^`\\s]*).*$")
fun splitFences(markdown: String): List<Segment> {
fun splitFences(markdown: String, pages: Boolean = false): List<Segment> {
val out = mutableListOf<Segment>()
val prose = StringBuilder()
val lines = markdown.split("\n")
@@ -79,7 +83,7 @@ fun splitFences(markdown: String): List<Segment> {
flushProse()
val fence = open.groupValues[1]
val language = open.groupValues[2]
val page = PAGE_OPENING.matchEntire(lines[i])
val page = if (pages) PAGE_OPENING.matchEntire(lines[i]) else null
val closing = Regex("^ {0,3}${Regex.escape(fence.substring(0, 1))}{${fence.length},}\\s*$")
val code = mutableListOf<String>()
i++
@@ -388,7 +388,9 @@ fun StepsCompact(steps: List<Step>, modifier: Modifier = Modifier, onShow: ((Sho
when (step.kind) {
"thinking" -> ThinkingChip(step)
"text" -> RichMarkdown(step.shownMarkdown, onLongPress = onLongPress)
// A closed step's pages are the server's to name (its `text`); in the step still
// being written a page's fence is a page already, not source scrolling by.
"text" -> RichMarkdown(step.shownMarkdown, onLongPress = onLongPress, pages = step.open)
// A page the server took out of the text as a step of its own: the same card.
"page" -> PageCard(step.title.orEmpty())
@@ -403,8 +405,8 @@ fun StepsCompact(steps: List<Step>, modifier: Modifier = Modifier, onShow: ((Sho
/** Markdown with its fenced code taken out into [CodeBlock]s, each with its own Copy. */
@Composable
fun RichMarkdown(markdown: String, modifier: Modifier = Modifier, onLongPress: (() -> Unit)? = null) {
val segments = remember(markdown) { splitFences(markdown) }
fun RichMarkdown(markdown: String, modifier: Modifier = Modifier, onLongPress: (() -> Unit)? = null, pages: Boolean = false) {
val segments = remember(markdown, pages) { splitFences(markdown, pages) }
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(12.dp)) {
segments.forEach { segment ->
when (segment) {
@@ -277,6 +277,9 @@ class WakeWordService : LifecycleService() {
const val HEARD_ID = 7002
private const val SHEET_GRACE_MS = 3_000L
/** `PackageManager.FEATURE_VOICE_RECOGNIZERS`, which the SDK does not name for apps: without it Android runs no voice-interaction service. */
private const val FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"
/** The app's own scope: a wake and its record outlive the listening loop, and the service too. */
private val wakeScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
@@ -285,7 +288,7 @@ class WakeWordService : LifecycleService() {
connected = LembasAssistService.current != null,
active = LembasAssistService.isActive(context),
role = LembasAssistService.holdsRole(context),
recognizers = context.packageManager.hasSystemFeature(PackageManager.FEATURE_VOICE_RECOGNIZERS),
recognizers = context.packageManager.hasSystemFeature(FEATURE_VOICE_RECOGNIZERS),
screenOn = context.getSystemService(PowerManager::class.java).isInteractive,
locked = context.getSystemService(KeyguardManager::class.java).isKeyguardLocked,
visible = AppVisibility.visible,