Repository navigation
Conversation
Deleting a scan or guide node only routed http(s) URLs to onDeleteAsset. Local asset:// Files (up to 200 MB per scan) stayed in IndexedDB forever. - Add deleteAsset + sweepOrphanAssets to @pascal-app/core asset storage - Schedule delayed local deletes on node removal (undo-safe grace period) - Sweep unreferenced assets after applySceneGraphToEditor - Cover storage, lifecycle, undo-restore, and cancel paths with tests Fixes pascalorg#733
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: 92c31b27-f9c4-4ce1-a2fb-ce2e00b06d8f |
IndexedDB is origin-global and not scoped by project/scene. Sweeping every asset_data: entry missing from the just-loaded graph deleted local Files still referenced by other scenes, blank canvases, and previews. Keep only the undo-safe delayed delete when a node is removed. Fixes the orphaned-File leak from pascalorg#733 without a multi-scene wipe. Addresses review on pascalorg#854.
|
Addressed the Bugbot finding in d44b09d: removed the scene-load orphan sweep. IndexedDB is origin-global, so sweeping entries missing from the just-loaded graph could wipe assets still referenced by other scenes. Cleanup is now only the undo-safe delayed delete of a specific �sset:// File after its last live node is removed. |
The grace-period re-check only inspected the active useScene graph. Switching projects during the window could delete an origin-global IndexedDB File that another saved scene still referenced. Bump a scene epoch in applySceneGraphToEditor; timers scheduled under a previous epoch refuse to delete. Addresses review on pascalorg#854.
|
Addressed the latest Bugbot finding: delayed deletes now capture a scene epoch at schedule time. �pplySceneGraphToEditor bumps the epoch; timers from a previous epoch refuse to deleteAsset. Switching projects during the grace window no longer deletes origin-global IndexedDB Files that another saved scene still references. Covered by a new unit test. |
|
This finding is already fixed on the current HEAD (cb97731), which is ahead of the reviewed 7ae66a2.
No further code change needed for this comment. |
Aymericr
left a comment
There was a problem hiding this comment.
Blocker: cleanup is attached to two UI handlers rather than the deletion lifecycle, so the bug still reproduces through supported delete paths.
For example, packages/editor/src/hooks/use-keyboard.ts deletes a selected guide/scan directly with useScene.getState().deleteNode(...), and the generic selection/delete surfaces in selection-routing.ts and group-actions.ts also bypass scheduleLocalAssetDelete. Deleting the same local reference with the Delete key therefore still leaves its asset:// File in IndexedDB.
Please move the scheduling to a single path that observes all committed node removals/replacements, or route every supported guide/scan deletion path through one shared helper. Add a regression test for keyboard deletion (and ideally delete-mode/generic selection deletion) so this cannot remain UI-entry-point dependent. The 120-second grace period, live-reference recheck, cache revocation, and scene-epoch guard are otherwise sensible.
Cleanup was attached to the Site panel and reference-panel handlers, so keyboard Delete (use-keyboard.ts), selection delete, MCP, and group actions still orphaned asset:// Files in IndexedDB (pascalorg#733). - Move grace-period scheduling into @pascal-app/core - Hook deleteNodesAction and applyNodeChanges delete/update paths - Cover keyboard-style deleteNode with a core regression test Fixes the remaining delete paths called out in review.
|
Addressed the deletion-lifecycle blocker in $(git rev-parse --short HEAD):
Grace period, live-reference recheck, cache revocation, and scene-epoch guard are unchanged. |
Aymericr
left a comment
There was a problem hiding this comment.
The central delete lifecycle now covers the missing keyboard/generic paths, but the current head still has three correctness blockers before cleanup is safe: (1) URL replacement schedules deletion without a fire-time scan of all live nodes, so undo or another node sharing the same asset:// URL can lose its File; (2) the reference-panel replacement schedules before updateNode commits, so a no-op/throw can delete the still-current asset; and (3) the scene epoch only advances in applySceneGraphToEditor, while unload/import/reset paths can replace the graph through setScene/clearScene and leave an old timer valid. Please make the timer predicate query the current graph for the URL at fire time, schedule replacements only after a committed change, and put epoch invalidation at the shared graph-replacement boundary. CI also needs the three Biome organize-import fixes shown by quality. Add regressions for shared-reference replacement, undo restoration, failed/no-op replacement, and a clear/set scene transition.
…Scene Address review on pascalorg#733 cleanup: - URL-replacement timers re-check the live graph at fire time (undo / shared asset:// handles) - Guide replace no longer schedules delete before updateNode commits - Epoch invalidation lives on unloadScene/setScene, not only applySceneGraphToEditor - organizeImports on the three CI-flagged files Regressions: shared-reference replace, undo restore, unreferenced replace, setScene epoch.
|
Addressed the three correctness blockers and Biome organizeImports on $head:
Regressions added for shared-reference replacement, undo restoration, unreferenced replacement, and setScene epoch. packages/core: 1545 tests pass. |
Aymericr
left a comment
There was a problem hiding this comment.
The new fire-time live-graph checks fix the reported undo/shared-node cases, but there is still a cross-scene data-loss blocker. asset:// storage is origin-global, and scene/project duplication preserves those URLs. If scene A and an unopened saved scene B reference the same File, deleting the last reference in the currently loaded A schedules deleteAsset; staying in A for 120 seconds means the timer sees no current reference and deletes B’s File. The epoch only protects a scene switch during the grace window, not references in persisted scenes that were never loaded. This is the same ownership problem that made the original sweep unsafe.
Please do not physically delete origin-global Files based only on the active graph. The cleanup path needs a durable cross-scene reference index/refcount (updated atomically with scene persistence), per-scene asset ownership/copying, or a conservative explicit garbage-collection pass that can inspect every saved graph. Until one of those exists, this PR trades an orphan leak for silent corruption of another project. Add a regression with two persisted scenes sharing one asset URL; deleting from one must not break the other.
Move bumpLocalAssetSceneEpoch import before material-library and put events/bus value export before its type export.
IndexedDB asset:// Files are origin-global and survive scene duplication, so deleting based on the loaded graph alone corrupts other saved scenes (pascalorg#733 review). - Remove automatic deleteAsset from deleteNodes/updateNodes timers - Core exposes sweepLocalAssetsExcept(keepUrls) for explicit GC - apps/editor GC unions current + localStorage + every server scene; skips the sweep when any source cannot be enumerated - Regression: two persisted scenes sharing one URL — delete from one must not break the other Fixes the cross-scene data-loss blocker.
|
Addressed the cross-scene data-loss blocker in No longer deletes origin-global Files from the active graph.
Orphan leak may remain until a successful full enumeration runs — that is preferred over silent corruption of another project. |
- Treat a full /api/scenes page (limit=500, no cursor) as incomplete — never sweep when older scenes may still reference a File - Re-read useScene nodes immediately before sweepLocalAssetsExcept so uploads during the long per-scene fetch stay in the keep-set - Keep initialScene urls in the extra keep-set Addresses Bugbot findings on 55e04ae.
|
Fixed the two High findings on
Unit tests cover truncated list, failed list, and mid-GC live-graph growth. |
Mount-time GC races keepalive flush, other tabs, and uploads that have reached IndexedDB but not a node; sequential per-scene GETs also burn the autosave rate bucket. Keep runLocalAssetGc as an explicit host API only — never called from SceneLoader. Prefer leftover orphans over deleting live Files.
|
Addressed the mount-time GC findings on
This leaves possible orphans in IndexedDB rather than deleting Files another tab, keepalive flush, or unpersisted upload still needs. |
Top-level url/src missed item.asset.*, captureSession.manifestUrl, and materials texture maps. Deep-walk nodes (depth-capped) and include graph.materials via collectGraphAssetUrlsFromParts.
|
Fixed keep-set completeness on
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 276e5b0. Configure here.
|
Reviewing this against #733 — verified the fix routes local Questions while reading:
|
|
Thanks for the careful questions. The PR had changed substantially since its original description, so I corrected the title and body to match the current code.
This means the PR is groundwork for #733, not a complete automatic fix. I removed the closing |
|
@Aymericr The review threads are resolved, and the latest push fixes the live-material keep-set and makes GC abort on malformed or incomplete scene inventories. All current checks pass. Could you take another look? The PR description now states clearly that this is an explicit cleanup API and does not fully close #733. |
|
Merged current main (c5eaf51) in eb19a8f and resolved the core export conflict, preserving both the new upstream exports and the local asset APIs. I also removed leftover comments and hook dependencies from the earlier automatic-cleanup implementation. Cleanup remains explicit, with no mount/load caller. Local validation: bun install --frozen-lockfile, bun run check, all 13 check-types tasks, and all 23 focused asset storage/collection/GC tests passed. The standalone app's full lib suite also passed (59 tests). The full monorepo run is not green on Windows: unchanged upstream checks hit Windows path/POSIX-mode assumptions and a geometry golden comparison, and standalone history probes hit module resolution issues. No unrelated fixes are included here. GitHub now reports the PR as mergeable. The new CI run (quality and macOS cli-smoke) and mcp-ci run have all passed at eb19a8f. Ready for another review of the explicit-cleanup scope. |

