Skip to content

feat: Add scan cancellation (Stop button) and rebuild release - #23

Open
iam-saiteja wants to merge 1 commit into
Prithvi-Web:mainfrom
iam-saiteja:main
Open

feat: Add scan cancellation (Stop button) and rebuild release#23
iam-saiteja wants to merge 1 commit into
Prithvi-Web:mainfrom
iam-saiteja:main

Conversation

@iam-saiteja

@iam-saiteja iam-saiteja commented Aug 14, 2026

Copy link
Copy Markdown

When running a disk scan on large folders or whole drives, users had no quick way to interrupt or stop an in-progress scan from the UI without refreshing the app or closing the process.

This PR adds full scan cancellation support end-to-end introducing a backend cancellation API and dynamically transforming the Scan button into a Stop button while a scan is active.


What is the change?

  1. Frontend UI Transformation (public/index.html):

    • While a scan is active, the primary Scan button dynamically switches to a red Stop button (.btn-danger) with a stop icon.
    • Clicking Stop immediately triggers the cancellation API, closes the active EventSource (SSE) progress stream, updates the status message to "Scan stopped by user", and restores the button back to Scan.
  2. Backend Cancellation Endpoint (src/api/scanRoutes.ts & src/services/diskScanner.ts):

    • Implemented cancelScan(scanId) service function that cleanly halts active directory queue walking or GDU scanning and sets the scan status to error with a descriptive message.
    • Added POST /api/scan/:scanId/cancel route and documented it in src/api/openapi.ts.
  3. Release Rebuild:

    • Cleared previous build artifacts and compiled fresh production packages (npm run dist:win).

Before vs After

Feature Before After
Scan Control The Scan button was disabled (disabled = true) while scanning. Users could not cancel an active scan. The Scan button turns into a red Stop button. Users can click it at any point to stop the scan cleanly.
Backend API No API route existed to stop an individual scan by scanId. POST /api/scan/:scanId/cancel stops the scan and terminates SSE progress streaming gracefully.
User Experience Had to wait for long scans to finish or refresh the browser. Immediate feedback and control stopping a scan updates the status UI to "Scan stopped by user" without breaking app state.

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