Daemon Controls

Code Desktop includes a dedicated daemon panel for managing the Opta daemon lifecycle, viewing real-time logs, and monitoring connection health -- all from the graphical interface.

Daemon Panel

The daemon panel is a dedicated section of the Code Desktop interface that surfaces daemon status and control actions. It shows:

  • Current state -- whether the daemon is running, stopped, or starting
  • PID -- the process ID of the running daemon
  • Uptime -- how long the daemon has been running since last start
  • Port -- the port the daemon is listening on (default 9999)
  • Session count -- number of active sessions

Lifecycle Controls

The daemon panel provides three primary lifecycle actions:

  • Start -- launches the daemon if it is not running. The panel polls the daemon health endpoint until it responds, then transitions to the connected state.
  • Stop -- sends a graceful shutdown signal to the daemon. Active sessions are preserved on disk before the process exits.
  • Restart -- performs a stop followed by a start. The WebSocket connection automatically reconnects after the daemon comes back online.
Token rotation
When the daemon restarts, it generates a new authentication token. Code Desktop detects this and updates the stored token in localStorage automatically. If you see authentication errors after a restart, try refreshing the page.

Log Viewer

The log viewer provides a real-time tail of daemon log output. Logs are streamed from the daemon's log file and displayed in a scrollable terminal-style panel with:

  • Timestamp -- when each log entry was written
  • Level -- color-coded severity (debug, info, warn, error)
  • Component -- which daemon subsystem generated the log (e.g., session, tools, lmx)
  • Message -- the log content

The log viewer auto-scrolls to the latest entry by default. Scrolling up pauses auto-scroll so you can inspect older entries; scrolling back to the bottom resumes auto-scroll.

Log entries can be filtered by severity level. Setting the filter to "error" shows only errors and warnings, which is useful for diagnosing issues without wading through verbose debug output.

Connection Status

The connection status indicator is always visible in the Code Desktop header. It shows one of three states:

StateIndicatorMeaning
ConnectedGreen dotWebSocket active, daemon responding to health checks
ReconnectingAmber pulseWebSocket disconnected, attempting reconnection with backoff
DisconnectedRed dotDaemon unreachable, multiple reconnection attempts failed

Auto-Discovery

Code Desktop automatically discovers the daemon running on localhost. On startup, it checks the default daemon address (127.0.0.1:9999) and establishes a connection if the daemon is running. If the daemon is not running, it displays the disconnected state with a "Start Daemon" button.

The daemon configuration path is XDG-aware, matching the CLI's behavior. On macOS, the daemon state file is read from ~/.config/opta/daemon/state.json, which contains the authentication token and port number.

Background daemon
For the best experience, install the daemon as a system service using opta daemon install. This ensures the daemon starts automatically at login and is always available for Code Desktop to connect to.