fix(sessions): Messages stat card + slim prune button (#855)

* fix(sessions): show Messages stat + slim prune button

The Active stat card always rendered 0: the mobile model declared
'val active: Int = 0', a key GET /api/sessions/stats never sends
(backend returns total/active_store/archived/messages/by_source), and
with ignoreUnknownKeys = true deserialization silently fell back to 0.

Rework the stats row instead of just key-mapping:
- Messages card replaces Active, reading the 'messages' key
  (db.message_count(), web_routers/sessions.py:523-550)
- Prune becomes a slim 52dp icon-only card (contentDescription keeps it
  accessible) so the Messages card keeps width for large counts

* feat(sessions): compact stat counts (100k / 1.23m) for Total & Messages

formatCompactCount renders counts as max 3 digits + unit letter:
987 -> '987', 100987 -> '100k', 1234567 -> '1.23m', 100000000 -> '100m'.
Applied to both the Total and Messages stat cards so large numbers fit
the row. Covered by SessionsStatsFormatTest (5 test cases).

* fix(sessions): label prune + empty-cleanup buttons, drop top select toggle

- Prune card now sizes to its label (icon + 'Prune' text) instead of a
  52dp icon-only square, staying compact via wrap-content width.
- Empty-session cleanup becomes a labeled FilledTonalButton (icon +
  'Delete empty sessions', count badge kept) instead of a bare icon.
- Removed the top-bar select toggle (SelectAll icon); selection mode
  remains reachable via long-press > Select on any session row.
- Dropped now-orphaned content_desc_enter/exit_selection strings (en/ko).

* fix(sessions): prune card wrap-content width + shorter cleanup label

The prune card dropped its fixed 52dp width but kept fillMaxSize on the
inner Box — as an unweighted Row child that expands to the full row
width, starving the weighted Total/Messages cards (reported broken on
device). The Box now fills height only, so the Card wraps to its
content (icon + 'Prune').

Empty-session cleanup button label shortened to 'Delete empty'.

* fix(sessions): stack prune label under icon, cleanup button reads 'Empty'

- Prune card: trash icon above the 'Prune' label (column layout),
  still wrap-content width so Total/Messages keep their space.
- Empty-session cleanup button label shortened to 'Empty'.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-08-09 15:35:42 +03:00
1 parent 3b033a025b
commit 57dc4cdf5c
6 files changed
+108 -43

No files matched your search

@@ -0,0 +1,44 @@
package com.m57.hermescontrol.ui.sessions
import org.junit.Assert.assertEquals
import org.junit.Test
class SessionsStatsFormatTest {
@Test
fun `under 1000 shows raw number`() {
assertEquals("0", formatCompactCount(0))
assertEquals("7", formatCompactCount(7))
assertEquals("987", formatCompactCount(987))
assertEquals("999", formatCompactCount(999))
}
@Test
fun `thousands compact to 3 digits plus k`() {
assertEquals("1k", formatCompactCount(1_000))
assertEquals("10k", formatCompactCount(10_000))
assertEquals("100k", formatCompactCount(100_987))
assertEquals("999k", formatCompactCount(999_999))
}
@Test
fun `fractional thousands keep one or two digits`() {
assertEquals("1.5k", formatCompactCount(1_500))
assertEquals("1.05k", formatCompactCount(1_050))
assertEquals("12.5k", formatCompactCount(12_500))
}
@Test
fun `millions compact to 3 digits plus m`() {
assertEquals("1m", formatCompactCount(1_000_000))
assertEquals("1.23m", formatCompactCount(1_234_567))
assertEquals("100m", formatCompactCount(100_000_000))
assertEquals("999m", formatCompactCount(999_999_999))
}
@Test
fun `billions compact to b`() {
assertEquals("1b", formatCompactCount(1_000_000_000))
assertEquals("2b", formatCompactCount(2_000_000_000))
assertEquals("2.15b", formatCompactCount(Int.MAX_VALUE))
}
}