Fix UI/UX sweep findings across the Android app

Addresses the survey/review findings on the sweep-ui branch, reusing the
app's existing patterns and named tokens (DetailTabBody, formatLocalTimestamp,
stageCountText, ATTENTION_CHIP_RESERVE) rather than hardcoding values.

Fixed findings:
- n:1  attention-chip reserve (OmniSearchResults, ATTENTION_CHIP_RESERVE in
       Dimens, PipelinesApp bottom content reserve).
- n:2  formatted local timestamps via the shared Format.formatLocalTimestamp
       (PipelinesApp lists, RunHistory, RunSummaryTab, PipelineDetail).
- n:3  decodeHtmlEntities for the session export's HTML entities (Markdown),
       with regression cases for entities and a bold-only line.
- n:4  Raw/Rendered control now labels the current view and its state
       (SourceView).
- n:5  filters as a Material modal bottom sheet capped at a window-derived
       filterMenuMaxHeight with a scrolling body (FilterMenu), plus tests.
- n:7  stage-count wording via the shared stageCountText helper.
- n:8  labelled key row on the template detail screen.
- n:9  stage pane de-duplicates identity / folds the definition.
- n:10 wide-flag plumbing into the destination lists and ChatListPane, which
       now wraps its session list in DetailTabBody(wide, ...) so wide rows keep
       DETAIL_MAX_WIDTH_DP centred.
- n:13 Settings: Disconnect is the filled primary while connected and the
       trust warning moved into a surfaceVariant card.
- n:15 CodeBlock bounded height plus a scroll affordance with an unbounded
       option.

Deferred findings (with reason):
- n:3  (Chat transcript) residual is server-side data: chat_messages returns a
       single assistant part whose text is already interleaved/doubled, so the
       renderer cannot close it. The android half (entities/Markdown) is fixed.
- n:6  Runs list titles arrive truncated to 80 chars mid-word from the server.
- n:11 Two-pane top-band layering is a product/design decision.
- n:12 48dp graph-node hit targets and label dodging are product decisions.
- n:14 The session-list chip is OpenChatStrip (open chats), not a list filter;
       relabelling it would misdescribe it.

