Skip to content

fix(web): Restore device defaults resets environment-wide settings while a project is picked - #35182

Open
juliusmarminge wants to merge 1 commit into
mainfrom
factory/issue-35155
Open

juliusmarminge wants to merge 1 commit into
mainfrom
factory/issue-35155

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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) with node src/bin.ts project add --title Sample, paired the preview browser with node 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:prove exited 0.

Evidence Before — 7d3635e572 After — c01b6cbc9a
Reset confirmation Before: confirmation includes Auto-settle After: confirmation includes Auto-settle
Result Before: Auto-settle remains off After: Auto-settle on with 7 days
Interaction, half-speed; sign-in trimmed Before recording After recording

Scenario source.

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Other environment-wide settings and multi-environment targeting were not exercised; this proof covers the reported Auto-settle web flow.

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.

…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.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR changes the test suite by +1 test cases (browser +1, unit 0, server 0).

New browser test files: apps/web/src/components/settings/SettingsRestore.browser.test.tsx.
Each browser test file costs CI seconds of module loading before its first test runs; a unit test costs milliseconds.

Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing.

@macroscopeapp

macroscopeapp Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c01b6cb

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.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The device-defaults restore button moved from the settings route into SettingsPanels.tsx. The new button uses the selected machine’s settings scope. A browser test checks that restoration sends default settings to both primary and remote environments.

Changes: Device defaults restore

Layer / File(s) Summary
Scoped restore control and verification
apps/web/src/components/settings/SettingsPanels.tsx, apps/web/src/routes/_chat.settings.tsx, apps/web/src/components/settings/SettingsRestore.browser.test.tsx
SettingsPanels.tsx now exports the restore button and keeps the restore hook file-local. The settings route imports the shared button. The browser test checks that clicking the button updates both environments with default settings and omits projectSettingsOverrides.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: t3dotgg, macroscopeapp

Merge Risk: Minimal · up to c01b6

Restore device defaults now applies environment-wide while a project is selected, which fixes the reported auto-settle issue. Behavior without a project scope is unchanged. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary change: restore device defaults no longer resets environment-wide settings while a project is picked. It follows the conventional commit form with a fix(web) prefix. It mat…
Linked Issues check Passed [#35155] The linked issue requires that Restore device defaults turn "Auto-settle inactive threads" back on (7 days) when a project is selected. The diff in apps/web/src/components/settings/SettingsPa…
Out of Scope Changes check Passed All changes map to #35155. SettingsPanels.tsx changes the restore scope and moves RestoreDeviceDefaultsButton next to useSettingsRestore. The import of SettingsScopeProvider and RotateCcwIcon supports…
Description check Passed The description follows the template's main sections: Problem, Change, Scope, and Verification. It explains the bug, why the scope narrowing fixes it, and that the fix is for a linked issue (#35155). …
Full details: Title check

Explanation

The title names the primary change: restore device defaults no longer resets environment-wide settings while a project is picked. It follows the conventional commit form with a fix(web) prefix. It matches the objectives, which scope the restore action to environment-wide settings when a project is selected.

Full details: Linked Issues check

Explanation

[#35155] The linked issue requires that Restore device defaults turn "Auto-settle inactive threads" back on (7 days) when a project is selected. The diff in apps/web/src/components/settings/SettingsPanels.tsx adds RestoreDeviceDefaultsButton. It wraps RestoreDeviceDefaultsAction in SettingsScopeProvider with search reduced to { machine } when a machine is chosen, or {} otherwise. Project and checkout scope are dropped, so the confirmation labels and the updateSettings writes use the environment-wide scope. This removes the project-scoped path that caused the silent drop of environment-wide keys. Behavior without a project scope is unchanged, which the diff supports because the empty search is only applied when machine is absent and the no-project path has no project key to drop. The PR also adds SettingsRestore.browser.test.tsx, which asserts two updateSettings calls with sidebarAutoSettleAfterDays at default and no projectSettingsOverrides. The test result itself was reported by the author and was not re-executed in this review. The code evidence supports the fix; the test outcome is unverified.

Full details: Out of Scope Changes check

Explanation

All changes map to #35155. SettingsPanels.tsx changes the restore scope and moves RestoreDeviceDefaultsButton next to useSettingsRestore. The import of SettingsScopeProvider and RotateCcwIcon supports that move. Unexporting useSettingsRestore is a direct consequence of moving the button and resolves the knip failure. The new browser test supports the fix. The _chat.settings.tsx change removes the local button and imports the moved component, so it is part of the same move. The PR description states that the mixed-key planScopedSettingsPatch behavior and PR #32729's machine-scope behavior were intentionally left unchanged, and the diff does not modify those paths. No unrelated change was found in the reviewed hunks.

Full details: Description check

Explanation

The description follows the template's main sections: Problem, Change, Scope, and Verification. It explains the bug, why the scope narrowing fixes it, and that the fix is for a linked issue (#35155). It gives a reproduction on main, before/after evidence, and test results with and without the fix. Two items are weak. The Scope section does not explicitly justify a bug fix versus a feature, though it links the issue. The title is not shown in the provided text, so conventional commit title compliance cannot be checked. The description also does not name the model and harness used, but it does state the work was AI-assisted and lists the tools used, which is close to the template's request. Overall the description is mostly complete and specific.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 26e769d and c01b6cb.

Files selected for processing: 3

  • apps/web/src/components/settings/SettingsPanels.tsx
  • apps/web/src/components/settings/SettingsRestore.browser.test.tsx
  • apps/web/src/routes/_chat.settings.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Restore device defaults leaves Auto-settle off after a project is picked on Threads settings

1 participant