Files
Interlap 6af86fb728 feat: add simslim top — live fleet monitor with per-daemon drill-down
A top(1) for the simulator fleet: every booted simulator with its OS,
slim state, process count, CPU, RAM, and disk, refreshing live. Enter a
row (or pass a UDID) to drill into that simulator's per-daemon footprint.
Columns sort via n/o/s/p/c/m/d with a version-aware OS comparator; the
name column flexes to the terminal width. --json and piped output emit
one-shot snapshots, keeping the JSON contract for the GUI.

Library side stays dependency-free: MeasureProcesses keeps per-process
footprint+cpu from the shared ps/top snapshot, and FleetSnapshot
composes booted devices, slim status (fanned out per device), and
MeasureMany. The TUI (bubbletea + lipgloss, CLI-only deps) anchors the
cursor by UDID across live re-sorts, keeps the last snapshot on
transient refresh errors, and guards disk sweeps against overlap.

Also adds `simslim list --booted` to filter the listing to booted
simulators.
2026-07-24 11:52:03 +02:00

84 lines
2.9 KiB
Go

package simslim
// DeviceSummary is the stable, machine-readable representation used by the
// macOS app and other integrations. managedDisabled is omitted for shutdown
// simulators because launchd state can only be read while a simulator is booted.
type DeviceSummary struct {
Device
ManagedDisabled *int `json:"managedDisabled,omitempty"`
ManagedTotal int `json:"managedTotal"`
StatusError string `json:"statusError,omitempty"`
Memory *Measurement `json:"memory,omitempty"`
MemoryError string `json:"memoryError,omitempty"`
}
type StatusOutput struct {
Status
Verdict string `json:"verdict"`
Dropped []DroppedCategory `json:"dropped,omitempty"` // only when `status --dropped` is requested
}
// DroppedCategory lists the managed daemons a category has disabled on a
// simulator, alongside the feature that stops working as a result.
type DroppedCategory struct {
ID string `json:"id"`
Name string `json:"name"`
Downside string `json:"downside"`
Labels []string `json:"labels"`
}
// SimulatorMutationOutput is returned by simulator-management commands so the
// GUI can refresh and, for clone, select the newly created device.
type SimulatorMutationOutput struct {
Action string `json:"action"`
UDID string `json:"udid"`
Name string `json:"name,omitempty"`
SourceUDID string `json:"sourceUdid,omitempty"`
}
// DoctorOutput reports whether each required feature survives the device's
// current slimming. OK is false when any required feature has a disabled daemon.
type DoctorOutput struct {
UDID string `json:"udid,omitempty"`
OK bool `json:"ok"`
Features []FeatureStatus `json:"features"`
}
// FeatureStatus is one feature's verdict: the daemons it needs that are down.
type FeatureStatus struct {
ID string `json:"id"`
Name string `json:"name"`
OK bool `json:"ok"`
Disabled []string `json:"disabled,omitempty"`
}
type DiskMeasurement struct {
Bytes int64 `json:"bytes"`
}
// TopSim is one booted simulator's live resource snapshot for `simslim top`.
type TopSim struct {
Device
ManagedDisabled *int `json:"managedDisabled,omitempty"`
ManagedTotal int `json:"managedTotal"`
StatusError string `json:"statusError,omitempty"`
Memory *Measurement `json:"memory,omitempty"`
MemoryError string `json:"memoryError,omitempty"`
DiskBytes *int64 `json:"diskBytes,omitempty"`
}
// TopOutput is the fleet view: every booted simulator plus the summed footprint
// that decides how many more fit.
type TopOutput struct {
Sims []TopSim `json:"sims"`
TotalBytes int64 `json:"totalBytes"`
}
// TopProcesses is one simulator's per-daemon breakdown, the top drill-down.
type TopProcesses struct {
UDID string `json:"udid"`
Name string `json:"name,omitempty"`
Processes []Process `json:"processes"`
TotalBytes int64 `json:"totalBytes"`
}