Commands: :app:compileDebugKotlin + :app:testDebugUnitTest (562 tests, 0
failures) and :app:assembleDebug all succeed.
This commit is contained in:
2026-10-17 23:27:57 +01:00
parent bdbc964793
commit 2e9ba100bd
22 changed files with 466 additions and 238 deletions
@@ -2,6 +2,8 @@ package net.awan.pipelines.ui
import java.time.Duration
import java.time.OffsetDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
@@ -82,6 +84,27 @@ fun formatDuration(totalSeconds: Long): String {
}
}
/**
* An RFC3339 timestamp as the app's one human, local rendering (`d MMM HH:mm`,
* e.g. `17 Oct 21:26`), or null when blank/unparseable so a caller omits the
* value rather than printing a blank. The runs list's own start line uses it, and
* the pipeline list, versions and every detail share it, so no surface prints the
* server's raw ISO string and the same instant never reads two ways.
*/
fun formatLocalTimestamp(instant: String): String? {
val parsed = parseInstant(instant) ?: return null
return parsed.atZoneSameInstant(ZoneId.systemDefault()).format(LOCAL_TIMESTAMP_FORMAT)
}
private val LOCAL_TIMESTAMP_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMM HH:mm")
/**
* A stage count in the app's one singular/plural spelling (`1 stage` /
* `n stages`), shared by the pipeline list, the pipeline detail and the template
* detail so a single-stage pipeline never reads "1 stages".
*/
fun stageCountText(count: Int): String = "$count ${if (count == 1) "stage" else "stages"}"
/** Compact rendering of arbitrary protocol JSON values for read-only display. */
fun JsonElement.displayText(): String = when (this) {
is JsonPrimitive -> content
@@ -67,14 +67,14 @@ fun searchRow(hit: SearchResult, query: String): SearchRow {
pipeline != null -> SearchRow(
badge,
pipeline.name.ifBlank { "pipeline ${pipeline.id}" },
"pipeline ${pipeline.id} · v${pipeline.version} · ${pipeline.stages} stages",
"pipeline ${pipeline.id} · v${pipeline.version} · ${stageCountText(pipeline.stages)}",
)
version != null -> SearchRow(
badge,
"pipeline ${version.pipelineId} · v${version.version}",
listOfNotNull(
version.contentHash.takeIf { it.isNotBlank() }?.let { "content $it" },
version.createdAt.takeIf { it.isNotBlank() },
formatLocalTimestamp(version.createdAt),
).joinToString(" · "),
)
run != null -> SearchRow(
@@ -83,7 +83,7 @@ fun searchRow(hit: SearchResult, query: String): SearchRow {
listOfNotNull(
run.status.takeIf { it.isNotBlank() },
run.workspace?.takeIf { it.isNotBlank() },
run.createdAt.takeIf { it.isNotBlank() },
formatLocalTimestamp(run.createdAt),
).joinToString(" · "),
)
step != null -> SearchRow(
@@ -68,6 +68,7 @@ internal fun PipelineDestination(
modifier = paneModifier,
selectedId = selection.itemId.takeIf { depth >= 1 },
covered = covered,
wide = wide,
listState = listState,
)
1 -> rememberPaneContent(
@@ -54,6 +54,7 @@ import net.awan.pipelines.ui.components.MotionStandard
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.spec
import net.awan.pipelines.ui.screens.SettingsScreen
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
import net.awan.pipelines.ui.theme.SPACING_S
@@ -230,7 +231,7 @@ fun PipelinesApp(
val bannerVisible = connectionState !is ConnectionState.Connected
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
Box(Modifier.fillMaxSize().padding(padding)) {
Column(Modifier.fillMaxSize().padding(bottom = destinationPillReserve(pillVisible))) {
Column(Modifier.fillMaxSize().padding(bottom = destinationPillReserve(pillVisible) + ATTENTION_CHIP_RESERVE)) {
ConnectionBanner(
state = connectionState,
configuredUrl = configuredUrl,
@@ -287,7 +288,7 @@ fun PipelinesApp(
TemplatesDestination(vm = vm, wide = wide, listState = templateListState)
}
composable("settings") {
SettingsScreen(vm)
SettingsScreen(vm, wide = wide)
}
}
}
@@ -79,6 +79,7 @@ internal fun RunsDestination(
modifier = paneModifier,
selectedRunId = selection.itemId.takeIf { depth >= 1 },
covered = covered,
wide = wide,
listState = listState,
)
1 -> rememberPaneContent(
@@ -73,6 +73,5 @@ internal fun templateGridColumns(
*/
internal fun templateStageCountLabel(stageCount: Int?): String = when (stageCount) {
null -> "stage count unavailable"
1 -> "1 stage"
else -> "$stageCount stages"
else -> stageCountText(stageCount)
}
@@ -46,6 +46,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import net.awan.pipelines.data.protocol.ChatSession
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.EmptyState
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.FilterMenu
@@ -70,6 +71,7 @@ internal fun ChatListPane(
state: ChatState,
connected: Boolean,
covered: Boolean,
wide: Boolean,
modifier: Modifier,
) {
// A covered pane shows its compact identity only; the server list and the
@@ -162,30 +164,36 @@ internal fun ChatListPane(
actionLabel = "New chat",
onAction = vm::startNewChat,
)
else -> LazyColumn(Modifier.fillMaxSize()) {
if (groups.size > 1) {
// More than one directory: one section per repository so
// same-directory chats sit together, each keeping the
// recency order inside it.
groups.forEach { group ->
item(key = "dir-" + group.directory) { DirectoryHeader(group.directory) }
items(group.sessions, key = { it.id }) { session ->
// On a wide window the session rows keep the app's comfortable
// reading width (centred) instead of letting the identity's chips
// drift hundreds of pixels from its title, the same constraint the
// other lists and detail bodies use; narrow windows fill as before.
else -> DetailTabBody(wide, Modifier.fillMaxSize()) { listModifier ->
LazyColumn(listModifier) {
if (groups.size > 1) {
// More than one directory: one section per repository so
// same-directory chats sit together, each keeping the
// recency order inside it.
groups.forEach { group ->
item(key = "dir-" + group.directory) { DirectoryHeader(group.directory) }
items(group.sessions, key = { it.id }) { session ->
SessionListItem(state, session, vm, onRename = { renaming = it })
}
}
} else {
items(sessions, key = { it.id }) { session ->
SessionListItem(state, session, vm, onRename = { renaming = it })
}
}
} else {
items(sessions, key = { it.id }) { session ->
SessionListItem(state, session, vm, onRename = { renaming = it })
}
}
if (state.sessionsError != null) {
item("error") {
Text(
text = state.sessionsError,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
modifier = Modifier.padding(CHAT_GUTTER),
)
if (state.sessionsError != null) {
item("error") {
Text(
text = state.sessionsError,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
modifier = Modifier.padding(CHAT_GUTTER),
)
}
}
}
}
@@ -67,6 +67,7 @@ fun ChatScreen(vm: AppViewModel, wide: Boolean, modifier: Modifier = Modifier) {
state = state,
connected = connection is ConnectionState.Connected,
covered = covered,
wide = wide,
modifier = paneModifier,
)
1 -> when {
@@ -75,9 +75,52 @@ internal data class MdLinkSpan(val spans: List<MdSpan>, val url: String) : MdSpa
// ---- Block parser ------------------------------------------------------------
/**
* Decodes the HTML entities an assistant message can carry: the server's own
* session export escapes text with Go's `html.EscapeString`, so a message that
* quotes an export arrives with `&#x27;`, `&quot;`, `&amp;` and friends still in
* it. The common named entities plus numeric decimal and hex references are
* decoded; an unknown or malformed reference is left exactly as written so no
* visible text is invented. A single left-to-right pass never re-decodes an entity
* produced by decoding another (`&amp;lt;` stays `&lt;`).
*/
internal fun decodeHtmlEntities(text: String): String {
if ('&' !in text) return text
return HTML_ENTITY.replace(text) { match ->
when (val body = match.groupValues[1]) {
"amp" -> "&"
"lt" -> "<"
"gt" -> ">"
"quot" -> "\""
"apos" -> "'"
"nbsp" -> "\u00A0"
"hellip" -> "\u2026"
"mdash" -> "\u2014"
"ndash" -> "\u2013"
"lsquo" -> "\u2018"
"rsquo" -> "\u2019"
"ldquo" -> "\u201C"
"rdquo" -> "\u201D"
else -> numericReference(body) ?: match.value
}
}
}
/** The character one numeric entity's body (`#27`/`#x1b`) names, or null. */
private fun numericReference(body: String): String? {
val codePoint = when {
body.startsWith("#x") || body.startsWith("#X") -> body.drop(2).toIntOrNull(16)
body.startsWith("#") -> body.drop(1).toIntOrNull()
else -> null
} ?: return null
return if (codePoint in 1..0x10FFFF) String(Character.toChars(codePoint)) else null
}
private val HTML_ENTITY = Regex("&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z][A-Za-z0-9]*);")
/** Parses [source] into the block list the renderer walks. Never throws. */
internal fun parseMarkdown(source: String): List<MdBlock> {
val lines = source.replace("\r\n", "\n").replace('\r', '\n').split('\n')
val lines = decodeHtmlEntities(source).replace("\r\n", "\n").replace('\r', '\n').split('\n')
val blocks = mutableListOf<MdBlock>()
var i = 0
while (i < lines.size) {
@@ -1,9 +1,12 @@
package net.awan.pipelines.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -20,6 +23,8 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -27,6 +32,7 @@ import net.awan.pipelines.ui.theme.ICON_INLINE_DP
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_S
import net.awan.pipelines.ui.theme.SPACING_XS
import net.awan.pipelines.ui.theme.SPACING_XXL
import net.awan.pipelines.ui.theme.pipelinesText
/**
@@ -41,7 +47,8 @@ import net.awan.pipelines.ui.theme.pipelinesText
* - monospace body at the shared [pipelinesText] `mono` size/line height;
* - a bounded height so long content scrolls *inside* the card instead of
* pushing the page down. The internal scroll is finite-height, so it is safe
* inside the tab's single LazyColumn (never an unbounded same-direction nest).
* inside the tab's single LazyColumn (never an unbounded same-direction nest);
* a fade at the cut edge marks that more content remains below.
*
* Pass `maxHeight = null` to render the whole block unbounded and let the
* surrounding page scroll as a whole (used by the Source tab, whose single
@@ -60,6 +67,9 @@ fun CodeBlock(
if (text.isBlank()) return
val styles = pipelinesText()
val clipboard = LocalClipboardManager.current
// One scroll state for the bounded body, so the fade below tracks exactly the
// scroll the body performs.
val scrollState = rememberScrollState()
Card(
modifier = modifier.fillMaxWidth(),
@@ -88,19 +98,41 @@ fun CodeBlock(
)
}
}
val body = if (maxHeight != null) {
Modifier
.fillMaxWidth()
.heightIn(max = maxHeight)
.verticalScroll(rememberScrollState())
val bodyPadding = Modifier.padding(start = SPACING_L, end = SPACING_L, bottom = SPACING_L)
if (maxHeight != null) {
Box(Modifier.fillMaxWidth()) {
Text(
text = text,
style = styles.mono,
modifier = Modifier
.fillMaxWidth()
.heightIn(max = maxHeight)
.verticalScroll(scrollState)
.then(bodyPadding),
)
// A fade at the cut edge while more content remains below, so a
// value clipped at the cap reads as continuing rather than ended.
if (scrollState.canScrollForward) {
Box(
Modifier
.align(Alignment.BottomCenter)
.fillMaxWidth()
.height(SPACING_XXL)
.background(
Brush.verticalGradient(
listOf(Color.Transparent, MaterialTheme.colorScheme.surfaceContainerHigh),
),
),
)
}
}
} else {
Modifier.fillMaxWidth()
Text(
text = text,
style = styles.mono,
modifier = Modifier.fillMaxWidth().then(bodyPadding),
)
}
Text(
text = text,
style = styles.mono,
modifier = body.padding(start = SPACING_L, end = SPACING_L, bottom = SPACING_L),
)
}
}
}
@@ -2,28 +2,28 @@ package net.awan.pipelines.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -37,6 +37,7 @@ import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import net.awan.pipelines.ui.theme.SPACING_L
@@ -47,12 +48,11 @@ import net.awan.pipelines.ui.theme.pipelinesText
/**
* The tallest a list-filter menu may grow, as a fraction of the window height.
* Derived from the window rather than a fixed row count so the menu stays inside
* the window and clear of the navigation inset no matter how many distinct
* pipelines the runs list contributes (N made the old menu unbounded); beyond
* this the menu scrolls internally.
* Deliberately well under the window so the bottom sheet that presents the
* filters always leaves the app bar (and the list behind it) visible; beyond this
* the sheet's body scrolls rather than growing to cover the whole screen.
*/
internal fun filterMenuMaxHeight(screenHeightDp: Int): Dp = (screenHeightDp * 0.85f).dp
internal fun filterMenuMaxHeight(screenHeightDp: Int): Dp = (screenHeightDp * 0.7f).dp
/**
* The filter icon's content description. With active filters the count is spoken
@@ -70,18 +70,19 @@ internal fun filterMenuDescription(base: String, activeCount: Int): String = whe
* badge, opening the caller's [optionContent] plus one [resetLabel] action. It is
* its own action with a distinct glyph and content description, so it cannot
* collide with the adjacent sort or refresh actions, and the same control serves
* both list widths (a `DropdownMenu` is not width-dependent geometry).
* both list widths.
*
* [activeCount] is drawn as a numeric badge (0 hides it) and folded into the
* icon's description, so "filters are active" is never colour alone and the
* count is announced. The menu is capped at a window-derived [filterMenuMaxHeight]
* and the reset action is the first item, so the reset is always in view on open
* and the last option is reachable by scrolling rather than clipped; a trailing
* navigation-bar spacer keeps the final option above the gesture inset.
* [optionContent] receives a `dismiss` callback: a single-select entry calls it to
* close the menu, while a multi-select toggle simply omits it to keep the menu
* open.
* The options are presented as a Material modal bottom sheet, not an anchored
* menu: the sheet is bottom-anchored and scrolls, so a filter popup can never grow
* up over the app-bar title, and its body is capped at a window-derived
* [filterMenuMaxHeight] (leaving the app bar visible) with a familiar scroll
* affordance. [activeCount] is drawn as a numeric badge (0 hides it) and folded
* into the icon's description, so "filters are active" is never colour alone and
* the count is announced. [optionContent] receives a `dismiss` callback: a
* single-select entry calls it to close the sheet, while a multi-select toggle
* simply omits it to keep the sheet open.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FilterMenu(
activeCount: Int,
@@ -92,8 +93,8 @@ fun FilterMenu(
optionContent: @Composable (dismiss: () -> Unit) -> Unit,
) {
var expanded by remember { mutableStateOf(false) }
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val maxMenuHeight = filterMenuMaxHeight(LocalConfiguration.current.screenHeightDp)
val bottomInset = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
Box(modifier) {
BadgedBox(
badge = {
@@ -109,34 +110,42 @@ fun FilterMenu(
)
}
}
DropdownMenu(
expanded = expanded,
}
if (expanded) {
ModalBottomSheet(
onDismissRequest = { expanded = false },
modifier = Modifier.heightIn(max = maxMenuHeight),
sheetState = sheetState,
) {
Row(
modifier = Modifier.fillMaxWidth().padding(start = SPACING_L, end = SPACING_XS),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
Column(
modifier = Modifier
.fillMaxWidth()
.heightIn(max = maxMenuHeight)
.verticalScroll(rememberScrollState())
.padding(bottom = SPACING_L),
) {
Text(
text = "Filters",
style = pipelinesText().label,
color = MaterialTheme.colorScheme.primary,
)
TextButton(
onClick = {
onReset()
expanded = false
},
enabled = activeCount > 0,
Row(
modifier = Modifier.fillMaxWidth().padding(start = SPACING_L, end = SPACING_XS),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(resetLabel)
Text(
text = "Filters",
style = pipelinesText().label,
color = MaterialTheme.colorScheme.primary,
)
TextButton(
onClick = {
onReset()
expanded = false
},
enabled = activeCount > 0,
) {
Text(resetLabel)
}
}
HorizontalDivider()
optionContent { expanded = false }
}
HorizontalDivider()
optionContent { expanded = false }
Spacer(Modifier.height(bottomInset))
}
}
}
@@ -156,7 +165,7 @@ fun FilterCheckItem(
onClick: () -> Unit,
) {
DropdownMenuItem(
text = { Text(label) },
text = { Text(label, maxLines = 1, overflow = TextOverflow.Ellipsis) },
onClick = onClick,
modifier = Modifier.semantics {
role = Role.Checkbox
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
@@ -25,6 +26,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import net.awan.pipelines.data.protocol.Graph
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.collapsibleSection
@@ -76,8 +79,24 @@ internal fun PipelineSourceView(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
) {
OutlinedButton(onClick = { showRaw = !showRaw }) {
Text(if (showRaw) "Rendered" else "Raw")
// The label always names the raw-source view; the selected
// container colour (a tonal fill while raw is showing) and the
// state description carry the current view, so the control never
// names the state it would switch to.
if (showRaw) {
FilledTonalButton(
onClick = { showRaw = false },
modifier = Modifier.semantics { stateDescription = "Showing the raw source" },
) {
Text("Raw")
}
} else {
OutlinedButton(
onClick = { showRaw = true },
modifier = Modifier.semantics { stateDescription = "Showing the rendered view" },
) {
Text("Raw")
}
}
OutlinedButton(onClick = { clipboard.copyText(source) }) {
Icon(
@@ -28,8 +28,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -530,11 +528,9 @@ private fun StageDetailBody(
// unconditionally so the open sheet survives a refusal (which clears the
// decision) and can report the server's reason.
DecisionPrompt(decision = decision, onSend = onDecide)
Text(
GraphSemantics.nodeLabel(stageKey),
style = text.screenTitle,
modifier = Modifier.semantics { heading() },
)
// The stage's own name is the app bar's title, so the body does not
// repeat it: the pane leads with the stage's type and facts instead of
// a duplicated heading.
StageTypeChip(typeLabel)
StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
@@ -762,7 +758,7 @@ private fun StageSectionBody(
.padding(horizontal = SPACING_L, vertical = SPACING_L),
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
Text(GraphSemantics.nodeLabel(stageKey), style = text.meta)
KeyValueRow("Stage", GraphSemantics.nodeLabel(stageKey))
if (spec != null && spec.key != STAGE_DEFINITION_KEY) {
StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
}
@@ -54,8 +54,10 @@ import net.awan.pipelines.ui.components.detailLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.formatLocalTimestamp
import net.awan.pipelines.ui.graph.PipelineSourceView
import net.awan.pipelines.ui.graph.WorkflowGraph
import net.awan.pipelines.ui.stageCountText
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_M
import net.awan.pipelines.ui.theme.SPACING_S
@@ -207,14 +209,14 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
) {
Text(detail.name, style = text.screenTitle)
Text(
"id ${detail.id} · v${detail.version} · ${detail.graph.stages.size} stages",
"id ${detail.id} · v${detail.version} · ${stageCountText(detail.graph.stages.size)}",
style = text.meta,
)
KeyValueRow("Content hash", detail.contentHash, monospace = true)
KeyValueRow("Latest version", if (detail.latestVersion > 0) "v${detail.latestVersion}" else "")
KeyValueRow("Version created", detail.versionCreatedAt)
KeyValueRow("Pipeline created", detail.createdAt)
KeyValueRow("Pipeline updated", detail.updatedAt)
KeyValueRow("Version created", formatLocalTimestamp(detail.versionCreatedAt).orEmpty())
KeyValueRow("Pipeline created", formatLocalTimestamp(detail.createdAt).orEmpty())
KeyValueRow("Pipeline updated", formatLocalTimestamp(detail.updatedAt).orEmpty())
}
}
@@ -281,8 +283,8 @@ private fun VersionRow(v: VersionSummary, modifier: Modifier = Modifier) {
Card(modifier.fillMaxWidth()) {
Row(Modifier.padding(SPACING_M), horizontalArrangement = Arrangement.spacedBy(SPACING_M)) {
Text("v${v.version}", style = text.cardTitle)
Text("${v.stages} stages", style = text.meta)
Text(v.createdAt, style = text.meta)
Text(stageCountText(v.stages), style = text.meta)
formatLocalTimestamp(v.createdAt)?.let { Text(it, style = text.meta) }
}
}
}
@@ -37,6 +37,7 @@ import java.time.OffsetDateTime
import java.time.ZoneId
import net.awan.pipelines.data.protocol.PipelineSummary
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.EmptyState
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.FilterCheckItem
@@ -55,6 +56,8 @@ import net.awan.pipelines.ui.components.animateListItem
import net.awan.pipelines.ui.components.listLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.rememberLiveNowMillis
import net.awan.pipelines.ui.formatLocalTimestamp
import net.awan.pipelines.ui.stageCountText
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_M
import net.awan.pipelines.ui.theme.SPACING_S
@@ -68,6 +71,7 @@ fun PipelineListScreen(
modifier: Modifier = Modifier,
selectedId: Long? = null,
covered: Boolean = false,
wide: Boolean = false,
listState: LazyListState,
) {
val state by vm.pipelines.collectAsStateWithLifecycle()
@@ -216,20 +220,25 @@ fun PipelineListScreen(
// Restores the saved position (clamped to the current,
// possibly shrunken, list) without fighting a later scroll.
RestoreListScroll(listState, items.size)
LazyColumn(
state = listState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = SPACING_S),
) {
items(items, key = { it.id }) { pipeline ->
PipelineRow(
pipeline = pipeline,
selected = pipeline.id == selectedId,
badge = badges[pipeline.id],
runsKnown = runsKnown,
onClick = { onOpen(pipeline.id, pipeline.version) },
modifier = animateListItem(),
)
// On a wide window the rows keep the app's comfortable
// reading width (centred) instead of stretching to the whole
// pane, the same constraint every detail body uses.
DetailTabBody(wide, Modifier.fillMaxSize()) { listModifier ->
LazyColumn(
state = listState,
modifier = listModifier,
contentPadding = PaddingValues(vertical = SPACING_S),
) {
items(items, key = { it.id }) { pipeline ->
PipelineRow(
pipeline = pipeline,
selected = pipeline.id == selectedId,
badge = badges[pipeline.id],
runsKnown = runsKnown,
onClick = { onOpen(pipeline.id, pipeline.version) },
modifier = animateListItem(),
)
}
}
}
}
@@ -342,14 +351,14 @@ private fun PipelineRow(
overflow = TextOverflow.Ellipsis,
)
Text(
"id ${pipeline.id} · v${pipeline.version} · ${pipeline.stages} stages",
"id ${pipeline.id} · v${pipeline.version} · ${stageCountText(pipeline.stages)}",
style = text.meta,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
if (pipeline.updatedAt.isNotBlank()) {
formatLocalTimestamp(pipeline.updatedAt)?.let { updated ->
Text(
"updated ${pipeline.updatedAt}",
"updated $updated",
style = text.meta,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
@@ -48,6 +48,7 @@ import java.time.format.DateTimeFormatter
import net.awan.pipelines.data.protocol.RunSummary
import net.awan.pipelines.data.protocol.UsageStats
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.EmptyState
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.FilterCheckItem
@@ -72,6 +73,7 @@ import net.awan.pipelines.ui.components.runStateColor
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.RUN_ROW_TITLE_LINES
import net.awan.pipelines.ui.formatDuration
import net.awan.pipelines.ui.formatLocalTimestamp
import net.awan.pipelines.ui.runDurationText
import net.awan.pipelines.ui.runIdentity
import net.awan.pipelines.ui.theme.ICON_LIST_DP
@@ -93,6 +95,7 @@ fun RunHistoryScreen(
filterPipelineId: Long? = null,
selectedRunId: Long? = null,
covered: Boolean = false,
wide: Boolean = false,
listState: LazyListState,
) {
val state by vm.runs.collectAsStateWithLifecycle()
@@ -207,6 +210,7 @@ fun RunHistoryScreen(
error = state.error,
onOpenRun = onOpenRun,
onClearFilters = onClearFilters,
wide = wide,
listState = listState,
modifier = Modifier.padding(padding),
)
@@ -276,6 +280,7 @@ private fun RunHistoryContent(
error: String?,
onOpenRun: (Long) -> Unit,
onClearFilters: () -> Unit,
wide: Boolean,
listState: LazyListState,
modifier: Modifier = Modifier,
) {
@@ -318,46 +323,51 @@ private fun RunHistoryContent(
val live = remember(matched) { matched.any { it.executing } }
val nowMillis = rememberLiveNowMillis(live)
LazyColumn(
state = listState,
modifier = modifier.fillMaxSize(),
contentPadding = PaddingValues(bottom = SPACING_L),
) {
entries.forEach { entry ->
when (entry) {
is RunListEntry.Usage -> item(key = entry.key) {
UsageMetrics(
entry.usage,
Modifier.padding(horizontal = SPACING_L, vertical = SPACING_S),
)
}
is RunListEntry.Empty -> item(key = entry.key) {
EmptyState(
message = entry.message,
actionLabel = entry.actionLabel,
// Only the filtered-empty case offers a clear action, which
// [runListEntries] encodes as a non-null label.
onAction = if (entry.actionLabel != null) onClearFilters else null,
modifier = animateListItem(),
)
}
is RunListEntry.Day -> stickyHeader(key = entry.key) { DayHeader(entry.label) }
is RunListEntry.Run -> item(key = entry.key) {
RunRow(
run = entry.run,
selected = entry.run.id == selectedRunId,
nowMillis = nowMillis,
onClick = { onOpenRun(entry.run.id) },
modifier = animateListItem(),
)
}
is RunListEntry.Error -> item(key = entry.key) {
Text(
entry.message,
color = MaterialTheme.colorScheme.error,
style = pipelinesText().body,
modifier = animateListItem(Modifier.padding(SPACING_L)),
)
// On a wide window the list keeps the app's comfortable reading width
// (centred) instead of stretching to the whole pane, the same constraint every
// detail body uses; a narrow window fills it as before.
DetailTabBody(wide, modifier) { listModifier ->
LazyColumn(
state = listState,
modifier = listModifier,
contentPadding = PaddingValues(bottom = SPACING_L),
) {
entries.forEach { entry ->
when (entry) {
is RunListEntry.Usage -> item(key = entry.key) {
UsageMetrics(
entry.usage,
Modifier.padding(horizontal = SPACING_L, vertical = SPACING_S),
)
}
is RunListEntry.Empty -> item(key = entry.key) {
EmptyState(
message = entry.message,
actionLabel = entry.actionLabel,
// Only the filtered-empty case offers a clear action, which
// [runListEntries] encodes as a non-null label.
onAction = if (entry.actionLabel != null) onClearFilters else null,
modifier = animateListItem(),
)
}
is RunListEntry.Day -> stickyHeader(key = entry.key) { DayHeader(entry.label) }
is RunListEntry.Run -> item(key = entry.key) {
RunRow(
run = entry.run,
selected = entry.run.id == selectedRunId,
nowMillis = nowMillis,
onClick = { onOpenRun(entry.run.id) },
modifier = animateListItem(),
)
}
is RunListEntry.Error -> item(key = entry.key) {
Text(
entry.message,
color = MaterialTheme.colorScheme.error,
style = pipelinesText().body,
modifier = animateListItem(Modifier.padding(SPACING_L)),
)
}
}
}
}
@@ -617,20 +627,11 @@ private fun metaText(run: RunSummary, nowMillis: Long): String = buildString {
if (run.executing) {
runDurationText(run.createdAt, run.finishedAt, executing = true, nowMillis)?.let { append(" · $it") }
} else {
formatRunStart(run.createdAt)?.let { append(" · $it") }
formatLocalTimestamp(run.createdAt)?.let { append(" · $it") }
runDurationText(run.createdAt, run.finishedAt, executing = false, nowMillis)?.let { append(" · $it") }
}
}
private fun formatRunStart(createdAt: String): String? {
if (createdAt.isBlank()) return null
return runCatching {
OffsetDateTime.parse(createdAt)
.atZoneSameInstant(ZoneId.systemDefault())
.format(START_FORMAT)
}.getOrNull()
}
internal data class RunDayGroup(val label: String, val runs: List<RunSummary>)
/**
@@ -662,4 +663,3 @@ internal fun dayLabel(createdAt: String, today: LocalDate, zone: ZoneId): String
}
private val DAY_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMM yyyy")
private val START_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMM HH:mm")
@@ -25,6 +25,7 @@ import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.rememberLiveNowMillis
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.formatLocalTimestamp
import net.awan.pipelines.ui.graph.ArtifactGallery
import net.awan.pipelines.ui.graph.ArtifactSelection
import net.awan.pipelines.ui.runArtifactsHeader
@@ -133,8 +134,8 @@ internal fun RunSummaryTab(
KeyValueRow("Stage", run.currentStage)
KeyValueRow("Workspace", run.workspace)
KeyValueRow("Content hash", run.contentHash, monospace = true)
KeyValueRow("Started", run.createdAt)
KeyValueRow("Finished", run.finishedAt)
KeyValueRow("Started", formatLocalTimestamp(run.createdAt).orEmpty())
KeyValueRow("Finished", formatLocalTimestamp(run.finishedAt).orEmpty())
RunDurationRow(run)
KeyValueRow("Retry of", if (run.retryOf > 0) "run ${run.retryOf}" else "")
CodeBlock("Diagnostic", run.diagnostic, Modifier.padding(top = SPACING_S))
@@ -4,18 +4,20 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.WarningAmber
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
@@ -30,11 +32,12 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import net.awan.pipelines.data.transport.ConnectionState
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.paneSafeArea
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier) {
fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier, wide: Boolean = false) {
val serverUrl by vm.serverUrlDraft.collectAsStateWithLifecycle()
val workspace by vm.workspaceDraft.collectAsStateWithLifecycle()
val urlError by vm.urlError.collectAsStateWithLifecycle()
@@ -56,6 +59,7 @@ fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier) {
) { padding ->
SettingsContent(
padding = Modifier.padding(padding),
wide = wide,
serverUrl = serverUrl,
onServerUrlChange = vm::updateServerUrlDraft,
urlError = urlError,
@@ -78,6 +82,7 @@ fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier) {
@Composable
private fun SettingsContent(
padding: Modifier,
wide: Boolean,
serverUrl: String,
onServerUrlChange: (String) -> Unit,
urlError: String?,
@@ -94,72 +99,106 @@ private fun SettingsContent(
onReconnect: () -> Unit,
onSaveWorkspace: () -> Unit,
) {
Column(
modifier = padding
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Text("Connection", style = MaterialTheme.typography.titleMedium)
// The settings body keeps the app's comfortable reading width on a wide
// window (centred) instead of letting a helper line run the whole 2000px.
DetailTabBody(wide, padding) { columnModifier ->
Column(
modifier = columnModifier
.verticalScroll(rememberScrollState())
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Text("Connection", style = MaterialTheme.typography.titleMedium)
OutlinedTextField(
value = serverUrl,
onValueChange = onServerUrlChange,
label = { Text("Server URL") },
placeholder = { Text("ws://192.168.1.20:8081/connect") },
singleLine = true,
isError = urlError != null,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
supportingText = {
Text(urlError ?: "ws:// on a trusted LAN/VPN, or wss:// through a proxy/VPN. No authentication is used.")
},
modifier = Modifier.fillMaxWidth(),
)
OutlinedTextField(
value = serverUrl,
onValueChange = onServerUrlChange,
label = { Text("Server URL") },
placeholder = { Text("ws://192.168.1.20:8081/connect") },
singleLine = true,
isError = urlError != null,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
supportingText = {
Text(urlError ?: "ws:// on a trusted LAN/VPN, or wss:// through a proxy/VPN. No authentication is used.")
},
modifier = Modifier.fillMaxWidth(),
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(onClick = onConnect) { Text("Connect") }
if (state is ConnectionState.Connected || state is ConnectionState.Connecting) {
OutlinedButton(onClick = onDisconnect) { Text("Disconnect") }
} else {
OutlinedButton(onClick = onReconnect) { Text("Reconnect") }
// The primary action reflects the connection: while connected (or
// connecting) the meaningful action is Disconnect, so it takes the
// filled button and Connect drops to the de-emphasised outline.
val active = state is ConnectionState.Connected || state is ConnectionState.Connecting
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
if (active) {
Button(onClick = onDisconnect) { Text("Disconnect") }
OutlinedButton(onClick = onConnect) { Text("Connect") }
} else {
Button(onClick = onConnect) { Text("Connect") }
OutlinedButton(onClick = onReconnect) { Text("Reconnect") }
}
}
ConnectionStatusCard(state, buildVersion, buildCommit, serverTime)
TrustWarning()
Text("Workspace", style = MaterialTheme.typography.titleMedium)
OutlinedTextField(
value = workspace,
onValueChange = onWorkspaceChange,
label = { Text("Workspace path (on the server)") },
placeholder = { Text("/Users/you/repos/pipelines") },
singleLine = true,
isError = workspaceError != null,
supportingText = {
Text(
workspaceError
?: "An absolute directory that already exists on the execution server. For Docker, " +
"mount the host directory at the same absolute path with its owner's UID/GID. " +
"This is not the phone's storage.",
)
},
modifier = Modifier.fillMaxWidth(),
)
Button(onClick = onSaveWorkspace, enabled = workspaceError == null) { Text("Save workspace") }
Text("Saved workspace: ${configuredWorkspace.ifBlank { "(none)" }}")
}
}
}
/**
* The trusted-network warning: an error-tinted icon and headline on the
* low-emphasis surface-variant container, so it still warns without the
* full-saturation error container dominating the screen.
*/
@Composable
private fun TrustWarning() {
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant)) {
Row(
modifier = Modifier.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
imageVector = Icons.Default.WarningAmber,
contentDescription = null,
tint = MaterialTheme.colorScheme.error,
)
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
Text(
text = "Trusted LAN/VPN only",
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.error,
)
Text(
text = "The Pipelines API has no authentication and is not internet-safe. Do not " +
"expose it to untrusted networks, and never enter provider credentials here \u2014 " +
"the app stores none.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
ConnectionStatusCard(state, buildVersion, buildCommit, serverTime)
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer)) {
Text(
text = "Trusted LAN/VPN only. The Pipelines API has no authentication and is not " +
"internet-safe. Do not expose it to untrusted networks, and never enter provider " +
"credentials here \u2014 the app stores none.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onErrorContainer,
modifier = Modifier.padding(16.dp),
)
}
Text("Workspace", style = MaterialTheme.typography.titleMedium)
OutlinedTextField(
value = workspace,
onValueChange = onWorkspaceChange,
label = { Text("Workspace path (on the server)") },
placeholder = { Text("/Users/you/repos/pipelines") },
singleLine = true,
isError = workspaceError != null,
supportingText = {
Text(
workspaceError
?: "An absolute directory that already exists on the execution server. For Docker, " +
"mount the host directory at the same absolute path with its owner's UID/GID. " +
"This is not the phone's storage.",
)
},
modifier = Modifier.fillMaxWidth(),
)
Button(onClick = onSaveWorkspace, enabled = workspaceError == null) { Text("Save workspace") }
Text("Saved workspace: ${configuredWorkspace.ifBlank { "(none)" }}")
}
}
@@ -42,6 +42,7 @@ import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.DetailTabs
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
@@ -171,7 +172,7 @@ private fun TemplateSummaryTab(entry: TemplateEntry, wide: Boolean, modifier: Mo
if (entry.description.isNotBlank()) {
Text(entry.description, style = text.body)
}
Text("key ${entry.key}", style = text.meta)
KeyValueRow("Key", entry.key, monospace = true)
Text(templateStageCountLabel(entry.graph?.stages?.size), style = text.meta)
if (entry.scheduled) {
Text("Includes a schedule", style = text.meta)
@@ -81,6 +81,15 @@ internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp
*/
internal val DESTINATION_PILL_RESERVE = 88.dp
/**
* Bottom space the floating attention chip occupies above the destination pill:
* the chip's own height (its single label line plus its vertical padding) plus the
* gap below it. Reserved at the bottom of the content whether or not a chip is
* present, so the chip can never be laid out over a row, a field or a button and
* the content does not jump as it appears and clears.
*/
internal val ATTENTION_CHIP_RESERVE = SPACING_XXL + SPACING_M
// ---- Detail rail and max content width (ui/components/DetailTabs.kt) -------
/** The always-visible wide section rail's width (icons with labels). */
@@ -92,4 +92,31 @@ class MarkdownTest {
assertEquals(emptyList<MdBlock>(), parseMarkdown(""))
assertEquals(emptyList<MdBlock>(), parseMarkdown("\n\n"))
}
@Test
fun htmlEntitiesFromASessionExportAreDecoded() {
// The server's session export escapes text with html.EscapeString, so a
// message quoting one arrives with these still in it.
assertEquals(
"it's a \"quoted\" line",
(parseMarkdown("it&#x27;s a &quot;quoted&quot; line").single() as MdParagraph).text,
)
assertEquals(
"a & b < c > d",
(parseMarkdown("a &amp; b &lt; c &gt; d").single() as MdParagraph).text,
)
assertEquals("it's", (parseMarkdown("it&#39;s").single() as MdParagraph).text)
}
@Test
fun decodingAnEntityNeverReDecodesAnother() {
// `&amp;lt;` is the literal text "&lt;", not the "<" a second pass would make.
assertEquals("&lt;", (parseMarkdown("&amp;lt;").single() as MdParagraph).text)
}
@Test
fun aBoldOnlyLineBecomesAStrongSpan() {
val paragraph = parseMarkdown("**ai**").single() as MdParagraph
assertEquals(listOf(MdStrong(listOf(MdPlain("ai")))), parseInline(paragraph.text))
}
}
@@ -11,11 +11,18 @@ class FilterMenuTest {
@Test
fun menuHeightGrowsWithTheWindowAndStaysPositive() {
assertEquals(0.85f * 700f, filterMenuMaxHeight(700).value, 0.01f)
assertEquals(0.7f * 700f, filterMenuMaxHeight(700).value, 0.01f)
assertTrue(filterMenuMaxHeight(360) > 0.dp)
assertTrue(filterMenuMaxHeight(700) > filterMenuMaxHeight(360))
}
@Test
fun theMenuLeavesMostOfTheWindowForTheAppBarAndList() {
// The cap is well under the window so the bottom sheet never grows up over
// the app-bar title.
assertTrue(filterMenuMaxHeight(700) < 700.dp * 0.8f)
}
// --- accessibility description ---------------------------------------------
@Test