"Nobody here yet" was also what a failed load looked like

🔴 **A claim about the account, made about a request that failed.** Both roster
load sites swallow failures with
`runCatching { … }.getOrDefault(emptyList())`, so a network hiccup, an expired
token or a rate limit all produced an empty list — and the contacts card then
said "Nobody here yet. Add someone by the username they signed up with."

Someone whose contacts had simply failed to fetch was told they had none.

Found by auditing the shape that hid the iOS group bug: a swallowed failure
that renders as a confident empty state. Six such sites exist on Android; the
two on the sign-in and restore paths are the ones a user meets first.

`Phase.SignedIn` now carries `buddiesLoaded`, defaulting to FALSE so a phase
built without saying so cannot assert the fetch succeeded. The empty state only
claims emptiness when the list actually loaded; otherwise it says the load
failed and what to do.

Verified on the emulator with the radios off: the card reads "Couldn't load
your contacts. Check the connection and sign in again." With the network back,
the roster loads and the contact shows as before.

⚠️ Four sites remain that still default to empty on failure — groups, stories,
and two others. They deserve the same treatment; contacts came first because it
is the screen somebody lands on. Android suites green (194 tests).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Paul Hitt
2026-08-26 12:00:15 -04:00
co-authored by Claude Opus 5
parent 6527f76151
commit 62b4798881
3 changed files with 75 additions and 3 deletions
@@ -141,10 +141,19 @@ fun ColumnScope.BuddyList(model: MessengerViewModel, phase: MessengerViewModel.P
}
if (phase.buddies.isEmpty()) {
// ⚠️ Only claim the list is empty if it was actually FETCHED. A failed
// load also produces an empty list, and "Nobody here yet" is then a
// statement about the person's account rather than about the request —
// which is how somebody concludes their contacts are gone.
//
// Says what to do, not merely that there is nothing. An empty state
// that only reports emptiness leaves the person stuck.
Text(
"Nobody here yet. Add someone by the username they signed up with.",
if (phase.buddiesLoaded) {
"Nobody here yet. Add someone by the username they signed up with."
} else {
"Couldn't load your contacts. Check the connection and sign in again."
},
style = MaterialTheme.typography.bodyMedium,
)
return
@@ -51,6 +51,20 @@ class MessengerViewModel(app: Application) : AndroidViewModel(app) {
val relay: String,
val status: String,
val buddies: List<MessengerApi.Buddy> = emptyList(),
/**
* Whether the contact list was actually FETCHED, as opposed to
* defaulted to empty because the fetch failed.
*
* 🔴 Both load sites swallow failures with
* `runCatching { … }.getOrDefault(emptyList())`, so a network
* hiccup, an expired token or a rate limit all produced an empty
* roster — and the UI then told the user "Nobody here yet", which
* is a claim about their account rather than about the request.
* The same swallow-and-look-empty shape hid a decode bug that made
* groups invisible on iOS for far longer.
*/
val buddiesLoaded: Boolean = false,
val groups: List<io.flamenet.client.RelayClient.Group> = emptyList(),
val blocked: Set<Long> = emptySet(),
val notifications: List<MessengerApi.Notification> = emptyList(),
@@ -221,13 +235,15 @@ class MessengerViewModel(app: Application) : AndroidViewModel(app) {
api = MessengerApi(
credential.relayBaseUrl, credential.username, credential.appPassword),
)
val fetchedBuddies = runCatching { session!!.api.buddies() }
stored to Phase.SignedIn(
handle = credential.username,
userId = credential.userId,
deviceId = stored.deviceId,
relay = SiteConfig(credential.relayBaseUrl).host,
status = "Signed in on this device.",
buddies = runCatching { session!!.api.buddies() }.getOrDefault(emptyList()),
buddies = fetchedBuddies.getOrDefault(emptyList()),
buddiesLoaded = fetchedBuddies.isSuccess,
groups = runCatching { session!!.relay.listGroups() }.getOrDefault(emptyList()),
)
}
@@ -334,13 +350,15 @@ class MessengerViewModel(app: Application) : AndroidViewModel(app) {
api = io.flamenet.client.MessengerApi(config.baseUrl, account.username, credential),
)
val fetchedBuddies = runCatching { session!!.api.buddies() }
return Phase.SignedIn(
handle = account.username,
userId = account.userId,
deviceId = device.deviceId,
relay = config.host,
status = "Registered with ${preKeys.size} one-time prekeys published.",
buddies = runCatching { session!!.api.buddies() }.getOrDefault(emptyList()),
buddies = fetchedBuddies.getOrDefault(emptyList()),
buddiesLoaded = fetchedBuddies.isSuccess,
groups = runCatching { session!!.relay.listGroups() }.getOrDefault(emptyList()),
)
}