Repository navigation
fix(platform): reconnect a lapsed cloud import, warn on a partial one - #3984
Conversation
A toast could only say success or failure, so an operation that finished in part had to read as one or the other. The warning variant carries Alert's warning glyph and tones (amber-600, which keeps 3:1 on the light surface where the --warning token does not). The toast guide, its demo and the stories show it.
The import doors read the member's grant once, when the request started. A grant revoked or expired while the files came in failed every later file on a refused token, and the import answered a plain failure. Both import pipelines now read the grant again before each file, the check every listing makes, and ask for a new token once more when the provider refuses the one a file's call carried (401). A grant that answers "reconnect" stops the import at that file: the files before it stay, and the answer carries the counts and the grant check's sentence. A read that throws or cannot be answered leaves the import on the token it has and is not retried for 30 seconds. The sync engine passes no resolver and is unchanged. The listing doors refresh once on a 401 as well, so access removed at the provider reaches the connect dialog from the picker and from an import's folder walk. A refreshed token is stored only while its grant is still active, so a Disconnect during a refresh is no longer undone. A file past the size cap carries the upload door's own sentence as its reason; every other failed file keeps its text for the log.
The single-failure-toast guard could not see the cloud import's handoffs. The import writes are quiet, and handing a failure to the connect dialog was no report to it. A function that always calls onRequireConnect now counts as one. A toasting write whose catch hands off is reported twice, and a new check fails when a toast shares the branch that hands off: in that block, unconditionally before it unless the branch takes that notice down, in a finally around it, or after it while the branch runs on.
An import that access ended part-way, and one where only some files came in, both read "Import failed" with a generic line. The OneDrive, SharePoint and Google Drive pickers read the import's answer with the rule their listings hand off on. Access that ended closes the picker and opens the connect dialog, which says so, how many files came in, and how to bring in the rest; the "Import started" notice is taken down and no toast is raised. An import where some files failed is one warning, "Imported N of M files", naming the first failed file with its words (firstFailureDetail) or giving the counts alone for a fault. Nothing imported keeps "Import failed" with the same rule. Files an earlier import brought in unchanged count as imported, the success toast included. An empty OneDrive selection is refused in words, as Google's is, instead of the door's English. The re-run needs no change: the import finds a document by its provider file id and skips an unchanged one, which the tests prove. The knowledge suite adds KNOW-B19 and KNOW-B20, the automation register owns their unit half, and the manual readme's suite table is recounted.
The Documents guide (EN/DE/FR) says what an import's notices count and name, and what happens when access to Microsoft 365 or Google Drive ends during an import.
|
Independent review of Both new Reproduction for OneDrive and Google Drive:
Please scope the handoff to the interaction that started it, preserve a newer picker/selection, and retain a once-only, non-disruptive report for the completed background request. Dismissing the UI does not mean the server import was cancelled. Local controls used the real Documents menu, pickers, Dialog, action hook and toast, with action answers and authorization/configuration status stubbed. Both cases fail at this head in jsdom and real Chromium; replacing only the four UI components with their base Other focused checks passed: 65 UI tests, 154 backend/guard tests, 27 provider-boundary tests, and two independent partial-retry controls. No new tenant/auth exposure or additional blocker was established in this bounded review. |
Follow-up to #3905, on the owner's decision about its two "Left open" items: an import whose Microsoft or Google grant ends part-way, and an import where only some files come in. Refs #3905. No GitHub issue asks for this, so nothing is closed.
What changed
1. Access that ends mid-import lands in the connect dialog (OneDrive, SharePoint, Google Drive)
Before this change, the import door read the member's grant once, when the request started. A grant revoked or expired while the files came in (Disconnect in another tab, access removed at Microsoft or Google, a refresh token that died) failed every later file on a refused token. The import then read Import failed with a generic line, and the files already imported went unsaid.
The backend (
backend/core/cloud_import/import_grant.ts, used by both importers):tokenFormakes for every listing, so it sees a Tale-side revoke, a dead grant and a token near expiry (refreshed).resolveCloudAccessToken(…, { forceRefresh: true })) when the provider refuses the token a file's call carried (HTTP 401). Access removed at Google ends the token at once, while the stored expiry still counts it live.listUnderGrant, all five listing routes). Access removed at the provider therefore reaches the connect dialog from the picker and from an import's folder walk, instead of Couldn't load items / Import failed.UPDATE … AND status = 'active'). A refresh racing a Disconnect used to write the grant back toactive.The app:
isCloudImportAuthErrorrule to the import's answer, and to the folder walk's listing error.onRequireConnect({ imported, total }), takes the Import started notice down, and raises no toast.documents.cloudImport.importInterrupted). It reads No files were imported. when access ended during the folder walk.documents.cloudImport.reconnectToImportRest). The button is the sync dialog's reconnect button.Re-running the same selection: I checked how the import dedupes before changing anything, and nothing needed to change.
findDocumentByExternalIdfinds a document by(org_id, external_item_id), the provider file id, with no lifecycle filter (unique since 0073). An unchanged file is skipped without a download, and a changed one is updated in place. New tests prove that a re-run after an interrupted import skips the files already in and creates only the rest.2. A partial import is one warning
@tale/uigets awarningvariant. It uses Alert's warning glyph and tones: amber-600, which keeps 3:1 on the light surface where the--warningtoken does not. The toast guide and its demo are updated.warningtoast titled Imported N of M files (documents.cloudImport.importedPartial, andsyncedPartialfor a sync import). Its line names the first failed file with that failure's words (firstFailureDetail, throughdocuments.cloudImport.failedFileDetail,'{name}: {reason}'). A fault gets the counts alone. The dialog stays open, so importing again retries the failed files and skips the rest.documents.onedrive.noFilesSelected), as Google's already was. Before, it sent an empty list, which the door refused in zod's English.reasononly for a refusal Tale wrote for people. Today that is the size cap's 413, the upload door's own sentence (The file is … bytes; the limit is 512 MiB). Everything else is a fault whose text goes to the log alone: a provider's 403/404/429/5xx, an empty file'sInvalid blob size, a database error. The import answer's ownerrorstill never reaches a toast (fix(platform): close the #3806 cloud import and bulk send findings #3905's rule).3. The single-failure-toast guard sees handoffs
As written, the guard could not see these paths. The import writes are quiet (
errorToast: false), and a handoff to the connect dialog was not a report to it.It now treats
onRequireConnect, or a function that always calls it, as a report, and checks two things:.catchhands off is reported twice.handoffsBesideToasts, fails when a toast shares the branch that hands off. That covers a toast in that block; a toast unconditionally before it, unless the branch takes that notice down (started.dismiss()); a toast in afinallyaround it; and a toast after it while the block runs on.Samples cover each shape. Four mutations of the real dialogs are each caught by the new check alone:
returnafter the walk handoff removed;returnafter the answer handoff removed;started.dismiss()removed, which leaves Import started on screen beside the dialog.Docs and the manual layer
docs/{en,de,fr}/platform/knowledge/documents.mdsay what the import's notices mean, and what happens when access ends mid-import.KNOW-B19covers access that ends mid-import, provoked by Disconnect in a second tab, plus the re-run.KNOW-B20covers the partial import: a file over 512 MiB, and an empty file for the fault path.KNOW-B16also covers access removed at Google while the picker is open. The suite's Cost is now 60.reference/automation.md: the import-path row from fix(platform): close the #3806 cloud import and bulk send findings #3905 is updated, a row owns the unit half of both new boxes, theKNOW-B16row names the listings' refresh on a 401, and the "one failure, one toast" row names the handoff rule.tests/manual/readme.mdsuite table is recounted from the suites: knowledge 60, plus main's new responsive and tasks boxes. The total is now 1023.How I verified it
Local runs were on a sandbox shared with other agents. Workspace-wide gates (the whole platform suite,
tsc, Playwright) are left to CI.Tests at the pushed commit (all green)
backend/core/{cloud_import,onedrive,google_drive},backend/domains/{onedrive,google_drive,cloud_import}, plus thesingle-failure-toastanderror-message-descriptionguards andlib/i18n/messages.test.tsapp/features/documentsandapp/lib/backend(client project)packages/uitoaster.test.tsxservices/docs): locale tree, outline, components, linksservices/ui-docsNew and changed tests include:
cloud-import-dialogs.import-outcome.test.tsx: the Documents menu → picker → walk → import throughuseBackendActionand its adapter row → the connect dialog or the real toast, for OneDrive, SharePoint and Google Drive. It has 38 cases:import_grant.test.ts(11),import_files.test.tsfor OneDrive/SharePoint and for Google Drive,routes.grant.test.tsfor both domains (the import door plus every listing door on a 401),service.import-deps.test.ts(download flags),cloud_import/service.test.ts(the forced refresh; a refreshed token dropped after a revoke), and the lister and metadata tests.lib/cloud-import-outcome.test.ts(5).CI on
b589a663e: every check passed (60 in all; 8 were skipped by design), about 20 minutes after the push. These tasks executed rather than replaying a cached verdict (cache miss, executing):@tale/platform:test@tale/platform:test:ui@tale/platform:typecheck@tale/platform:lint@tale/ui:testNegative controls, run on the final tree with the sources swapped back to
origin/mainand the new tests keptorigin/main: all 38 outcome cases fail.origin/main: 47 of the 115 cases in the ten changed backend test files fail. The 68 that still pass are the tests that were already there.Guard mutations: the four mutations above each fail only
never toasts on a branch that hands the failure to the connect dialog.Static checks:
oxlint --type-aware --type-checkon every changed file (39 platform files, pluspackages/uiandservices/ui-docs): clean.oxfmt --check: clean.bun run knip:check: clean.bun run lint:manual: ok.check-guide.tsonknowledge.md: OK. Onreference/automation.mdit reports the same 50 lines as on the base.Review: two passes by a read-only adversarial reviewer. The first found two medium defects, both fixed here:
It also found low ones, all fixed: a refresh storm on a throttled token endpoint, a refresh that could undo a Disconnect, guard gaps, the OneDrive empty selection, and the docs wording. The second pass confirmed every fix and found no regression.
Left open
Invalid blob size). Naming them needs new backend sentences.firstFailureDetailreads the first failure only. This is unchanged shared behaviour, as fix(platform): close the #3806 cloud import and bulk send findings #3905 noted.updated_at_mswould close it.handleImportitself.suites/governance.mdstill says Cost 72 for its 73 boxes on main. I did not touch it.