Snapshots in the info screen: take, roll back, delete #21

Merged
Duckboot merged 1 commits from feat/snapshots-8 into main 2026-11-02 23:28:19 +01:00
Owner

What

A "Snapshots" section on the info screen lists the snapshots, newest first. Proxmox's "current" pseudo entry is left out.

  • p takes a snapshot. The name defaults to tui_YYYYMMDD_HHMM, the description is optional, and VMs can include RAM.
  • R rolls back to the snapshot under the cursor, after a confirm that names the snapshot and its date. If the guest is running, it is started again. The status is read right before the rollback; if it cannot be read, the rollback does not run.
  • D deletes the snapshot under the cursor, after a confirm.

This PR is stacked on #9's branch (feat/not-backed-up-9). Merge that one first.

Safety

delete ct|vm <node> <vmid> -y without the snapshot subcommand destroys the whole guest. To make sure the app can never send that:

  • delete_snapshot validates the name first: a letter, then [A-Za-z0-9_-], at most 40 characters, and not current.
  • It writes snapshot into the argv as a literal.
  • It checks the argv shape before running, with an explicit raise rather than an assert.
  • A property test checks that rejected names never reach the CLI.

An adversarial review found no path to the guest-destroying form, and no way to act on a snapshot other than the one confirmed.

Review fixes

  • Rollback start: the start flag uses the status read at rollback time, not when the screen loaded.
  • Scrolling: the info screen now scrolls, because four sections do not fit short terminals.
  • Description: one starting with - is refused. It is passed as a positional argument and could be read as an option.

Verification

  • 374 tests pass (cv4pve-cli is mocked).
  • ruff check and ruff format --check report no issues.
  • betterleaks found no secrets.
  • Live test on CT 104: tui_live_test was taken, rolled back (the CT was started again) and deleted. The snapshot list, status, config and IPv4/IPv6 addresses match the baseline.
  • Not handled: the 330 s CLI timeout. A very slow VM snapshot with RAM could be reported as failed while it is still running. This has not been observed.

Closes #8

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

## What A "Snapshots" section on the info screen lists the snapshots, newest first. Proxmox's "current" pseudo entry is left out. - `p` takes a snapshot. The name defaults to `tui_YYYYMMDD_HHMM`, the description is optional, and VMs can include RAM. - `R` rolls back to the snapshot under the cursor, after a confirm that names the snapshot and its date. If the guest is running, it is started again. The status is read right before the rollback; if it cannot be read, the rollback does not run. - `D` deletes the snapshot under the cursor, after a confirm. This PR is stacked on #9's branch (`feat/not-backed-up-9`). Merge that one first. ## Safety `delete ct|vm <node> <vmid> -y` without the `snapshot` subcommand destroys the whole guest. To make sure the app can never send that: - `delete_snapshot` validates the name first: a letter, then `[A-Za-z0-9_-]`, at most 40 characters, and not `current`. - It writes `snapshot` into the argv as a literal. - It checks the argv shape before running, with an explicit raise rather than an `assert`. - A property test checks that rejected names never reach the CLI. An adversarial review found no path to the guest-destroying form, and no way to act on a snapshot other than the one confirmed. ## Review fixes - **Rollback start:** the start flag uses the status read at rollback time, not when the screen loaded. - **Scrolling:** the info screen now scrolls, because four sections do not fit short terminals. - **Description:** one starting with `-` is refused. It is passed as a positional argument and could be read as an option. ## Verification - 374 tests pass (`cv4pve-cli` is mocked). - `ruff check` and `ruff format --check` report no issues. - `betterleaks` found no secrets. - Live test on CT 104: `tui_live_test` was taken, rolled back (the CT was started again) and deleted. The snapshot list, status, config and IPv4/IPv6 addresses match the baseline. - Not handled: the 330 s CLI timeout. A very slow VM snapshot with RAM could be reported as failed while it is still running. This has not been observed. Closes #8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot added 2 commits 2026-11-02 23:27:57 +01:00
The guest table marks with "!" each guest that Proxmox's not-backed-up
list returns. The frame's bottom border shows the count, e.g.
"mainframe · 2 without backup job". This uses Proxmox's own answer, so
it also counts jobs that select guests by pool.

If the coverage call fails, the guests are still listed and a warning
says the coverage is unknown.

Closes #9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "Snapshots" section on the info screen lists the snapshots, newest
first, without Proxmox's "current" pseudo entry. Keys:

- p takes a snapshot. The name defaults to tui_YYYYMMDD_HHMM, the
  description is optional, and VMs can include RAM.
- R rolls back to the snapshot under the cursor. The confirm names the
  snapshot and its date. A running guest is started again; its status
  is read right before the rollback, and if it cannot be read the
  rollback does not run.
- D deletes the snapshot under the cursor, after a confirm.

`delete ct|vm <node> <vmid> -y` without the snapshot subcommand
destroys the whole guest. delete_snapshot therefore validates the name
first (letter first, then [A-Za-z0-9_-], not "current"), writes
"snapshot" into the argv as a literal, and checks the argv shape
before running it. A property test covers rejected names.

The info screen now scrolls, because four sections do not fit short
terminals. A description starting with "-" is refused, since it is a
positional argument and could be read as an option.

Live test on CT 104: take, roll back (started again) and delete. The
snapshot list, status, config and IPv4/IPv6 match the baseline.

Closes #8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot merged commit ec35a4c996 into main 2026-11-02 23:28:19 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Duckboot/cv4pve-cli-tui#21