From 038729540132f3f0e70eef2c9209d6f750398981 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Tue, 30 Dec 2025 10:10:10 -0700 Subject: [PATCH] Fix viewer-only installs registering as agents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, any installation with the protocol handler registered would default to running as an agent. This caused admin/technician machines (viewer-only) to appear in the sessions list. Changes: - Add Config::has_agent_config() to check for explicit agent config - Only run as agent when: explicit 'agent' command, support code provided, OR agent config file exists - Viewer-only installs (protocol handler but no config) now exit silently when launched without arguments 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- agent/src/config.rs | 25 +++++++++++++++++++++++++ agent/src/main.rs | 17 +++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/agent/src/config.rs b/agent/src/config.rs index 375a562..2f75ca8 100644 --- a/agent/src/config.rs +++ b/agent/src/config.rs @@ -105,6 +105,31 @@ impl Default for EncodingConfig { } impl Config { + /// Check if an explicit agent configuration file exists + /// This returns true only if there's a real config file, not generated defaults + pub fn has_agent_config() -> bool { + // Check for config in current directory + let local_config = PathBuf::from("guruconnect.toml"); + if local_config.exists() { + return true; + } + + // Check in program data directory (Windows) + #[cfg(windows)] + { + if let Ok(program_data) = std::env::var("ProgramData") { + let path = PathBuf::from(program_data) + .join("GuruConnect") + .join("agent.toml"); + if path.exists() { + return true; + } + } + } + + false + } + /// Load configuration from file or environment pub fn load() -> Result { // Try loading from config file diff --git a/agent/src/main.rs b/agent/src/main.rs index 7355c1b..7869e8b 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -221,14 +221,23 @@ fn main() -> Result<()> { if let Some(code) = cli.support_code { run_agent_mode(Some(code)) } else { - // No args: check if protocol handler is installed - // If not, run install mode (user likely downloaded from web) + // No args: check what mode to run if !install::is_protocol_handler_registered() { + // Protocol handler not registered - user likely downloaded from web + // Run installer to set up protocol handler info!("Protocol handler not registered, running installer"); run_install(false) - } else { - // Protocol handler exists, run as agent + } else if config::Config::has_agent_config() { + // Protocol handler exists AND agent config exists + // This is an agent installation - run as agent + info!("Agent config found, running as agent"); run_agent_mode(None) + } else { + // Protocol handler exists but NO agent config + // This is a viewer-only installation - just exit silently + // The protocol handler will launch the viewer when needed + info!("Viewer-only installation, exiting (use 'guruconnect agent' to run as agent)"); + Ok(()) } } }