Commit 2bfc1bd
authored
feat!: implement virtual scrolling for large file lists (#45)
* feat: implement virtual scrolling for large file lists
- Add virtual scrolling to FileList component using useStdout hook
- Calculate viewport height and render only visible items
- Add scroll indicators showing number of items above/below viewport
- Track scroll position and automatically adjust when navigating
- Reset scroll position when search query changes
- Improve SplitPane with dynamic width options and min/max constraints
- Reduce left panel width to 35% for more preview space
Fixes #43
* refactor: remove unnecessary comments from source code
* refactor: improve code readability with constants for width and scroll calculations
- Extract SplitPane width values into constants for better maintainability
- Move RESERVED_LINES constant outside useMemo to prevent recalculation
- Simplify scroll indicator visibility logic with descriptive boolean variables
- Improve code organization and readability based on PR review feedback
* fix: improve USER MEMORY file display and overflow handling
- Increase left pane width from 35% to 45% to accommodate USER MEMORY files
- Handle tab characters in filenames by replacing with spaces for display
- Reduce reserved lines from 11 to 9 for more visible content
- Increase max viewport height from 15 to 20 lines for better visibility
- Maintain ~/.claude/CLAUDE.md display format for USER MEMORY files
These changes ensure USER MEMORY files are properly displayed at the top
of the file list without text truncation or overlap issues.
* perf: optimize virtual scrolling with flattened item list
- Introduce flattened item list to reduce recalculations during scroll
- Extract magic numbers as named constants for better maintainability
- DEFAULT_TERMINAL_ROWS, MAX_VIEWPORT_HEIGHT, MIN_VIEWPORT_HEIGHT, TEST_VIEWPORT_HEIGHT
- Simplify test environment check in SplitPane configuration
- Improve performance by calculating visible items with simple array slice
instead of complex iteration on each scroll offset change
* refactor: improve code quality based on PR review
- Convert IIFE to useMemo for better readability
- Replace spread operator with explicit props for stricter type checking
- Add FlatItem type definition for virtual scrolling type safety
- Fix performance: use useMemo instead of useCallback for getCurrentLinePosition
- Remove unnecessary implementation comments following coding style guidelines
- Add comprehensive virtual scrolling tests
All quality checks pass (TypeScript, Biome, Knip, Tests, Build)
* test: improve virtual scrolling tests for better reliability and relevance
- Replace unrealistic 105+ navigation tests with meaningful behavior tests
- Add test to verify virtual scrolling renders only visible items (performance)
- Add test to ensure selection stays visible during navigation (UX)
- Simplify search reset test to use reasonable file counts
- Remove flaky tests that relied on exact scroll indicator positions
- Focus on user-centric behaviors rather than implementation details
* refactor: extract virtual scroll logic to custom hook and reduce panel width
- Extract scroll position management from FileList to useVirtualScroll hook
- Reduce left panel width from 45% to 35% for better preview space
- Remove unnecessary null check for fileIndex (guaranteed by TypeScript types)
- Document RESERVED_LINES breakdown for UI chrome space calculation
* fix: add tests for useVirtualScroll hook and fix stdout dependency
- Add comprehensive InSource tests for useVirtualScroll hook
- Fix optional chaining for stdout.rows in dependency array
- Adjust panel width from 35% to 40% for better visibility
- Unify es-toolkit import paths for consistency
* refactor: change interface to type in useVirtualScroll hook
- Replace interface declarations with type aliases for consistency
- Follow TypeScript coding standards that prefer type over interface
* refactor: improve code quality based on review feedback
- Extract magic numbers as named constants in useVirtualScroll.tsx
- Define MIN_VIEWPORT_HEIGHT, MAX_VIEWPORT_HEIGHT, DEFAULT_TERMINAL_ROWS, TEST_VIEWPORT_HEIGHT
- Optimize navigation loops in FileList.test.tsx
- Remove waitForEffects() after each keystroke, call once after loop
- Improves test performance
- Remove unnecessary comments for cleaner code
* refactor: improve code quality with ts-pattern and functional programming
- Remove unnecessary "Virtual scrolling types" comment
- Simplify RESERVED_LINES comment to one line
- Replace nested ternary operators with ts-pattern in FileItem
- Convert flatItems generation from for loops to flatMap
- Implement getCurrentLinePosition using ts-pattern
- Replace process.env.NODE_ENV check with testViewportHeight parameter
- Extract scroll adjustment logic to getAdjustedScrollOffset function
* fix: prevent text overflow in FileItem component
Add text truncation with ellipsis to file names to prevent overflow
when terminal width is reduced. This ensures proper display of file
names with badges in split-pane layout regardless of terminal size.
- Add wrap="truncate-end" to all Text components displaying file names
- Set flexGrow={1} and marginRight={1} on file name container
- Set flexShrink={0} on badge container to prevent badge compression
* test: fix virtual scrolling test for CI compatibility
Update test to be more flexible with viewport differences between
local and CI environments. Instead of expecting exact file position,
verify that relevant files are visible within a reasonable range.1 parent 77410ec commit 2bfc1bd
File tree
9 files changed
+714
-94
lines changed- src
- components
- FileList
- Layout
- hooks
9 files changed
+714
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
| |||
25 | 38 | | |
26 | 39 | | |
27 | 40 | | |
28 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
29 | 54 | | |
30 | 55 | | |
31 | 56 | | |
| |||
35 | 60 | | |
36 | 61 | | |
37 | 62 | | |
38 | | - | |
39 | 63 | | |
40 | 64 | | |
41 | 65 | | |
42 | 66 | | |
43 | | - | |
44 | 67 | | |
45 | 68 | | |
46 | 69 | | |
| |||
58 | 81 | | |
59 | 82 | | |
60 | 83 | | |
61 | | - | |
62 | 84 | | |
63 | 85 | | |
64 | 86 | | |
65 | | - | |
66 | 87 | | |
67 | 88 | | |
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
72 | 93 | | |
73 | | - | |
74 | 94 | | |
75 | 95 | | |
76 | 96 | | |
| |||
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
92 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
93 | 116 | | |
94 | 117 | | |
95 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
58 | | - | |
| 55 | + | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
70 | 63 | | |
71 | 64 | | |
72 | 65 | | |
73 | 66 | | |
74 | 67 | | |
75 | 68 | | |
76 | 69 | | |
77 | | - | |
| 70 | + | |
78 | 71 | | |
79 | 72 | | |
80 | 73 | | |
81 | 74 | | |
| 75 | + | |
82 | 76 | | |
83 | 77 | | |
84 | 78 | | |
85 | 79 | | |
86 | 80 | | |
87 | | - | |
| 81 | + | |
88 | 82 | | |
89 | 83 | | |
90 | 84 | | |
91 | 85 | | |
92 | | - | |
| 86 | + | |
93 | 87 | | |
94 | 88 | | |
95 | 89 | | |
96 | 90 | | |
97 | 91 | | |
98 | | - | |
| 92 | + | |
99 | 93 | | |
100 | 94 | | |
101 | 95 | | |
| |||
0 commit comments