Scope
Adds conservative, explicit cleanup for local
asset://Files related to #733. This PR does not automatically delete a File when a node is removed, and it does not fully fix #733. IndexedDB is shared by every scene and tab on the origin; deleting from one active scene could corrupt another saved scene that references the same URL.Changes
@pascal-app/coreprovidesdeleteAsset,listLocalAssetUrls,sweepLocalAssetsExcept, and collectors for nestedasset://references in nodes and material maps.deleteAssetalso revokes its cached object URL.apps/editor/lib/local-asset-gc.tsprovides an explicit host API. It collects references from the current graph, the localStorage draft, and every server scene. A failed, truncated, or malformed scene inventory (or unparseable local draft) aborts the sweep. The live graph is read again immediately before deletion; both nodes and materials are included, including unsaved texture references added during the inventory walk.Review questions
Validation
bun test apps/editor/lib/local-asset-gc.test.ts— 8 passed, including an IndexedDB File referenced by a live material added during inventory and malformed-inventory guard cases.bun run --cwd apps/editor check-types— passed.bunx biome check apps/editor/lib/local-asset-gc.ts apps/editor/lib/local-asset-gc.test.ts— passed.bunx turbo run build --filter='./apps/editor^...'— passed (existing Turbopack dynamic filesystem tracing warning).Note
Medium Risk
Sweep logic can permanently delete IndexedDB blobs if mis-invoked with an incomplete keep-set, though the implementation aborts on uncertain inventories; shared
asset://handles across scenes make correct union-of-references critical.Overview
Adds explicit, opt-in garbage collection for local
asset://files in IndexedDB, aimed at #733 without deleting assets when a single node is removed.Core gains
deleteAsset,listLocalAssetUrls, andsweepLocalAssetsExcept, plus deep collectors that walk nodes and material maps forasset://strings. Deletes also revoke cached object URLs.Editor exposes
runLocalAssetGc, which builds a keep-set from the live graph, thelocalStoragedraft, and every server scene (one GET per scene). If the inventory cannot be proven complete—list failure, malformed payloads, a full 500-scene page, or bad local draft—it returnsnulland does not sweep. The live graph is read again right before deletion so mid-run uploads and unsaved material textures stay protected.There is no automatic caller in this PR; hosts must invoke GC only when writes are idle and API budget allows. Tests cover abort paths and live-graph re-read behavior;
fake-indexeddbis added for editor tests.Reviewed by Cursor Bugbot for commit eb19a8f. Bugbot is set up for automated code reviews on this repo. Configure here.