feat: preview results found so far during a scan (Tab)#594
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #594 +/- ##
==========================================
- Coverage 85.53% 85.45% -0.09%
==========================================
Files 55 55
Lines 6085 6175 +90
==========================================
+ Hits 5205 5277 +72
- Misses 676 691 +15
- Partials 204 207 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9391b04 to
79fd426
Compare
A long scan previously gave no way to look at what had been found until it finished. Pressing Tab during a scan now opens a read-only, point-in-time view of the directory tree discovered so far, with real aggregated directory sizes; pressing Tab (or Esc) returns to the progress modal. The preview does not auto-refresh - re-entering it takes a fresh snapshot. Destructive/external actions are ignored while previewing since the tree is still being built. Implementation: - analyze: expose the in-progress root via BaseAnalyzer.GetCurrentDir so the partial tree can be inspected mid-scan; the TUI uses an optional interface assertion so the common.Analyzer interface and its other implementations are untouched. - analyze: make Dir.AddFile take the write lock and have Dir.updateStats read the file list under the read lock, so computing stats on the live tree while the analyzer is still appending is race-free (paired with the existing RLock in showDir). Verified with a concurrent -race test. - tui: enter/exit preview, snapshot stats with a throwaway hard-link map, preview-only key handling, and a "Press Tab to preview" hint in the scanning modal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
79fd426 to
52bfab4
Compare
Owner
|
Nice feature, thanks! |
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.
Problem
During a scan there is currently no way to look at what has been found — you
have to wait for the whole scan to finish. For very large / slow targets that
can be a long time (see #150, where users describe 53–60 TB scans).
Change
Pressing Tab during a scan opens a read-only, point-in-time view of the
directory tree discovered so far, with real aggregated directory sizes. Pressing
Tab (or Esc) returns to the progress modal. The scan keeps running in
the background the whole time.
(so sizes/sorting do not jump around while you read).
hjkl/ Enter) and sorting work; destructive or externalactions are ignored while previewing, since the tree is still being built.
Press Tab to preview results found so farhint.Relation to #150
#150 asks to stop a scan and keep the results (to save RAM / time). This PR is
a related step — you can now inspect partial results during a scan — but it
intentionally keeps the scan running rather than stopping it. Happy to extend
this toward fully resolving #150 (stop-and-keep) if you would like.
Implementation
analyze: expose the in-progress root viaBaseAnalyzer.GetCurrentDir. TheTUI reads it through an optional interface assertion, so the
common.Analyzerinterface and its other implementations are untouched.analyze:Dir.AddFilenow takes the write lock andDir.updateStatsreadsthe file list under the read lock, so computing stats on the live tree while
the analyzer is still appending is race-free (paired with the existing
RLockinshowDir). Verified with a dedicated concurrent-racetest(
TestPreviewWhileScanning).tui: enter/exit preview, snapshot stats with a throwaway hard-link map, andpreview-only key handling.
All tests pass under
go test -race ./....Companion PR #593 adds a confirmation before quitting when a long scan would be lost.