Add cancellation flow for support sessions

Server changes:
- Allow cancelling connected codes (not just pending)
- Reject agent connections with cancelled codes
- Periodic cancellation check during active sessions
- Send Disconnect message when code is cancelled

Agent changes:
- Detect cancellation via Disconnect message
- Show Windows MessageBox to notify user
- Exit cleanly without reconnecting for support sessions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 15:30:43 -07:00
parent f408667a3f
commit 8246d135f9
4 changed files with 150 additions and 8 deletions

View File

@@ -176,11 +176,11 @@ impl SupportCodeManager {
}
}
/// Cancel a code
/// Cancel a code (works for both pending and connected)
pub async fn cancel_code(&self, code: &str) -> bool {
let mut codes = self.codes.write().await;
if let Some(support_code) = codes.get_mut(code) {
if support_code.status == CodeStatus::Pending {
if support_code.status == CodeStatus::Pending || support_code.status == CodeStatus::Connected {
support_code.status = CodeStatus::Cancelled;
return true;
}
@@ -188,6 +188,18 @@ impl SupportCodeManager {
false
}
/// Check if a code is cancelled
pub async fn is_cancelled(&self, code: &str) -> bool {
let codes = self.codes.read().await;
codes.get(code).map(|c| c.status == CodeStatus::Cancelled).unwrap_or(false)
}
/// Check if a code is valid for connection (exists and is pending)
pub async fn is_valid_for_connection(&self, code: &str) -> bool {
let codes = self.codes.read().await;
codes.get(code).map(|c| c.status == CodeStatus::Pending).unwrap_or(false)
}
/// List all codes (for dashboard)
pub async fn list_codes(&self) -> Vec<SupportCode> {
let codes = self.codes.read().await;