Skip to content

Move scrape cancellation into MainWindowViewModel#18

Merged
astar-development-jb merged 1 commit into
mainfrom
feature/main-window-viewmodel-cancellation
Jul 14, 2026
Merged

Move scrape cancellation into MainWindowViewModel#18
astar-development-jb merged 1 commit into
mainfrom
feature/main-window-viewmodel-cancellation

Conversation

@jbarden

@jbarden jbarden commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Cancel button now cancels the actual scrape work in MainWindowViewModel (was previously wired to a dead CancellationTokenSource in MainWindow code-behind that never touched the ViewModel's work).
  • IsBusy drives CancelCommand.CanExecute; a per-run CancellationTokenSource is checked before/after the confirm dialog and before Playwright configuration.
  • MainWindowViewModel implements IDisposable, cancelling any in-flight run on teardown.
  • Found and fixed a latent bug along the way: none of the scrape commands subscribed to ThrownExceptions, so ReactiveCommand.CreateFromTask would swallow an unobserved exception and hang forever instead of faulting. Now routed to StatusText.
  • Removed now-dead code-behind (OnScrapeClicked, OnCancelClicked, cts, IDisposable) from MainWindow.axaml.cs.

Test plan

  • New GivenMainWindowViewModel test class (6 tests: cancel enablement, cancellation before Playwright config, cancel resets IsBusy, successful completion, dispose cancels)
  • dotnet build clean, 0 warnings/errors
  • dotnet test on affected test project: 23/25 pass (2 pre-existing failures unrelated to this change - env-specific connection string test, flaky temp-dir cleanup race in GivenPlaywrightService)

🤖 Generated with Claude Code

Code-behind held a CancellationTokenSource but never touched the
scrape work, which lives in the ViewModel. Move ownership there:
CancelCommand (enabled only while a scrape is running) cancels the
active run at checkpoints around confirmation and Playwright setup.

Also subscribe each scrape command's ThrownExceptions - without it,
ReactiveCommand.CreateFromTask swallows an unobserved exception and
the command hangs forever instead of faulting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jbarden
jbarden requested a review from a team July 14, 2026 13:01
@astar-development-jb
astar-development-jb enabled auto-merge (squash) July 14, 2026 13:15
@astar-development-jb
astar-development-jb merged commit 6183299 into main Jul 14, 2026
4 checks passed
@astar-development-jb
astar-development-jb deleted the feature/main-window-viewmodel-cancellation branch July 14, 2026 13:15
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