@devries-cameron20 / t3code-1 / commits / cf530050df
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): programmatic scrolls jump instead of glide when Reduce Motion is on (#16014)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Oct 20, 2026 at 07:22 UTC cf530050dfdc9b5bf0e539e26a3382c63f7c594d
5 files changed +74 -20
apps/web/src/components/ChatView.tsx
+4 -2
@@ -4192,7 +4192,9 @@ export default function ChatView(props: ChatViewProps) {
4192 // The anchored end space must be gone before the scroll measures, or the
4193 // list lands short of the real end (#6519).
4194 requestAnimationFrame(() => {
4195 - void legendListRef.current?.scrollToEnd?.({ animated });
4195 + void legendListRef.current?.scrollToEnd?.({
4196 + animated: animated && !window.matchMedia("(prefers-reduced-motion: reduce)").matches,
4197 + });
4198 });
4199 };
4200 const scrollToEndStable = useStableCallback(scrollToEnd);
@@ -4397,7 +4399,7 @@ export default function ChatView(props: ChatViewProps) {
4399 scrollNode.addEventListener("scrollend", finishAnimatedPositioning, { once: true });
4400 void list.scrollToIndex({
4401 index: anchorIndex,
4400 - animated: true,
4402 + animated: !window.matchMedia("(prefers-reduced-motion: reduce)").matches,
4403 viewPosition: 0,
4404 viewOffset: CHAT_LIST_ANCHOR_OFFSET,
4405 });
apps/web/src/components/chat/MessagesTimeline.tsx
+1 -1
@@ -1545,7 +1545,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
1545 onManualNavigation();
1546 void listRef.current?.scrollToIndex({
1547 index: item.rowIndex,
1548 - animated: true,
1548 + animated: !window.matchMedia("(prefers-reduced-motion: reduce)").matches,
1549 viewOffset: 24,
1550 });
1551 }}
apps/web/src/components/chat/pageScrollController.test.ts
+56 -12
@@ -17,6 +17,8 @@ class TestClock {
17 private animationFrames = new Map<number, FrameRequestCallback>();
18 private timeouts = new Map<number, { at: number; callback: () => void }>();
19
20 + reducedMotion = false;
21 +
22 readonly env = {
23 now: () => this.currentTime,
24 requestAnimationFrame: (callback: FrameRequestCallback) => {
@@ -37,6 +39,7 @@ class TestClock {
39 clearTimeout: (handle: number) => {
40 this.timeouts.delete(handle);
41 },
42 + prefersReducedMotion: () => this.reducedMotion,
43 };
44
45 advanceBy(ms: number, frameMs = 16) {
@@ -201,12 +204,12 @@ describe("createPageScrollController", () => {
204 );
205 });
206
204 - test("continues scrolling on hold without repeated keydown events and stops on keyup", () => {
207 + test("uses the current motion preference for page taps in both directions", () => {
208 const clock = new TestClock();
209 const container = {
210 clientHeight: 600,
211 scrollHeight: 4_000,
209 - scrollTop: 0,
212 + scrollTop: 1_200,
213 getBoundingClientRect: () => ({ height: 600 }),
214 };
215 const controller = createPageScrollController({
@@ -214,20 +217,61 @@ describe("createPageScrollController", () => {
217 getScrollPaddingBottomPx: () => 24,
218 env: clock.env,
219 });
217 - controller.handleKeyDown("PageDown");
218 - clock.advanceBy(PAGE_SCROLL_ANIMATION_MS + 50);
220
220 - const afterHoldStarts = container.scrollTop;
221 - clock.advanceBy(200);
221 + for (const reducedMotion of [false, true, false]) {
222 + clock.reducedMotion = reducedMotion;
223 + for (const [key, destination] of [
224 + ["PageDown", 1_740],
225 + ["PageUp", 1_200],
226 + ] as const) {
227 + const start = container.scrollTop;
228 + controller.handleKeyDown(key);
229 + controller.handleKeyUp(key);
230 +
231 + if (!reducedMotion) {
232 + clock.advanceBy(16);
233 + expect(container.scrollTop).toBeGreaterThan(Math.min(start, destination));
234 + expect(container.scrollTop).toBeLessThan(Math.max(start, destination));
235 + clock.advanceBy(PAGE_SCROLL_ANIMATION_MS);
236 + }
237 + expect(container.scrollTop).toBeCloseTo(destination, 5);
238 + clock.advanceBy(PAGE_SCROLL_ANIMATION_MS * 2);
239 + expect(container.scrollTop).toBeCloseTo(destination, 5);
240 + }
241 + }
242 + });
243 +
244 + test.each([false, true])(
245 + "continues scrolling on hold without repeated keydown events and stops on keyup (reduced motion: %s)",
246 + (reducedMotion) => {
247 + const clock = new TestClock();
248 + clock.reducedMotion = reducedMotion;
249 + const container = {
250 + clientHeight: 600,
251 + scrollHeight: 4_000,
252 + scrollTop: 0,
253 + getBoundingClientRect: () => ({ height: 600 }),
254 + };
255 + const controller = createPageScrollController({
256 + getContainer: () => container,
257 + getScrollPaddingBottomPx: () => 24,
258 + env: clock.env,
259 + });
260 + controller.handleKeyDown("PageDown");
261 + clock.advanceBy(PAGE_SCROLL_ANIMATION_MS + 50);
262
223 - expect(container.scrollTop).toBeGreaterThan(afterHoldStarts);
263 + const afterHoldStarts = container.scrollTop;
264 + clock.advanceBy(200);
265
225 - const stoppedAt = container.scrollTop;
226 - controller.handleKeyUp("PageDown");
227 - clock.advanceBy(250);
266 + expect(container.scrollTop).toBeGreaterThan(afterHoldStarts);
267
229 - expect(container.scrollTop).toBe(stoppedAt);
230 - });
268 + const stoppedAt = container.scrollTop;
269 + controller.handleKeyUp("PageDown");
270 + clock.advanceBy(250);
271 +
272 + expect(container.scrollTop).toBe(stoppedAt);
273 + },
274 + );
275
276 test("notifies once when a page scroll starts", () => {
277 const clock = new TestClock();
apps/web/src/components/chat/pageScrollController.ts
+9 -2
@@ -81,6 +81,7 @@ type PageScrollEnv = {
81 cancelAnimationFrame: (handle: number) => void;
82 setTimeout: (callback: () => void, delay: number) => number;
83 clearTimeout: (handle: number) => void;
84 + prefersReducedMotion: () => boolean;
85 };
86
87 function getDefaultEnv(): PageScrollEnv {
@@ -90,6 +91,7 @@ function getDefaultEnv(): PageScrollEnv {
91 cancelAnimationFrame: (handle) => window.cancelAnimationFrame(handle),
92 setTimeout: (callback, delay) => window.setTimeout(callback, delay),
93 clearTimeout: (handle) => window.clearTimeout(handle),
94 + prefersReducedMotion: () => window.matchMedia("(prefers-reduced-motion: reduce)").matches,
95 };
96 }
97
@@ -206,9 +208,14 @@ export function createPageScrollController({
208 state.holdActive = false;
209 };
210
209 - const smoothScrollBy = (container: PageScrollContainer, deltaY: number) => {
211 + const scrollBy = (container: PageScrollContainer, deltaY: number) => {
212 cancelDiscreteAnimation();
213
214 + if (env.prefersReducedMotion()) {
215 + container.scrollTop += deltaY;
216 + return;
217 + }
218 +
219 const startScrollTop = container.scrollTop;
220 const startTime = env.now();
221
@@ -279,7 +286,7 @@ export function createPageScrollController({
286 state.activeKey = key;
287 onScrollStart?.(key);
288
282 - smoothScrollBy(container, readPageScrollDistance(container) * getDirection(key));
289 + scrollBy(container, readPageScrollDistance(container) * getDirection(key));
290
291 state.holdDelayTimeout = env.setTimeout(() => {
292 state.holdDelayTimeout = 0;
apps/web/src/components/settings/ThemeEditorPanel.tsx
+4 -3
@@ -504,9 +504,10 @@ export function ThemeEditorPanel({
504 if (!reveal) return;
505
506 requestAnimationFrame(() => {
507 - panelRef.current
508 - ?.querySelector(`[data-theme-color-role="${visibleRole}"]`)
509 - ?.scrollIntoView({ behavior: "smooth", block: "nearest" });
507 + panelRef.current?.querySelector(`[data-theme-color-role="${visibleRole}"]`)?.scrollIntoView({
508 + behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth",
509 + block: "nearest",
510 + });
511 });
512 };
513