Files
accounted/messages
Mattsson dcb5d329a3 fix(skatteverket): show a banner when the connection is dead (#1925)
* fix(skatteverket): make a dead Skatteverket connection impossible to miss

A company whose SKV session had expired got no usable signal anywhere.
/skattekonto/saldo answers 200 for a token already flagged needs_reconsent
(it keeps the stale snapshot visible on purpose), so the page looked healthy
on load, and the reconnect AttnLine lived inside the `data` branch: a company
that had never completed a sync had no snapshot, so clicking "Synkronisera nu"
set the reconnect message and rendered absolutely nothing. The 401 branch
returns before the toast, so the click was a silent no-op. On /transactions
the same banner was gated on the 'skatteverket' source filter, which most
users never select.

Skattekonto page:
- probe /status on load through the shared skvStatusNeedsReconnect predicate,
  so the prompt appears before the user clicks anything
- render the reconnect line at page level, regardless of `data`
- swap the "Synkronisera nu" header action for "Anslut igen": the sync cannot
  succeed while the session is dead, and offering it is what made the failure
  look like nothing happening
- give the expired case its own StartCard instead of the onboarding one, which
  reads as "you never set this up" to someone who did
- drop the "klicka pa Synkronisera nu" hint while a reconnect is pending

Transactions page: show the reconnect line on every source filter.

Max one attn line per page is preserved: reconnect outranks the imported-rows
line and the saldo shortfall, the latter because a shortfall computed from a
stale snapshot must not outrank "the data is stale".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(skatteverket): show a banner when the connection is dead

Cut back to a banner and nothing else, after three skeptics refuted the
first cut.

/skattekonto: the reconnect line lived inside the `data` branch of the
saldo section, so a company with no snapshot (never completed a sync) saw
nothing at all when the sync it just clicked died on an expired session.
The 401 path returns before the toast, so the click was a silent no-op.
Move the line to page level and probe /status on load so it also appears
without clicking, since /skattekonto/saldo answers 200 for a token flagged
needs_reconsent and nothing else in the payload reveals a dead session.

/transactions: show the same line on every source filter.

Nothing is hidden or removed while the flag is true: the saldo tiles, the
Kronofogden line, "Synkronisera nu", the empty state and the shortfall
warning all stay exactly as they were. Prod has 151 of 162 connected
companies with every token dead, so a flag that hides anything hides it
from nearly everyone, and the shortfall warning's action is the page's
only route to the bankgiro and OCR.

Also: a healthy probe clears a message left by an earlier failed sync
(previously only syncNow's success path did, so a transient 401 kept the
banner up until a remount), and the existing visibility refetch now covers
the reconnect state so the banner does not survive the consent that fixed
it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(skatteverket): guard status probe against stale responses

A fire-and-forget /status probe from an earlier reload could resolve after
a later one and overwrite needsReconnect with an outdated result, restoring
the reconnect banner right after a successful sync. Each reload now bumps a
probe sequence and a result is applied only while it is still the latest.

Also puts the 2026-08-26 decision record in the required
[date] decision: why format.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-26 15:56:25 +02:00
..