From e5bb5706500c7d4b7e72e9ce6434c7d303363673 Mon Sep 17 00:00:00 2001 From: bkellam Date: Thu, 23 Oct 2025 12:49:57 -0700 Subject: [PATCH] more cleanup --- .../components/searchModeSelector.tsx | 12 ++-- .../web/src/app/[domain]/repos/[id]/page.tsx | 2 +- ...{repo-jobs-table.tsx => repoJobsTable.tsx} | 27 ++++++-- .../{repos-table.tsx => reposTable.tsx} | 61 ++++++++++++++----- packages/web/src/app/[domain]/repos/page.tsx | 5 +- packages/web/src/components/ui/select.tsx | 26 +++++++- 6 files changed, 102 insertions(+), 31 deletions(-) rename packages/web/src/app/[domain]/repos/components/{repo-jobs-table.tsx => repoJobsTable.tsx} (90%) rename packages/web/src/app/[domain]/repos/components/{repos-table.tsx => reposTable.tsx} (81%) diff --git a/packages/web/src/app/[domain]/components/searchModeSelector.tsx b/packages/web/src/app/[domain]/components/searchModeSelector.tsx index e615ac8c..cf63f734 100644 --- a/packages/web/src/app/[domain]/components/searchModeSelector.tsx +++ b/packages/web/src/app/[domain]/components/searchModeSelector.tsx @@ -2,7 +2,7 @@ import { KeyboardShortcutHint } from "@/app/components/keyboardShortcutHint"; import { useDomain } from "@/hooks/useDomain"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Select, SelectContent, SelectItemNoItemText, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Separator } from "@/components/ui/separator"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; @@ -87,7 +87,7 @@ export const SearchModeSelector = ({ onMouseEnter={() => setFocusedSearchMode("precise")} onFocus={() => setFocusedSearchMode("precise")} > - @@ -99,7 +99,7 @@ export const SearchModeSelector = ({ - + setFocusedSearchMode("agentic")} onFocus={() => setFocusedSearchMode("agentic")} > - @@ -138,7 +138,7 @@ export const SearchModeSelector = ({ - + @@ -167,5 +167,3 @@ export const SearchModeSelector = ({ ) } - - diff --git a/packages/web/src/app/[domain]/repos/[id]/page.tsx b/packages/web/src/app/[domain]/repos/[id]/page.tsx index 4dd48e25..dd473c66 100644 --- a/packages/web/src/app/[domain]/repos/[id]/page.tsx +++ b/packages/web/src/app/[domain]/repos/[id]/page.tsx @@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Skeleton } from "@/components/ui/skeleton" -import { RepoJobsTable } from "../components/repo-jobs-table" +import { RepoJobsTable } from "../components/repoJobsTable" import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants" import { sew } from "@/actions" import { withOptionalAuthV2 } from "@/withAuthV2" diff --git a/packages/web/src/app/[domain]/repos/components/repo-jobs-table.tsx b/packages/web/src/app/[domain]/repos/components/repoJobsTable.tsx similarity index 90% rename from packages/web/src/app/[domain]/repos/components/repo-jobs-table.tsx rename to packages/web/src/app/[domain]/repos/components/repoJobsTable.tsx index 5e18c6a3..ef14d6dd 100644 --- a/packages/web/src/app/[domain]/repos/components/repo-jobs-table.tsx +++ b/packages/web/src/app/[domain]/repos/components/repoJobsTable.tsx @@ -21,6 +21,9 @@ import { cva } from "class-variance-authority" import { AlertCircle, ArrowUpDown } from "lucide-react" import * as React from "react" import { CopyIconButton } from "../../components/copyIconButton" +import { useMemo } from "react" + +// @see: https://v0.app/chat/repo-indexing-status-uhjdDim8OUS export type RepoIndexingJob = { id: string @@ -189,6 +192,20 @@ export const RepoJobsTable = ({ data }: { data: RepoIndexingJob[] }) => { }, }) + const { + numCompleted, + numInProgress, + numPending, + numFailed, + } = useMemo(() => { + return { + numCompleted: data.filter((job) => job.status === "COMPLETED").length, + numInProgress: data.filter((job) => job.status === "IN_PROGRESS").length, + numPending: data.filter((job) => job.status === "PENDING").length, + numFailed: data.filter((job) => job.status === "FAILED").length, + }; + }, [data]); + return (
@@ -200,11 +217,11 @@ export const RepoJobsTable = ({ data }: { data: RepoIndexingJob[] }) => { - All statuses - Pending - In Progress - Completed - Failed + Filter by status + Completed ({numCompleted}) + In progress ({numInProgress}) + Pending ({numPending}) + Failed ({numFailed}) diff --git a/packages/web/src/app/[domain]/repos/components/repos-table.tsx b/packages/web/src/app/[domain]/repos/components/reposTable.tsx similarity index 81% rename from packages/web/src/app/[domain]/repos/components/repos-table.tsx rename to packages/web/src/app/[domain]/repos/components/reposTable.tsx index b7265af0..b48bb39c 100644 --- a/packages/web/src/app/[domain]/repos/components/repos-table.tsx +++ b/packages/web/src/app/[domain]/repos/components/reposTable.tsx @@ -14,7 +14,7 @@ import { Input } from "@/components/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants" -import { getRepoImageSrc } from "@/lib/utils" +import { getCodeHostInfoForRepo, getRepoImageSrc } from "@/lib/utils" import { type ColumnDef, type ColumnFiltersState, @@ -31,7 +31,10 @@ import { cva } from "class-variance-authority" import { ArrowUpDown, ExternalLink, MoreHorizontal } from "lucide-react" import Image from "next/image" import Link from "next/link" -import * as React from "react" +import { useMemo, useState } from "react" +import { getBrowsePath } from "../../browse/hooks/utils" + +// @see: https://v0.app/chat/repo-indexing-status-uhjdDim8OUS export type Repo = { id: number @@ -42,6 +45,7 @@ export type Repo = { indexedAt: Date | null createdAt: Date webUrl: string | null + codeHostType: string imageUrl: string | null latestJobStatus: "PENDING" | "IN_PROGRESS" | "COMPLETED" | "FAILED" | null } @@ -112,7 +116,12 @@ export const columns: ColumnDef[] = [ {repo.displayName?.charAt(0) ?? repo.name.charAt(0)}
)} - + {repo.displayName || repo.name}
@@ -141,6 +150,12 @@ export const columns: ColumnDef[] = [ enableHiding: false, cell: ({ row }) => { const repo = row.original + const codeHostInfo = getCodeHostInfoForRepo({ + codeHostType: repo.codeHostType, + name: repo.name, + displayName: repo.displayName ?? undefined, + webUrl: repo.webUrl ?? undefined, + }); return ( @@ -155,12 +170,12 @@ export const columns: ColumnDef[] = [ View details - {repo.webUrl && ( + {(repo.webUrl && codeHostInfo) && ( <> - Open in GitHub + Open in {codeHostInfo.codeHostName} @@ -174,10 +189,26 @@ export const columns: ColumnDef[] = [ ] export const ReposTable = ({ data }: { data: Repo[] }) => { - const [sorting, setSorting] = React.useState([]) - const [columnFilters, setColumnFilters] = React.useState([]) - const [columnVisibility, setColumnVisibility] = React.useState({}) - const [rowSelection, setRowSelection] = React.useState({}) + const [sorting, setSorting] = useState([]) + const [columnFilters, setColumnFilters] = useState([]) + const [columnVisibility, setColumnVisibility] = useState({}) + const [rowSelection, setRowSelection] = useState({}) + + const { + numCompleted, + numInProgress, + numPending, + numFailed, + numNoJobs, + } = useMemo(() => { + return { + numCompleted: data.filter((repo) => repo.latestJobStatus === "COMPLETED").length, + numInProgress: data.filter((repo) => repo.latestJobStatus === "IN_PROGRESS").length, + numPending: data.filter((repo) => repo.latestJobStatus === "PENDING").length, + numFailed: data.filter((repo) => repo.latestJobStatus === "FAILED").length, + numNoJobs: data.filter((repo) => repo.latestJobStatus === null).length, + } + }, [data]); const table = useReactTable({ data, @@ -217,12 +248,12 @@ export const ReposTable = ({ data }: { data: Repo[] }) => { - All Statuses - Completed - In Progress - Pending - Failed - No Jobs + Filter by status + Completed ({numCompleted}) + In progress ({numInProgress}) + Pending ({numPending}) + Failed ({numFailed}) + No status ({numNoJobs}) diff --git a/packages/web/src/app/[domain]/repos/page.tsx b/packages/web/src/app/[domain]/repos/page.tsx index 6769f119..322dd186 100644 --- a/packages/web/src/app/[domain]/repos/page.tsx +++ b/packages/web/src/app/[domain]/repos/page.tsx @@ -2,7 +2,7 @@ import { sew } from "@/actions"; import { ServiceErrorException } from "@/lib/serviceError"; import { isServiceError } from "@/lib/utils"; import { withOptionalAuthV2 } from "@/withAuthV2"; -import { ReposTable } from "./components/repos-table"; +import { ReposTable } from "./components/reposTable"; export default async function ReposPage() { @@ -27,7 +27,8 @@ export default async function ReposPage() { createdAt: repo.createdAt, webUrl: repo.webUrl, imageUrl: repo.imageUrl, - latestJobStatus: repo.jobs.length > 0 ? repo.jobs[0].status : null + latestJobStatus: repo.jobs.length > 0 ? repo.jobs[0].status : null, + codeHostType: repo.external_codeHostType, }))} /> ) diff --git a/packages/web/src/components/ui/select.tsx b/packages/web/src/components/ui/select.tsx index f28b0b86..9a6cd13f 100644 --- a/packages/web/src/components/ui/select.tsx +++ b/packages/web/src/components/ui/select.tsx @@ -129,11 +129,34 @@ const SelectItem = React.forwardRef< - {children} + {children} )) SelectItem.displayName = SelectPrimitive.Item.displayName +const SelectItemNoItemText = React.forwardRef< +React.ElementRef, +React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + + + + + {children} + +)) +SelectItemNoItemText.displayName = SelectPrimitive.Item.displayName + const SelectSeparator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef @@ -154,6 +177,7 @@ export { SelectContent, SelectLabel, SelectItem, + SelectItemNoItemText, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton,