Skip to content

fix: sidebar collapse preference not persisting after reload#2474

Open
cleanjunc wants to merge 1 commit into
we-promise:mainfrom
cleanjunc:fix/sidebar-preference-persistence
Open

fix: sidebar collapse preference not persisting after reload#2474
cleanjunc wants to merge 1 commit into
we-promise:mainfrom
cleanjunc:fix/sidebar-preference-persistence

Conversation

@cleanjunc

@cleanjunc cleanjunc commented Jun 23, 2026

Copy link
Copy Markdown

What

Collapsing the left or right sidebar did not survive a page reload. The toggle animated correctly, but the preference was never saved.

Why

The app-layout Stimulus controller saves the preference by calling PATCH /users/${this.userIdValue}, but it never declared a static values block. Without userId registered, Stimulus does not bind the data-app-layout-user-id-value attribute that the layout renders, so this.userIdValue resolves to undefined.

Every toggle therefore hit /users/undefined, which could not update show_sidebar or show_ai_sidebar, and the layout reset on the next load.

How

Add the missing value declaration to the controller:

static values = { userId: String };

Closes #2473

Summary by CodeRabbit

  • Enhancement
    • Improved user preference management functionality.

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b737f96f-8f1c-4a21-9849-0f7dfdb1d5e2

📥 Commits

Reviewing files that changed from the base of the PR and between fdcd0c7 and 067de43.

📒 Files selected for processing (1)
  • app/javascript/controllers/app_layout_controller.js

📝 Walkthrough

Walkthrough

A single static values entry (userId: String) is added to the AppLayout Stimulus controller. This registers the data-app-layout-user-id-value DOM attribute so that this.userIdValue resolves to the actual user ID when the controller calls #updateUserPreference.

Changes

AppLayout Controller userId Value

Layer / File(s) Summary
Static values declaration for userId
app/javascript/controllers/app_layout_controller.js
Adds static values = { userId: String } so Stimulus binds the data-app-layout-user-id-value attribute and this.userIdValue returns the correct user ID instead of undefined during preference PATCH requests.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 One small line is all it took,
A userId hidden in the nook.
The sidebar remembers, left and right,
No more resetting after night.
Stimulus now reads the DOM with glee! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary bug being fixed: sidebar collapse preference not persisting after reload, matching the core issue addressed in the changeset.
Linked Issues check ✅ Passed The PR directly addresses issue #2473 by adding the missing static values = { userId: String } declaration to enable Stimulus value binding, which allows sidebar preferences to persist correctly.
Out of Scope Changes check ✅ Passed The single change (adding static values = { userId: String }) is directly scoped to fixing issue #2473 with no extraneous modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

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.

Bug: Sidebar collapse preference does not persist after reload

1 participant