batch processing
This commit is contained in:
parent
9dd1b7a36e
commit
8227cabd17
44
orchestrator/package-lock.json
generated
44
orchestrator/package-lock.json
generated
@ -9,6 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||||
|
"@radix-ui/react-checkbox": "^1.3.2",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||||
"@radix-ui/react-progress": "^1.1.8",
|
"@radix-ui/react-progress": "^1.1.8",
|
||||||
"@radix-ui/react-separator": "^1.1.8",
|
"@radix-ui/react-separator": "^1.1.8",
|
||||||
@ -1392,6 +1393,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-checkbox": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.3.tgz",
|
||||||
|
"integrity": "sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/primitive": "1.1.3",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.2",
|
||||||
|
"@radix-ui/react-context": "1.1.2",
|
||||||
|
"@radix-ui/react-presence": "1.1.5",
|
||||||
|
"@radix-ui/react-primitive": "2.1.3",
|
||||||
|
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||||
|
"@radix-ui/react-use-previous": "1.1.1",
|
||||||
|
"@radix-ui/react-use-size": "1.1.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-collection": {
|
"node_modules/@radix-ui/react-collection": {
|
||||||
"version": "1.1.7",
|
"version": "1.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",
|
||||||
@ -2068,6 +2098,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-use-previous": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-use-rect": {
|
"node_modules/@radix-ui/react-use-rect": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz",
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
"pipeline:run": "tsx src/server/pipeline/run.ts"
|
"pipeline:run": "tsx src/server/pipeline/run.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@radix-ui/react-checkbox": "^1.3.2",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-progress": "^1.1.8",
|
"@radix-ui/react-progress": "^1.1.8",
|
||||||
|
|||||||
@ -25,9 +25,9 @@ import { StatusBadge } from "./StatusBadge";
|
|||||||
|
|
||||||
interface JobCardProps {
|
interface JobCardProps {
|
||||||
job: Job;
|
job: Job;
|
||||||
onApply: (id: string) => void;
|
onApply: (id: string) => void | Promise<void>;
|
||||||
onReject: (id: string) => void;
|
onReject: (id: string) => void | Promise<void>;
|
||||||
onProcess: (id: string) => void;
|
onProcess: (id: string) => void | Promise<void>;
|
||||||
isProcessing: boolean;
|
isProcessing: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import React, { useEffect, useMemo, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { ArrowUpDown, LayoutGrid, Search, Table2 } from "lucide-react";
|
import { ArrowUpDown, LayoutGrid, Search, Table2 } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
@ -26,9 +27,9 @@ import { JobTable, type JobSort } from "./JobTable";
|
|||||||
|
|
||||||
interface JobListProps {
|
interface JobListProps {
|
||||||
jobs: Job[];
|
jobs: Job[];
|
||||||
onApply: (id: string) => void;
|
onApply: (id: string) => void | Promise<void>;
|
||||||
onReject: (id: string) => void;
|
onReject: (id: string) => void | Promise<void>;
|
||||||
onProcess: (id: string) => void;
|
onProcess: (id: string) => void | Promise<void>;
|
||||||
processingJobId: string | null;
|
processingJobId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +180,8 @@ export const JobList: React.FC<JobListProps> = ({
|
|||||||
const [activeTab, setActiveTab] = useState<FilterTab>("ready");
|
const [activeTab, setActiveTab] = useState<FilterTab>("ready");
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [sort, setSort] = useState<JobSort>(DEFAULT_SORT);
|
const [sort, setSort] = useState<JobSort>(DEFAULT_SORT);
|
||||||
|
const [selectedJobIds, setSelectedJobIds] = useState<Set<string>>(() => new Set());
|
||||||
|
const [batchAction, setBatchAction] = useState<null | "process" | "reject" | "apply">(null);
|
||||||
const [viewMode, setViewMode] = useState<ViewMode>(() => {
|
const [viewMode, setViewMode] = useState<ViewMode>(() => {
|
||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem(JOB_LIST_VIEW_STORAGE_KEY);
|
const raw = localStorage.getItem(JOB_LIST_VIEW_STORAGE_KEY);
|
||||||
@ -197,6 +200,10 @@ export const JobList: React.FC<JobListProps> = ({
|
|||||||
}
|
}
|
||||||
}, [viewMode]);
|
}, [viewMode]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSelectedJobIds(new Set());
|
||||||
|
}, [activeTab, viewMode]);
|
||||||
|
|
||||||
const counts = useMemo(() => {
|
const counts = useMemo(() => {
|
||||||
const byTab: Record<FilterTab, number> = {
|
const byTab: Record<FilterTab, number> = {
|
||||||
ready: 0,
|
ready: 0,
|
||||||
@ -242,12 +249,63 @@ export const JobList: React.FC<JobListProps> = ({
|
|||||||
return map;
|
return map;
|
||||||
}, [jobsForTab, searchQuery, sort]);
|
}, [jobsForTab, searchQuery, sort]);
|
||||||
|
|
||||||
|
const activeTabJobs = visibleJobsForTab.get(activeTab) ?? [];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSelectedJobIds((current) => {
|
||||||
|
const visibleIds = new Set(activeTabJobs.map((job) => job.id));
|
||||||
|
const next = new Set<string>();
|
||||||
|
for (const id of current) {
|
||||||
|
if (visibleIds.has(id)) next.add(id);
|
||||||
|
}
|
||||||
|
return next.size === current.size ? current : next;
|
||||||
|
});
|
||||||
|
}, [activeTabJobs]);
|
||||||
|
|
||||||
const activeResultsCount = visibleJobsForTab.get(activeTab)?.length ?? 0;
|
const activeResultsCount = visibleJobsForTab.get(activeTab)?.length ?? 0;
|
||||||
const hasActiveFilters =
|
const hasActiveFilters =
|
||||||
searchQuery.trim().length > 0 ||
|
searchQuery.trim().length > 0 ||
|
||||||
sort.key !== DEFAULT_SORT.key ||
|
sort.key !== DEFAULT_SORT.key ||
|
||||||
sort.direction !== DEFAULT_SORT.direction;
|
sort.direction !== DEFAULT_SORT.direction;
|
||||||
|
|
||||||
|
const selectedJobs = useMemo(() => {
|
||||||
|
if (selectedJobIds.size === 0) return [];
|
||||||
|
return activeTabJobs.filter((job) => selectedJobIds.has(job.id));
|
||||||
|
}, [activeTabJobs, selectedJobIds]);
|
||||||
|
|
||||||
|
const selectedCount = selectedJobIds.size;
|
||||||
|
|
||||||
|
const runBatch = async (action: "process" | "reject" | "apply") => {
|
||||||
|
if (selectedJobs.length === 0) return;
|
||||||
|
|
||||||
|
const eligible = selectedJobs.filter((job) => {
|
||||||
|
if (action === "process") return job.status === "discovered";
|
||||||
|
if (action === "apply") return job.status === "ready";
|
||||||
|
return job.status === "discovered" || job.status === "ready";
|
||||||
|
});
|
||||||
|
|
||||||
|
const skipped = selectedJobs.length - eligible.length;
|
||||||
|
if (eligible.length === 0) {
|
||||||
|
toast.message("No eligible jobs selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBatchAction(action);
|
||||||
|
try {
|
||||||
|
for (const job of eligible) {
|
||||||
|
if (action === "process") await Promise.resolve(onProcess(job.id));
|
||||||
|
if (action === "apply") await Promise.resolve(onApply(job.id));
|
||||||
|
if (action === "reject") await Promise.resolve(onReject(job.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedJobIds(new Set());
|
||||||
|
const actionLabel = action === "process" ? "Processed" : action === "apply" ? "Applied" : "Skipped";
|
||||||
|
toast.success(`${actionLabel} ${eligible.length} jobs`, skipped > 0 ? { description: `Skipped ${skipped} ineligible.` } : undefined);
|
||||||
|
} finally {
|
||||||
|
setBatchAction(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
value={activeTab}
|
value={activeTab}
|
||||||
@ -387,19 +445,65 @@ export const JobList: React.FC<JobListProps> = ({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{viewMode === "table" ? (
|
{viewMode === "table" ? (
|
||||||
<Card>
|
<div className="space-y-2">
|
||||||
<CardContent className="p-0">
|
{tab.id === activeTab && selectedCount > 0 && (
|
||||||
<JobTable
|
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/20 px-3 py-2">
|
||||||
jobs={filteredJobs}
|
<div className="text-sm">
|
||||||
sort={sort}
|
<span className="font-medium">{selectedCount}</span>{" "}
|
||||||
onSortChange={setSort}
|
<span className="text-muted-foreground">selected</span>
|
||||||
onApply={onApply}
|
</div>
|
||||||
onReject={onReject}
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
onProcess={onProcess}
|
<Button
|
||||||
processingJobId={processingJobId}
|
size="sm"
|
||||||
/>
|
variant="secondary"
|
||||||
</CardContent>
|
onClick={() => runBatch("process")}
|
||||||
</Card>
|
disabled={batchAction !== null}
|
||||||
|
>
|
||||||
|
Generate Resumes
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="destructive"
|
||||||
|
onClick={() => runBatch("reject")}
|
||||||
|
disabled={batchAction !== null}
|
||||||
|
>
|
||||||
|
Skip
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
onClick={() => runBatch("apply")}
|
||||||
|
disabled={batchAction !== null}
|
||||||
|
>
|
||||||
|
Mark Applied
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSelectedJobIds(new Set())}
|
||||||
|
disabled={batchAction !== null}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardContent className="p-0">
|
||||||
|
<JobTable
|
||||||
|
jobs={filteredJobs}
|
||||||
|
sort={sort}
|
||||||
|
onSortChange={setSort}
|
||||||
|
selectedJobIds={selectedJobIds}
|
||||||
|
onSelectedJobIdsChange={setSelectedJobIds}
|
||||||
|
onApply={onApply}
|
||||||
|
onReject={onReject}
|
||||||
|
onProcess={onProcess}
|
||||||
|
processingJobId={processingJobId}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid gap-4">
|
<div className="grid gap-4">
|
||||||
{filteredJobs.map((job) => (
|
{filteredJobs.map((job) => (
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import {
|
|||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@ -49,9 +50,11 @@ export interface JobTableProps {
|
|||||||
jobs: Job[];
|
jobs: Job[];
|
||||||
sort: JobSort;
|
sort: JobSort;
|
||||||
onSortChange: (sort: JobSort) => void;
|
onSortChange: (sort: JobSort) => void;
|
||||||
onApply: (id: string) => void;
|
selectedJobIds: Set<string>;
|
||||||
onReject: (id: string) => void;
|
onSelectedJobIdsChange: (ids: Set<string>) => void;
|
||||||
onProcess: (id: string) => void;
|
onApply: (id: string) => void | Promise<void>;
|
||||||
|
onReject: (id: string) => void | Promise<void>;
|
||||||
|
onProcess: (id: string) => void | Promise<void>;
|
||||||
processingJobId: string | null;
|
processingJobId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,15 +126,36 @@ export const JobTable: React.FC<JobTableProps> = ({
|
|||||||
jobs,
|
jobs,
|
||||||
sort,
|
sort,
|
||||||
onSortChange,
|
onSortChange,
|
||||||
|
selectedJobIds,
|
||||||
|
onSelectedJobIdsChange,
|
||||||
onApply,
|
onApply,
|
||||||
onReject,
|
onReject,
|
||||||
onProcess,
|
onProcess,
|
||||||
processingJobId,
|
processingJobId,
|
||||||
}) => {
|
}) => {
|
||||||
|
const selectedCount = jobs.reduce((count, job) => count + (selectedJobIds.has(job.id) ? 1 : 0), 0);
|
||||||
|
const allSelected = jobs.length > 0 && selectedCount === jobs.length;
|
||||||
|
const someSelected = selectedCount > 0 && selectedCount < jobs.length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table className="table-fixed">
|
<Table className="table-fixed">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<TableHead className="w-10">
|
||||||
|
<Checkbox
|
||||||
|
aria-label="Select all rows"
|
||||||
|
checked={allSelected ? true : someSelected ? "indeterminate" : false}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
const next = new Set(selectedJobIds);
|
||||||
|
if (checked) {
|
||||||
|
for (const job of jobs) next.add(job.id);
|
||||||
|
} else {
|
||||||
|
for (const job of jobs) next.delete(job.id);
|
||||||
|
}
|
||||||
|
onSelectedJobIdsChange(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</TableHead>
|
||||||
<TableHead className="w-[28%]">
|
<TableHead className="w-[28%]">
|
||||||
<SortButton label="Title" sortKey="title" sort={sort} onSortChange={onSortChange} />
|
<SortButton label="Title" sortKey="title" sort={sort} onSortChange={onSortChange} />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
@ -178,9 +202,22 @@ export const JobTable: React.FC<JobTableProps> = ({
|
|||||||
const canProcess = job.status === "discovered";
|
const canProcess = job.status === "discovered";
|
||||||
const canReject = ["discovered", "ready"].includes(job.status);
|
const canReject = ["discovered", "ready"].includes(job.status);
|
||||||
const isProcessing = processingJobId === job.id;
|
const isProcessing = processingJobId === job.id;
|
||||||
|
const isSelected = selectedJobIds.has(job.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={job.id}>
|
<TableRow key={job.id} data-state={isSelected ? "selected" : undefined}>
|
||||||
|
<TableCell className="align-top">
|
||||||
|
<Checkbox
|
||||||
|
aria-label={`Select ${job.title}`}
|
||||||
|
checked={isSelected}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
const next = new Set(selectedJobIds);
|
||||||
|
if (checked) next.add(job.id);
|
||||||
|
else next.delete(job.id);
|
||||||
|
onSelectedJobIdsChange(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
<TableCell className="align-top">
|
<TableCell className="align-top">
|
||||||
<Button
|
<Button
|
||||||
asChild
|
asChild
|
||||||
|
|||||||
27
orchestrator/src/components/ui/checkbox.tsx
Normal file
27
orchestrator/src/components/ui/checkbox.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||||
|
import { Check } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Checkbox = React.forwardRef<
|
||||||
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<CheckboxPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
</CheckboxPrimitive.Indicator>
|
||||||
|
</CheckboxPrimitive.Root>
|
||||||
|
))
|
||||||
|
Checkbox.displayName = "Checkbox"
|
||||||
|
|
||||||
|
export { Checkbox }
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user