Skip to content

fix(core): exclude dot-directories and node_modules from studio composition discovery and lint#1385

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
leorivastech:fix/studio-discovery-dot-dirs
Jun 13, 2026
Merged

fix(core): exclude dot-directories and node_modules from studio composition discovery and lint#1385
jrusso1020 merged 1 commit into
heygen-com:mainfrom
leorivastech:fix/studio-discovery-dot-dirs

Conversation

@leorivastech

Copy link
Copy Markdown
Contributor

Summary

Fixes #1384. walkDir only skipped three exact names (.thumbnails, node_modules, .git), so HTML inside any other dot-directory (.hyperframes/, .cache/, …) surfaced in the comps sidebar (each entry preview-rendered) and inflated the studio Lint badge with findings from files that aren't part of the video.

Changes

  • New isInHiddenOrVendorDir helper in studio-api/helpers/safePath.ts: rejects paths with a dot-directory or node_modules segment.
  • Applied to composition discovery (routes/projects.ts) and the studio lint route (routes/lint.ts) — the two surfaces named in the issue.
  • The file tree is deliberately left unfiltered: this only gates discovery. Happy to extend the exclusion to walkDir itself if you'd rather hide dot-directories everywhere.
  • The meta.json ignore-list idea from the issue would compose well on top of this; left out to keep the change minimal.

Tests

projects.test.ts + lint.test.ts (new, following the files.test.ts patterns): a vendored .hyperframes/examples/preset.html carrying data-composition-id is excluded from compositions and lint but stays visible in the file tree. Both exclusion tests fail against the pre-fix code.

Verification

  • studio-api route tests — 14/14 pass
  • typecheck on @hyperframes/core passes; oxlint / oxfmt --check clean; fallow audit gate clean

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real issue, clean fix.

walkDir only skips 3 hardcoded dirs (.thumbnails, node_modules, .git), so any HTML in .hyperframes/, .cache/, .waveform-cache/ etc. leaks into composition discovery and lint. The fix is minimal and correct:

  • isInHiddenOrVendorDir checks path segments for dot-prefix or node_modulessegments.slice(0, -1) correctly excludes the filename itself so a root-level .foo.html isn't affected
  • Applied only at the discovery/lint layer, not walkDir itself — file tree stays unfiltered (deliberate, and the right call)
  • Tests create real temp dirs with .hyperframes/examples/preset.html carrying data-composition-id, verify exclusion from compositions + lint while confirming visibility in the file tree

No concerns. LGTM.

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This fixes the reported #1384 surfaces by filtering hidden/vendor directory HTML out of composition discovery and lint without hiding the files from the tree, and the route tests cover both behaviors. Live checks are green.

@jrusso1020

Copy link
Copy Markdown
Collaborator

@leorivastech

Copy link
Copy Markdown
Contributor Author

@jrusso1020 Got it — setting up commit signing now, will re-push the branch signed shortly.

…sition discovery and lint

Projects that vendor tooling assets under dot-directories ended up with
every example/preset HTML inside them listed and preview-rendered in the
comps sidebar, and the studio Lint badge inflated with findings from
files that are not part of the video. walkDir only skipped three exact
names (.thumbnails, node_modules, .git), so any other dot-directory
(.hyperframes/, .cache/, ...) was walked.

Add an isInHiddenOrVendorDir helper that rejects paths with a
dot-directory or node_modules segment and apply it to composition
discovery and the studio lint route. The file tree is deliberately left
unfiltered - this only gates discovery.

Fixes heygen-com#1384
@leorivastech leorivastech force-pushed the fix/studio-discovery-dot-dirs branch from 7aabf28 to fed58af Compare June 13, 2026 00:02
@leorivastech

Copy link
Copy Markdown
Contributor Author

@jrusso1020 Done — branch re-pushed with the commit signed (SSH signing set up); GitHub now shows it as Verified. Should be mergeable on your end.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after the signing re-push — approving.

Signing (my earlier comment): resolved. Head commit fed58af now verifies verified: true / reason: valid, so the BLOCKED mergeStateStatus is purely the review-required gate, not a failing check (only CI check, WIP, is green).

@miguel-heygen already covered the core fix; this is additive on the bits worth confirming on a re-review:

Correctness

  • isInHiddenOrVendorDir (safePath.ts) uses segments.slice(0, -1), so it gates dot-dir / node_modules path segments but never the filename — a root-level .foo.html composition still surfaces. Paths from walkDir are always /-joined regardless of OS, so the split("/") is consistent cross-platform.
  • Complementary to walkDir's existing IGNORE_DIRS (it prunes .git/node_modules/.thumbnails at the dir level; this helper catches every other dot-dir it recurses into). No double-negative or conflict.

All discovery surfaces covered (the thing I most wanted to verify on re-review)

  • The two project-wide HTML enumerators — filterCompositionFiles (projects.ts:10) and lint (lint.ts:12) — are both filtered.
  • The only other data-composition-id match, files.ts:1084, operates on a single caller-addressed file (res.absPath), not a project walk, so it's correctly out of scope.
  • File tree (files) intentionally left unfiltered — matches #1384's ask that vendored HTML stays browsable.

Tests — both projects.test.ts and lint.test.ts pin positive (real comps lint/discover) and negative (vendored .hyperframes/** excluded) and confirm file-tree visibility; both fail pre-fix.

nit (non-blocking): no explicit test for the deliberate root-level .foo.html keep-case or a node_modules/** exclusion — both are exercised implicitly but a one-line assert would pin the slice(0, -1) intent against future edits.

Verdict: APPROVE
Reasoning: Real bug, minimal and correct fix, all enumeration surfaces filtered, tests pin both directions, commit now signed/verified, CI green.

@jrusso1020 jrusso1020 merged commit b952dc9 into heygen-com:main Jun 13, 2026
46 checks passed
jrusso1020 added a commit that referenced this pull request Jun 13, 2026
…1385) (#1399)

#1385 ("exclude dot-directories from composition discovery", b952dc9)
merged with a failing test, leaving main red. Its commit message assumed
"walkDir only skipped three exact names (.thumbnails, node_modules, .git)",
but `.hyperframes` had already been added to walkDir's IGNORE_DIRS by the
backup feature (with its own passing "hides internal backup files" test).

So the new test "keeps dot-directory files visible in the file tree" used
`.hyperframes/examples/preset.html` — the one dot-dir that walkDir hides —
and asserted it appears in `files`, which can never hold: `files = walkDir(...)`
filters `.hyperframes`. The implementation is coherent; the test picked the
wrong fixture and never exercised the isInHiddenOrVendorDir gating it meant to.

Fix the fixtures (test-only, no production change):
- Add a genuinely-vendored dot-dir `.cache/examples/preset.html` — walkDir does
  not special-case it, so it stays in the file tree but must be gated out of
  composition discovery by isInHiddenOrVendorDir. This is what #1385 actually
  targets, now properly exercised.
- Keep `.hyperframes/examples/preset.html` and assert it is hidden from the file
  tree (IGNORE_DIRS) — documenting the deliberate divergence so the two features
  (Studio-internal backups vs. browsable vendored dot-dirs) don't collide again.

Full non-producer suite green; the walkDir "hides backups" test is untouched.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

studio: comps browser indexes HTML from dot-directories as compositions

3 participants