The device list was rendering its own source code
`"Registered ${'$'}{fmt.format(instant)}"` — `${'$'}` emits a LITERAL dollar
sign, so the template was never evaluated and every device row read
Registered ${fmt.format(instant)}
Kotlin cannot warn about this: escaping a dollar is a legitimate thing to want,
just never here. And nothing could test it, because the string was assembled
inline inside a `Text(...)`.
Lifted into `registeredLine` so it can be asserted, with a test that fails if
template source ever reaches the screen again. That is the real fix — the
one-character correction would have left the next one just as invisible.
engine 155, client 96, app 35.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
db7d05bd98
commit
2481af6cc8
@@ -2565,15 +2565,7 @@ fun RegisteredDevicesSection(
|
||||
}
|
||||
}
|
||||
Text(
|
||||
device.createdAt?.let { raw ->
|
||||
runCatching {
|
||||
val instant = java.time.Instant.parse(raw)
|
||||
val fmt = java.time.format.DateTimeFormatter
|
||||
.ofPattern("MMM d, yyyy HH:mm")
|
||||
.withZone(java.time.ZoneId.systemDefault())
|
||||
"Registered ${'$'}{fmt.format(instant)}"
|
||||
}.getOrDefault("Registered $raw")
|
||||
} ?: "Registered date unknown",
|
||||
registeredLine(device.createdAt),
|
||||
fontSize = 12.sp,
|
||||
color = Palette.SecondaryText,
|
||||
)
|
||||
@@ -2671,3 +2663,26 @@ private val DISAPPEAR_LABELS = mapOf(
|
||||
86_400 to "a day",
|
||||
604_800 to "a week",
|
||||
)
|
||||
|
||||
/**
|
||||
* "Registered <date>" for one device row.
|
||||
*
|
||||
* 🔴 **This shipped rendering its own source code.** The string was written
|
||||
* `"Registered ${'$'}{fmt.format(instant)}"`, and `${'$'}` emits a LITERAL
|
||||
* dollar sign — so the template was never evaluated and the screen showed
|
||||
* `Registered ${fmt.format(instant)}` to the user. Kotlin cannot warn about
|
||||
* it: escaping a dollar is a legitimate thing to want, just never here.
|
||||
*
|
||||
* Lifted out of the Composable so it can be asserted. A string built inline in
|
||||
* a `Text(...)` is a string nothing can test, which is why this survived.
|
||||
*/
|
||||
internal fun registeredLine(createdAt: String?): String {
|
||||
val raw = createdAt ?: return "Registered date unknown"
|
||||
return runCatching {
|
||||
val instant = java.time.Instant.parse(raw)
|
||||
val fmt = java.time.format.DateTimeFormatter
|
||||
.ofPattern("MMM d, yyyy HH:mm")
|
||||
.withZone(java.time.ZoneId.systemDefault())
|
||||
"Registered ${fmt.format(instant)}"
|
||||
}.getOrDefault("Registered $raw")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user