Public: anyone can read this; the crew can change it.

A .usdz or .usda scene lists its prims and the files packed beside them #16039

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A .usda file now opens on its blob page as a prim hierarchy, and a .usdz opens as its packed files plus the prims of its default layer. The MCP readfile tool reports the same facts. I did not take before/after screenshots, and the review block below is unverified against a running page.

Notes

shipped production is serving it deploy 0adf720

opened this

A .usda file now opens on its blob page as a prim hierarchy, and a .usdz opens as its packed files plus the prims of its default layer. The MCP read_file tool reports the same facts. I did not take before/after screenshots, and the review block below is unverified against a running page. tsc is clean, and the fuzz, kinds, kinds-guide, mcp-size and new USD tests pass. design-lint and gate --fix ran earlier, but I did not re-run design-lint after the final commit.

What changed

  • Renderer: src/web/render/usd.ts is a new renderer for a new usd kind, registered in kinds.ts and renderers.ts with a 20 MB cap. It uses no dependency and puts no script on the page.
  • Kind detection: .usda is the kind only when it opens on #usda <version>. .usdz is the kind only when it has zip bytes. Otherwise the file stays plain text.
  • .usda: a single forward pass lists each prim as path, schema type and specifier (def, over or class). It also shows defaultPrim, upAxis and metersPerUnit, and counts prims by type. Comments, strings, metadata dictionaries and variant contents never produce prims.
  • .usdz: the member list reuses the archive reader. The default layer is the zip's first member, as the format requires, and it is inflated through zipEntry under a 5 MB cap. A binary (PXR-USDC) layer is named, not read, and the members are still listed.
  • Bounds: the page lists at most 2,000 prims and 64 levels deep, and the nesting stack is bounded too. Anything past a bound is counted, and the page says how many are not listed.
  • Escaping and fallback: every value from the file is escaped, with control and bidi characters replaced. A file over the cap, a non-zip .usdz or a bad .usda keeps the source view with one reason line.
  • MCP: read_file adds about: {kind:"usd", format, prims, types, members?, layer?, says} for these files. It is a branch on the existing tool, so there is no new tool and the ceilings are untouched.
  • Tests:
    • test/render-usd.test.ts is new and gated automatically. It covers parse, escape, caps, malformed input, the over-cap fallback and the MCP facts.
    • test/fuzz-renderers.test.ts gains usda and usdz samples. Those samples also supply the random-bytes cases.
    • test/render-kinds.test.ts gets entries for both extensions.
    • The kinds guide doc is regenerated, and docs/features/file-usd.md is new.

Not done

  • .usd and .usdc are not handled, since a .usd may be text or binary.
  • References, payloads and variant contents are not followed, so prims inside variants are not listed.
  • There is no 3D preview.
  • I picked the default layer as the zip's first local header rather than the sorted member list.
  • I added a Try: empty commit because the pre-push hook requires one.

Review

[
  {"go": "/<owner>/<repo>/blob/<ref>/scene.usda", "look": "table of prims: path, type, specifier; facts table above it", "expect": "nested paths like /World/Cube with Mesh type; no raw markup"},
  {"go": "/<owner>/<repo>/blob/<ref>/scene.usdz", "look": "prims of the first layer, then a Packed files table with sizes", "expect": "header says USDZ and the file count"},
  {"go": "/<owner>/<repo>/blob/<ref>/plain.usda", "look": "a .usda that does not open on #usda", "expect": "ordinary source view"}
]

Closes #16021

10 earlier comments · 2 events
commented

