Skip to content

fix(analysis): the run outlives leaving Discover; a queued run is not cancelled by auto-advance - #115

Merged
iLevyTate merged 1 commit into
mainfrom
fix/analysis-run-survives-navigation
Nov 11, 2026
Merged

iLevyTate merged 1 commit into
mainfrom
fix/analysis-run-survives-navigation

Conversation

@iLevyTate

Copy link
Copy Markdown
Owner

Stacked on #114. Base is fix/complete-phase-and-preview-ux; GitHub retargets this to main when #114 merges. The diff below is only this change.

Summary

Reproduced from a manual run's log: 8 files analyzing, 70 more added mid-run.

  • 17:03:26 first batch completes → showAnalysisCompletionNotification schedules a jump to Organize in 2 s.
  • 17:03:27 the 70 queued files start as the next run.
  • ~17:03:28 the jump fires anyway (it only checked "still on Discover?"). Discover unmounts and its cleanup aborts the run: Analysis interrupted by navigation, main reports cancelled: true, processed: 0.
  • 17:06:34 the user returns to Discover; resume restarts all 70. Because the run lived inside Discover, isAnalyzing locked every phase tab for the whole run (~43 s/file), so the first batch could not be reviewed or organized.

Changes:

  • Auto-advance skips when another run is active or queued, checked when the timer fires (pendingFilesRef or store isAnalyzing).
  • Run ownership: useAnalysis moves out of DiscoverPhase into a new AnalysisRunProvider mounted in PhaseRenderer around every phase, with the stuck-run watchdog and the total-failure flag. Discover reads it via useAnalysisRun(). A phase change no longer unmounts the run, and files queued mid-run survive leaving Discover.
  • Navigation: a running analysis no longer pauses the phase tabs (NavigationBar.isBlockedByOperation), selectIsNavigationPaused (Alt+Arrow, dashboard links, File-menu pickers) or Discover's Continue (still needs ≥1 analyzed file). File moves, loading and undo/redo still pause. Switching to the dashboard still waits for the run, since the dashboard replaces PhaseRenderer.
  • Merge guard: the run's final merge drops results for paths in the organized index, so a file organized mid-run is not re-added under its old path.

Scope

  • Area(s): discover/analysis run, phase navigation, dashboard links
  • Risk Level: medium (moves run ownership; navigation rules change)
  • Breaking Changes: none; the behavior change is intended (tabs open during analysis)

Type of Change

  • Bug fix
  • Enhancement
  • New feature
  • Refactor
  • Documentation update
  • Breaking change

Test Plan

Automated

  • npm run format:check / npm run lint (changed files; pre-commit hooks)
  • npm test — full suite: 940 suites green after updating the 7 tests that encoded "analysis pauses navigation"
  • npm run typecheck, npm run verify:checkjs-ratchet
  • Additional tests added/updated when behavior changed
    • useAnalysis.test.js — auto-advance stays on Discover when the next run has started (confirmed failing with the fix disabled); moves to Organize otherwise
    • AnalysisRunProvider.test.js (new) — run survives a phase change, actions reach Discover, total-failure flag, missing-provider error
    • DiscoverPhase.test.js — Continue stays enabled during analysis once a file is ready
    • Updated: phaseNavigation, usePhaseJump, useKeyboardShortcuts.phaseGating, DashboardView, PhaseRenderer
  • Full npm run ci / e2e not run locally

Manual QA

  • Manual checklist completed (see docs/TESTING.md)
  • Not applicable (explain below)

Manual QA notes (not yet run in the app):

  1. Start a batch, add more files mid-run → when the first finishes, the app stays on Discover and the queued run starts (no interrupted by navigation in the log).
  2. Go to Organize mid-run → the "Analysis continuing in background: N/M" banner keeps advancing; moving ready files works.
  3. Return to Discover → the same run is still going, not restarted.
  4. Dashboard toggle stays disabled until the run ends.

Checklist

  • I scoped this PR to one logical change
  • I self-reviewed code and naming for clarity
  • I updated docs/config references where needed (comments describing run ownership)
  • I called out follow-up work or known limitations

Known limitations

  • The provider mounts with PhaseRenderer, so with a persisted isAnalyzing after a reload the resume now starts at app launch rather than when Discover opens.
  • useAnalysis now loads in the PhaseRenderer chunk instead of the Discover chunk (still lazy, after the shell paints).
  • Discover's embedding-rebuild prompt still only appears if Discover is open when a run ends.

@iLevyTate
iLevyTate deleted the branch fix/complete-phase-and-preview-ux November 11, 2026 18:44
@iLevyTate iLevyTate closed this Nov 11, 2026
@iLevyTate iLevyTate reopened this Nov 11, 2026
@iLevyTate
iLevyTate changed the base branch from fix/complete-phase-and-preview-ux to main November 11, 2026 18:46
@iLevyTate iLevyTate closed this Nov 11, 2026
@iLevyTate iLevyTate reopened this Nov 11, 2026
… not cancelled by auto-advance

A finished batch scheduled a jump to Organize 2 s later. Files added during
that batch start as the next run right away, and the jump fired anyway:
Discover unmounted and aborted the queued run 1.5 s in (logged as
"Analysis interrupted by navigation", 70 files, 0 processed). Returning to
Discover restarted all 70, and because the run lived in Discover, analysis
locked every phase tab for the whole run, so the earlier batch could not be
organized meanwhile.

- Auto-advance skips when another run is active or queued (read at fire time).
- The run moves out of DiscoverPhase into AnalysisRunProvider, mounted in
  PhaseRenderer above every phase, together with the stuck-run watchdog and
  the total-failure flag. Discover reads it through useAnalysisRun().
- A running analysis no longer pauses the phase tabs, Alt+Arrow, dashboard
  jump links or Discover's Continue (once a file is ready). File moves,
  loading and undo/redo still pause; switching to the dashboard still waits,
  since the dashboard replaces PhaseRenderer.
- The run's final merge drops results for files organized mid-run, so a
  moved file's old-path result is not re-added.
@iLevyTate
iLevyTate force-pushed the fix/analysis-run-survives-navigation branch from cabf493 to 0d0c1eb Compare November 11, 2026 19:18
@iLevyTate
iLevyTate enabled auto-merge November 11, 2026 19:18
@iLevyTate
iLevyTate merged commit b0c17c9 into main Nov 11, 2026
10 checks passed
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.

1 participant