Skip to content

sidebar: Clip floating surface materials#5

Merged
BumpyClock merged 3 commits into
mainfrom
fix/floating-sidebar-surface
Jul 15, 2026
Merged

sidebar: Clip floating surface materials#5
BumpyClock merged 3 commits into
mainfrom
fix/floating-sidebar-surface

Conversation

@BumpyClock

@BumpyClock BumpyClock commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • make SurfacePreset own one rounded surface geometry for background, backdrop blur, noise, content, border, and elevation
  • remove the separate square shadow wrapper and keep the composed Sidebar background transparent
  • crop partial noise tiles without stretching the noise texture
  • add Floating Sidebar elevation controls, builder coverage, and documentation
  • update Cargo and vendor/gpui to merged rounded-mask support from gpui: Support rounded content masks gpui#5 and the Windows retained-layer follow-up windows: Clip rounded retained layers gpui#6 (4332ea7deae4838c12bad6ea64292ca22a33cf98)

Verification

  • cargo check -p gpui-component -p gpui-component-story -p gpui-wry
  • cargo check -p gpui-component --tests
  • cargo fmt --all --check
  • git diff --check main...HEAD
  • Story Gallery launched against the merged GPUI revision
  • visual inspection captured clean nested rounded sidebar corners using the same GPUI patch; a final post-merge recapture was blocked by the macOS lock screen
  • local CodeRabbit final review: 0 findings
  • independent Codex final review: no blockers

Platform notes

AI assistance

Implementation and review were AI-assisted with Claude Code. CodeRabbit and an independent Codex review were also run before opening this PR.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change updates the GPUI revision, initializes content masks with defaults, reworks surface noise tiling, and changes sidebar elevation defaults and rendering. Floating sidebar stories, tests, and documentation now expose and describe elevation settings.

Changes

Sidebar rendering

Layer / File(s) Summary
GPUI revision update
Cargo.toml, vendor/gpui
Workspace dependencies and the vendored GPUI reference now use revision 4332ea7deae4838c12bad6ea64292ca22a33cf98.
Content mask initialization
crates/ui/src/scroll/*, crates/ui/src/virtual_list.rs, crates/webview/lib.rs
Content masks retain their bounds while incorporating default field values across scrolling, virtual-list, and webview rendering paths.
Surface noise tiling
crates/ui/src/surface/mod.rs
Noise overlays use scale-aware exact tile layouts, partial-edge sizing, shared clipping, and expanded layout tests.
Sidebar elevation integration
crates/ui/src/sidebar_shell/mod.rs, crates/ui/src/floating_sidebar/mod.rs, crates/story/src/stories/floating_sidebar_story.rs, docs/docs/components/sidebar.md
Sidebar elevation defaults change to ElevationToken::Sm; panel shadows are applied through the theme surface, story controls expose elevation choices, and related tests and documentation are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Story as FloatingSidebarStory
  participant FloatingSidebar
  participant SidebarShell
  participant SurfacePreset
  Story->>FloatingSidebar: Apply selected elevation
  FloatingSidebar->>SidebarShell: Render configured shell
  SidebarShell->>SurfacePreset: Apply panel elevation
  SurfacePreset-->>SidebarShell: Render elevated panel
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is specific, but it does not follow the required template and is missing several mandatory sections. Add the required sections from the template: Closes #, Description, Screenshot, Break Changes, How to Test, and Checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed It clearly points to the floating sidebar surface clipping work, which is a main change in the PR.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/floating-sidebar-surface

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

@BumpyClock

Copy link
Copy Markdown
Owner Author

@codex review this PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ui/src/sidebar_shell/mod.rs`:
- Around line 378-380: Update SidebarShell’s elevation handling so the
theme-controlled surface panel shadow remains the default: make the elevation
override optional and apply with_elevation only when explicitly provided. Update
FloatingSidebar to stop forwarding its default elevation as an override, while
preserving explicit elevation overrides.

In `@crates/ui/src/surface/mod.rs`:
- Around line 515-517: Update noise_tile_layout to clamp the rounded
tile_size_value to a minimum of 1px before converting it with px, preventing
zero-sized tiles at extreme scale factors. Add a regression test covering scale
factors above 256 and verify render_noise_tiles receives a bounded tile range.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 93bf5604-f762-4d42-b6cc-78d711466032

📥 Commits

Reviewing files that changed from the base of the PR and between 8266056 and 386ba4c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Cargo.toml
  • crates/story/src/stories/floating_sidebar_story.rs
  • crates/ui/src/floating_sidebar/mod.rs
  • crates/ui/src/scroll/scrollable_mask.rs
  • crates/ui/src/scroll/scrollbar.rs
  • crates/ui/src/sidebar_shell/mod.rs
  • crates/ui/src/surface/mod.rs
  • crates/ui/src/virtual_list.rs
  • crates/webview/src/lib.rs
  • docs/docs/components/sidebar.md
  • vendor/gpui

Comment on lines 378 to 380
let sidebar_surface = SurfacePreset::panel()
.with_elevation(self.elevation)
.wrap_with_bounds(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== sidebar_shell outline ==\n'
ast-grep outline crates/ui/src/sidebar_shell/mod.rs --view expanded || true

printf '\n== relevant lines in sidebar_shell ==\n'
sed -n '320,450p' crates/ui/src/sidebar_shell/mod.rs

printf '\n== search for SurfacePreset definitions and with_elevation ==\n'
rg -n "struct SurfacePreset|impl SurfacePreset|with_elevation|use_theme_elevation_defaults|surface_panel_shadow|FloatingSidebar" crates/ui/src -S

Repository: BumpyClock/gpui-component

Length of output: 11367


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== SurfacePreset implementation slice ==\n'
sed -n '191,470p' crates/ui/src/surface/mod.rs

printf '\n== FloatingSidebar render slice ==\n'
sed -n '230,340p' crates/ui/src/floating_sidebar/mod.rs

printf '\n== SidebarShell constructor/default slice ==\n'
sed -n '160,210p' crates/ui/src/sidebar_shell/mod.rs

printf '\n== tests around shadow defaults ==\n'
sed -n '480,620p' crates/ui/src/floating_sidebar/mod.rs

Repository: BumpyClock/gpui-component

Length of output: 17975


Preserve the theme-controlled default elevation. SidebarShell always calls with_elevation(self.elevation), which disables use_theme_elevation_defaults and forces the sidebar shadow to ElevationToken::Sm instead of cx.theme().elevation.surface_panel_shadow. Make elevation an optional override and only apply it when explicitly set; FloatingSidebar should stop forwarding its default as an override too.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/ui/src/sidebar_shell/mod.rs` around lines 378 - 380, Update
SidebarShell’s elevation handling so the theme-controlled surface panel shadow
remains the default: make the elevation override optional and apply
with_elevation only when explicitly provided. Update FloatingSidebar to stop
forwarding its default elevation as an override, while preserving explicit
elevation overrides.

Comment on lines +515 to +517
fn noise_tile_layout(width: Pixels, height: Pixels, scale_factor: f32) -> NoiseTileLayout {
let tile_size_value = (GLASS_NOISE_TILE_SIZE_BASE / scale_factor.max(1.0)).round();
let tile_size = px(tile_size_value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="crates/ui/src/surface/mod.rs"

echo "== outline =="
ast-grep outline "$FILE" --view expanded || true

echo
echo "== relevant lines =="
sed -n '500,560p' "$FILE" | cat -n

echo
echo "== search for noise_tile_layout uses =="
rg -n "noise_tile_layout|GLASS_NOISE_TILE_SIZE_BASE|tile_size_value|tile_size" "$FILE"

Repository: BumpyClock/gpui-component

Length of output: 7125


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="crates/ui/src/surface/mod.rs"

echo "== render_noise_tiles section =="
sed -n '543,590p' "$FILE" | cat -n

echo
echo "== existing tests =="
sed -n '590,660p' "$FILE" | cat -n

echo
echo "== zero-tile-size behavior probe =="
python3 - <<'PY'
import math

base = 128.0
for scale in [128.0, 256.0, 257.0, 512.0, 1000.0]:
    tile = round(base / max(scale, 1.0))
    cols = math.ceil(200.0 / tile) if tile != 0 else "DIV0"
    rows = math.ceil(150.0 / tile) if tile != 0 else "DIV0"
    tiles = (cols * rows) if isinstance(cols, int) else "DIV0"
    print(scale, tile, cols, rows, tiles)
PY

Repository: BumpyClock/gpui-component

Length of output: 4246


Clamp the rounded tile size to at least 1px.
For scale factors above 256, this rounds to 0 and render_noise_tiles can expand to a near-unbounded tile range. Add a high-scale regression test.

Proposed fix
-    let tile_size_value = (GLASS_NOISE_TILE_SIZE_BASE / scale_factor.max(1.0)).round();
+    let tile_size_value =
+        (GLASS_NOISE_TILE_SIZE_BASE / scale_factor.max(1.0))
+            .round()
+            .max(1.0);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn noise_tile_layout(width: Pixels, height: Pixels, scale_factor: f32) -> NoiseTileLayout {
let tile_size_value = (GLASS_NOISE_TILE_SIZE_BASE / scale_factor.max(1.0)).round();
let tile_size = px(tile_size_value);
fn noise_tile_layout(width: Pixels, height: Pixels, scale_factor: f32) -> NoiseTileLayout {
let tile_size_value =
(GLASS_NOISE_TILE_SIZE_BASE / scale_factor.max(1.0))
.round()
.max(1.0);
let tile_size = px(tile_size_value);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/ui/src/surface/mod.rs` around lines 515 - 517, Update
noise_tile_layout to clamp the rounded tile_size_value to a minimum of 1px
before converting it with px, preventing zero-sized tiles at extreme scale
factors. Add a regression test covering scale factors above 256 and verify
render_noise_tiles receives a bounded tile range.

@BumpyClock
BumpyClock merged commit 01847f3 into main Jul 15, 2026
1 check passed
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