Skip to content

fix restore diff sidebar width after resize#1026

Open
donnes wants to merge 1 commit intopingdotgg:mainfrom
donnes:fix/diff-sidebar-resize
Open

fix restore diff sidebar width after resize#1026
donnes wants to merge 1 commit intopingdotgg:mainfrom
donnes:fix/diff-sidebar-resize

Conversation

@donnes
Copy link
Contributor

@donnes donnes commented Mar 13, 2026

What Changed

  • Revalidated the stored diff sidebar width when the app window resizes.
  • Reset the diff sidebar back to its default width when a persisted width no longer fits the current layout.
  • Restored the diff toggle interaction after monitor unplug and window resize scenarios.

Why

The bug was caused by the diff sidebar restoring a previously saved custom width without re-checking whether that width still fit after the app window became smaller, like after unplugging a monitor.

Once that stale width no longer fit, the diff panel could end up in a broken layout state, so clicking the diff toggle button or pressing Cmd+D appeared to stop working even though the toggle logic still ran.

The fix makes the sidebar revalidate its stored width on restore and on window resize, and if that width is no longer valid, it falls back to the default sidebar width instead of keeping the broken one.

UI Changes

  • Diff toggle now recovers after unplugging an external monitor or resizing the desktop window smaller.
  • No intentional visual redesign; this is a behavior fix for the existing diff sidebar interaction.

Demos

Before Fix

T3Code.toggle.diff.panel.not.working.demo.mp4

After Fix

T3Code.toggle.diff.panel.working.mp4

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Restore diff sidebar width on window resize using shouldAcceptWidth validation

  • The SidebarRail component in sidebar.tsx now re-validates and re-applies the stored sidebar width on every window resize event, not just on mount.
  • An optional shouldAcceptWidth predicate receives the current and next widths plus relevant DOM refs; if it rejects the width, the sidebar resets to its CSS default and clears the stored value from localStorage.
  • Behavioral Change: the effect now also re-runs when sidebarInstance?.side changes, and onResize is only called when a stored width is accepted.

Macroscope summarized 6afe307.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fb8f429c-a8a5-4d96-bfdc-4af0d2a1ecc9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 13, 2026
@donnes donnes force-pushed the fix/diff-sidebar-resize branch from 6464dbc to 6afe307 Compare March 13, 2026 14:07
@donnes donnes changed the title restore diff sidebar width after resize fix restore diff sidebar width after resize Mar 13, 2026
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:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant