Skip to content

Add virtualized flat-list TreeView component and preview sandbox#2972

Merged
sawka merged 2 commits intomainfrom
copilot/add-virtual-file-explorer-widget
Mar 4, 2026
Merged

Add virtualized flat-list TreeView component and preview sandbox#2972
sawka merged 2 commits intomainfrom
copilot/add-virtual-file-explorer-widget

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

This PR introduces a new frontend TreeView widget intended for VSCode-style explorer use cases, without backend wiring yet. It provides a reusable, backend-agnostic API with virtualization, flat visible-row projection, and preview coverage under frontend/preview.

  • What this adds

    • New TreeView component in frontend/app/treeview/treeview.tsx designed around:
      • flat visibleRows projection with depth (not recursive render)
      • TanStack Virtual row virtualization
      • responsive width constraints + horizontal/vertical scrolling
      • single-selection, expand/collapse, and basic keyboard navigation
    • New preview: frontend/preview/previews/treeview.preview.tsx with async mocked directory loading and width controls.
    • Focused tests: frontend/app/treeview/treeview.test.ts for projection/sorting/synthetic-row behavior.
  • Tree model + projection behavior

    • Defines a canonical TreeNodeData wrapper (separate from direct FileInfo coupling) with:
      • id, parentId, isDirectory, mimeType, flags, childrenStatus, childrenIds, capInfo
    • Builds visibleRows from nodesById + expandedIds and injects synthetic rows for:
      • loading
      • error
      • capped (“Showing first N entries”)
  • Interaction model implemented

    • Click: select row
    • Double-click directory (or chevron click): expand/collapse
    • Double-click file: emits onOpenFile
    • Keyboard:
      • Up/Down: move visible selection
      • Left: collapse selected dir or move to parent
      • Right: expand selected dir or move to first child
  • Sorting + icon strategy

    • Child sorting is deterministic and stable:
      • directories first
      • case-insensitive label order
      • id/path tie-breaker
    • Icon resolution supports directory/file/error states and simple mimetype/extension fallbacks.
  • Example usage

<TreeView
    rootIds={["workspace:/"]}
    initialNodes={{ "workspace:/": { id: "workspace:/", isDirectory: true, childrenStatus: "unloaded" } }}
    fetchDir={async (id, limit) => ({ nodes: data[id].slice(0, limit), capped: data[id].length > limit })}
    maxDirEntries={120}
    minWidth={100}
    maxWidth={400}
    height={420}
    onSelectionChange={(id) => setSelection(id)}
/>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 4, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 874b1a0
Status: ✅  Deploy successful!
Preview URL: https://3c9f9206.waveterm.pages.dev
Branch Preview URL: https://copilot-add-virtual-file-exp.waveterm.pages.dev

View logs

Copilot AI changed the title [WIP] Add virtual file explorer widget for preview Add virtualized flat-list TreeView component and preview sandbox Mar 4, 2026
Copilot finished work on behalf of sawka March 4, 2026 00:19
@sawka sawka marked this pull request as ready for review March 4, 2026 01:33
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 4, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • frontend/app/treeview/treeview.tsx - Well-structured TreeView component with proper error handling and defensive programming
  • frontend/app/treeview/treeview.test.ts - Good test coverage for sorting and synthetic row rendering
  • frontend/preview/previews/treeview.preview.tsx - Comprehensive preview with async loading simulation
  • package.json / package-lock.json - Added @tanstack/react-virtual dependency

Review Notes

The TreeView implementation is solid with:

  • ✅ Proper null/undefined checks throughout
  • ✅ Defensive programming (e.g., line 441 filters null nodes before rendering)
  • ✅ Good error handling in async operations
  • ✅ Comprehensive keyboard navigation
  • ✅ Virtualization for performance
  • ✅ Test coverage for core functionality

The code follows the project's conventions and handles edge cases appropriately.

@sawka sawka merged commit f4acfc9 into main Mar 4, 2026
7 checks passed
@sawka sawka deleted the copilot/add-virtual-file-explorer-widget branch March 4, 2026 02:25
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.

2 participants