Roll back in-memory mutations when saving fails #12

Closed
opened 2026-09-03 10:18:50 +00:00 by phg · 0 comments
Owner

Context

Several TUI workflows mutate the in-memory Hosts File before calling HostsManager.save_hosts_file. When the save fails, add, delete, move, toggle, edit, or DNS workflows can leave the display changed while /etc/hosts remains unchanged. A later successful save can then persist state the user was told had failed.

Issue #7 separately covers making undo and redo persist immediately. This issue establishes the failure invariant for all mutations: failed persistence restores the pre-action model and UI state.

Acceptance criteria

  • Every mutating workflow reports success only after its resulting Hosts File is saved successfully.
  • A save failure restores the complete pre-action in-memory state, visible selection, and relevant undo/redo history.
  • Entry Editor and DNS refresh failures restore fields and metadata as well as the IP mapping.
  • Retrying or performing a later mutation cannot accidentally persist a previously failed change.
  • Tests cover each mutation family with mocked save failures and never access real sudo, DNS, or /etc/hosts.
  • The save-failure warning is removed from user documentation once fixed.
Context Several TUI workflows mutate the in-memory Hosts File before calling `HostsManager.save_hosts_file`. When the save fails, add, delete, move, toggle, edit, or DNS workflows can leave the display changed while `/etc/hosts` remains unchanged. A later successful save can then persist state the user was told had failed. Issue #7 separately covers making undo and redo persist immediately. This issue establishes the failure invariant for all mutations: failed persistence restores the pre-action model and UI state. Acceptance criteria - Every mutating workflow reports success only after its resulting Hosts File is saved successfully. - A save failure restores the complete pre-action in-memory state, visible selection, and relevant undo/redo history. - Entry Editor and DNS refresh failures restore fields and metadata as well as the IP mapping. - Retrying or performing a later mutation cannot accidentally persist a previously failed change. - Tests cover each mutation family with mocked save failures and never access real sudo, DNS, or `/etc/hosts`. - The save-failure warning is removed from user documentation once fixed.
phg added the
Priority
High
Kind/Bug
labels 2026-09-03 10:18:50 +00:00
phg closed this issue 2026-09-04 07:40:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: phg/hosts#12
No description provided.