daemon¶
Package daemon implements the cosmonaut menu bar applet which hosts a system tray icon, global hotkey listener, and codespace lifecycle management.
Cosmonaut unified window: native Fyne implementation of the redesign.
Layout:
┌────────────┬──────────────────────────────────────┐
│ Sidebar │ Detail panel │
│ (logo, │ (codespace detail / create / repo) │
│ search, │ │
│ tree, │ │
│ account) │ │
└────────────┴──────────────────────────────────────┘
The bulk of structure mirrors the existing gui_window.go; this file rewrites the visual wrapping (title bar, search chrome, captions, action buttons) to match the design system.
Package daemon: Cosmonaut custom Fyne theme.
Palette and type scale derived from the Cosmonaut design system (Zed-inspired dark: graphite surfaces, lime accent, mono labels).
Cosmonaut native UI primitives.
Small building blocks reused across the unified window, codespace detail, create flow, and settings: keeps widget wiring consistent.
Index¶
- type Daemon
- func New(cfg *config.Config, configPath string) *Daemon
- func (d *Daemon) Codespaces() []codespace.Codespace
- func (d *Daemon) DismissCheck(id string)
- func (d *Daemon) IsDismissed(id string) bool
- func (d *Daemon) ListErr() error
- func (d *Daemon) Run() error
- func (d *Daemon) SetCodespaces(cs []codespace.Codespace)
- func (d *Daemon) SetListErr(err error)
- func (d *Daemon) Stop()
- func (d *Daemon) UndismissCheck(id string)
- type Inhibitor
- type SessionTracker
- func (s *SessionTracker) SetMode(mode string)
- func (s *SessionTracker) Stop()
- func (s *SessionTracker) TrackSession(alias string)
type Daemon¶
Daemon is the long-running background process that hosts the system tray, hotkey listener, and codespace poller.
type Daemon struct {
Cfg *config.Config
ConfigPath string
Runner codespace.GHRunner
// contains filtered or unexported fields
}
func New¶
New creates a new Daemon with the given config.
func (*Daemon) Codespaces¶
Codespaces returns the last-polled codespace list.
func (*Daemon) DismissCheck¶
DismissCheck marks a doctor check ID as dismissed for the current session. Banners hide it; the Settings page health section still shows it so the user can come back to it.
func (*Daemon) IsDismissed¶
IsDismissed reports whether the given check ID has been dismissed.
func (*Daemon) ListErr¶
ListErr returns the error from the most recent codespace list attempt, or nil on success.
func (*Daemon) Run¶
Run starts all applet components. It blocks until Stop is called. This must be called from the main OS thread.
func (*Daemon) SetCodespaces¶
SetCodespaces updates the cached codespace list.
func (*Daemon) SetListErr¶
SetListErr stores the error from the most recent codespace list attempt.
func (*Daemon) Stop¶
Stop signals the applet to shut down.
func (*Daemon) UndismissCheck¶
UndismissCheck clears a previous dismissal so the banner can show again.
type Inhibitor¶
Inhibitor prevents the system from sleeping (and optionally shutting down) while at least one codespace session is active. Implementations are platform-specific; see inhibit_darwin.go and inhibit_linux.go.
type Inhibitor interface {
// Engage asks the OS to hold a sleep inhibit assertion. Mode is one of
// "sleep" or "sleep+shutdown". Safe to call when already engaged (no-op).
Engage(mode string) error
// Release drops any held assertion. Safe to call when not engaged.
Release() error
}
type SessionTracker¶
SessionTracker ref-counts live codespace SSH sessions across the whole daemon. When the count transitions from 0→1 it engages the inhibitor; when it drops back to 0 it releases.
Each call to TrackSession launches a background scan for ssh processes matching the given alias and watches their exit via kernel events (pidfd on Linux, kqueue on macOS). Reconnections after the initial scan window are not tracked: the next Cosmonaut launch re-scans.
func (*SessionTracker) SetMode¶
SetMode hot-swaps the inhibit mode. If sessions are currently tracked, the inhibitor is re-engaged with the new mode.
func (*SessionTracker) Stop¶
Stop releases any held inhibitor; watcher goroutines keep running but their decrement calls become no-ops.
func (*SessionTracker) TrackSession¶
TrackSession scans for SSH processes whose command line contains the given alias, registers each and watches them for exit. Safe to call when mode is "off": it still runs but the inhibitor is a no-op.
The scan retries for a short window because the launch chain (osascript → Terminal.app, or terminal emulator fork) means the ssh pid may not exist the instant LaunchRemote returns.
Generated by gomarkdoc