Skip to content

Keep the Files panel fluent at the 5000-file import cap — every row renders today, unwindowed #166

Open

Description

@bencode

Problem

The product's scale contract for a project is explicit: a folder import is allowed to bring in up to 5000 files (ui-packages/web/src/core/folder-import.ts:4, refused only above it, line 47), and folder import is a headline feature ("Organise files in projects, bring in folders", README). But the Files panel renders every one of those rows in the DOM: the tree maps buildFileTree(files) with no windowing (ui-packages/web/src/features/resources/resource-tree.tsx:103-107), and each filter keystroke recomputes the shown set and re-renders the rows (ui-packages/web/src/features/resources/resource-panel.tsx:104-111). The codebase already virtualizes the surface with the same shape — the spreadsheet grid renders only the rows on screen (ui-packages/web/src/features/reader/xlsx-reader/sheet-grid.tsx:34-39, @tanstack/react-virtual) — so a 5000-file library opens the session mounting thousands of FileRow buttons and types laggy into the filter on modest hardware, while a 5000-row sheet scrolls fluently. The import cap invites the scale; the one list that must absorb it is the only long list not windowed.

Proposal

  • Window the Files panel tree and flat views the way the spreadsheet grid already is: render visible rows plus overscan (@tanstack/react-virtual is already a dependency), preserving folder expand/collapse state and the filter.
  • Recent/Starred need nothing — they are bounded (50 recents).
  • The 5000-file import cap stays as the scale contract.

Goal

After this, a project holding the import cap's 5000 files opens with the Files panel mounting only visible rows, and typing in the filter feels the same as in a 50-file project; folder expansion and the reveal-on-open behavior are unchanged.

Verification

grep -rq "useVirtualizer" ui-packages/web/src/features/resources
pnpm --filter @gamma-reader/web test --silent
pnpm check

