feat(gpui): port container_query and sticky-axis div scrolling - #5
Merged
freefcw merged 2 commits intoAug 29, 2026
Merged
Conversation
审查者指南将响应式容器查询和手势感知的轴锁定滚动移植到 GPUI 中,包括公共 API、响应式布局示例、有状态的精确滚动过滤、保持兼容性的行为,以及针对性的测试覆盖。 容器查询测量与渲染的时序图sequenceDiagram
participant Parent as Parent layout
participant CQ as ContainerQuery
participant Window
participant Builder as Render callback
participant Child as Child element
Parent->>CQ: request_layout()
CQ->>Window: request_layout(style)
Window-->>CQ: measured bounds
CQ->>Builder: render(bounds.size, window, cx)
Builder-->>CQ: child element
CQ->>Child: layout_as_root(bounds.size)
CQ->>Child: prepaint_at(bounds.origin)
CQ->>Child: paint()
手势感知的轴锁定 div 滚动时序图sequenceDiagram
actor User
participant Div as Scrollable div
participant Ongoing as OngoingScroll
participant Offset as Scroll offset
User->>Div: ScrollWheelEvent precise delta
Div->>Ongoing: filter(delta, touch_phase)
Ongoing-->>Div: delta filtered to dominant axis
Div->>Div: apply allow_concurrent_scroll and overflow rules
Div->>Offset: update scroll position
User->>Div: Perpendicular delta
Div->>Ongoing: filter(delta, Moved)
Ongoing-->>Div: unlock when ratio >= 1.9 and delta >= 6px
Div->>Offset: apply unlocked delta
响应式容器布局选择流程图flowchart TD
A[Window resize or layout pass] --> B[container_query measures assigned size]
B --> C{Width below 400px?}
C -->|Yes| D[Build stacked flex-column layout]
C -->|No| E[Build three-column grid layout]
D --> F[Render child contents at measured size]
E --> F
文件级变更
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's GuidePorts responsive container queries and gesture-aware axis-locked scrolling into GPUI, including public APIs, a responsive layout example, stateful precise-scroll filtering, compatibility-preserving behavior, and focused test coverage. Sequence diagram for container query measurement and renderingsequenceDiagram
participant Parent as Parent layout
participant CQ as ContainerQuery
participant Window
participant Builder as Render callback
participant Child as Child element
Parent->>CQ: request_layout()
CQ->>Window: request_layout(style)
Window-->>CQ: measured bounds
CQ->>Builder: render(bounds.size, window, cx)
Builder-->>CQ: child element
CQ->>Child: layout_as_root(bounds.size)
CQ->>Child: prepaint_at(bounds.origin)
CQ->>Child: paint()
Sequence diagram for gesture-aware axis-locked div scrollingsequenceDiagram
actor User
participant Div as Scrollable div
participant Ongoing as OngoingScroll
participant Offset as Scroll offset
User->>Div: ScrollWheelEvent precise delta
Div->>Ongoing: filter(delta, touch_phase)
Ongoing-->>Div: delta filtered to dominant axis
Div->>Div: apply allow_concurrent_scroll and overflow rules
Div->>Offset: update scroll position
User->>Div: Perpendicular delta
Div->>Ongoing: filter(delta, Moved)
Ongoing-->>Div: unlock when ratio >= 1.9 and delta >= 6px
Div->>Offset: apply unlocked delta
Flow diagram for responsive container layout selectionflowchart TD
A[Window resize or layout pass] --> B[container_query measures assigned size]
B --> C{Width below 400px?}
C -->|Yes| D[Build stacked flex-column layout]
C -->|No| E[Build three-column grid layout]
D --> F[Render child contents at measured size]
E --> F
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
cursor
Bot
force-pushed
the
cursor/gpui-container-query-scroll-lock-0066
branch
from
August 29, 2026 09:38
625311a to
bed0bb6
Compare
freefcw
marked this pull request as ready for review
August 29, 2026 09:38
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
cursor
Bot
force-pushed
the
cursor/gpui-container-query-scroll-lock-0066
branch
from
August 29, 2026 09:39
bed0bb6 to
c8c9fd9
Compare
cursor
Bot
force-pushed
the
cursor/gpui-container-query-scroll-lock-0066
branch
from
August 29, 2026 12:06
c8c9fd9 to
12bbb51
Compare
Add a CSS-style container query element whose size comes from its style and the space offered by its parent. Once that size is known, the provided closure builds children from the measured size. Defaults to filling the parent; contents cannot influence the container. Export it from the public facade and adapt the Holy Grail grid_layout example. Zed-Origin: 49ad06c1b4047b018b1622e1cf94cafcacd39247 Co-authored-by: freefcw <freefcw@gmail.com>
Port editor-quality sticky-axis scrolling onto the existing restrict_scroll_to_axis flag. Precise trackpad gestures lock to the axis they start on and only unlock when the opposite axis is strong enough. Line-based wheel remapping and allow_concurrent_scroll keep their previous semantics for callers who already set the style. Zed-Origin: 79cc17c216cf62d5deec7b3eed986d0f652d1c9a Co-authored-by: freefcw <freefcw@gmail.com>
cursor
Bot
force-pushed
the
cursor/gpui-container-query-scroll-lock-0066
branch
from
August 29, 2026 12:53
12bbb51 to
5dac140
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Selective GPUI ports from Zed. Not a wholesale sync.
Rebased onto
develop/0.9atb767199db831b04e78ebd9f8f75c18b4cd8da491after PR #4 merged (Taffy 0.12.2 → 0.13 +grid_cols_max_contenttest). Conflict incrates/gpui/src/elements/div.rstests at the end of the module: #4 appendedgrid_cols_max_content_sizes_columns_to_their_contentafter theshadow_smtest; this PR appendedrestrict_scroll_to_axistests after the same test. Kept both.container_query
Adds
container_query(|size, window, cx| { … }). The element’s size comes from its style plus the parent offer; the closure then builds children from that measured size. Defaults to filling the parent (size_full()), overridable viaStyled. Contents cannot influence the container.crates/gpui/src/elements/container_query.rselements/mod.rsand therefore theadabraka-gpuifacade (same asdiv/list)grid_layoutexample now chooses stacked vs three-column layout from the measured widthCommit:
5c58b4e95dbe0c0fdfc2ff85d88fcb750750f6daZed-Origin:
49ad06c1b4047b018b1622e1cf94cafcacd39247(merge of zed#60774)Axis-locked div scrolling
Ports editor-quality start-axis stick onto the existing
restrict_scroll_to_axis/allow_concurrent_scrollmachinery. Precise (trackpad) gestures lock to the axis they start on and only unlock when the opposite axis is strong enough (1.9×and at least6px).Existing flag semantics are preserved:
style.restrict_scroll_to_axis = Some(true)still get no axis remappingallow_concurrent_scrollstill picks a dominant axis when both deltas are non-zeroAlso adds a fluent
restrict_scroll_to_axis()builder next tooverflow_*_scroll. LocalTouchPhasehas noPartialEq/Cancelled, so gesture end is matched withmatches!(…, Ended).Commit:
5dac1407b64be5fbe353e31ec1e92bca91b7e73eZed-Origin:
79cc17c216cf62d5deec7b3eed986d0f652d1c9a(merge of zed#61797)Skipped upstream hunks
gestures.rs/PlatformGestures/scheduler::Instant— this tree has no gesture arena;OngoingScrolllives next toScrollDeltaininteractive.rsand usesstd::time::InstantTouchPhase::Cancelled— localTouchPhaseisStarted | Moved | Endedonlygpui_platform::applicationin Zed’s grid example — keptApplication::new()Verification
cargo test --locked -p adabraka-gpui-core --lib --features test-support: 227 passedcargo check --locked -p adabraka-gpui --example grid_layout: okcargo fmt --all -- --check: okcargo clippy --locked -p adabraka-gpui-core --lib --tests -- -D warnings: okSourcery 摘要
为 GPUI 添加响应式容器查询和支持手势感知的轴锁定滚动。
新功能:
container_query元素,该元素根据元素的测量尺寸构建其内容,并支持响应式布局。增强功能:
测试:
Original summary in English
Sourcery 摘要
为 GPUI 滚动功能添加响应式容器查询和手势感知的轴锁定。
新功能:
container_query元素,该元素会根据测量到的容器大小重建其内容,并支持显式设置尺寸。增强功能:
测试:
Original summary in English
Sourcery 总结
为 GPUI 添加响应式容器查询,以及支持手势感知的轴锁定滚动功能。
新功能:
container_query元素,根据测量到的尺寸构建响应式内容。增强功能:
测试:
Original summary in English
Sourcery 摘要
为 GPUI 添加响应式容器查询,以及支持手势感知的轴锁定滚动。
新功能:
增强:
测试:
Original summary in English
Sourcery 总结
为 GPUI 添加响应式容器查询,以及支持手势感知的轴锁定滚动。
新功能:
增强功能:
测试:
Original summary in English
Sourcery 摘要
为 GPUI 滚动功能添加响应式容器查询和手势感知的轴锁定。
新功能:
增强功能:
测试:
Original summary in English
Summary by Sourcery
Add responsive container queries and gesture-aware axis locking to GPUI scrolling.
New Features:
Enhancements:
Tests: