Skip to content

Fix: stop the admin UI announcing saves that failed - #38

Merged
SandObserver merged 3 commits into
mainfrom
fix/report-save-failures
Aug 12, 2026
Merged

SandObserver merged 3 commits into
mainfrom
fix/report-save-failures

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Add snapshotItems and saveWithRevert to admin-save-logic.js, and a saveOrRevert wrapper in admin.js that restores the item list and re-renders when a write does not reach the server.
  • Take a snapshot before every optimistic list mutation: delete, move up/down, both drag-drop paths, the Settings hide toggle, and the four folder-picker membership changes.
  • Gate the "Updated"/"Added" toast and closeModal in doSave on the save result, so a failed write leaves the editor open with the form intact instead of reporting success over its own error toast.
  • Gate the "Imported" toast in the JSON import path on the save result, and revert the replaced item list when the write fails.
  • Keep the edit view open on a failed delete, rather than returning to a list that shows the item as gone.
  • Wrap saveLabels in a catch that restores the toggled checkbox and reports the error, instead of leaving an unhandled rejection and a switch the server never agreed to.

Testing
All green. Added 6 tests covering snapshotItems cloning and saveWithRevert on success, reported failure, a throw, and a void return.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.
  • CHANGELOG.md updated under Unreleased if the change is user-visible.

Turning certificate verification off is now decided in one place and only
ever applies to a host on the local network. The server-wide setting was
already scoped that way; the per-app switch and the per-request flag were
handed straight to the transport, and those are the paths that carry a
stored credential.

Session tokens now expire after 12 hours idle rather than 30 days, and a
session still in use is reissued once it is past halfway, so the shorter
window bounds an unused token without signing anyone out mid-task.
The seeding helper posts through an API request context, which is not a
page and so states no origin. Writes now require one, which refused every
seed. The address comes from the same definition the Playwright config
resolves relative paths against, so the two cannot drift apart.
save() already reported whether the write reached the server, but no caller
read the result. A failed write toasted "Save failed" and was immediately
overwritten by "Updated", "Added" or "Imported" in the same shared toast
element, and the item editor closed on top of it.

The list edits had the same gap from the other side: delete, reorder,
drag-drop, the Settings hide toggle and every folder-membership change mutate
the in-memory list and save after, with no path back if the save failed. The
admin list then showed a dashboard the server did not have until a reload.

Add snapshotItems and saveWithRevert to the save logic, take a snapshot before
each mutation, and put the list back when the write does not land. The item
editor now stays open on failure so the filled-in form is not discarded.

The label-visibility toggles were wired straight to change with no catch, so a
failure was an unhandled rejection with no message and the switch left in its
new position.
@SandObserver SandObserver added the bug Something isn't working label Aug 12, 2026
@SandObserver
SandObserver merged commit 42dbbb2 into main Aug 12, 2026
4 checks passed
@SandObserver
SandObserver deleted the fix/report-save-failures branch August 12, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant