Fix #7: persist undo and redo results immediately

This commit is contained in:
Philip Henning 2026-09-03 19:39:12 +02:00
parent 68a9696e7d
commit 89b37239b2
4 changed files with 149 additions and 22 deletions

View file

@ -6,7 +6,7 @@ authorization before it can change `/etc/hosts`.
> [!WARNING]
> `hosts` is alpha software. Read [Persistence and recovery](#persistence-and-recovery)
> before entering Privileged Mode. In particular, undo, redo, sorting, and save
> before entering Privileged Mode. In particular, sorting and save
> failures can currently leave the interface and `/etc/hosts` out of sync.
## Before you begin
@ -74,7 +74,7 @@ additional hostnames are Aliases.
Default Entries represent protected baseline localhost or broadcasthost
mappings. They cannot be changed, deleted, activated, deactivated, or moved.
Most successful mutations are saved to `/etc/hosts` immediately. Read the
Successful mutations are saved to `/etc/hosts` immediately. Read the
status message after every action. A message that reports a save failure means
the interface may have changed while the system file did not.
@ -99,9 +99,8 @@ stored mapping.
## Verify what is on disk
The details shown by the application normally match the last successful save,
except for the known persistence cases below. To discard in-memory state and
read `/etc/hosts` again, press `Ctrl+R`.
The details shown by the application normally match the last successful save.
To discard in-memory state and read `/etc/hosts` again, press `Ctrl+R`.
You can also inspect the file from another terminal:
@ -117,19 +116,15 @@ a management header while retaining the modeled Host Entries and comments.
### What saves immediately
Adding, editing, deleting, moving, activating, deactivating, and successfully
refreshing DNS Entries normally save immediately. `Ctrl+S` explicitly saves the
entire current in-memory Hosts File.
Adding, editing, deleting, moving, activating, deactivating, undoing, redoing,
and successfully refreshing DNS Entries save immediately. `Ctrl+S` explicitly
saves the entire current in-memory Hosts File.
### What does not save immediately
If saving an undo or redo result fails, the application restores the prior
in-memory state and undo/redo history. Reload with `Ctrl+R` to verify the
on-disk state before attempting another change.
Undo and redo currently update the in-memory state without saving it. After
`Ctrl+Z` or `Ctrl+Y`, use `Ctrl+S` if you want `/etc/hosts` to match the display.
Reloading or quitting discards that unsaved in-memory result. Leaving
Privileged Mode does not save it: the result remains displayed, but its
undo/redo history is cleared and `/etc/hosts` still differs from the display.
A save failure can also leave the interface changed while the file on disk is
Other save failures can leave the interface changed while the file on disk is
unchanged. Reload with `Ctrl+R` to return the interface to the on-disk state
before attempting another change.
@ -206,9 +201,9 @@ specific failure.
### The display differs from `/etc/hosts`
This can occur after undo, redo, a failed save, or sorting followed by other
actions. Press `Ctrl+R` to discard in-memory state and reload the file. If an
unwanted change reached disk, follow the manual restoration procedure above.
This can occur after a failed save or sorting followed by other actions. Press
`Ctrl+R` to discard in-memory state and reload the file. If an unwanted change
reached disk, follow the manual restoration procedure above.
### DNS resolution fails
@ -245,7 +240,7 @@ continually retrying it.
| `Shift+Up` / `Shift+Down` | Move the selected Host Entry |
| `r` | Refresh the selected DNS Entry |
| `Shift+R` | Refresh all DNS Entries |
| `Ctrl+Z` / `Ctrl+Y` | Undo or redo in memory |
| `Ctrl+Z` / `Ctrl+Y` | Undo or redo and save the result |
| `Ctrl+S` | Save the current in-memory state |
Within the Entry Editor, use `Tab` and `Shift+Tab` to move between fields and