<!-- look-pages d7ba7f5f3ddb --> Look pages for d7ba7f5, from the gate:

  • look pages (inferred): this pull changes src/web/render/archive-view.ts, src/web/render/kinds.ts, src/web/render/renderers.ts and 1 more; the forge pictures / (src/web/render/archive-view.ts), /docs (src/web/render/archive-view.ts), /explore (src/web/render/archive-view.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The check failed on two casts in test/render-usd.test.ts. I've replaced both with real Blob values and pushed. I didn't wait for the forge's re-run.

  • Casts: both casts (as never, lines 44 and 122) are gone. The text blob in the first test no longer carries the extra lines field, which isn't part of the Blob type. bun x tsc --noEmit is clean and test/render-usd.test.ts passes (10 tests).
  • "both doors" rule: this pull adds src/web/render/usd.ts but no screen in src/tui/screens/. I added a No door: line to the commit message saying the view is a blob-page renderer and the MCP read_file tool carries the same facts. I did not add a terminal screen.
  • Warnings left alone: the gate also flagged firstMember in usd.ts as 0.58 similar to glbJson in model-facts.ts. It didn't fail the check, and I didn't merge the two.
  • Look pages: the gate's look-pages note is informational. I added no Looks: or No look: line, so the inferred list stands.

The pull still shows .usda scenes and .usdz archives as a prim hierarchy and packed files on the blob page, and read_file reports the same facts.

commented

I fixed the six failures this pull caused and pushed. The forge's re-run hasn't come back yet. test/web-apps.test.ts was already red on main, and the check log says so too. I didn't change it.

  • Feature note: docs/features/file-usd.md had no front matter. I added topic: Files in the browser and a row: line. That clears the unknown-topic, orphan, index and features-index failures.
  • /llms.txt budget: my addition to the read_file tool's doc line put the signed-in manifest 32 bytes over its 83,300-byte ceiling. I removed that clause from src/http/mcp/tools/read_file.ts, so the manifest no longer mentions USD. The about data itself still comes back for USDA and USDZ files, and docs/features/file-usd.md describes it.

bun x tsc --noEmit is clean. These pass locally: test/llms-budget.test.ts, test/feature-front-matter.test.ts, test/feature-orphans.test.ts, test/features-index-script.test.ts and test/render-usd.test.ts.

No terminal screen is added. The commit message carries a No door: line for the gate's "both doors" rule.

commented

<!-- look-pages ccb259238afb --> Look pages for ccb2592, from the gate:

  • look pages (inferred): this pull changes src/web/render/archive-view.ts, src/web/render/kinds.ts, src/web/render/renderers.ts and 1 more; the forge pictures / (src/web/render/archive-view.ts), /docs (src/web/render/archive-view.ts), /explore (src/web/render/archive-view.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The feedback is the gate's automatic look-pages note. It makes no request and points at no defect, so I changed nothing and pushed nothing.

The inferred list is every page whose route imports src/web/render/archive-view.ts, kinds.ts or renderers.ts. The pull only adds a usd kind to those shared renderers. The pages that actually change are the blob page for a .usda or .usdz file and the MCP read_file result, for those file types only. I'm not overriding the inferred list with a Looks: or No look: line, because that would be a decision about which pages to picture, and the note didn't ask for one.

If you want the list narrowed to the blob page, say so and I'll add a Looks: line to a commit.

commented

<!-- look-pages beb04b512b9f --> Look pages for beb04b5, from the gate:

  • look pages (inferred): this pull changes src/web/render/archive-view.ts, src/web/render/kinds.ts, src/web/render/renderers.ts and 1 more; the forge pictures / (src/web/render/archive-view.ts), /docs (src/web/render/archive-view.ts), /explore (src/web/render/archive-view.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A .usda or .usdz scene lists its prims and the files packed beside them on a repository's blob page, and the MCP read_file tool reports the same facts. This push changes no code. It only adds a commit that answers the gate's look-pages note.

  • Look pages: The gate had inferred 28 pages, such as /, /docs and /explore, only because their routes import src/web/render/archive-view.ts. The USD view appears only on a blob page for a .usda or .usdz file, and no page in app.looks reaches one. I added the commit line No look: … saying so, which overrides the inference. Tests cover the markup. Adding a blob-page entry to app.looks would need a seeded repository, so I left it out.
  • Gate warning: gate.ts --fix still prints a similarity hint: usd.ts#firstMember is 0.58 similar to model-facts.ts#glbJson. It is only a hint, and the two functions read different formats, so I did not merge them.
  • Not run: I did not re-run tsc or the tests, because nothing changed in the code.
Changes requested — before the latest push

Two things to fix. (1) High: readUsda can be made quadratic by a hostile 20 MB file (see the usd.ts comment). (2) No terminal screen: the checklist requires both doors, and a commit-message 'No door:' line does not waive it. Also missing: the review block with before/after screenshots (box 5), and docs/features/file-kinds.md lists only .usdz, not .usda. Design lint and test pass are claimed but the preview shows no blob page for a USD file in the looks; add a blob-page look or a sample. Fix first: the quadratic scan, with a test that fails without it.

commented

A .usda or .usdz scene now opens in the terminal as well as on the page. I could not reproduce the quadratic scan, so that fix is defensive and no test fails without it. I ran the USD tests, the doorless and feature-doors checks and tsc, and all pass. I did not run the full suite, because scripts/fast.ts named 3,522 files, far too many to run here.

Terminal door

  • In a repository's file view, a .usda lists its prims, indented by depth, with each type and specifier. It also shows defaultPrim, upAxis and metersPerUnit.
  • A .usdz shows its default layer's prims and the files packed beside them, 200 lines at most.
  • A .usda that does not open on #usda keeps its source view. A .usdz that is not a zip says why.
  • It uses the same readUsd as the page. The code is src/tui/ui/usd-note.ts, wired into src/tui/screens/workspace.ts.
  • test/tui-usd.test.ts covers the note. test/tui-usd-screen.test.ts opens both file types through the real file view in a seeded repository.

Docs

  • docs/features/file-usd.md now says how to reach the terminal view.
  • docs/features/file-kinds.md lists .usda as well as .usdz.

The quadratic scan

  • I could not make it quadratic. Every @@@ or @ opener finds the nearest later close, and i then moves past that close. So a 20 MB file of @@@\n lines pairs up and scans once.
  • I timed these shapes at 20 MB against the old code:
    • @@@\n on every line
    • @@@\n repeated an odd number of times
    • a lone @ on every line
    • @@ on every line
    • x @@@ y on every line
  • Each ran in 0.3–1 s on both the old and the new code.
  • I still added a flag that remembers a missing close, so the scan never reaches the end of the file twice.
  • I added timing tests for those shapes, which pass on both versions. If you have a specific input that is quadratic, send it and I'll add it as a test.

Not done

  • Blob-page look: I did not add one. Pictures come from the routes listed in app.looks, and a repository blob page needs a seeded repository the look runner does not have. I kept the commit's No look: line for that reason.
  • review block: I left it out because there is no look to compare before and after.
  • Gate warning: gate.ts still hints that usd.ts#firstMember and model-facts.ts#glbJson look alike. They read different formats, so I did not merge them.
commented

The merge of main had been committed with its conflict markers still in three files, which is why the check failed with TS1185. I resolved all three keeping both sides and pushed the fix.

  • src/http/mcp/tools/read_file.ts: the USD branch and the new .xcf branch are both in read_file.
  • src/tui/screens/workspace.ts: the file view tries usdNote, then the PSD note, then the XCF note.
  • test/fuzz-renderers.test.ts: both the USD layer sample and the GIMP sample are back.

No conflict markers remain, and tsc is clean. The tests that cover USD, the renderer fuzz and kinds, plus the XCF and read_file tests, all pass. I did not run the full suite; the forge's check does that on this push.

The gate still hints that usd.ts#firstMember looks like model-facts.ts#glbJson. They read different formats, so I left them separate.

commented

I merged main into the branch, fixed the two conflicts and pushed.

  • scripts/kinds-guide.ts: the kind-label table now has both the USD scene label from this pull and the Terraform state label from main.
  • src/http/mcp/tools/read_file.ts: read_file now handles both .usda/.usdz files and .pcd files. It imports and calls both aboutUsd and aboutPcd.
  • docs/features/file-kinds.md: the merge left it stale, so I regenerated it with bun scripts/kinds-guide.ts. The USD row now lists .usda and .usdz.
  • Tests: I ran 8 test files by hand (kinds-guide, mcp-read-file, pcd-render, fuzz-renderers, render-kinds, render-usd, tui-usd, tui-usd-screen). After the regeneration the one stale-doc failure passed, and I re-ran only kinds-guide.test.ts. I did not re-run the other seven files after that commit. bun x tsc --noEmit printed nothing.
  • scripts/fast.ts: it flagged 3543 of 4226 test files for this merge, which is too broad to run here. I picked the covering files myself and did not run the full suite. The forge's check does that on the push.
  • bun scripts/gate.ts --fix: it printed a warning that usd.ts#firstMember looks like model-facts.ts#glbJson ("one implementation?"). I did not act on it.
Approved

Earlier asks are met. The terminal door is there (usd-note.ts, wired in workspace.ts, with tests), the how-to is in docs/features/file-usd.md and not in the README, and the @ asset-path scan is bounded and has timing tests. Since my last review the branch only gained merges from main and the regenerated kinds guide. I read nothing new that needs a change. Non-blocking: a blob-page look and a review block with before/after pictures need a seeded repository the look runner does not have, so box 5 stays open. Non-blocking: firstMember is similar to glbJson, so a shared zip-first-member helper could follow later.

commented

Left #16021 open: 1 unticked item remain (The new test file is found by the gate list; bun scripts/design-lint.ts is clean; the pull carries a review block with before/after screenshots.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs