Skip to content

fix(sidebar): persist the expanded width across restarts - #350

Open
mydd7 wants to merge 1 commit into
zephium-browser:mainfrom
mydd7:fix/sidebar-persist-expanded-width
Open

mydd7 wants to merge 1 commit into
zephium-browser:mainfrom
mydd7:fix/sidebar-persist-expanded-width

Conversation

@mydd7

@mydd7 mydd7 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The sidebar restores its mode after a restart but always initializes the expanded width to 240 px. Resize commits never save a width. A person who chooses 350 px therefore loses that width after quitting and relaunching.

Persist the expanded width when a native/fallback drag commits or a keyboard resize changes it, and read it alongside the mode before publishing the initial native layout. The native preference allowlist accepts only canonical whole widths from 180 through 460 px. Missing or invalid saved values retain 240 px.

Hidden mode retains the last expanded width. Cancelled/in-progress drags, stale native revisions and temporary utility-panel widths do not replace it.

Fixes #337.

Validation on Windows:

  • Before the fix, the new persistence and hidden-width regressions failed; invalid/missing-value cases passed.
  • Session tests simulate a new module/session reading the saved width, plus native commits, keyboard resize, cancellation, temporary panels, stale revisions and invalid values.
  • cargo test -p zephium-core --locked: 469 tests passed, including native preference admission bounds.
  • SidebarResizeHandle browser test passed on Chromium.
  • pnpm -C frame check --maxWorkers 2: static checks and 1,073 unit tests passed (181 files).
  • pnpm -C frame build and emitted CSS check (144 files) passed.
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings

Session and renderer tests mock IPC. A packaged-app quit/relaunch on macOS or Windows has not been exercised. Existing native setting commands and layout admission are reused; no IPC bindings change.

Summary by CodeRabbit

  • New Features
    • The sidebar now remembers its expanded width when you reopen the app.
    • You can resize the sidebar within the supported width range; if no valid saved width is available, it opens at the default width.
    • The expanded width is retained while the sidebar is hidden, so it is restored when the sidebar is shown again.

@mydd7
mydd7 requested a review from crynta as a code owner November 2, 2026 07:26
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f0dba76 and b11f1ee.

Files selected for processing: 3
  • crates/zephium-core/src/preferences.rs
  • frame/src/session/sidebar-mode.svelte.ts
  • frame/src/session/tests/sidebar-width.svelte.test.ts

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

Walkthrough

The sidebar now saves changed expanded widths and restores valid saved widths during initialization. The sidebar.width preference accepts canonical decimal values from 180 through 460.

Changes: Sidebar width persistence

Layer / File(s) Summary
Width setting contract
crates/zephium-core/src/preferences.rs
The preferences registry recognizes sidebar.width and accepts canonical decimal values from 180 through 460. Tests cover accepted and rejected values.
Sidebar width save and restore
frame/src/session/sidebar-mode.svelte.ts, frame/src/session/tests/sidebar-width.svelte.test.ts
Width changes are persisted, and initialization restores valid saved widths. Tests cover resize persistence, restoration, hidden mode, native resize values, and invalid saved values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • zephium-browser/Zephium#183: Introduced live sidebar resizing and hidden-sidebar mode, whose expanded width this change persists and restores.
  • zephium-browser/Zephium#206: Uses the expanded width for temporary sidebar expansion; this change restores that width from settings.

Suggested labels: bug, area: browse, size: M

Merge Risk: Minimal · up to b11f1

The reviewed change has no established issue requiring a fix before merge. Normal checks and a packaged-app quit-and-relaunch test remain appropriate.

Pre-merge checks: Passed 9 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Performance Impact Stated Warning The PR changes the sidebar session hot path and startup initialization. The diff adds width persistence in frame/src/session/sidebar-mode.svelte.ts and adds a second concurrent settingGet in `init… Update the PR description with the performance impact or a performance measurement. Include startup read overhead and resize persistence write behavior, or provide benchmark/timing results.
Passed Passed checks: 9 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the required Conventional Commits format and accurately describes persisting the sidebar's expanded width across restarts.
Linked Issues check Passed Issue #337 requires the sidebar to reopen at its prior custom width after a full restart. The change adds the sidebar.width preference, saves completed drag and native resize widths through `remembe…
Out of Scope Changes check Passed The changes stay within issue #337. The native preference allowlist change admits the new sidebar width setting, and the session tests verify the required persistence, restoration, cancellation, stale…
One Logical Change Passed All three changed files serve the sidebar-width persistence change: preference admission, sidebar save/restore behavior, and focused regression tests. The diff contains no unrelated refactors, renames…
Linked Issue For Larger Changes Passed The pull request is a small, contained bug fix. It changes three files to persist and restore the sidebar width and adds focused validation tests. The description links issue #337 with “Fixes #337,” w…
Tests Cover Changed Behavior Passed Tests cover the changed behavior. Rust tests verify the new sidebar.width allowlist, accepted bounds, canonical formatting, and rejected values. Sidebar tests verify drag and keyboard saves, restora…
Generated Files Follow Their Source Passed The pull request changes only crates/zephium-core/src/preferences.rs, frame/src/session/sidebar-mode.svelte.ts, and a sidebar test. It does not change frame/src/shared/ipc/bindings.ts, `Cargo.lo…
Privileged Boundary Intact Passed The PR changes only the preference allowlist, the privileged browser-session sidebar module, and its tests. It reuses existing setting_get and setting_set commands; it adds no IPC command, Wry han…
Full details: Linked Issues check

Explanation

Issue #337 requires the sidebar to reopen at its prior custom width after a full restart. The change adds the sidebar.width preference, saves completed drag and native resize widths through rememberWidth, restores a valid width during init() before publishing the initial layout, and keeps 240 px for missing or invalid values. Tests cover save, new-session restore, and validation behavior.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #337. The native preference allowlist change admits the new sidebar width setting, and the session tests verify the required persistence, restoration, cancellation, stale-revision, hidden-mode, and temporary-panel behavior. No unrelated product behavior or IPC binding changes are present.

Full details: One Logical Change

Explanation

All three changed files serve the sidebar-width persistence change: preference admission, sidebar save/restore behavior, and focused regression tests. The diff contains no unrelated refactors, renames, or formatting of untouched code, and git diff --check reports no whitespace errors.

Full details: Linked Issue For Larger Changes

Explanation

The pull request is a small, contained bug fix. It changes three files to persist and restore the sidebar width and adds focused validation tests. The description links issue #337 with “Fixes #337,” which meets the stated issue-link condition.

Full details: Tests Cover Changed Behavior

Explanation

Tests cover the changed behavior. Rust tests verify the new sidebar.width allowlist, accepted bounds, canonical formatting, and rejected values. Sidebar tests verify drag and keyboard saves, restoration after a new session, hidden-mode and temporary-panel preservation, stale/non-finite native inputs, rounding, and missing or invalid stored widths retaining 240 px.

Full details: Generated Files Follow Their Source

Explanation

The pull request changes only crates/zephium-core/src/preferences.rs, frame/src/session/sidebar-mode.svelte.ts, and a sidebar test. It does not change frame/src/shared/ipc/bindings.ts, Cargo.lock, pnpm-lock.yaml, or generated i18n output. Therefore, none of the specified generated-file failure conditions apply.

Full details: Privileged Boundary Intact

Explanation

The PR changes only the preference allowlist, the privileged browser-session sidebar module, and its tests. It reuses existing setting_get and setting_set commands; it adds no IPC command, Wry handler, custom protocol, or privileged initialization object. Rust authorizes setting_set only for the main privileged webview and validates the key and value through zephium_core::preferences::value_allowed; the new sidebar.width validator accepts only canonical decimal widths from 180 through 460. The CSP, devtools configuration, and desktop IPC boundary files are unchanged. No content-page IPC exposure or release devtools change is introduced.

Full details: Performance Impact Stated

Explanation

The PR changes the sidebar session hot path and startup initialization. The diff adds width persistence in frame/src/session/sidebar-mode.svelte.ts and adds a second concurrent settingGet in init(). The description reports functional test and build results, but it does not state the performance impact or provide a performance measurement.

Resolution

Update the PR description with the performance impact or a performance measurement. Include startup read overhead and resize persistence write behavior, or provide benchmark/timing results.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • 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

@coderabbitai coderabbitai Bot added area: browse Browser chrome: tabs, sidebar, address field, settings, windows bug Something isn't working size: M 100 to 499 changed lines labels Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: browse Browser chrome: tabs, sidebar, address field, settings, windows bug Something isn't working size: M 100 to 499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar width resets after fully quitting and relaunching the browser

1 participant