fix(integrations): a provider with no history is "unknown"

The ledger's synthetic "no row" snapshot returned `state: "connected"`, so
the field's default meant the opposite of its name: every account that had
never connected a provider published `connected` on the status envelope.
Settings survived it by never reading `state`; the setup flow's connect step
did read it, and told brand-new accounts their wearable was connected.

The snapshot now reads `unknown`. `syncHealth.verdict` is unchanged and stays
the only liveness truth; the managed-record projection maps `unknown` onto
`disconnected` the way it already maps a missing connection.
This commit is contained in:
Marc-André Bombeck committed 2026-09-11 09:08:38 +02:00
1 parent 274923a060
commit 0bdbf009f6
8 files changed
+126 -23

No files matched your search

+2 -1
View File
@@ -326,9 +326,10 @@ const integrationLedgerState = z
"error_reauth",
"disconnected",
"parked",
"unknown",
])
.describe(
"Last recorded ledger state for this provider. `connected` is also the value a user who has never synced sees — the ledger row is created on the first attempt, and its absence reads as `connected`, not as an error.",
"Last recorded ledger state for this provider. `unknown` (added v1.38.19) is what a user who has never synced sees: the ledger row is created on the first attempt, and its absence is no claim about the connection in either direction — it used to read as `connected`, which is why a client must never treat this field as liveness. Read `syncHealth.verdict` for that, and treat `unknown` as `disconnected` anywhere a ledger state is painted.",
);
const nightscoutConnectRequest = nightscoutConnectSchema.meta({