Problem: the guard around caller callbacks logs only the label and the
exception, so a Sentry event cannot be tied back to a specific drive
transfer within a batch.
Decision: index placeholders by task id in transfer() and pass the
matching placeholder into _notify, which attaches task id, file size and
mime type as log extras. File name is left out on purpose — extras reach
Sentry and the three remaining fields already correlate the event with
the chip and the upload request.
Addresses: 3860970649
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3860970649
Problem: CodeScene flags handleDrivePickResult twice — cyclomatic
complexity 9 (threshold 9) and a complex conditional with 2 branches
(threshold 2). Both come from the same cause: the entry point decides
which toast to show as well as what to attach.
Decision: keep the entry point to the pick flow (split, insert, transfer)
and move each toast decision to its own named method. The dropped-docs
conditional is split as `droppedCount == 0 || !attachedAny` inside
_showDroppedDocsFailure, with the two-list check passed in as one
argument, so no single expression chains two operators. Behaviour is
unchanged — all 29 handler tests pass untouched.
Addresses: 3860581376, 3860587468
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3860581376https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3860587468
Problem: the failure is logged only when there is no context to toast into, so
the common path leaves no record of which upload failed.
Decision: log first, then toast — the log line is the only durable trace once the
chip is removed.
Addresses: 3859378962
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3859378962
Problem: saving a draft while a drive transfer is waiting rebuilds the attachment
list from the server response, which has no entry for a chip that has no blob yet.
The chip and its cancel token are dropped while the request keeps running, so a
late success has nothing to resolve and the attachment disappears.
Decision: carry not-yet-completed states through the refresh instead of filtering
the server response, so the rule holds for any pending upload, not just drive.
Addresses: 3859504637
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3859504637
Problem: cancellation is only checked before the upload call, so a response that
lands after the user removed the chip still fires onSuccess and toasts success.
Decision: re-check the cancel token right after the await and drop the result.
Cancellation resolves neither counter, matching the queued-task guard above it.
Addresses: 3859630902
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3859630902
The expand-button condition mis-expanded the web check, so the compact
chevron could render alongside the inline prefix buttons on the web path.
Rewrite it as the exact complement of the inline-buttons gate
(isMobileResponsive || !_isWeb), keeping the two recipient-add
affordances mutually exclusive while still showing the chevron on native
tablet.
Add widget tests for the native-mobile, web-wide, native-tablet and
narrow-web (web-responsive) branches.
(cherry picked from commit b503de2278)
The web handler routed its two keep-the-session paths through the mobile one,
which had since grown a leading force-logout branch. That branch could not fire
on web — it re-tests the same classifier call the web handler had already
evaluated to false — but the safety rested on a call-ordering invariant inside
the web handler rather than on anything structural. Adding an earlier delegation
would have quietly made it live and started logging web users out on failures
already ruled transient.
Extract the tail both handlers shared into _propagateKeepingSession and have web
call it directly, so the logout branch leaves web's call graph entirely.
Cover the behaviour too: an OAuthAuthorizationError — the mobile error shape —
arriving on web must keep the session. Verified by mutation: re-coupling both
delegation sites and pointing the guard at the mobile classifier fails exactly
these two tests.
Pure move, no behaviour change. Also splits a doc comment that had been merged
into the paragraph above it.
A confirmed mobile rejection was rethrown out of the refresh helper, caught by
the outer handler in onError(), logged there as a generic event, and only then
routed to the platform handler that logged the real structured one. One failure,
two events, the less useful of them arriving first.
Route a rejection the platform handler already classifies straight to it, so the
outer catch never sees it.
Failures that stay unclassified are still rethrown on purpose: the generic event
is then their only trace, and dropping it would make them invisible. Both halves
are covered — one event for a rejection, the generic event retained for the rest.
On mobile the refresh runs through flutter_appauth (native), so a rejected
refresh token never reaches Dio and the statusCode == 400 branch is unreachable.
The rejection arrives as an OAuthAuthorizationError carrying the RFC 6749 code
from the response body, and nothing handled it: the dead session was kept, and
because the refresh-attempt marker lives on the request, every new request
retried the same doomed refresh. The mailbox spun forever instead of sending
the user back to login.
Force the logout when — and only when — the classifier confirms a bad-grant
code. Transient codes (server_error, temporarily_unavailable) and failures that
never reached the OAuth server keep the session, so a flaky mobile connection
still does not sign the user out.
Also pin the native-error to domain-error boundary the fix depends on. Every
test so far constructed OAuthAuthorizationError directly, leaving both the
conversion in handleException and the wiring that reaches it unproven — a
plugin upgrade that stopped populating platformErrorDetails.error would have
resurrected the bug with the suite still green. The client test is verified by
mutation: dropping the catch that calls handleException fails it.
The mobile invalid_grant case in the stale-401 group changes verdict here: it
asserted the session survived, which was the bug.
Web and mobile refresh through different plugins, so the same token-endpoint
rejection surfaces as a different Dart type on each platform. Classification
lived in a single web-shaped class, which left no place to describe the native
error shape without letting web's types influence a mobile verdict.
Extract the platform-independent rules — the RFC 6749 bad-grant code set,
AccessTokenInvalidException, Dio 400/401, the Sentry extras skeleton — into an
abstract RefreshTokenErrorClassifier, and leave each subclass to recognise only
the shape its own plugin throws.
The interceptor now resolves its classifier from the platform. That resolution
is lazy rather than done in the constructor: the interceptor is built before the
platform is known under test, so reading PlatformInfo too early would pin the
wrong one.
Behaviour is unchanged; the web classifier keeps its existing verdicts.
SearchEmailNotifier consumes interactors through the shared seam (auto routing across all intents); SearchEmailController gates its retry toast with isUrgentException; SearchEmailResult drops the pendingUrgentException field and reverts to pure display state.
consumeInteractor centralizes interactor result folding with automatic urgent-exception routing (ADR-0103) for Riverpod notifiers bypassing consumeState. isUrgentException mirrors that routing's resolution so consumers can suppress fallback UI without re-routing.
- _runLoadMore drops emails already in the list (_dropAlreadyLoaded) so a same-timestamp page boundary never duplicates rows.
- Rename SearchEmailResult.loadMoreException to pendingUrgentException and have _runRefresh surface it like _runLoadMore, so the notifier no longer routes urgent exceptions itself; SearchEmailController._routePendingUrgentException handles load-more and refresh through the same path as a full-search error.
- _applySearchResult rebuilds the presentation list only when result.emails changes identity, skipping the map/combine/sync on load-more spinner toggles.