Repository navigation
fix(scroll): clamp WebDriver and HarmonyOS swipes inside the container - #4554
aribaskagan wants to merge 2 commits into
Conversation
Directional scroll on those owners ignored containerRect, so a swipe could start or end outside the resolved list. The shared planner now shortens that gesture and reports the dispatched distance beside the requested one.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
All reported issues were addressed across 5 files
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
|
Thanks for this. At c03127a the clamp logic looks right for WebDriver, but the HarmonyOS route still sends the swipe in the wrong coordinate frame, and its only regression test locks that in. The check run is green (one check, none failing), but no CI lane has a HarmonyOS device, so it does not cover the changed device path. Before merge, fix the Harmony translate-out and add one live run. The test 'translates an offset window into the swipe frame before clamping' in https://github.com/callstack/agent-device/blob/c03127a/packages/platform-harmonyos/src/__tests__/input-actions.test.ts#L154 adds OFFSET_WINDOW.x/y back to the dispatched swipe before it checks the swipe is inside the container. That asserts the coordinates sent to The frame rule now has several owners. This changes swipe dispatch on two backends, and the PR body says no live WebDriver grid or HarmonyOS device was used. Every test uses a stubbed client or a mocked Could the planner take a The open inline thread on the Harmony translate-out (#4554 (comment)) still applies and matches the first finding above. Not blocking, and fine to take or leave: I did not run the tests, so the author's 3 failed / 8 passed before-the-fix count is unverified. I also could not confirm that a HarmonyOS Application rect has a non-zero origin on shipping hardware, so the reach of the translate-out problem is limited to non-origin windows. I did not trace repeated |
HarmonyOS translated the container into a zero-origin frame and then sent those local endpoints to hdc, which takes screen coordinates. The planner now accepts the frame origin, plans in that zero-origin frame, and returns absolute endpoints, so HarmonyOS, WebDriver, and Android dispatch the plan instead of translating it themselves.
There was a problem hiding this comment.
1 issue found across 7 files (changes from recent commits).
You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/contracts/src/scroll-gesture.ts">
<violation number="1" location="packages/contracts/src/scroll-gesture.ts:158">
P2: When the cross-axis band is empty, `keepSwipeInContainer` returns the padded lane without applying the scrolled-axis clamp. A narrow container (under about 17px across) can therefore receive a swipe that starts outside its vertical range. Keep the axis clamp and fall back only the cross coordinate, or document this case explicitly.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| const crossPadding = scrollEdgePadding(crossLength); | ||
| const lane = options.container | ||
| ? keepSwipeInContainer(unclamped, options.container, vertical, { | ||
| const lane = container |
There was a problem hiding this comment.
P2: When the cross-axis band is empty, keepSwipeInContainer returns the padded lane without applying the scrolled-axis clamp. A narrow container (under about 17px across) can therefore receive a swipe that starts outside its vertical range. Keep the axis clamp and fall back only the cross coordinate, or document this case explicitly.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/contracts/src/scroll-gesture.ts, line 158:
<comment>When the cross-axis band is empty, `keepSwipeInContainer` returns the padded lane without applying the scrolled-axis clamp. A narrow container (under about 17px across) can therefore receive a swipe that starts outside its vertical range. Keep the axis clamp and fall back only the cross coordinate, or document this case explicitly.</comment>
<file context>
@@ -138,8 +155,8 @@ export function buildScrollGesturePlan(options: ScrollGestureOptions): ScrollGes
const crossPadding = scrollEdgePadding(crossLength);
- const lane = options.container
- ? keepSwipeInContainer(unclamped, options.container, vertical, {
+ const lane = container
+ ? keepSwipeInContainer(unclamped, container, vertical, {
axis: { min: edgePadding, max: axisLength - edgePadding },
</file context>
|
Thanks for the review. Pushed ed6665a on top of c03127a. HarmonyOS now sends screen coordinates. The test is now Android and WebDriver pass the same origin and absolute container and dispatch the plan's endpoints, so the Harmony and Android No live WebDriver grid or HarmonyOS device was available, so there is no live run. That remains an unresolved risk; the tests use a mocked
|
|
Thanks for the update. At ed6665a the Harmony path now passes the Application origin and dispatches the planner's absolute endpoints, and the offset-window test checks the raw points against the absolute container, so that earlier gap is fixed. One thing still needs live evidence before merge. The change alters the swipe coordinates sent on real device paths (input-actions.ts#L61). Harmony now sends Application-origin-shifted screen coordinates to The review thread on the empty cross band (#4554 (comment)) still applies. It only reaches sliver-width containers, so it is not blocking. The thread on Harmony origin (#4554 (comment)) no longer applies because Not blocking, take or leave: the changeset and the PR body Summary do not say that an unclamped HarmonyOS scroll in a non-origin Application window now dispatches screen coordinates instead of window-local ones, so one clause in the changeset plus a refreshed Validation SHA when you add the live evidence would cover it. CI shows one check, passing. It only runs unit tests with mocked Harmony and WebDriver clients, so no CI lane exercises these device paths. No conflicts. Merge needs the live run above. |
Summary
WebDriver and HarmonyOS directional scrolls ignored
containerRect, so a swipe could start or end outside the resolved list. Both owners now convert that rect into the swipe frame and clamp it withbuildScrollGesturePlan. A shortened swipe reportspixels(dispatched) besiderequestedPixels. A span that already fits, and a scroll with no container, stay unchanged.Part of #2714 (WebDriver + HarmonyOS slice; Android done in #3746, local iOS runner left out since it plans in Swift).
AI assistance (Cursor) was used to prepare this change; I reviewed and tested it.
Validation
Tested SHA
c03127a4958a7b0aecff57f6525f03e6ba3f6c4c, based78be6c88715ad80fc658497f23f91c86bf9489b.pnpm exec vitest run --project unit-coreon the two scroll test files: 3 failed, 8 passed (inset-container swipes ended outside the list). After: 11 passed.pnpm check:affected --run --head c03127a4958a7b0aecff57f6525f03e6ba3f6c4cpassed (format, lint, typecheck, layering, fallow, build, vitest-related, unit).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.