GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — fix(fork): preserve folder structure across a fork edge for files, tables, and knowledge bases by waleedlatif1 · Pull Request #6752 · simstudioai/sim Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
PR SummaryMedium Risk Overview
Files: Fork create / promote: workflow, file, table, and KB folder maps are merged into one map for Reviewed by Cursor Bugbot for commit a07e14b. Configure here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Greptile SummaryThis PR extends fork folder preservation from workflows to files, tables, and knowledge bases in create and promote flows.
Confidence Score: 4/5The PR should not merge until the outstanding dangling-parent mapping defect is fixed, because copied content can be assigned to an unrelated target folder. The shared mapper still converts an unresolved soft-deleted parent to a root-level mapping key and may reuse an unrelated same-named target folder; the new file, table, and knowledge-base paths consume that mapping directly. Files Needing Attention: apps/sim/ee/workspace-forking/lib/copy/copy-workflows.ts
|
| Filename | Overview |
|---|---|
| apps/sim/ee/workspace-forking/lib/copy/copy-workflows.ts | Generalizes the shared folder-subtree mapper to operate on each folder-bearing resource type. |
| apps/sim/ee/workspace-forking/lib/copy/copy-files.ts | Mirrors selected files’ folder subtree and carries the resolved target folder into deferred metadata finalization. |
| apps/sim/ee/workspace-forking/lib/copy/copy-resources.ts | Mirrors table and knowledge-base folder trees and assigns remapped folder IDs to inserted resources. |
| apps/sim/ee/workspace-forking/lib/create-fork.ts | Combines workflow, file, table, and knowledge-base folder maps during initial fork creation. |
| apps/sim/ee/workspace-forking/lib/promote/copy-unmapped.ts | Combines per-family folder maps when rewriting references for unmapped resources copied during synchronization. |
| apps/sim/ee/workspace-forking/lib/promote/promote.ts | Explicitly scopes the existing promote-time workflow folder mapping to the workflow tree. |
%%{init: {'theme': 'neutral'}}%%
flowchart LR
S[Selected source resources] --> W[Map workflow folders]
S --> F[Map file folders]
S --> T[Map table folders]
S --> K[Map knowledge-base folders]
W --> U[Merge folder ID maps]
F --> U
T --> U
K --> U
U --> P[Place copied resources in target folders]
U --> R[Rewrite sim:folder references]
Reviews (3): Last reviewed commit: "fix(fork): drop the sync-time re-home pa..." | Re-trigger Greptile
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…s, and KBs Only workflow folders were mirrored into the target workspace on fork create and on sync. Copied files, tables, and knowledge bases were written with a hardcoded `folderId: null`, so a push or pull flattened them all into the target root and lost the source's grouping — visible as a fork sync that drops folder structure when copying files to the parent. `resolveForkFolderMapping` already did the real work (prune to folders holding copied content plus ancestors, reuse same-named target folders, remap parentId), but was pinned to `resourceType: 'workflow'` on both reads and on the folder-ceiling check. Parameterize it by resource type and run it per family, threading the resulting map into each copy instead of nulling. The four folder-bearing families own disjoint trees and folder ids are globally unique, so the per-family maps merge cleanly for the `sim:folder/<id>` content rewrite, which previously resolved only for workflow folders. Existing forks are healed on their next sync rather than by a migration: `rehomeFlattenedForkResources` re-homes mapped files/tables/KBs whose target `folder_id` is still NULL — the exact signature of the old flattening — so a placement chosen in the target is never overwritten and the pass converges to a no-op. `BlobCopyTask.targetFolderId` is optional so tasks queued by an earlier deploy replay at the root exactly as before.
…y rows Self-review of the folder-transit change surfaced two scaling problems in the re-home pass, both of which grow with the size of the fork edge rather than the size of the sync: - The resource lookups built `IN (...)` lists straight from the edge's mapping rows, so a large fork could hand Postgres a list approaching the bind-parameter ceiling and a pathological query plan. Page them at 500, matching the paging the rest of the fork copy already uses. - The pass re-read the whole edge mapping via `getEdgeMappingRows`, which the promote plan had already loaded in the same transaction — a second full load of identical rows. Expose them on `ForkPromotePlan` and pass them in, which also drops a mock from the re-home tests. Also tally moved rows from `returning()` rather than the planned batch size, so the log line reports what the `folder_id IS NULL` guard actually wrote instead of what was attempted.
…rd-only Review surfaced three findings and every one of them was in the re-home pass, none in the forward-looking fix: - It keyed mapping orientation off `direction`, but the promote route resolves the edge from whichever workspace the caller is acting in, so a caller in the PARENT pushing to its child is `direction: 'push'` with the parent as source. The plan derives this as `sourceWorkspaceId === edge.parentWorkspaceId` for exactly that reason. - Moving a file into a mirrored folder can violate `workspace_files_workspace_folder_name_active_unique`, which would abort the whole promote transaction and take the workflow sync down with it. - `folder_id IS NULL` cannot distinguish "flattened by the old copy" from "the user moved this to the root", so the pass re-applied on every sync and would fight a deliberate placement indefinitely. The first two are fixable; the third is not without a one-time marker per edge, which means a migration. A heal that re-applies forever is worse than no heal, so remove the pass entirely rather than ship it half-right. Folder structure now transits correctly from this point forward, which is the actual reported bug; healing already-flattened resources can be a separate change with a marker to make it run exactly once. Reverts the `ForkPromotePlan.mappingRows` field with it — it existed only to feed this pass.
68bc46e to
a07e14b
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@cursor review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a07e14b. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Re: the remaining "Dangling parent aliases root folder" finding on 1. The state it describes isn't reachable through the delete path. It requires an active folder whose parent is soft-deleted. 2. The suggested remedy would throw. A "distinct re-rooted copy" cannot exist: 3. Reuse-by-name is the mapper's deliberate policy, not a quirk of this branch. The same This is also pre-existing behavior that predates the PR — it shipped for workflow folders and is unchanged here; this PR only parameterizes the mapper by Happy to change it if you disagree — but the fix would need to be "re-root the content to the target root ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
a07e14bf
Deployed
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.