Skip to content

[Feature] Fix StopLogCatMonitor QuickPick cancellation and add unit tests #2760

Description

@ConnorQi01

Summary

stopLogCatMonitor hangs indefinitely when the user cancels the device-selection QuickPick. The code uses await new Promise(() => {}) as a placeholder (marked #todo!>selectionHandling>), which leaves the command permanently pending instead of exiting cleanly. No unit tests exist for this command.

Why this is useful

Users who accidentally open the Stop LogCat Monitor command and press Escape are silently blocked — the command never completes and no error is shown. Fixing this makes the command behave consistently with other command-palette flows that handle QuickPick cancellation with a clean early return.

Suggested scope

  • Replace await new Promise(() => {}) with an early return (or an explicit cancellation notice) in selectLogCatMonitor at src/extension/commands/stopLogCatMonitor.ts:39
  • Add unit tests covering:
    • No monitors running → AndroidCouldNotFindActiveLogCatMonitor error thrown
    • Exactly one monitor running → monitor deleted without showing QuickPick
    • Multiple monitors running, user selects one → selected monitor deleted
    • Multiple monitors running, user cancels QuickPick → command exits cleanly, no monitor deleted

Evidence

Validation

  • Run the new unit tests: npm test (mocha suite for stopLogCatMonitor)
  • Manually open "Stop React Native LogCat Monitor" with multiple active monitors and press Escape — command should exit without hanging

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions