Repository navigation
feat(platform): auto-sync OneDrive/SharePoint documents - #2507
Merged
Merged
Conversation
Reuse the Entra ID SSO token as a Microsoft Graph token so members can import OneDrive/SharePoint files right after signing in, and reconcile every active sync config on a schedule. - capture the granted OAuth scope on SSO login and thread the Graph token - provision the sync workflow install + schedule idempotently on upsert - drive per-config reconcile through a workflow loop (durable, retryable, observable) instead of processing-records/backoff - reconcile folders (batch import + prune) and single files; add stop-sync
Use a Set for slug membership checks and negate booleans directly so the lint job passes on provision_defaults_mutations.
Patching indexable file metadata now marks the row queued again when ragStatus was unset; align the internal_mutations tests with that behavior.
larryro
marked this pull request as ready for review
July 6, 2026 00:04
When a file or subdirectory is deleted at the OneDrive/SharePoint source, the folder-sync reconcile pruned the orphaned documents by calling `deleteDocumentById` directly. That left two artifacts behind: - the now-empty subfolder rows lingered in the hub (the reported bug), and - the documents' RAG vector index was never purged, so removed files stayed retrievable by the assistant. Reconcile is the only place a source-side deletion is noticed — the document was never deleted through Tale's UI — so it must do the full cleanup. Mirror the generic drive-reconcile path in document_action.ts: - resolve the sync-target root and pass `cleanupAncestorsUpTo` so each prune reaps its now-empty ancestor folders, stopping at (never deleting) the root; - route blob-bearing docs through `deleteDocumentFromRag` (staggered, with the externalItemId/fileId snapshot guard against an interleaving re-upload) so the vector index is dropped; metadata-only docs delete directly. Covered by onedrive/run_folder_reconcile.test.ts.
`fetchChildren` read only the first Graph `/children` page and ignored `@odata.nextLink`, so a synced folder with more than one page (~200 direct children) listed only its first page. On the next sync run, every file past the first page looked "gone" to the reconcile and was pruned — deleting live documents (row, blob, and now RAG index) whose source files still exist. Follow `@odata.nextLink` to the end so large folders list in full. Bound the walk with a fail-safe page cap that THROWS rather than truncating: a short read would silently re-introduce the mass-delete, so failing the sync (which leaves every document untouched) is the safe outcome. Recurring sync reads `/me/drive` only (SharePoint and the browse picker are one-time imports where a truncated page is a missing import, not a deletion), so this is the one listing on the destructive path. Covered by list_folder_contents.test.ts.
Add the missing OneDrive sync mock, point the external-agent spec at the correct i18n key, symlink token-sources into E2E fixtures, and give org scaffold more reload attempts on cold CI boot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sync_one_config) so failures are isolated and the engine can persist/retry per step.This branch also includes two earlier commits not yet on
main:fix: implement cursor agent cli as a sandbox external agentfeat(platform): return-loop notifications and actionable emailTest plan
*/15schedule (or trigger manually) and confirm add/update/delete reconcilelist_active_configs→loop_configs→ per-configsync_one_configstepsbun run --filter @tale/platform testfor onedrive + workflow structure testsDefinition of done
onedriveSyncConfigstable)origin/fix/onedrive-sso-entra-id