Interactive compare mode: live review with pause/diff/skip controls
Problem
The compare command currently runs as a batch process -- it compares all files, shows results at the end, and only then can the user review. For users with many files, this means waiting for the full comparison to finish before seeing anything actionable.
With the progress bar now showing per-file and per-fuzzy-candidate detail (window01\tab09.txt [fuzzy 47/154]), users can see what's happening but can't intervene. If they spot a file being fuzzy-compared that they know isn't relevant, they can't skip it. If they see an interesting near-match, they can't pause and diff it immediately.
Proposed solution
Add --interactive / -i flag to compare that enables live controls during comparison:
notepad-cleanup compare <folder> -s "..." --interactive
During processing, the status line shows available actions:
⠇ Comparing... ━━━━━━╺━━━━━ 23/93 window07\tab02.txt [fuzzy 88/154]
[(p)ause (s)kip file (d)iff (q)uit]
Controls:
- (p)ause -- Pause processing. Shows the current file's comparison details (which files it's being compared against, current best near-match if any). Resume with Enter
- (s)kip -- Skip the current file entirely, mark as "new" regardless of fuzzy results. Useful when the user knows a file isn't a real near-match
- (d)iff -- Launch the configured diff tool (Beyond Compare, etc.) for the current file vs. its best near-match candidate so far. Processing pauses while diff tool is open
- (q)uit -- Stop comparison early. Files processed so far are reported normally; unprocessed files are listed as "not compared"
Design considerations
- Non-blocking key detection: On Windows,
msvcrt.kbhit() + msvcrt.getch() can detect keypresses without blocking. On Unix, select.select() on stdin. This needs to be platform-aware
- Rich progress bar interaction: Rich's Progress context manager owns the terminal. Key detection must work alongside it without corrupting the display. May need to use Rich's
Live display instead of Progress
- Batch mode is the default:
--interactive is opt-in. Scripts and CI get the current batch behavior. This also means the progress_callback API stays the same for batch mode
- Diff tool mid-stream: When the user presses
d, we need to (1) pause the inner loop, (2) identify the current best candidate, (3) launch the diff tool, (4) wait for it to close or not, (5) resume. The diff tool should launch in the background (user may want to keep it open while resuming comparison)
- Skip feedback: When a user skips a file, it should be noted in the results output: "window07\tab02.txt (skipped by user)" so there's a record of the intervention
Implementation approach
- Add
--interactive / -i flag to compare command in cli.py
- Add
InteractiveController class that wraps the progress callback and handles key detection
- Modify
find_duplicates to accept an optional control_callback that can return "continue", "skip", or "quit" -- checked at each iteration
- Platform-specific key detection:
msvcrt on Windows, termios + select on Unix
- The diff tool integration reuses the existing
resolve_diff_tool() / launch_diff_tool() from dedup.py
Acceptance criteria
Related issues
Interactive compare mode: live review with pause/diff/skip controls
Problem
The
comparecommand currently runs as a batch process -- it compares all files, shows results at the end, and only then can the user review. For users with many files, this means waiting for the full comparison to finish before seeing anything actionable.With the progress bar now showing per-file and per-fuzzy-candidate detail (
window01\tab09.txt [fuzzy 47/154]), users can see what's happening but can't intervene. If they spot a file being fuzzy-compared that they know isn't relevant, they can't skip it. If they see an interesting near-match, they can't pause and diff it immediately.Proposed solution
Add
--interactive/-iflag tocomparethat enables live controls during comparison:During processing, the status line shows available actions:
Controls:
Design considerations
msvcrt.kbhit()+msvcrt.getch()can detect keypresses without blocking. On Unix,select.select()on stdin. This needs to be platform-awareLivedisplay instead ofProgress--interactiveis opt-in. Scripts and CI get the current batch behavior. This also means theprogress_callbackAPI stays the same for batch moded, we need to (1) pause the inner loop, (2) identify the current best candidate, (3) launch the diff tool, (4) wait for it to close or not, (5) resume. The diff tool should launch in the background (user may want to keep it open while resuming comparison)Implementation approach
--interactive / -iflag tocomparecommand incli.pyInteractiveControllerclass that wraps the progress callback and handles key detectionfind_duplicatesto accept an optionalcontrol_callbackthat can return "continue", "skip", or "quit" -- checked at each iterationmsvcrton Windows,termios+selecton Unixresolve_diff_tool()/launch_diff_tool()fromdedup.pyAcceptance criteria
--interactiveflag added tocomparecommand-i) behavior unchanged (batch mode)Related issues