using System.ComponentModel; using System.Diagnostics; using CursorLang.Core.Services; namespace CursorLang.Agent.Services; /// /// Starts the settings window. /// /// /// The agent does not keep track of whether the window is already open, and does not /// need to: the settings process guards a single-instance slot of its own, so a second /// launch raises the window already there and exits. That costs a process start to find /// out, which is a fraction of the time it takes a person to look at the tray, and it /// saves the agent from holding a handle to something it does not own. /// internal static class SettingsLauncher { /// /// Opens the settings window. Returns false when the executable is not /// where it should be — a half-copied installation, or the agent run from a build /// folder of its own. /// internal static bool Open() { if (AgentExecutable.SettingsPath is not { } path) { return false; } try { using Process? started = Process.Start(new ProcessStartInfo(path) { UseShellExecute = false }); return started is not null; } catch (Exception e) when (e is Win32Exception or InvalidOperationException) { // Nothing to tell the user with: the agent has no window of its own, and // the one that would have shown the message is the one that failed to start return false; } } }