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: awaiting the pick callback inside the re-entrancy guard's try left
_modalOpen true for the whole consumer handler, so the Drive button stayed dead
while the picked documents uploaded.
Decision: extract the modal phase into _openPicker() and dispatch the outcome
after the guard is released, so the guard means "a modal is on screen" and
nothing more; the failure paths now all route through _handleOutcome.
Addresses: 65fc450fc
Problem: the ComposerController Drive tests covered link insertion only, so the
attachment path was unverified when jmapUrl is empty or the session exposes no
upload-from-url endpoint — a regression there is a silent no-op with no toast.
Decision: test through handleDrivePickResult with the real DriveAttachmentHandler
rather than calling the private guard, so the assertions pin the production
wiring between DynamicUrlInterceptors, Session, AccountId and the toast. The
failure's bare Exception is asserted to tell the not-started outcome apart from
handleDrivePickResult's catch-all, which would otherwise let the test pass on a
thrown error. The existing alice session fixture already lacks the capability,
so the unsupported endpoint case needs no new fixture.
Addresses: 3860779187
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3860779187
Problem: onPickerTap() resolved localizations, session capabilities and the
theme outside any catch, so a throw there escaped as an unhandled asynchronous
error and the tap silently did nothing instead of dispatching DrivePickFailure.
Decision: catch around the whole tap body rather than guarding each getter —
the mixin takes arbitrary injected getters from consumers, so the boundary
cannot rely on any of them staying null-safe. failingMessage is hoisted and
assigned before the capability read, so a resolver throw still carries the
localized text and only a localization failure falls back to the generic toast.
The finally already released _modalOpen; a regression test now pins that a
retry after a failed tap works.
Addresses: 3860772852
https://github.com/linagora/tmail-flutter/pull/4767#discussion_r3860772852
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