Skip to content

Take only the fields the page edits on the settings route - #1945

Merged
BarganConstantin merged 1 commit into
developmentfrom
fix/prefs-route-fields
Oct 5, 2026
Merged

BarganConstantin merged 1 commit into
developmentfrom
fix/prefs-route-fields

Conversation

@BarganConstantin

Copy link
Copy Markdown
Owner

What changes

  • The settings route (POST /api/prefs) only takes the fields the page edits: the notifications, tour and auto-update switches, and the LAN dialog's name, enabled, shared, addresses, current-account, pairing-mode, ask, accept and Tailscale switches. These are listed once, in PAGE_FIELDS beside publicPrefs in deck-prefs.mjs, and the route cuts each body down to them with pagePatch.
  • Every other field keeps what is on disk, whatever a body names. That covers the deck's LAN key, its accepted and unpaired decks, which ticks an arrival made, its port, the names given to other decks (they have their own route), the reports switch and the reporter's state, and the accounts the deck signed in. The three top-level fields the route already dropped are now covered by the same list.
  • Every page write in src/web and the desktop app's notifications toggle works as before. No client changed.

Verification

  • npm run typecheck: clean.
  • Full suite, 3 workers: 902 files, 11804 tests passed.
  • New src/web/__tests__/prefs-route-fields.test.ts posts through the real route into a real prefs.json and reads it back as a restart would:
    • a body that sets lan.secret and lan.trusted leaves both as they were on disk. This failed before the fix: the page's value landed.
    • a body naming every deck-owned field (lan.unpaired, onward, port, aliases, reports, report, accounts) leaves each one as it was. This failed before the fix (lan.unpaired was replaced).
    • a body that mixes page and deck-owned fields: the page fields land and the rest do not. This failed before the fix.
    • each of the 14 page writes, in the shape the page sends it, still lands. Unticking an account still drops the arrival's mark for it.
    • guard: PAGE_FIELDS is exactly the listed fields. Every field in the file is either page-writable or deck-owned, by name. Every page field is exercised through the route. So adding a new page-writable field takes a deliberate change.
  • reauth-prompt-1893.test.ts: the guard that pinned the old destructuring line now checks that pagePatch drops accounts and that the route writes pagePatch(body).
  • Every test that reads the prefs modules or /api/prefs (50 files, 1021 tests) passed again after rebasing on development.
  • No browser check: no page flow changed.

POST /api/prefs now writes the fields the page and the desktop app edit:
the notifications, tour and auto-update switches, and the LAN dialog's
name, sharing, address and pairing switches. Every other field (the deck's
LAN key and pairings, its port, names given to other decks, the reports
switch and the reporter's state, the accounts it signed in) keeps what is
on disk whatever a body names. A preference becomes writable from a page
only once it is added to that list.
@BarganConstantin
BarganConstantin merged commit 662c7ef into development Oct 5, 2026
10 checks passed
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