# 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 `_`), `revert`, `snapdelete`, `ssh`. virsh's stderr becomes the error. - `ssh`: the first `$XDG_RUNTIME_DIR/kitty-` socket that answers gets `kitty @ launch --type=tab ssh ` and its window is focused through hyprctl (`pid:`, Lua or classic as `windows`); with no kitty, `kitty ssh ` 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 (``) 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.