aboutsummaryrefslogtreecommitdiffstats
path: root/docs/superpowers/specs/2026-11-13-vm-tab-design.md
blob: 4a90f05fdfb4d6d8c3eed3e8a298268ac2fd4b19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# VM tab design

A tab that manages the libvirt VMs on `qemu:///system`: power, state,
snapshots, and an ssh session in kitty. Mirrors keystone's drawer VM page
(quickshell `desktop/modules/vm/Virsh.qml`) so the tab can supersede it.

## Server: `deckit/modules/vm.py`

- `state()` runs `virsh domstats --state --cpu-total --balloon --vcpu` (one
  call for every VM, default URI) and returns `{vms: [{name, state, vcpus,
  cpu, mem, ip, saved, snapshots}]}`. CPU% is the delta of `cpu.time`
  between two polls over wall time and vCPUs. Memory is `balloon.current`.
- A background thread (like `stats`' updates) refreshes the slow parts at
  most every 10s: `dominfo` (managed save), `snapshot-list --name`, and the
  guest agent IP (`domifaddr --source agent`, running VMs only). A missing
  agent gives no IP, never an error. Any action triggers a refresh.
- `virsh` failing gives `{offline: true, reason}`, drawn by `offline.js`.
- Actions take `{vm, snap?}`; `vm` must be in the last listed names and
  `snap` in that VM's snapshots, else `ModuleError`:
  `start`, `shutdown` (acpi), `reboot`, `reset`, `destroy`, `suspend`,
  `resume`, `discardsave`, `snapshot` (named `<vm>_<ddMMyyyy_HHmmss>`),
  `revert`, `snapdelete`, `ssh`. virsh's stderr becomes the error.
- `ssh`: the first `$XDG_RUNTIME_DIR/kitty-<pid>` socket that answers gets
  `kitty @ launch --type=tab ssh <vm>` and its window is focused through
  hyprctl (`pid:<pid>`, Lua or classic as `windows`); with no kitty,
  `kitty ssh <vm>` is spawned. The host is the VM name, so an `~/.ssh/config`
  alias named after the VM is expected (as the drawer assumes).

## Panel: `static/modules/vm.js`, tab "VMs"

One card per VM: name, state pill, CPU and memory bars, IP, a managed-save
badge. Buttons by state as in the drawer. Destructive ones (`destroy`,
`reset`, `discardsave`, `revert`, `snapdelete`) are press-and-hold like the
K1C stop. Snapshot rows under each VM with revert and delete. An action's
error shows on the card.

## Keystone

`Modules.js` (quickshell repo): `vm` in `TABS`, `vm: "VMs"` in `NAMES`. The
`[modules] vm` switch appears by itself from `deck-it defaults`.

## Skipped

VM delete (undefine with storage), `qemu:///session`, the ssh-ready notice,
Docker, a dashboard chip. Add when wanted.

## Tests

`tests/test_vm.py`: domstats parsing, CPU delta, action validation, the ssh
command choice. `node --check static/modules/vm.js`.

## Tablet UI (second pass)

The first panel copied the drawer row for row. The tab now is a grid of
tiles: the VM's screen (`virsh screenshot`, JPEG via ffmpeg, every 5s while
the tab shows), name and status ("booting…" until sshd answers at the
`ssh -G` host and port, then "ssh ready · IP"), CPU and RAM trends drawn
with the dashboard's `line`/`area`, and a bar with a big power button (tap:
start, shut down or resume; hold: force stop), SSH and a "more" button. A
tap on the tile opens a sheet (`<dialog closedby="any">`) with every action
as an icon, and the snapshots as a timeline of chips with their age, the
current one marked; a tapped chip shows its revert and delete. RAM used is
`balloon.available - balloon.usable` when the balloon reports it.
`static/hold.js` is now the one press and hold, used by K1C too, and
vibrates the tablet when it fires.