Skip to content

feat(selfupdate): list + delete snapshots from the update modal - #151

Merged
frahlg merged 1 commit into
masterfrom
150-snapshot-list-delete-ui
Apr 20, 2026
Merged

frahlg merged 1 commit into
masterfrom
150-snapshot-list-delete-ui

Conversation

@frahlg

@frahlg frahlg commented Apr 20, 2026

Copy link
Copy Markdown
Member

Erik @Xorath (field tester) asked for snapshot management in the UI:
"en rollback funktion som listar alla snapshots, så man inte måste
ssh'a in, och möjlighet att radera gamla snapshots från samma lista"
.

This PR delivers the list + delete half. Rollback-to-snapshot comes next
in a focused follow-up (design sketch in #140 Phase 2 comment).

Summary

  • `DELETE /api/version/snapshots/{id}` — validates the id (no traversal, no dot-segments), checks the target exists inside SnapshotDir, `os.RemoveAll`.
  • Update modal grows a collapsible "Backup snapshots (N)" table below the 🛟 hint. Columns: created-at, from→to version, size in MB, Delete button.
  • Empty state + "deleting…" placeholder for rapid double-clicks.
  • Auto-refreshes on modal open and after each delete.

Test plan

  • Unit tests: `TestVersionSnapshots_DeleteByID` (happy path) + `TestVersionSnapshots_DeleteRejectsInvalidID` (traversal/missing).
  • `make test` + `make e2e` green.
  • Smoke on Pi: open modal → expand Backup snapshots → see existing entries → Delete one → list shrinks without page reload.

Follow-up

PR with rollback-to-snapshot comes next. Design in #140 Phase 2 comment.

🤖 Generated with Claude Code

Follow-up to #141, driven by a field-tester request: *"en rollback funktion
som listar alla snapshots, så man inte måste ssh'a in, och möjlighet att
radera gamla snapshots från samma lista"* — Erik @Xorath, 2026-04-20.

This PR covers the first half (list + delete). Rollback-to-snapshot is
tracked as a separate PR so the review stays focused per logical change.

Backend
- New endpoint DELETE /api/version/snapshots/{id}. Validates the ID is
  a simple directory name (no traversal, no dot-segments), checks the
  target exists + is inside SnapshotDir, then os.RemoveAll.
- GET /api/version/snapshots already returned the list — UI just wasn't
  showing it.

Frontend
- Update modal grows a collapsible "Backup snapshots (N)" section
  below the 🛟 hint. Shows created-at, from→to version, size in MB,
  and a Delete button per row.
- Empty state tells the operator where snapshots come from.
- Delete uses window.confirm + an optimistic "deleting…" placeholder
  so rapid double-clicks can't fire duplicates.
- Refreshes on modal open and after every delete.

Tests
- TestVersionSnapshots_DeleteByID — happy path, dir gone after DELETE.
- TestVersionSnapshots_DeleteRejectsInvalidID — missing id returns 404;
  traversal attempts are rejected by Go's ServeMux before reaching the
  handler (accept any non-200 outcome as sufficient).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@frahlg
frahlg merged commit d1ac37f into master Apr 20, 2026
1 check passed
@frahlg
frahlg deleted the 150-snapshot-list-delete-ui branch April 20, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant