updated header for chunks page

This commit is contained in:
Brent O'Neill 2025-09-19 12:16:20 -06:00
parent 2cd286de97
commit 99bf3772b5

View file

@ -1,8 +1,10 @@
"use client"; "use client";
import { import {
ArrowLeft,
Building2, Building2,
Cloud, Cloud,
File as FileIcon,
FileText, FileText,
HardDrive, HardDrive,
Loader2, Loader2,
@ -21,6 +23,9 @@ import {
type File, type File,
useGetSearchQuery, useGetSearchQuery,
} from "../../api/queries/useGetSearchQuery"; } from "../../api/queries/useGetSearchQuery";
import { Label } from "@/components/ui/label";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
// Function to get the appropriate icon for a connector type // Function to get the appropriate icon for a connector type
function getSourceIcon(connectorType?: string) { function getSourceIcon(connectorType?: string) {
@ -47,9 +52,14 @@ function ChunksPageContent() {
const filename = searchParams.get("filename"); const filename = searchParams.get("filename");
const [chunks, setChunks] = useState<ChunkResult[]>([]); const [chunks, setChunks] = useState<ChunkResult[]>([]);
const [selectAll, setSelectAll] = useState(false);
const [queryInputText, setQueryInputText] = useState(
parsedFilterData?.query ?? ""
);
// Use the same search query as the knowledge page, but we'll filter for the specific file // Use the same search query as the knowledge page, but we'll filter for the specific file
const { data = [], isFetching } = useGetSearchQuery("*", parsedFilterData); const { data = [], isFetching } = useGetSearchQuery("*", parsedFilterData);
console.log({ data });
// Extract chunks for the specific file // Extract chunks for the specific file
useEffect(() => { useEffect(() => {
if (!filename || !(data as File[]).length) { if (!filename || !(data as File[]).length) {
@ -98,30 +108,53 @@ function ChunksPageContent() {
> >
<div className="flex-1 flex flex-col min-h-0 px-6 py-6"> <div className="flex-1 flex flex-col min-h-0 px-6 py-6">
{/* Header */} {/* Header */}
<div className="flex items-center justify-between mb-6"> <div className="flex flex-col mb-6">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3 mb-2">
<Button <Button variant="ghost" onClick={handleBack}>
variant="ghost" <ArrowLeft size={18} />
size="sm" <FileIcon className="text-muted-foreground" size={18} />
onClick={handleBack} <h1 className="text-lg font-semibold">
className="text-muted-foreground hover:text-foreground px-2" {filename.replace(/\.[^/.]+$/, "")}
> </h1>
Back
</Button> </Button>
<div className="flex flex-col"> </div>
<h2 className="text-lg font-semibold">Document Chunks</h2> <div className="flex items-center gap-3 pl-6 mt-2">
<p className="text-sm text-muted-foreground truncate max-w-md"> <div className="flex items-center gap-2">
{decodeURIComponent(filename)} <Checkbox
</p> id="selectAllChunks"
checked={selectAll}
onCheckedChange={(checked) => setSelectAll(checked === true)}
/>
<Label
htmlFor="selectAllChunks"
className="font-medium text-muted-foreground whitespace-nowrap"
>
Select all
</Label>
</div>
<div className="flex-1 flex items-center gap-2">
<Input
name="search-query"
id="search-query"
type="text"
defaultValue={parsedFilterData?.query}
value={queryInputText}
onChange={(e) => setQueryInputText(e.target.value)}
placeholder="Search chunks..."
className="flex-1 bg-muted/20 rounded-lg border border-border/50 px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring"
/>
<Button variant="outline" size="sm">
<Search />
</Button>
</div> </div>
</div> </div>
<div className="text-sm text-muted-foreground"> {/* <div className="text-sm text-muted-foreground">
{!isFetching && chunks.length > 0 && ( {!isFetching && chunks.length > 0 && (
<span> <span>
{chunks.length} chunk{chunks.length !== 1 ? "s" : ""} found {chunks.length} chunk{chunks.length !== 1 ? "s" : ""} found
</span> </span>
)} )}
</div> </div> */}
</div> </div>
{/* Content Area - matches knowledge page structure */} {/* Content Area - matches knowledge page structure */}