Restrict session termination to support sessions only

- Persistent agents: No "End Session" menu, shows "Managed by Administrator"
- Persistent agents: Always reconnect, can only be removed via admin disconnect
- Support sessions: User can end via tray icon
- Tray icon still shows for persistent agents (status display only)

🤖 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 17:04:08 -07:00
parent 52c47b2de1
commit d7c272dabc
2 changed files with 22 additions and 19 deletions

View File

@@ -187,7 +187,8 @@ async fn run_agent(config: config::Config) -> Result<()> {
}
// Create tray icon
let tray = match tray::TrayController::new(&hostname, config.support_code.as_deref()) {
// Only support sessions can be ended by user - persistent agents are admin-managed
let tray = match tray::TrayController::new(&hostname, config.support_code.as_deref(), is_support_session) {
Ok(t) => {
info!("Tray icon created");
Some(t)
@@ -208,11 +209,14 @@ async fn run_agent(config: config::Config) -> Result<()> {
loop {
info!("Connecting to server...");
// Check if user requested exit via tray before connecting
if let Some(ref t) = tray {
if t.exit_requested() {
info!("Exit requested by user");
return Ok(());
// Check if user requested exit via tray before connecting (support sessions only)
if is_support_session {
if let Some(ref t) = tray {
if t.exit_requested() {
info!("Exit requested by user");
cleanup_on_exit();
return Ok(());
}
}
}
@@ -290,16 +294,7 @@ async fn run_agent(config: config::Config) -> Result<()> {
return Ok(());
}
// Check if user requested exit via tray
if let Some(ref t) = tray {
if t.exit_requested() {
info!("Exit requested by user");
cleanup_on_exit();
return Ok(());
}
}
// Wait before reconnecting (only for persistent agent connections)
// Wait before reconnecting (persistent agents only - support sessions already exited above)
info!("Reconnecting in 5 seconds...");
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
}