Refs

  • ui-packages/web/src/core/folder-import.ts:4,47 — maximumFolderFiles = 5000, the scale the import path allows
  • ui-packages/web/src/features/resources/resource-tree.tsx:103-107 — full unwindowed tree render
  • ui-packages/web/src/features/resources/resource-panel.tsx:104-111 — per-keystroke filter recompute over all files
  • ui-packages/web/src/features/reader/xlsx-reader/sheet-grid.tsx:34-39 — the virtualization pattern already in the codebase
  • README.md — "Organise files in projects, bring in folders and links"
  • Bound Lab cell output — one large print can freeze the reading tab #55 — same family: bound what scale can freeze the reading tab (Lab output then, the Files panel list now)

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 22, 2026
  2. bencode commented on Oct 22, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against main@ebb0ee0.

    Evidence audit: all citations confirmed.

    • ✅ core/folder-import.ts:4,47-48 — maximumFolderFiles = 5000, refused as too-many above it.
    • ✅ features/resources/resource-tree.tsx:103-107 — the tree renders <TreeRows nodes={buildFileTree(files)}> unwindowed; useVirtualizer appears nowhere under features/resources/ (repo-wide its only home is sheet-grid.tsx:1,34).
    • ✅ features/resources/resource-panel.tsx:104-111 — normalizeSearchText at :104 and shownFiles/shownEntries recomputed by plain filter per keystroke (unmemoized), re-rendering every matching row.
    • ✅ Precedent real: @tanstack/react-virtual is already a dependency, sheet-grid.tsx:34 uses it with overscan: 12 — the exact pattern mandated for reuse. Recents are indeed bounded (50, pinned by use-file-navigation.test.tsx:31).
    • ✅ README:18 carries the quote (bold markers around "Organise" hide it from a plain-text grep, but the substance is exact).

    Duplicate check: none. #55 (closed) is the same scale family on a different surface (Lab output, not the Files panel) and is correctly cross-referenced; #69 concerns the sheet grid. No open or closed issue covers windowing the Files panel.

    Sensor: lint ✓; verify ✗ on main today — for the right reason: useVirtualizer under features/resources/ passes only when the mandated reuse actually lands (deliverable-shaped, same form as #68's repaired anchor). No Verification edit needed.

    Verdict: valid, keep open. Two sharpening notes for implementation:

    • The tree needs a flattened visible-row model before windowing — isOpen/expanded/collapsed already define "visible", so the flattening is mechanical; the regressions to pin with a test are the reveal-on-open path (resource-tree.tsx:87-95) and folder toggle state.
    • Filter recompute and row windowing are separable; windowing alone removes the mounting cost, which is the dominant term at 5000 files.
  3. bencode commented on Oct 26, 2026

    @bencode
    OwnerAuthor

    Independent re-review — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against main@23a11fc (2026-10-26), four days of commits after the last review.

    Evidence re-audit: all anchors still hold, zero drift.

    • core/folder-import.ts:4 — maximumFolderFiles = 5000; refused as too-many at :47–48.
    • features/resources/resource-tree.tsx:105 — <TreeRows nodes={buildFileTree(files)} …> still renders the whole tree unwindowed; no useVirtualizer under features/resources/.
    • features/resources/resource-panel.tsx:104,110–111 — normalizeSearchText + shownFiles/shownAttachments still recomputed by plain filter per keystroke.
    • Precedent intact: sheet-grid.tsx:34–40 (useVirtualizer, overscan: 12).

    Sensor: lint ✓; verify ✗ on main for the right reason — the useVirtualizer grep under features/resources passes only when the mandated reuse lands.

    Commits since the last review: none touch features/resources/ or folder-import.ts. One adjacent change to account for: 93563a2 (2026-10-23) reworked file-row actions into a hover overlay on .resource-row (styles.css — position: relative, actions laid over the row's end instead of a reserved column). A windowed row keeps the identical DOM, so no conflict with virtualization; the fixed row height actually makes estimateSize exact. The overlay is the only row-level CSS coupling — a windowing change should not reintroduce a reserved actions column, or it regresses that fix.

    Duplicates: re-scanned open + closed titles — none. #201 (transcript windowing), #69 (sheet Ctrl+F) and #55 (closed, Lab output) are the same family on different surfaces.

    Verdict: valid — stays open. Prior sharpening stands: flatten visible rows from isOpen/expanded/collapsed before windowing, and pin the reveal-on-open path (resource-tree.tsx reveal flow) with a test.

  4. bencode commented on Oct 30, 2026

    @bencode
    OwnerAuthor

    Independent re-review — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against main@d05b6b6 (2026-10-28), two days of commits after the last review.

    Evidence re-audit: all anchors hold in substance; line drift only.

    • core/folder-import.ts:4 — maximumFolderFiles = 5000, too-many refusal at :46-48 — exact.
    • resource-tree.tsx:95 — <TreeRows nodes={buildFileTree(files)} …> still renders the whole tree unwindowed (cited :103-107; moved by 16ff78c).
    • resource-panel.tsx:107,113-114 — normalizeSearchText + shownFiles/shownAttachments still recomputed by plain filter per keystroke (cited :104,110-111).
    • Precedent intact but relocated: useVirtualizer now at xlsx-reader/sheet-grid.tsx:94 (cited :34-39; moved by 7f7ac7a). Still no useVirtualizer anywhere under features/resources/.

    Material change since the last review: 16ff78c (PR #242, 2026-10-26) reworked the tree's expansion state. Folder expansion moved into use-folder-expansion.ts; the filtered view now auto-opens every folder holding a match, with a separate collapsed set kept apart from hand-opened folders and reset when the filter changes (resource-tree.tsx:86-93). Two consequences for the windowing work:

    1. The visible-row model is cleaner than at last review: flatten from isOpen (:92), which already merges both regimes (unfiltered expanded ∪ filtered auto-open − collapsed) — the exact predicate TreeRows recurses on.
    2. New behavior a windowed tree must reproduce: under an active filter, visible rows = matches + ancestors, minus collapsed. The reveal/fold test the prior review asked for should cover the filtered regime too, or windowing can silently drop it.

    Sensor: lint ✓; verify ✗ on main for the right reason — the useVirtualizer grep under features/resources/ passes only when the mandated reuse lands.

    Duplicate re-scan (open + closed): none. #233 (reading pane), #201 (transcript), #275 (workbook parse) are the same family on different surfaces.

    Verdict: valid — stays open. Fixed row height keeps estimateSize exact; the hover-overlay coupling note from last review still applies.

  5. bencode commented on Nov 3, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit @ d05b6b6 — fourth pass, quiet window (0 commits since the last re-audit at the same HEAD; no issue filed in any state since 2026-11-01). Still valid; stays open; no edits.

  6. bencode commented on Nov 14, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit @ d05b6b6 — fifth pass, quiet window (0 commits since the fourth pass at the same HEAD on 2026-11-03; nothing filed in any state since #295, 2026-11-05, and it touches another surface). Still valid; stays open; no edits.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions