Skip to content

Conversation

@brianjlacy
Copy link

IMPORTANT: This proposed fix for for Issue #115 was generated by Claude Code and I have not tested it. I've perused through it and it looks promising, but I cannot guarantee anything about its suitability; as an engineer, I have limited experience developing VS Code extensions and my only experience with Claude Code is as a user of the tool.

My intent here is simply to offer a slight boost in the direction of a solution. @andrepimenta could certainly have done this himself, but I figured I'd throw it out there in case it's useful, as the Stop button issue is the top frustration I personally have with this otherwise excellent extension. 😁 Thanks.


Following is generated by Claude Code:

This commit addresses the issue where the Stop button did not fully stop Claude Code operations in all cases. The implementation now ensures that clicking Stop immediately ceases ALL operations.

Key improvements:

  1. AbortController Integration

    • Added AbortController to manage cancellable async operations
    • Created on each message send and aborted on stop request
    • Prevents lingering async operations after stop
  2. Pending Permission Cleanup

    • All pending permission promises are now rejected with 'false' on stop
    • Clears the _pendingPermissionResolvers Map to prevent memory leaks
    • Ensures permission dialogs don't block the UI after stop
  3. Event Listener Management

    • Track all process event listeners (stdout, stderr, close, error)
    • Properly remove all listeners before process termination
    • Prevents stale data processing after stop request
  4. Auto-save Cancellation

    • Added _saveConversationAborted flag to prevent auto-saves during stop
    • Conversation saves are skipped when stop is in progress
    • Prevents file I/O operations after user stops operation
  5. Enhanced Process Termination

    • Graceful SIGTERM followed by SIGKILL after 2 seconds
    • Termination validation after 3 seconds with logging
    • Process reference cleared immediately to prevent further use
    • Comprehensive logging for debugging termination issues
  6. New Session Cleanup

    • _newSession() now uses same comprehensive cleanup approach
    • Ensures clean state when starting fresh sessions

The Stop button now:

  • Aborts all pending async operations
  • Rejects all pending permission requests
  • Removes all process event listeners
  • Stops auto-save operations
  • Terminates the Claude process gracefully then forcefully
  • Validates process termination
  • Updates UI immediately with clear feedback

This ensures users have full control over Claude Code execution and can stop operations at any time without lingering background tasks.

This commit addresses the issue where the Stop button did not fully stop
Claude Code operations in all cases. The implementation now ensures that
clicking Stop immediately ceases ALL operations.

Key improvements:

1. AbortController Integration
   - Added AbortController to manage cancellable async operations
   - Created on each message send and aborted on stop request
   - Prevents lingering async operations after stop

2. Pending Permission Cleanup
   - All pending permission promises are now rejected with 'false' on stop
   - Clears the _pendingPermissionResolvers Map to prevent memory leaks
   - Ensures permission dialogs don't block the UI after stop

3. Event Listener Management
   - Track all process event listeners (stdout, stderr, close, error)
   - Properly remove all listeners before process termination
   - Prevents stale data processing after stop request

4. Auto-save Cancellation
   - Added _saveConversationAborted flag to prevent auto-saves during stop
   - Conversation saves are skipped when stop is in progress
   - Prevents file I/O operations after user stops operation

5. Enhanced Process Termination
   - Graceful SIGTERM followed by SIGKILL after 2 seconds
   - Termination validation after 3 seconds with logging
   - Process reference cleared immediately to prevent further use
   - Comprehensive logging for debugging termination issues

6. New Session Cleanup
   - _newSession() now uses same comprehensive cleanup approach
   - Ensures clean state when starting fresh sessions

The Stop button now:
- Aborts all pending async operations
- Rejects all pending permission requests
- Removes all process event listeners
- Stops auto-save operations
- Terminates the Claude process gracefully then forcefully
- Validates process termination
- Updates UI immediately with clear feedback

This ensures users have full control over Claude Code execution and can
stop operations at any time without lingering background tasks.
@dancherb
Copy link

I've also been horrified by the extension running destructively wild on my codebase, even after being "stopped". It also seems like it doesn't ask for permissions to perform terminal commands - I don't have any permissions allowed for it (so it should ask in all cases) but it still destroys and edits files without permission.

@brianjlacy
Copy link
Author

@dancherb Well, that's not ideal. I haven't run into that particular problem myself, but I'd definitely open another ticket for that if there isn't one already..

@dancherb
Copy link

dancherb commented Nov 26, 2025

@brianjlacy Honestly I already made a couple tickets for breaking issues that were never responded to (here's the most recent one) so I just uninstalled the extension 🥲

@akrpersonified
Copy link

I don't see any stop button while it is running. Can anyone help me ?

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.

4 participants