Skip to content

fix(platform): land imports in the open folder and allow moving a file - #3420

Merged
Israeltheminer merged 5 commits into
mainfrom
fix/folder-scoping-and-move
Sep 18, 2026
Merged

Israeltheminer merged 5 commits into
mainfrom
fix/folder-scoping-and-move

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

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 gets folderId, the create-folder dialog gets parentFolderId.

Nothing could correct that afterwards. updateDocument accepts folderId and 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 set folderId; the move action makes it the door.

What changed

  • updateDocument refuses a destination folder outside the caller's teams with FOLDER_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.
  • Both import routes take destinationFolderId through one shared gate, loadHubImportDestination: hub scope only, ordinary folder access, and the destination's team wins over the picker's selection.
  • A path-less pick lands in the destination; a provider subfolder is mirrored underneath it. getOrCreateHubFolderPath roots its walk at a parent and counts that parent's depth against MAX_FOLDER_DEPTH.
  • The row menu gains Move to folder for a file, listing every hub folder the caller can see by full path plus the root.

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

Mutation Result
destination access gate removed (fails open) 1 failed
folder team stamp removed 1 failed
stamp applied to an org-wide folder too (over-broad) 1 failed

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. folderPathLabels covers 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-daemon fails 3 tests identically on clean origin/main; @tale/docs times out only under concurrent load and passes 166/166 in isolation.

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.
@Israeltheminer
Israeltheminer merged commit 85e678f into main Sep 18, 2026
49 checks passed
@Israeltheminer
Israeltheminer deleted the fix/folder-scoping-and-move branch September 18, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant