Android: drop JobUtils aliases and PushJobRefs from the Jobs screen

JobUtils.kt was two one-line aliases of the uniffi jobKindLabel and
formatTimestamp; call them directly. PushJobRefs/asPushRefs paired each
id with its short form before building the push label, but IdRef already
takes a nullable short id. JobStatusLine's three identical
onSurfaceVariant branches collapse into the else, and the running-row
spinner is an InlineSpinner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-09-28 08:07:13 -07:00
1 parent 2fe3571081
commit 586f42cf44
2 files changed
+16 -66

No files matched your search

@@ -1,27 +0,0 @@
package com.gregshuflin.synchronicity.jobs
import uniffi.synchronicity.formatTimestamp
import uniffi.synchronicity.jobKindLabel
/**
* The display name for a job kind, from `JobKind::display_name` over the FFI.
*
* This used to mirror that method with a `when` here, and the mirror went stale exactly as you
* would expect: it never learned `library_build`, and `content_stream` broke it again, so both
* rendered through the fallback as "Library_build" and "Content_stream". Asking Rust means a kind
* added there shows up here without anyone remembering to come back.
*/
fun jobKindDisplayName(kind: String): String = jobKindLabel(kind)
/**
* Formats an RFC 3339 timestamp for display in [timezone] (an IANA zone id, e.g. from
* `NativeLib.getTimezone`), falling back to UTC when it is null or unparseable.
*
* This used to be a `DateTimeFormatter` here, described as matching `Timestamp::format_display`. It
* did not: it formatted `"MMM dd, yyyy HH:mm"` with **no zone suffix**, so the same job read "Aug
* 22, 2026 15:24" on Android and "Aug 22, 2026 15:24 PDT" on the desktop. A displayed time with no
* zone on it is a poor thing to show on a system whose premise is that the same documents are open
* on several machines at once.
*/
fun formatJobTimestamp(isoDateString: String, timezone: String? = null): String =
formatTimestamp(isoDateString, timezone)
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
@@ -32,6 +31,7 @@ import com.gregshuflin.synchronicity.OnStoreChange
import com.gregshuflin.synchronicity.ui.CenteredMessage
import com.gregshuflin.synchronicity.ui.ConfirmDialog
import com.gregshuflin.synchronicity.ui.IdRef
import com.gregshuflin.synchronicity.ui.InlineSpinner
import com.gregshuflin.synchronicity.ui.SectionTabs
import com.gregshuflin.synchronicity.ui.SharedCopy
import com.gregshuflin.synchronicity.ui.SubAppScreen
@@ -42,6 +42,8 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import uniffi.synchronicity.ChangeChannel
import uniffi.synchronicity.JobItem
import uniffi.synchronicity.formatTimestamp
import uniffi.synchronicity.jobKindLabel
import uniffi.synchronicity.jobStateLabel
/** How many terminal jobs the History tab requests. Mirrors `HISTORY_LIMIT` in `jobs.rs`. */
@@ -235,37 +237,13 @@ private fun JobRow(job: JobItem, showTimestamps: Boolean, timezone: String?, onC
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
CircularProgressIndicator(modifier = Modifier.size(20.dp), strokeWidth = 2.dp)
InlineSpinner(size = 20.dp)
TextButton(onClick = onCancel) { Text(SharedCopy.actions.cancel) }
}
}
}
}
/**
* The four job fields a `"push"` job's inline label needs, all-or-nothing: present only when the
* job is actually a push and every pre-resolved reference landed.
*/
private data class PushJobRefs(
val documentId: String,
val documentIdShort: String,
val peerId: String,
val peerIdShort: String,
)
private fun JobItem.asPushRefs(): PushJobRefs? {
if (kind != "push") return null
// Paired rather than checked as one 4-way condition so a partially-resolved job (only one
// side missing) still reads as clearly incomplete.
val doc = documentId?.let { id -> documentIdShort?.let { short -> id to short } }
val peer = peerId?.let { id -> peerIdShort?.let { short -> id to short } }
return if (doc != null && peer != null) {
PushJobRefs(doc.first, doc.second, peer.first, peer.second)
} else {
null
}
}
/**
* The job's kind/description line. `"push"` is special-cased to an inline "Push [document] to
* [peer]" built from the pre-resolved document/peer fields, instead of the raw label text every
@@ -273,8 +251,9 @@ private fun JobItem.asPushRefs(): PushJobRefs? {
*/
@Composable
private fun JobLabelRow(job: JobItem) {
val pushRefs = job.asPushRefs()
if (pushRefs != null) {
val documentId = job.documentId
val peerId = job.peerId
if (job.kind == "push" && documentId != null && peerId != null) {
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -283,16 +262,16 @@ private fun JobLabelRow(job: JobItem) {
IdRef(
name = job.documentTitle.orEmpty(),
isPlaceholder = job.documentTitleIsPlaceholder,
idFull = pushRefs.documentId,
idShort = pushRefs.documentIdShort,
idFull = documentId,
idShort = job.documentIdShort,
clipLabel = "Document ID",
)
Text(text = "to", style = MaterialTheme.typography.bodyMedium)
IdRef(
name = job.peerDisplayName.orEmpty(),
isPlaceholder = job.peerDisplayNameIsPlaceholder,
idFull = pushRefs.peerId,
idShort = pushRefs.peerIdShort,
idFull = peerId,
idShort = job.peerIdShort,
clipLabel = "Node ID",
)
}
@@ -304,7 +283,7 @@ private fun JobLabelRow(job: JobItem) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = jobKindDisplayName(job.kind),
text = jobKindLabel(job.kind),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
@@ -316,15 +295,13 @@ private fun JobLabelRow(job: JobItem) {
private fun JobStatusLine(job: JobItem) {
val (text, color) =
when (job.state) {
"queued" -> jobStateLabel(job.state) to MaterialTheme.colorScheme.onSurfaceVariant
"running" ->
(job.progressMessage ?: jobStateLabel(job.state)) to
MaterialTheme.colorScheme.onSurfaceVariant
"done" -> jobStateLabel(job.state) to SynTheme.palette.colorSuccess
"failed" -> (job.error ?: jobStateLabel(job.state)) to MaterialTheme.colorScheme.error
"canceled" -> jobStateLabel(job.state) to MaterialTheme.colorScheme.onSurfaceVariant
// An unknown tag comes back from Rust unchanged, so a job row written by a newer
// node still lists rather than blanking.
// Queued, canceled, and an unknown tag — which comes back from Rust unchanged, so a
// job row written by a newer node still lists rather than blanking.
else -> jobStateLabel(job.state) to MaterialTheme.colorScheme.onSurfaceVariant
}
Text(text = text, style = MaterialTheme.typography.labelSmall, color = color)
@@ -351,7 +328,7 @@ private fun JobProgressBar(job: JobItem) {
* "Started … · Finished …", shown only on History rows -- Active rows show live progress instead.
*/
private fun jobHistoryTimestamps(job: JobItem, timezone: String?): String {
val started = job.startedAt?.let { "Started ${formatJobTimestamp(it, timezone)}" }
val finished = job.finishedAt?.let { "Finished ${formatJobTimestamp(it, timezone)}" }
val started = job.startedAt?.let { "Started ${formatTimestamp(it, timezone)}" }
val finished = job.finishedAt?.let { "Finished ${formatTimestamp(it, timezone)}" }
return listOfNotNull(started, finished).joinToString(" · ")
}