Skip to content

Commit 74376c0

Browse files
Add skeletons to filter panel when search is streaming
1 parent b09def9 commit 74376c0

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

packages/web/src/app/[domain]/search/components/filterPanel/filter.tsx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { compareEntries, Entry } from "./entry";
55
import { Input } from "@/components/ui/input";
66
import Fuse from "fuse.js";
77
import { cn } from "@/lib/utils"
8+
import { Skeleton } from "@/components/ui/skeleton";
89

910
interface FilterProps {
1011
title: string,
1112
searchPlaceholder: string,
1213
entries: Entry[],
1314
onEntryClicked: (key: string) => void,
1415
className?: string,
16+
isStreaming: boolean,
1517
}
1618

1719
export const Filter = ({
@@ -20,6 +22,7 @@ export const Filter = ({
2022
entries,
2123
onEntryClicked,
2224
className,
25+
isStreaming,
2326
}: FilterProps) => {
2427
const [searchFilter, setSearchFilter] = useState<string>("");
2528

@@ -43,27 +46,34 @@ export const Filter = ({
4346
className
4447
)}>
4548
<h2 className="text-sm font-semibold">{title}</h2>
46-
<div className="pr-1">
47-
<Input
48-
placeholder={searchPlaceholder}
49-
className="h-8"
50-
onChange={(event) => setSearchFilter(event.target.value)}
51-
/>
52-
</div>
53-
54-
<div
55-
className="flex flex-col gap-0.5 text-sm overflow-scroll no-scrollbar"
56-
>
57-
{filteredEntries
58-
.sort((entryA, entryB) => compareEntries(entryB, entryA))
59-
.map((entry) => (
60-
<Entry
61-
key={entry.key}
62-
entry={entry}
63-
onClicked={() => onEntryClicked(entry.key)}
49+
{(isStreaming && entries.length === 0) ? (
50+
<Skeleton className="h-12 w-full" />
51+
) : (
52+
<>
53+
<div className="pr-1">
54+
<Input
55+
placeholder={searchPlaceholder}
56+
className="h-8"
57+
onChange={(event) => setSearchFilter(event.target.value)}
6458
/>
65-
))}
66-
</div>
59+
</div>
60+
61+
<div
62+
className="flex flex-col gap-0.5 text-sm overflow-scroll no-scrollbar"
63+
>
64+
{filteredEntries
65+
.sort((entryA, entryB) => compareEntries(entryB, entryA))
66+
.map((entry) => (
67+
<Entry
68+
key={entry.key}
69+
entry={entry}
70+
onClicked={() => onEntryClicked(entry.key)}
71+
/>
72+
))}
73+
</div>
74+
</>
75+
)}
76+
6777
</div>
6878
)
6979
}

packages/web/src/app/[domain]/search/components/filterPanel/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface FilePanelProps {
1616
matches: SearchResultFile[];
1717
repoInfo: Record<number, RepositoryInfo>;
1818
onFilterChange?: () => void;
19+
isStreaming: boolean;
1920
}
2021

2122
/**
@@ -33,11 +34,13 @@ interface FilePanelProps {
3334
* @param matches - Array of search result files to filter
3435
* @param repoInfo - Information about repositories including their display names and icons
3536
* @param onFilterChange - Optional callback that is called whenever a filter is applied or removed
37+
* @param isStreaming - Whether the search is streaming
3638
*/
3739
export const FilterPanel = ({
3840
matches,
3941
repoInfo,
4042
onFilterChange,
43+
isStreaming,
4144
}: FilePanelProps) => {
4245
const router = useRouter();
4346
const searchParams = useSearchParams();
@@ -155,6 +158,7 @@ export const FilterPanel = ({
155158
}
156159
}}
157160
className="max-h-[50%]"
161+
isStreaming={isStreaming}
158162
/>
159163
<Filter
160164
title="Filter By Language"
@@ -178,6 +182,7 @@ export const FilterPanel = ({
178182
}
179183
}}
180184
className="overflow-auto"
185+
isStreaming={isStreaming}
181186
/>
182187
</div>
183188
)

packages/web/src/app/[domain]/search/components/searchResultsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ const PanelGroup = ({
249249
<FilterPanel
250250
matches={fileMatches}
251251
repoInfo={repoInfo}
252+
isStreaming={isStreaming}
252253
onFilterChange={() => {
253254
searchResultsPanelRef.current?.resetScroll();
254255
}}

0 commit comments

Comments
 (0)