Skip to content

feat: preview results found so far during a scan (Tab)#594

Merged
dundee merged 1 commit into
dundee:masterfrom
ultranity:feat/scan-preview
Jun 24, 2026
Merged

feat: preview results found so far during a scan (Tab)#594
dundee merged 1 commit into
dundee:masterfrom
ultranity:feat/scan-preview

Conversation

@ultranity

@ultranity ultranity commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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.

  • The preview does not auto-refresh — re-entering it takes a fresh snapshot
    (so sizes/sorting do not jump around while you read).
  • Navigation (arrows / hjkl / Enter) and sorting work; destructive or external
    actions are ignored while previewing, since the tree is still being built.
  • The scanning modal shows a Press Tab to preview results found so far hint.

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 via BaseAnalyzer.GetCurrentDir. The
    TUI reads it through an optional interface assertion, so the
    common.Analyzer interface and its other implementations are untouched.
  • analyze: Dir.AddFile now takes the write lock and Dir.updateStats reads
    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 dedicated concurrent -race test
    (TestPreviewWhileScanning).
  • tui: enter/exit preview, snapshot stats with a throwaway hard-link map, and
    preview-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.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.61224% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (ee9e4e2) to head (52bfab4).

Files with missing lines Patch % Lines
tui/keys.go 73.01% 14 Missing and 3 partials ⚠️
tui/progress.go 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ultranity ultranity force-pushed the feat/scan-preview branch from 9391b04 to 79fd426 Compare June 19, 2026 07:45
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>
@dundee dundee force-pushed the feat/scan-preview branch from 79fd426 to 52bfab4 Compare June 24, 2026 20:13
@dundee dundee merged commit 720cd5f into dundee:master Jun 24, 2026
9 checks passed
@dundee

dundee commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Nice feature, thanks!

@ultranity ultranity deleted the feat/scan-preview branch June 27, 2026 20:05
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