Repository navigation
fix(web): Restore device defaults resets environment-wide settings while a project is picked - #35182
juliusmarminge wants to merge 1 commit into
Conversation
…ile a project is picked Restore read and wrote through the current settings scope. When a project was picked (the choice carries over to General through the URL), the project-scope plan dropped every server write because the patch held settings a project cannot override, while device-only settings still saved, so environment-wide resets such as Auto-settle were silently lost. The Restore button now runs in its own scope that keeps only the chosen environment, so it reads and resets environment-wide values. AI-assisted; verified with the tests and tools listed above.
|
This PR changes the test suite by +1 test cases (browser +1, unit 0, server 0). New browser test files: Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The restore button now resets environment-wide settings even when a project or checkout is selected, while preserving any machine filter. Default values and the existing confirmation and permission safeguards are unchanged. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
useSettingsRestore read and wrote through the settings scope from the URL, which keeps the project picked on another settings page. In project scope planScopedSettingsPatch drops all server writes when the patch holds keys a project cannot override, while client-only keys still save, so no warning appeared and environment-wide resets (Auto-settle and others) were silently lost. RestoreDeviceDefaultsButton moved from routes/_chat.settings.tsx into SettingsPanels.tsx, next to the hook, and now wraps the action in a nested SettingsScopeProvider whose search keeps only
machine(project/checkout dropped). The confirmation labels and the writes therefore use the environment-wide scope: 'All environments', or the chosen machine. Behaviour without a project scope is unchanged. useSettingsRestore is no longer exported (knip). A new browser test (SettingsRestore.browser.test.tsx, harness adapted from open PR #32729) renders the button under a project scope across two environments and asserts that each environment receives sidebarAutoSettleAfterDays at its default and no projectSettingsOverrides. It fails with the fix reverted (0 updateSettings calls instead of 2) and passes with it. No new regex or parser.Fixes #35155
Reproduction on main
On origin/main 0627489, web client. Ran
T3CODE_DEV_SEED=0 vp run dev --home-dir <fresh empty dir> --no-seed, added /tmp/sample (empty-commit git repo) withnode src/bin.ts project add --title Sample, paired the preview browser withnode src/bin.ts pair. On /settings/threads turned the switch 'Auto-settle inactive threads' off, chose 'Sample' in the project scope picker, clicked General (URL became /settings/general?project=:/tmp/sample), clicked 'Restore device defaults'. The dialog read 'This will reset: Auto-settle inactive threads, New thread mode.' Clicked Confirm: the dialog closed with no toast. Opened /settings/threads fresh (scope 'All projects'): 'Auto-settle inactive threads' was still off (aria-checked=false). Control: the same Restore from /settings/general with no project scope listed 'Auto-settle inactive threads' and turned it back on.Evidence
Web client, Chromium, 1280×800, light theme; fresh isolated databases and synthetic Sample project.
Steps on both commits: turn Auto-settle inactive threads off in Threads settings → select Sample in Project scope → click General → Restore device defaults → confirm the dialog listing Auto-settle inactive threads → reopen Threads settings fresh with All projects.
Proven: Auto-settle remains off on base and returns to on with 7 days on head.
scenarios:proveexited 0.Scenario source.
AI-assisted; verified with the tests and tools listed above.
Not shown:
Tests
cd apps/web && vp test run src/components/settings/SettingsRestore.browser.test.tsx: 1 passed with the fix; with the scope narrowing reverted: 1 failed ('expected vi.fn() to be called 2 times, but got 0 times'). vp run check:changed: all pass (format, lint, knip 1/2 and 2/2, typecheck 2 packages, tests 2 files, react compiler). The first check:changed run failed only on knip (useSettingsRestore unused export), which was fixed by unexporting it.
Not in this change
AI-assisted; verified with the tests and tools listed above.