Skip to content

Commit 59ee92b

Browse files
authored
improvement(chat): reuse shared overflow fades on scroll edges (#8390)
1 parent 3ab8ed0 commit 59ee92b

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎apps/sim/app/o/[organizationId]/search/search-results-view.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { type ReactNode, useRef } from 'react'
2-
import { cn, scrollFadeAttributes, scrollFadeClass, useScrollEdges } from '@sim/emcn'
2+
import {
3+
cn,
4+
overflowFadeSizeClass,
5+
scrollFadeAttributes,
6+
scrollFadeClass,
7+
useScrollEdges,
8+
} from '@sim/emcn'
39
import { HEADER_ACTION_CLUSTER, PAGE_HEADER_BAR } from '@/components/page-header-bar'
410
import type { WorkspaceSearchFilters } from '@/lib/api/contracts/knowledge'
511
import type { SearchResource } from '@/lib/mothership/generated/resources'
@@ -51,6 +57,7 @@ export function SearchResultsView({
5157
SIDEBAR_DIVIDER_PAD_BELOW_CLASS,
5258
SIDEBAR_DIVIDER_PAD_ABOVE_CLASS,
5359
scrollFadeClass,
60+
overflowFadeSizeClass,
5461
'min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable_both-edges]'
5562
)}
5663
{...scrollFadeAttributes(scrollEdges)}

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ import {
1212
useRef,
1313
useState,
1414
} from 'react'
15-
import { type ClipboardContent, cn } from '@sim/emcn'
15+
import {
16+
type ClipboardContent,
17+
cn,
18+
overflowFadeSizeClass,
19+
scrollFadeAttributes,
20+
scrollFadeClass,
21+
useScrollEdges,
22+
} from '@sim/emcn'
1623
import { useQueryClient } from '@tanstack/react-query'
1724
import { defaultRangeExtractor, type Range, useVirtualizer } from '@tanstack/react-virtual'
1825
import { SMOOTH_CHASE_RATE } from '@/lib/core/utils/smooth-bottom-chase'
@@ -529,6 +536,10 @@ export function MothershipChat({
529536
})
530537

531538
const hasMessages = messages.length > 0
539+
const scrollEdges = useScrollEdges(scrollElementRef, {
540+
contentRef: sizerRef,
541+
enabled: !isLoading || hasMessages,
542+
})
532543

533544
/**
534545
* Keep a bottom-pinned transcript pinned when the scroll container resizes.
@@ -851,7 +862,12 @@ export function MothershipChat({
851862
inputRef={find.inputRef}
852863
/>
853864
)}
854-
<div ref={setScrollElement} className={styles.scrollContainer} onCopy={handleCopy}>
865+
<div
866+
ref={setScrollElement}
867+
className={cn(styles.scrollContainer, scrollFadeClass, overflowFadeSizeClass)}
868+
{...scrollFadeAttributes(scrollEdges)}
869+
onCopy={handleCopy}
870+
>
855871
{isLoading && !hasMessages ? (
856872
<MothershipChatSkeleton layout={layout} />
857873
) : (

0 commit comments

Comments
 (0)