Repository navigation
Phase 3 (#64): progressive BIDS tree (skeleton + lazy per-subject) - #69
Merged
neuromechanist merged 3 commits intoMay 26, 2026
Conversation
Splits /api/dataset/<id>/tree?v=<v> into two response modes via the new optional subject= parameter. Without subject= the endpoint emits a skeleton: top-level non-subject entries inline, each sub-XYZ as a collapsed <details data-subject="..."> with a lazy slot. With subject= it returns just that subject's inner subtree. The dataset detail page picks up subtree expansions on the first <details> toggle and drops the fragment into the matching slot. Targets on005505 specifically: 5,409 paths / 136 subjects used to ship 3.3 MB of HTML in one blob and block the file panel for seconds. Skeleton stays under 50 KB; subtree fetches are scoped to one subject at a time and edge-cached per (id, version, subject) for free via the existing URL-keyed cache. Adds isSubjectDir(name) predicate (used both for skeleton row identification and as the param-validation gate on the endpoint), renderBidsSubtree(node, basePath) for the subtree response, and 8 tests covering subject-vs-non-subject rendering plus the traversal-guard cases on the predicate. Closes #64 Part of epic #66
Deploying nemar-website with
|
| Latest commit: |
78053fa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://29b887ab.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-64-progressive.nemar-website.pages.dev |
Five sonnet reviewers ran in parallel. Critical and important fixes:
- silent-failure-hunter + code-reviewer: 503 response on the subtree
branch had no Cache-Control. Add FALLBACK_CACHE (no-store) so a
transient upstream failure doesn't pin at the edge, matching the
skeleton's no-manifest treatment.
- silent-failure-hunter + comment-analyzer: the 404 (subject not
found) inline comment promised a "short cache" the code never
set. Add a NOT_FOUND_SUBJECT_CACHE constant (60s s-maxage) so
the wire behavior matches the documented intent.
- code-reviewer: 400 responses (missing v=, invalid subject=)
carried no Cache-Control. Add no-store on both paths so an
intermediate proxy can't pin the error.
- code-reviewer: subject regex was alphanumeric-only; widen to
/^sub-[A-Za-z0-9-]+$/ so BIDS 2.0 + real OpenNeuro datasets
like sub-NDAR-AC904DMU don't silently regress to inline render.
Update isSubjectDir tests; embedded slash still rejected.
- code-reviewer: .tree__error class had no CSS rule. Add a scoped
rule in BidsTree.astro so the subtree-fetch-failure paragraph
reads as a retry prompt, not body text.
- type-design-analyzer: replace inline import("...").TreeNode
with a top-of-file import type so the dependency is legible.
- comment-analyzer: tighten the renderBidsSubtree docstring with
the concrete renderDirChildren(node, basePath, 1) call site,
and add a "keep in sync" warning to the subject-param
validation comment.
- pr-test-analyzer: add four endpoint-validation tests (no v=,
malformed subject, empty subject, underscore label) and two
rendering edge cases (subjects-only tree, nested sub-* doesn't
re-collapse).
393/393 tests (was 386).
Deferred to a follow-up issue: small-subject UX regression (2-3
subjects now require an extra click). Out of #64's stated scope
(100+ subject case).
CF Pages picks up *.test.ts under src/pages/** as a route entry and breaks the build (same class as PR #62 / commit 3cbc89f for the proxy test). Relocate to src/lib/tree-endpoint.test.ts; the file still imports GET from the route source, so the wire-contract coverage is unchanged. 393/393 tests pass; local astro build completes clean.
neuromechanist
merged commit May 26, 2026
55f24ff
into
feature/issue-66-epic-cold-paint
1 check passed
This was referenced May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The biggest cold-paint win of epic #66. The current
/api/dataset/<id>/tree?v=<v>endpoint emits a single 3.3 MB HTML blob for on005505 (5,409 paths / 136 subjects), blocking the file panel for seconds on low-bandwidth connections. This PR splits the endpoint into two response modes:subject=param): top-level non-subject entries rendered inline; everysub-XYZdirectory becomes a closed<details data-subject="sub-XYZ">carrying counts + size but no nested files, with a[data-subject-target]slot waiting for content. Target: < 50 KB for on005505.?subject=sub-NDARAC904DMU): returns just that subject's inner<ul class="tree__children">markup, which the client drops into the matching slot on first<details>toggle.Client-side glue is one new
document.addEventListener("toggle", ..., true)insrc/pages/dataset/[id].astro— capture phase because the toggle event does NOT bubble. The skeleton uses native<details>so keyboard nav (Tab + Enter/Space) works for free.Validation:
subject=must match^sub-[A-Za-z0-9]+$(rejects"",../,sub-x/y); invalid values get a400. A well-formed subject that doesn't exist in this version's tree gets a404. Per-subject responses are edge-cached underPUBLISHED_CACHE— the existing URL-keyed Workers cache namespace already gives us per-(id, version, subject) entries for free.Closes #64
Part of epic #66
Test plan
bun run typecheck— 0 errorsbun run lint— biome cleanbun run test— 386/386 (was 378 in Phase 2; +8 new in the newrender-tree.test.ts—isSubjectDirtraversal guard + skeleton/subtree rendering verification)on005505): cold paint shows top-level entries immediately; subject rows expand on click and on keyboard Enter; second expand of the same row does NOT re-fetch (data-loadedguard); collapsing and re-opening preserves the loaded subtree.?subject=sub-INVALID) returns 404, not 500./browseagainst the Pages preview after merge — verify the UX under the real Worker runtime.Files touched
src/lib/render-tree.ts—isSubjectDirpredicate,renderBidsSubtreeexport,renderBidsTreemodified to collapse subject branches.src/pages/api/dataset/[id]/tree.ts— new?subject=validation + dispatch; common TreeNode build path; subtree handler returnsrenderBidsSubtree(...)or 404.src/pages/dataset/[id].astro— one capture-phase toggle listener for lazy subject expansion.src/lib/render-tree.test.ts— new file, 8 tests.Notes
<details>instead of a custom widget keeps the keyboard / screen reader story free.<p class="tree__error" role="alert">if the subtree fetch fails — collapse/re-open retries.