The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): drive FadeScroll's edge fade with scroll-driven CSS
ethernet94b1b6d4221e
diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsxindex c05ba88fad6..e01ad5bf4c7 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx@@ -161,7 +161,7 @@ function ChipPicker({<SearchField onChange={setQuery} placeholder={t.assistant.setupChoose.findApp} value={query} />) : null}<div role="group">- <FadeScroll className="grid grid-cols-3 gap-2 p-1" maxHeight="18rem">+ <FadeScroll className="grid grid-cols-3 gap-2 p-1" fade="1.5rem" maxHeight="18rem" pad="1.5rem">{rows.map((row, index) =>search && !row.label.toLowerCase().includes(search) ? null : (<PickerItem active={cursor === index} className="rounded-[6px]" key={row.id}>diff --git a/apps/desktop/src/components/ui/fade-scroll.tsx b/apps/desktop/src/components/ui/fade-scroll.tsxindex 50a0acc3550..20b761d1432 100644--- a/apps/desktop/src/components/ui/fade-scroll.tsx+++ b/apps/desktop/src/components/ui/fade-scroll.tsx@@ -1,6 +1,5 @@-import { type ReactNode, useCallback, useLayoutEffect, useRef, useState } from 'react'+import { type CSSProperties, type ReactNode, useLayoutEffect, useRef } from 'react'-import { useResizeObserver } from '@/hooks/use-resize-observer'import { cn } from '@/lib/utils'/** How much of a clipped edge the gradient eats. */@@ -42,60 +41,51 @@ export function scrollEdges(el: Pick<HTMLElement, 'clientHeight' | 'scrollHeight* backdrop, inside a widget panel, and in a drawer without knowing any of* their fills. Same technique as FadeText, on the other axis.*- * The gradient is EDGE-AWARE — a side only fades when it actually has content- * clipped behind it, so a list that fits shows no gradient at all and a list- * scrolled to the bottom stops fading its last row. That state is tracked on- * scroll and on resize (via the app's shared observer, so N of these cost one- * delivery per frame rather than N).+ * The gradient is EDGE-AWARE and pure CSS: the `scroll-fade-y` utility+ * (styles.css) drives the mask off the scroller's own scroll position with+ * scroll-driven animations. A side only fades while content is clipped behind+ * it, a list that fits shows no gradient at all, and a list scrolled to the+ * bottom stops fading its last row, with no scroll or resize listener and no+ * React state. A browser without scroll-driven animations (Chromium < 115)+ * shows no fade rather than a broken one.*- * `deps` re-pins the scroller to the bottom when it changes — newest-at-bottom- * feeds want that; a plain list should leave it unset.+ * From each edge inward the mask is `pad` of fully hidden content, then `fade`+ * of gradient. Set `pad` to the scroller's own padding so the gradient starts+ * at the content instead of spending itself on the empty padding. `deps`+ * re-pins the scroller to the bottom when it changes — newest-at-bottom feeds+ * want that; a plain list should leave it unset.*/export function FadeScroll({children,className,deps,- maxHeight = '9rem'+ fade,+ maxHeight = '9rem',+ pad}: {children: ReactNodeclassName?: stringdeps?: unknown+ fade?: stringmaxHeight?: string+ pad?: string}) {const ref = useRef<HTMLDivElement>(null)- const [edges, setEdges] = useState({ above: false, below: false })-- const measure = useCallback(() => {- const el = ref.current-- if (!el) {- return- }-- const next = scrollEdges(el)-- setEdges(prev => (prev.above === next.above && prev.below === next.below ? prev : next))- }, [])useLayoutEffect(() => {if (deps !== undefined && ref.current) {ref.current.scrollTop = ref.current.scrollHeight}+ }, [deps])- measure()- }, [deps, measure])-- useResizeObserver(measure, ref)-- const mask = edgeMask(edges)+ const style = {+ maxHeight,+ ...(fade ? { '--scroll-fade-size': fade } : {}),+ ...(pad ? { '--scroll-fade-pad': pad } : {})+ } as CSSPropertiesreturn (- <div- className={cn('overflow-y-auto overscroll-contain', className)}- onScroll={measure}- ref={ref}- style={mask ? { maskImage: mask, maxHeight, WebkitMaskImage: mask } : { maxHeight }}- >+ <div className={cn('scroll-fade-y overflow-y-auto overscroll-contain', className)} ref={ref} style={style}>{children}</div>)diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex 33b50a08214..219de061127 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -1102,6 +1102,62 @@}}+/* Pure-CSS edge fade for a scroller (FadeScroll). From each edge inward the+ mask is `pad` of fully hidden content, then `size` of gradient up to fully+ visible. The pad is for the scroller's own padding, so the gradient starts+ at the content instead of spending itself on empty space. Both lengths are+ scaled by a 0..1 progress that the scroller's own scroll position animates+ (scroll-driven animations, Chromium 115+), so an edge only fades while+ content is clipped behind it: progress rests at 0, so a list that fits+ (inactive timeline, no animation) and a browser without support are never+ dimmed. The progress is a registered <number> so the keyframes can+ interpolate it, and an edge is fully faded in once `pad + size` px have+ been scrolled. */+@property --scroll-fade-top {+ syntax: '<number>';+ initial-value: 0;+ inherits: false;+}++@property --scroll-fade-bottom {+ syntax: '<number>';+ initial-value: 0;+ inherits: false;+}++@keyframes scroll-fade-top {+ to {+ --scroll-fade-top: 1;+ }+}++@keyframes scroll-fade-bottom {+ from {+ --scroll-fade-bottom: 1;+ }+}++@utility scroll-fade-y {+ --scroll-fade-size: 1.25rem;+ --scroll-fade-pad: 0px;++ mask-image: linear-gradient(+ to bottom,+ transparent calc(var(--scroll-fade-pad) * var(--scroll-fade-top)),+ #000 calc((var(--scroll-fade-pad) + var(--scroll-fade-size)) * var(--scroll-fade-top)),+ #000 calc(100% - (var(--scroll-fade-pad) + var(--scroll-fade-size)) * var(--scroll-fade-bottom)),+ transparent calc(100% - var(--scroll-fade-pad) * var(--scroll-fade-bottom))+ );+ animation:+ scroll-fade-top linear both,+ scroll-fade-bottom linear both;+ /* After the shorthand: it resets the timeline. */+ animation-timeline: scroll(self y), scroll(self y);+ animation-range:+ 0 calc(var(--scroll-fade-pad) + var(--scroll-fade-size)),+ calc(100% - var(--scroll-fade-pad) - var(--scroll-fade-size)) 100%;+}+/* The guided-onboarding thread is marked with [data-thread-type='onboarding']— the hook for onboarding-only transcript styling. */