Repository navigation
fix(platform): land imports in the open folder and allow moving a file - #3420
Merged
Merged
Conversation
updateDocument is the only path that can move a document between hub folders. It checked the organization and the project/hub scope, then wrote folder_id. It never asked whether the caller can see the destination, and never applied the destination's team. createDocumentFromBlobUpload has enforced both since the hub shipped: a folder whose team you are not in refuses with FOLDER_NOT_ACCESSIBLE, and a team folder stamps its team on what lands inside it. Without them a move could file a document into a folder the caller cannot open, and leave an org-wide document sitting in a place only one team can reach. Both rules were unreachable because no UI sets folderId. The move action that follows makes this the door, so they are enforced and pinned first. The inherited-team guard now reads the folder the call lands in rather than the one being left behind.
A Knowledge import placed documents by mirroring the provider's own path and nothing else. Pick files at the top of the OneDrive or Google Drive picker and there is no path to mirror, so every file went to the hub root however deep in the folder tree the person was standing. The two import dialogs were the only children of the documents action menu that were never told which folder was open. They now take destinationFolderId. A path-less pick lands there, and a provider subfolder is mirrored underneath it rather than beside it at the root, so getOrCreateHubFolderPath roots its walk at a parent and counts that parent's depth against the cap. A destination is a write into that folder, so the route puts it through the ordinary folder gate: hub scope only, and a team folder refuses a caller outside the team and then owns the team of everything imported into it. That gate is one helper both providers call.
Nothing in the product could change a document's folder. The backend accepted folderId on updateDocument and the REST door exposed it, but the only caller was the team-tags dialog, which never sends one — so a file that landed in the wrong place stayed there. The row menu gains Move to folder for a file, on a dialog that lists every hub folder the caller can see by full path, plus the root. Two folders sharing a name under different parents stay apart because the label is the path, and a folder whose ancestor the caller cannot see keeps its own name rather than dropping out of the list. Files only. Moving a folder takes its whole subtree and is a separate operation with no door here yet.
The row-menu memo now renders with the open folder, so it takes it as a dependency. The destination id is already typed on the import args, so the brand assertion beside it was redundant.
Its only caller is the adapter row beside it; exporting it mirrored hubFoldersQuery, which is exported because the route loader prefetches with it. Knip reads the difference.
This was referenced Sep 29, 2026
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.
A Knowledge import now lands in the folder you have open, and a file that landed in the wrong place can be moved.
Why
Import placement came from one function: mirror the provider's own path, create Tale folders to match, done (
core/google_drive/import_files.ts). Pick files at the top of the OneDrive or Google Drive picker and there is no path to mirror, so every file went to the hub root however deep in the tree you were standing. The two import dialogs were the only children of the documents action menu never told which folder was open — the upload dialog getsfolderId, the create-folder dialog getsparentFolderId.Nothing could correct that afterwards.
updateDocumentacceptsfolderIdand the REST door exposes it, but the only caller was the team-tags dialog, which never sends one.That move path was also missing two rules the create path has enforced since the hub shipped. It checked organization and project/hub scope, then wrote
folder_id— never asking whether the caller can see the destination, and never applying the destination's team. Unreachable while no UI setfolderId; the move action makes it the door.What changed
updateDocumentrefuses a destination folder outside the caller's teams withFOLDER_NOT_ACCESSIBLE, and a team folder stamps its team on what lands inside it. The inherited-team guard reads the folder the call lands in, not the one being left.destinationFolderIdthrough one shared gate,loadHubImportDestination: hub scope only, ordinary folder access, and the destination's team wins over the picker's selection.getOrCreateHubFolderPathroots its walk at a parent and counts that parent's depth againstMAX_FOLDER_DEPTH.Risk
Moving a document into a team folder changes who can see it, because the folder's team replaces the document's. That is the same rule an upload already follows, and it is the only way a team folder's contents stay consistent with the folder.
Tests
Placement is pinned per provider: a path-less pick lands in the destination, no destination still lands at the root, and a subfolder mirrors under the destination rather than beside it.
folderPathLabelscovers two folders sharing a name, a missing ancestor, and a parent cycle.Scope
Files only. Moving a folder takes its whole subtree and has no door here. Documents already at the root stay there — this adds the way to move them, not a migration.
Gate: platform typecheck, lint, test and test:ui pass.
@tale/sandbox-runtime-daemonfails 3 tests identically on cleanorigin/main;@tale/docstimes out only under concurrent load and passes 166/166 in isolation.