Fix viewer-only installs registering as agents

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 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 10:10:10 -07:00
parent 4e5328fe4a
commit 0387295401
2 changed files with 38 additions and 4 deletions

View File

@@ -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<Self> {
// Try loading from config file