Commit 31d96d8
fix(settings-ui): unify restart flow — save commits, button restarts
Every save endpoint (Tools, Server Settings, Backups) now goes through
the same restart UX: persist the change, surface a "Saved — restart
required" toast and the cross-tab restart banner, and let the user
pick the moment to actually fire the supervisor restart via the
global Restart Add-on button. No save handler auto-restarts the addon
anymore. The button auto-reloads the page 10 seconds after the click.
Why
- Adjusting a Server Setting toggle still produced a "Restart failed"
alert in addon mode. Root cause: the previous fix moved each save's
supervisor self-restart into a background task, but the user-visible
outcome was unchanged — every toggle change immediately fired a
supervisor restart, and if the user toggled multiple settings in
quick succession, a later POST would race the in-flight restart
(supervisor kills the addon → ingress returns 5xx → JS shows
"Restart failed").
- Saving auto-backup settings on the Backups tab jumped straight to
"addon is restarting" with no preview, no second-chance confirm,
and no way to bundle multiple edits before paying the restart cost.
- Clicking the explicit Restart button on the Tools tab left the page
stuck on "Restart initiated — reload page in ~30s" forever; the
user had to manually F5.
Server changes
- ``_save_feature_flags`` addon branch: drop
``_schedule_supervisor_self_restart`` call. Return
``{success, applied, mode, restart_required: True}`` instead of
``{..., restarting: True}``.
- ``_save_backup_config`` addon branch: same — no auto-restart.
- ``_save_backup_config`` file branch: rename ``restarting: False``
→ ``restart_required: False`` for naming consistency across all
save endpoints.
- ``_save_feature_flags`` file/default branch: now also returns
``restart_required: True`` (matches the FEATURE_META copy on every
flag, which says "Requires restart to take effect"). The UI
surfaces the banner; the restart button stays hidden in non-addon
mode since there is no supervisor to drive it.
JS changes
- ``saveFeatureFlag``: drops the "add-on is restarting…" branch.
Every successful save shows ``Saved — restart required`` and
surfaces the cross-tab banner.
- ``saveBackupConfig``: branches on ``data.restart_required`` instead
of ``data.restarting``. Re-enables the Save button so the user can
bundle further edits before clicking Restart.
- ``restartAddon``: auto-reloads the page after
``RESTART_RELOAD_DELAY_S = 10`` seconds. 4xx responses (genuine
config error, e.g. SUPERVISOR_TOKEN missing) suppress the reload
and surface the error inline; 5xx-from-ingress and network drops
fall through to the reload because both mean the supervisor killed
our upstream and the restart is in flight.
- ``ORIGIN_INFO_NOTE.addon`` and ``BACKUP_ORIGIN_LABELS.addon``:
"save will restart the add-on" → "restart required after save".
Test changes
- ``test_addon_save_merges_and_schedules_restart`` renamed to
``test_addon_save_merges_without_restart_returns_restart_required``
for both the backup-config and feature-flags variants. New
assertions: ``schedule_mock.assert_not_called()``,
``body["restart_required"] is True``,
``"restarting" not in body``.
- ``test_standalone_writes_file_and_invalidates_cache``: assert the
new field name.
Verified: ruff check, ruff format, mypy src/, 85 passing in
test_settings_ui.py (1 pre-existing Windows skip).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 493c6dc commit 31d96d8
2 files changed
Lines changed: 97 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| 924 | + | |
| 925 | + | |
924 | 926 | | |
925 | 927 | | |
926 | | - | |
| 928 | + | |
927 | 929 | | |
928 | | - | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
929 | 937 | | |
930 | 938 | | |
931 | | - | |
932 | | - | |
933 | | - | |
| 939 | + | |
| 940 | + | |
934 | 941 | | |
935 | 942 | | |
936 | 943 | | |
937 | | - | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
938 | 947 | | |
939 | 948 | | |
940 | 949 | | |
941 | 950 | | |
942 | 951 | | |
943 | 952 | | |
944 | | - | |
945 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
946 | 959 | | |
947 | 960 | | |
948 | 961 | | |
| |||
1204 | 1217 | | |
1205 | 1218 | | |
1206 | 1219 | | |
1207 | | - | |
| 1220 | + | |
1208 | 1221 | | |
1209 | 1222 | | |
1210 | 1223 | | |
| |||
1300 | 1313 | | |
1301 | 1314 | | |
1302 | 1315 | | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | | - | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1307 | 1324 | | |
| 1325 | + | |
1308 | 1326 | | |
1309 | 1327 | | |
1310 | | - | |
1311 | 1328 | | |
1312 | 1329 | | |
1313 | 1330 | | |
| |||
1497 | 1514 | | |
1498 | 1515 | | |
1499 | 1516 | | |
1500 | | - | |
| 1517 | + | |
1501 | 1518 | | |
1502 | 1519 | | |
1503 | 1520 | | |
| |||
1624 | 1641 | | |
1625 | 1642 | | |
1626 | 1643 | | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1634 | 1652 | | |
1635 | | - | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | 1653 | | |
1641 | 1654 | | |
1642 | 1655 | | |
| |||
2390 | 2403 | | |
2391 | 2404 | | |
2392 | 2405 | | |
2393 | | - | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
2394 | 2413 | | |
2395 | 2414 | | |
2396 | 2415 | | |
2397 | 2416 | | |
2398 | 2417 | | |
2399 | | - | |
| 2418 | + | |
2400 | 2419 | | |
2401 | 2420 | | |
2402 | 2421 | | |
| |||
2486 | 2505 | | |
2487 | 2506 | | |
2488 | 2507 | | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
2489 | 2513 | | |
2490 | | - | |
| 2514 | + | |
2491 | 2515 | | |
2492 | 2516 | | |
2493 | 2517 | | |
| |||
2817 | 2841 | | |
2818 | 2842 | | |
2819 | 2843 | | |
2820 | | - | |
2821 | | - | |
2822 | | - | |
2823 | | - | |
2824 | | - | |
2825 | | - | |
2826 | | - | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
2827 | 2847 | | |
2828 | 2848 | | |
2829 | 2849 | | |
2830 | 2850 | | |
2831 | 2851 | | |
2832 | | - | |
| 2852 | + | |
2833 | 2853 | | |
2834 | 2854 | | |
2835 | 2855 | | |
| |||
2871 | 2891 | | |
2872 | 2892 | | |
2873 | 2893 | | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
2874 | 2899 | | |
2875 | 2900 | | |
2876 | 2901 | | |
2877 | 2902 | | |
2878 | 2903 | | |
2879 | 2904 | | |
2880 | | - | |
| 2905 | + | |
2881 | 2906 | | |
2882 | 2907 | | |
2883 | 2908 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
1097 | | - | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1098 | 1104 | | |
1099 | 1105 | | |
1100 | 1106 | | |
| |||
1526 | 1532 | | |
1527 | 1533 | | |
1528 | 1534 | | |
1529 | | - | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
1530 | 1549 | | |
1531 | 1550 | | |
1532 | 1551 | | |
| |||
1547 | 1566 | | |
1548 | 1567 | | |
1549 | 1568 | | |
1550 | | - | |
| 1569 | + | |
| 1570 | + | |
1551 | 1571 | | |
1552 | 1572 | | |
1553 | 1573 | | |
1554 | 1574 | | |
1555 | | - | |
| 1575 | + | |
1556 | 1576 | | |
1557 | 1577 | | |
1558 | 1578 | | |
| |||
1670 | 1690 | | |
1671 | 1691 | | |
1672 | 1692 | | |
1673 | | - | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
1674 | 1699 | | |
1675 | 1700 | | |
1676 | 1701 | | |
| |||
1689 | 1714 | | |
1690 | 1715 | | |
1691 | 1716 | | |
1692 | | - | |
| 1717 | + | |
| 1718 | + | |
1693 | 1719 | | |
1694 | | - | |
| 1720 | + | |
1695 | 1721 | | |
1696 | 1722 | | |
1697 | 1723 | | |
| |||
0 commit comments