Skip to content

[codex] Reuse cached 3D model loads#899

Open
g8rr5dg2p7-svg wants to merge 2 commits into
tscircuit:mainfrom
g8rr5dg2p7-svg:codex/step-model-reuse-cached-glb
Open

[codex] Reuse cached 3D model loads#899
g8rr5dg2p7-svg wants to merge 2 commits into
tscircuit:mainfrom
g8rr5dg2p7-svg:codex/step-model-reuse-cached-glb

Conversation

@g8rr5dg2p7-svg
Copy link
Copy Markdown

@g8rr5dg2p7-svg g8rr5dg2p7-svg commented May 20, 2026

Summary

  • Reuse completed STEP conversions before hydrating the saved GLB cache, so repeated STEP mounts do not create duplicate blob URLs.
  • Add a shared load3DModel cache so repeated STL/OBJ/WRL/GLTF/GLB URLs reuse one in-flight/completed load instead of fetching and parsing duplicates.
  • Return independent clones from cached model loads and evict failed loads so retries are not poisoned by a transient failure.
  • Add regression coverage for registry-first STEP reuse, one-time saved-cache hydration, shared model-load dedupe, clone isolation, and failed-load retry.

Verification

  • npm run format:check
  • npx biome check src/utils/load-model.ts tests/load-model-cache.test.ts
  • npx --yes bun test tests/load-model-cache.test.ts tests/step-model-cache.test.ts
  • npx tsc --noEmit
  • npm run build
  • npm run test:node-bundle

Closes #93

/claim #93

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment May 23, 2026 9:31am

Request Review

@g8rr5dg2p7-svg
Copy link
Copy Markdown
Author

Quick review note for maintainers: this PR is intentionally scoped to the STEP cache lifecycle gap I mentioned in the attempt comment.

It checks the in-memory conversion registry before hydrating from the saved GLB cache, so remounting the same STEP model can reuse the existing converted file instead of creating another blob URL. I kept the fetch/conversion path unchanged and added focused regression coverage for registry-first reuse plus one-time saved-cache hydration.

Current GitHub checks are green, and the PR body lists the local verification commands I ran.

@g8rr5dg2p7-svg g8rr5dg2p7-svg changed the title [codex] Reuse cached STEP model blob URLs [codex] Reuse cached 3D model loads May 23, 2026
@g8rr5dg2p7-svg
Copy link
Copy Markdown
Author

Update: I pushed a second commit that broadens this PR from STEP cache reuse to the shared load3DModel path as well.

The new cache reuses one in-flight/completed load per URL, returns independent clones so callers can set transforms without mutating the cached source object, and evicts failed loads so a transient failure can be retried.

Verification run locally:

  • npm run format:check
  • npx biome check src/utils/load-model.ts tests/load-model-cache.test.ts
  • npx --yes bun test tests/load-model-cache.test.ts tests/step-model-cache.test.ts
  • npx tsc --noEmit
  • npm run build
  • npm run test:node-bundle

@g8rr5dg2p7-svg
Copy link
Copy Markdown
Author

One maintainer-facing verification note for the bounty claim: this PR is non-visual loader/cache work rather than a UI rendering change, so I verified it with focused regression tests plus the package checks/build instead of a demo video. The current checks are green, and the patch covers the duplicate in-flight/completed model load path while preserving independent clones and retry behavior after failed loads. Happy to add a short capture or narrow the scope further if that would make review easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve 3d model loading to avoid laggy browser

1 participant