copy: the Sync settings "Run now" summary is one sentence, shared

The desktop and Android each built it, capitalized differently, and both
counted thumbnails, artifact values and whole files together as
"artifact(s)". copy::settings::run_summary counts the three apart, and
says so plainly when nothing arrived; Android reaches it through
scheduler_run_summary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-09-29 02:07:01 -07:00
1 parent 9386ca7576
commit c7a72a990c
4 files changed
+53 -18

No files matched your search

@@ -53,6 +53,7 @@ import uniffi.synchronicity.RemoteDocumentSyncPolicy
import uniffi.synchronicity.SchedulerSettings
import uniffi.synchronicity.getSyncPolicyOptions
import uniffi.synchronicity.remoteConfigUnreachable
import uniffi.synchronicity.schedulerRunSummary
private const val TAG = "SyncSettingsScreen"
@@ -246,15 +247,7 @@ fun SyncSettingsScreen(
runNowStarting = false
runNowStatus =
result.fold(
onSuccess = { summary ->
val fetched =
summary.catalogFetch.thumbnailsReceived +
summary.catalogFetch.artifactsReceived +
summary.content.blobsFetched
"Synced ${summary.catalog.peersSynced} peer(s), fetched $fetched artifact(s) " +
"(${summary.catalogFetch.thumbnailsReceived} thumbnail(s)) for " +
"${summary.content.wantedDocuments} document(s)"
},
onSuccess = { summary -> schedulerRunSummary(summary) },
onFailure = { e -> "Failed: ${e.userMessage}" },
)
}
+1 -9
View File
@@ -402,15 +402,7 @@ impl SettingsView {
// setting Pending and its own `job_runner.start` call —
// rare, but report it plainly rather than as an error.
match summary {
Some(summary) => Ok::<_, String>(format!(
"synced {} peer(s), fetched {} artifact(s) ({} thumbnail(s)) for {} document(s)",
summary.catalog.peers_synced,
summary.catalog_fetch.thumbnails_received
+ summary.catalog_fetch.artifacts_received
+ summary.content.blobs_fetched,
summary.catalog_fetch.thumbnails_received,
summary.content.wanted_documents,
)),
Some(summary) => Ok::<_, String>(copy_settings::run_summary(&summary)),
None => Ok(busy::was_running(busy::BACKGROUND_SYNC)),
}
},
+43
View File
@@ -537,6 +537,28 @@ mod tests {
assert_eq!(busy::sentence(clause), expected);
}
#[rstest]
#[case((0, 0, 0), "Synced with 2 peer(s). Nothing new to fetch.")]
#[case((5, 1, 0), "Synced with 2 peer(s). Fetched 5 record(s), 1 thumbnail(s) and 0 file(s).")]
fn run_summary_counts_each_kind_apart(
#[case] (records, thumbnails, files): (u32, u32, u32),
#[case] expected: &str,
) {
use crate::scheduler::{
CatalogFetchPassResult, CatalogPassResult, ContentPassResult, SchedulerPassResult,
};
let result = SchedulerPassResult {
catalog: CatalogPassResult { peers_synced: 2, ..Default::default() },
catalog_fetch: CatalogFetchPassResult {
artifacts_received: records,
thumbnails_received: thumbnails,
..Default::default()
},
content: ContentPassResult { blobs_fetched: files, ..Default::default() },
};
assert_eq!(settings::run_summary(&result), expected);
}
/// The reading a canceled pull must never get: its counts describe how
/// far it reached, so "up to date" would tell the user their document is
/// complete at the moment they stopped it from becoming so.
@@ -1646,6 +1668,8 @@ pub mod linkages {
/// Settings explainers that more than one modality shows.
pub mod settings {
use crate::scheduler::SchedulerPassResult;
pub const TIMEZONE_HELP: &str =
"Select an IANA timezone for displaying times. Leave unset to use UTC.";
@@ -1670,6 +1694,25 @@ pub mod settings {
}
}
/// What a Sync settings "Run now" found, once it has finished. Records
/// (artifact values), thumbnails and files are counted apart because they
/// are different things arriving: a record is a few bytes of a document, a
/// file can be an album.
pub fn run_summary(result: &SchedulerPassResult) -> String {
let peers = format!("Synced with {} peer(s).", result.catalog.peers_synced);
let (records, thumbnails, files) = (
result.catalog_fetch.artifacts_received,
result.catalog_fetch.thumbnails_received,
result.content.blobs_fetched,
);
if records + thumbnails + files == 0 {
return format!("{peers} Nothing new to fetch.");
}
format!(
"{peers} Fetched {records} record(s), {thumbnails} thumbnail(s) and {files} file(s)."
)
}
/// What a node's public key is for, on the screen that shows it. The
/// reassurance is the point: a key labeled only "public key" invites the
/// question this answers.
+7
View File
@@ -14,6 +14,7 @@ use crate::jobs::{JobKind, JobSubject};
use crate::log::LogVerbosity;
use crate::node::NodePubkey;
use crate::p2p::node_admin;
use crate::scheduler::SchedulerPassResult;
use crate::stores::node_content_status::ContentKey;
use crate::stores::peer_health::PeerHealthIssue;
use crate::sync_prefs::{DocumentSyncOverride, SyncPolicy};
@@ -123,6 +124,12 @@ pub fn remote_config_unreachable(reason: Option<String>) -> String {
copy::settings::remote_config_unreachable(reason.as_deref())
}
/// What a Sync settings "Run now" found — [`copy::settings::run_summary`].
#[uniffi::export]
pub fn scheduler_run_summary(result: SchedulerPassResult) -> String {
copy::settings::run_summary(&result)
}
/// The Ensemble screen's roster summary and gossip diagnostic —
/// [`copy::ensemble_roster`]. Derived rather than fetched once, since both
/// lines depend on live counts.