Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 29, 2025

This PR implements a cancel button feature that allows users to cancel running scan jobs, addressing the need for better user control during scanning operations.

Changes Made

UI Enhancements

  • Dynamic button replacement: The scan button now transforms into a red cancel button when a scan job is running
  • Visual state feedback: During cancellation, the button shows "Cancelling..." text and becomes grayed out/disabled
  • Intuitive UX: Uses Material Design error colors (red) to clearly indicate the destructive nature of the cancel action

State Management

  • Added scanJobCancelling state to track cancellation process
  • Added currentScanJob reference to enable proper job cancellation
  • Implemented cancelCurrentScanJob() method in ScanningScreenViewModel with thread-safe cancellation logic

Technical Implementation

  • Thread safety: Cancellation runs in background thread to avoid blocking UI
  • Race condition prevention: Prevents multiple concurrent cancellation attempts
  • Resource cleanup: Ensures proper state reset and job reference cleanup in all scenarios (success, error, cancellation)
  • Exception handling: Graceful error handling if cancellation fails

Internationalization

  • Added cancel button strings in both English and German:
    • cancel_scan / Abbrechen
    • cancelling_scan / Bricht ab…

User Experience Flow

[Scan Button] → Start scan → [Cancel Button (Red)] → Click cancel → [Cancelling... (Gray)] → [Scan Button]
  1. Normal state: Blue "Scan" button with scan icon
  2. Scanning state: Red "Cancel" button with X icon - immediately cancellable
  3. Cancelling state: Grayed out "Cancelling..." button - disabled to prevent double-clicks
  4. Return to normal: Blue "Scan" button ready for next operation

Technical Details

The implementation leverages the existing job.scanJob.cancle() method and ensures all scan completion paths properly clean up the job reference. The UI automatically reflects the current state through reactive state management, providing immediate visual feedback to users.

This change significantly improves the user experience by giving users control over long-running scan operations without requiring app termination.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Chrisimx <54219305+Chrisimx@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] When a scanning job is running you should be able to cancle it using a red cancle button. This button should replace the "scan" button while the scan job is running. While waiting for the job to be cancled it should be grayed out with the text "Cancell... Add cancel button functionality for scanning jobs Aug 29, 2025
@Copilot Copilot AI requested a review from Chrisimx August 29, 2025 15:50
Copilot finished work on behalf of Chrisimx August 29, 2025 15:50
@Chrisimx Chrisimx closed this Aug 29, 2025
@Chrisimx Chrisimx reopened this Aug 29, 2025
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