Skip to content

fix(web): keep paired web starting when a settings migration write fails - #48524

Merged
AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-17981-web-settings-migration-write
Nov 24, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-17981-web-settings-migration-write

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Paired web could fail to start when the browser refused a settings write (storage full or writes denied).

#48442 removed the try/catch around the optional browser-settings migration write in getStoredSettings. That function runs while window.api is being built (installWebPreloadApi → createWebUiApi → readLocalWebUIState → getStoredSettings). So if localStorage.setItem threw, the error escaped before the app mounted, and the web root's Retry hit the same error again.

This PR restores the catch around the migration writes: the settings write and the OSC 52 notice write. Settings still load from what is stored. Existing browser profiles still read the app rail as off on every load until a write succeeds, so the new-user vs existing-user behavior from #48442 does not change. The next settings read retries the write.

Fixes STA-17981.

Out of scope: if the settings write succeeds but the OSC 52 notice write fails, that notice is not shown again. Main behaved the same way before #48442.

Testing

  • Added two cases to web-preferences-app-rail-default.test.ts: existing readable settings with every write denied, and only the OSC 52 notice write denied. Both fail on main with QuotaExceededError and pass with this change (run locally on this one file).
  • oxfmt, oxlint, the web typecheck and the changed-code quality check pass. CI runs the full test suite.

No comparable: mechanical.

Performance

None, by reading the code. This adds one try/catch on an existing path. When writes keep failing, each settings read retries one write: one JSON.stringify plus one thrown exception. That is the same cost as before #48442 and small next to the JSON parse each read already does. Nothing loops or recurses.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

The app rail cohort change dropped the catch around the optional web
settings migration write. getStoredSettings runs while window.api is
built, so a full or denied localStorage threw before the app mounted and
Retry threw again. Restore the catch; the migration reruns next load.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

getStoredSettings now continues settings loading if a migration-related localStorage write fails. Tests cover denied writes to settings storage and UI storage, and check returned settings and stored values.

Merge Risk: Minimal · up to 20e0e

This restores app startup when a browser blocks or exceeds quota for an optional settings migration write. No merge-blocking risk was found. If the settings write succeeds but the notice write fails, the OSC 52 notice is not shown again, which the PR states matches earlier behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (keeping paired web startup alive when a settings migration write fails), which matches the catch added around the migration writes in getStoredSettings. It is specific and sta…
Description check Passed The description follows the template closely. It covers the summary of the failure and fix, the testing performed, a performance note, and a linked issue (STA-17981). Gaps: the template's ELI5, Visual…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (keeping paired web startup alive when a settings migration write fails), which matches the catch added around the migration writes in getStoredSettings. It is specific and states the primary change, so it passes.

Full details: Description check

Explanation

The description follows the template closely. It covers the summary of the failure and fix, the testing performed, a performance note, and a linked issue (STA-17981). Gaps: the template's ELI5, Visual Proof, and Risk sections are missing or unfilled. The Risk level is not set, and the Visual Proof section does not state N/A with a reason. The Linked Issue section uses 'Fixes STA-17981' in the body rather than the template's 'Fixes #' line, and the Testing checkboxes are not ticked. Most required content is present, so the check passes, but the author should add the ELI5, Risk level and backout plan, and a Visual Proof N/A reason.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd055ebe-4efd-477b-91c1-8b2705629d49
Commits

Reviewing files that changed from the base of the PR and between 1f4588e and 20e0e06.

Files selected for processing: 2

  • src/renderer/src/web/preload-api/preferences/web-preferences-app-rail-default.test.ts
  • src/renderer/src/web/preload-api/preferences/web-preferences-store.ts

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

@AmethystLiang
AmethystLiang merged commit b3996c2 into main Nov 24, 2026
54 checks passed
Jinwoo-H pushed a commit that referenced this pull request Nov 24, 2026
…ils (#48524)

* fix(web): keep startup working when the settings migration write fails

The app rail cohort change dropped the catch around the optional web
settings migration write. getStoredSettings runs while window.api is
built, so a full or denied localStorage threw before the app mounted and
Retry threw again. Restore the catch; the migration reruns next load.

* test(web): restore the storage spy and cover a denied OSC 52 notice write
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