Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
feat: Implement status filtering for discovered jobs and add related tests
Khuram Niaz940eb7567d36
diff --git a/__tests__/DiscoveredJobsList.spec.tsx b/__tests__/DiscoveredJobsList.spec.tsxindex c36f6ac..ac7793f 100644--- a/__tests__/DiscoveredJobsList.spec.tsx+++ b/__tests__/DiscoveredJobsList.spec.tsx@@ -1,4 +1,5 @@import { render, screen, waitFor, act } from "@testing-library/react";+import userEvent from "@testing-library/user-event";import { DiscoveredJobsList } from "@/components/automations/DiscoveredJobsList";import type { DiscoveredJob } from "@/models/automation.model";@@ -47,6 +48,7 @@ function renderList() {const onLoadMore = vi.fn();const onRefresh = vi.fn();+ const onStatusFilterChange = vi.fn();const props: React.ComponentProps<typeof DiscoveredJobsList> = {jobs: [makeJob()],totalJobs: 1,@@ -54,12 +56,15 @@ function renderList(onLoadMore,dismissedCount: 0,newCount: 1,+ acceptedCount: 0,+ statusFilter: ["new", "accepted"],+ onStatusFilterChange,automationId: "automation-1",onRefresh,...overrides,};const result = render(<DiscoveredJobsList {...props} />);- return { ...result, onLoadMore, onRefresh };+ return { ...result, onLoadMore, onRefresh, onStatusFilterChange };}describe("DiscoveredJobsList", () => {@@ -140,4 +145,77 @@ describe("DiscoveredJobsList", () => {expect(onLoadMore).not.toHaveBeenCalled();});++ it("shows the true empty state (no header/filter) when there are no jobs at all", () => {+ renderList({+ jobs: [],+ totalJobs: 0,+ dismissedCount: 0,+ newCount: 0,+ acceptedCount: 0,+ });++ expect(screen.getByText("No discovered jobs")).toBeInTheDocument();+ expect(screen.queryByText("Status")).not.toBeInTheDocument();+ });++ it("keeps the status filter visible when the current filter matches no jobs but some exist", () => {+ renderList({+ jobs: [],+ totalJobs: 0,+ dismissedCount: 3,+ newCount: 0,+ acceptedCount: 0,+ statusFilter: ["new", "accepted"],+ });++ expect(screen.getByText("No jobs match this filter")).toBeInTheDocument();+ expect(screen.getByText("Status")).toBeInTheDocument();+ });++ it("checks New and Accepted but not Dismissed by default", async () => {+ renderList({ statusFilter: ["new", "accepted"] });++ await userEvent.click(screen.getByRole("button", { name: "Status" }));++ expect(+ screen.getByRole("menuitemcheckbox", { name: "New" }),+ ).toHaveAttribute("aria-checked", "true");+ expect(+ screen.getByRole("menuitemcheckbox", { name: "Accepted" }),+ ).toHaveAttribute("aria-checked", "true");+ expect(+ screen.getByRole("menuitemcheckbox", { name: "Dismissed" }),+ ).toHaveAttribute("aria-checked", "false");+ });++ it("adds Dismissed to the filter when checked", async () => {+ const { onStatusFilterChange } = renderList({+ statusFilter: ["new", "accepted"],+ });++ await userEvent.click(screen.getByRole("button", { name: "Status" }));+ await userEvent.click(+ screen.getByRole("menuitemcheckbox", { name: "Dismissed" }),+ );++ expect(onStatusFilterChange).toHaveBeenCalledWith([+ "new",+ "accepted",+ "dismissed",+ ]);+ });++ it("removes New from the filter when unchecked", async () => {+ const { onStatusFilterChange } = renderList({+ statusFilter: ["new", "accepted"],+ });++ await userEvent.click(screen.getByRole("button", { name: "Status" }));+ await userEvent.click(+ screen.getByRole("menuitemcheckbox", { name: "New" }),+ );++ expect(onStatusFilterChange).toHaveBeenCalledWith(["accepted"]);+ });});diff --git a/__tests__/getDiscoveredJobs.actions.spec.ts b/__tests__/getDiscoveredJobs.actions.spec.tsnew file mode 100644index 0000000..e4d116e--- /dev/null+++ b/__tests__/getDiscoveredJobs.actions.spec.ts@@ -0,0 +1,64 @@+import { getDiscoveredJobs } from "@/actions/automation.actions";+import { getCurrentUser } from "@/utils/user.utils";+import { PrismaClient } from "@prisma/client";++const prisma = new PrismaClient();++vi.mock("@prisma/client", () => {+ const mPrismaClient = {+ job: {+ findMany: vi.fn(),+ count: vi.fn(),+ groupBy: vi.fn(),+ },+ };+ return {+ PrismaClient: vi.fn(function () {+ return mPrismaClient;+ }),+ };+});++vi.mock("@/utils/user.utils", () => ({+ getCurrentUser: vi.fn(),+}));++describe("getDiscoveredJobs status filtering", () => {+ const mockUser = { id: "user-id" };++ beforeEach(() => {+ vi.clearAllMocks();+ (getCurrentUser as any).mockResolvedValue(mockUser);+ (prisma.job.findMany as any).mockResolvedValue([]);+ (prisma.job.count as any).mockResolvedValue(0);+ (prisma.job.groupBy as any).mockResolvedValue([]);+ });++ it("filters by a single discoveryStatus", async () => {+ await getDiscoveredJobs({ discoveryStatus: "new" });++ const where = (prisma.job.findMany as any).mock.calls[0][0].where;+ expect(where.discoveryStatus).toBe("new");+ });++ it("filters by multiple discoveryStatus values using an 'in' clause", async () => {+ await getDiscoveredJobs({ discoveryStatus: ["new", "accepted"] });++ const where = (prisma.job.findMany as any).mock.calls[0][0].where;+ expect(where.discoveryStatus).toEqual({ in: ["new", "accepted"] });+ });++ it("omits the discoveryStatus filter when none is given", async () => {+ await getDiscoveredJobs({});++ const where = (prisma.job.findMany as any).mock.calls[0][0].where;+ expect(where.discoveryStatus).toBeUndefined();+ });++ it("excludes discoveryStatus from the groupBy count so counts are unaffected by the filter", async () => {+ await getDiscoveredJobs({ discoveryStatus: ["new", "accepted"] });++ const countWhere = (prisma.job.groupBy as any).mock.calls[0][0].where;+ expect(countWhere.discoveryStatus).toBeUndefined();+ });+});diff --git a/__tests__/greenhouse-runner.spec.ts b/__tests__/greenhouse-runner.spec.tsindex 53d71eb..707ab0f 100644--- a/__tests__/greenhouse-runner.spec.ts+++ b/__tests__/greenhouse-runner.spec.ts@@ -38,6 +38,12 @@ vi.mock("@/lib/api-key-resolver", () => ({resolveApiKey: vi.fn().mockResolvedValue(undefined),}));+// Real verifier does a network fetch to Ollama; these tests aren't+// exercising Ollama connectivity, so stub it to always succeed.+vi.mock("@/lib/ai/provider-registry.server", () => ({+ PROVIDER_VERIFIERS: { ollama: vi.fn().mockResolvedValue({ success: true }) },+}));+vi.mock("ai", () => ({ generateText: vi.fn() }));vi.mock("@/lib/ai", async (orig) => {diff --git a/src/actions/automation.actions.ts b/src/actions/automation.actions.tsindex 17bcedb..9da9fd7 100644--- a/src/actions/automation.actions.ts+++ b/src/actions/automation.actions.ts@@ -31,8 +31,10 @@ import { getJobDetails } from "@/actions/job.actions";import { defaultUserSettings } from "@/models/userSettings.model";import { automationLogger } from "@/lib/automation-logger";--function formatError(error: unknown, fallback: string): { success: false; message: string } {+function formatError(+ error: unknown,+ fallback: string,+): { success: false; message: string } {console.error(error, fallback);if (error instanceof Error) {return { success: false, message: error.message || fallback };@@ -42,7 +44,7 @@ function formatError(error: unknown, fallback: string): { success: false; messagexport async function getAutomationsList(page: number = 1,- limit: number = APP_CONSTANTS.RECORDS_PER_PAGE+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,): Promise<{success: boolean;data?: AutomationWithResume[];@@ -112,16 +114,16 @@ export async function getAutomationById(id: string): Promise<{return {success: true,- data: automation as unknown as AutomationWithResume & { runs: AutomationRun[] },+ data: automation as unknown as AutomationWithResume & {+ runs: AutomationRun[];+ },};} catch (error) {return formatError(error, "Failed to get automation");}}-export async function createAutomation(- input: CreateAutomationInput-): Promise<{+export async function createAutomation(input: CreateAutomationInput): Promise<{success: boolean;data?: AutomationWithResume;message?: string;@@ -136,7 +138,10 @@ export async function createAutomation(const count = await db.automation.count({ where: { userId: user.id } });if (count >= APP_CONSTANTS.MAX_AUTOMATIONS_PER_USER) {- return { success: false, message: `Maximum of ${APP_CONSTANTS.MAX_AUTOMATIONS_PER_USER} automations allowed per user` };+ return {+ success: false,+ message: `Maximum of ${APP_CONSTANTS.MAX_AUTOMATIONS_PER_USER} automations allowed per user`,+ };}const resume = await db.resume.findFirst({@@ -147,7 +152,10 @@ export async function createAutomation(});if (!resume) {- return { success: false, message: "Resume not found or doesn't belong to you" };+ return {+ success: false,+ message: "Resume not found or doesn't belong to you",+ };}const nextRunAt = calculateNextRunAt(validated.scheduleHour);@@ -188,7 +196,7 @@ export async function createAutomation(export async function updateAutomation(id: string,- input: UpdateAutomationInput+ input: UpdateAutomationInput,): Promise<{success: boolean;data?: AutomationWithResume;@@ -218,7 +226,10 @@ export async function updateAutomation(},});if (!resume) {- return { success: false, message: "Resume not found or doesn't belong to you" };+ return {+ success: false,+ message: "Resume not found or doesn't belong to you",+ };}}@@ -375,7 +386,7 @@ export async function resumeAutomation(id: string): Promise<{export async function getDiscoveredJobs(options?: {automationId?: string;- discoveryStatus?: DiscoveryStatus;+ discoveryStatus?: DiscoveryStatus | DiscoveryStatus[];page?: number;limit?: number;sortBy?: "matchScore" | "discoveredAt";@@ -414,7 +425,9 @@ export async function getDiscoveredJobs(options?: {}if (discoveryStatus) {- where.discoveryStatus = discoveryStatus;+ where.discoveryStatus = Array.isArray(discoveryStatus)+ ? { in: discoveryStatus }+ : discoveryStatus;}// Status counts ignore the discoveryStatus filter so callers get the full@@ -447,8 +460,7 @@ export async function getDiscoveredJobs(options?: {const statusCounts = { new: 0, dismissed: 0, accepted: 0 };for (const g of grouped) {if (g.discoveryStatus && g.discoveryStatus in statusCounts) {- statusCounts[g.discoveryStatus as keyof typeof statusCounts] =- g._count;+ statusCounts[g.discoveryStatus as keyof typeof statusCounts] = g._count;}}@@ -750,7 +762,7 @@ export async function getAutomationRuns(options?: {page?: number;limit?: number;- }+ },): Promise<{success: boolean;data?: AutomationRun[];diff --git a/src/app/dashboard/automations/[id]/page.tsx b/src/app/dashboard/automations/[id]/page.tsxindex 5b2a016..c5a504d 100644--- a/src/app/dashboard/automations/[id]/page.tsx+++ b/src/app/dashboard/automations/[id]/page.tsx@@ -49,6 +49,7 @@ import type {AutomationWithResume,AutomationRun,DiscoveredJob,+ DiscoveryStatus,} from "@/models/automation.model";import type { JobMatchData } from "@/models/ai.schemas";import { DiscoveredJobsList } from "@/components/automations/DiscoveredJobsList";@@ -85,6 +86,17 @@ export default function AutomationDetailPage() {dismissed: number;accepted: number;}>({ new: 0, dismissed: 0, accepted: 0 });+ const [statusFilter, setStatusFilter] = useState<DiscoveryStatus[]>([+ "new",+ "accepted",+ ]);+ // Mirrors statusFilter for loadData, which must not depend on statusFilter+ // directly (that would re-trigger its mount effect and flash the full-page+ // loading state whenever the filter changes).+ const statusFilterRef = useRef(statusFilter);+ useEffect(() => {+ statusFilterRef.current = statusFilter;+ }, [statusFilter]);const [loading, setLoading] = useState(true);const [actionLoading, setActionLoading] = useState(false);const [runNowLoading, setRunNowLoading] = useState(false);@@ -110,58 +122,68 @@ export default function AutomationDetailPage() {// connection, so we don't latch onto the previous run's completed snapshot.const seenRunningRef = useRef(false);- const loadData = useCallback(async (showLoading = false) => {- if (showLoading) setLoading(true);- try {- const [automationResult, runsResult, jobsResult] = await Promise.all([- getAutomationById(automationId),- getAutomationRuns(automationId, {- page: 1,- limit: APP_CONSTANTS.RECORDS_PER_PAGE,- }),- getDiscoveredJobs({- automationId,- page: 1,- limit: APP_CONSTANTS.RECORDS_PER_PAGE,- }),- ]);-- if (automationResult.success && automationResult.data) {- setAutomation(automationResult.data);- setRuns(automationResult.data.runs || []);- } else {+ const fetchJobs = useCallback(+ (filter: DiscoveryStatus[], page = 1) =>+ getDiscoveredJobs({+ automationId,+ discoveryStatus: filter,+ page,+ limit: APP_CONSTANTS.RECORDS_PER_PAGE,+ }),+ [automationId],+ );++ const loadData = useCallback(+ async (showLoading = false) => {+ if (showLoading) setLoading(true);+ try {+ const [automationResult, runsResult, jobsResult] = await Promise.all([+ getAutomationById(automationId),+ getAutomationRuns(automationId, {+ page: 1,+ limit: APP_CONSTANTS.RECORDS_PER_PAGE,+ }),+ fetchJobs(statusFilterRef.current),+ ]);++ if (automationResult.success && automationResult.data) {+ setAutomation(automationResult.data);+ setRuns(automationResult.data.runs || []);+ } else {+ toast({+ title: "Error",+ description: automationResult.message || "Automation not found",+ variant: "destructive",+ });+ router.push("/dashboard/automations");+ return;+ }++ if (runsResult.success && runsResult.data) {+ setRuns(runsResult.data);+ setTotalRuns(runsResult.total ?? 0);+ setRunsPage(1);+ }++ if (jobsResult.success && jobsResult.data) {+ setJobs(jobsResult.data);+ setTotalJobs(jobsResult.total ?? 0);+ setJobsPage(1);+ if (jobsResult.statusCounts) {+ setJobStatusCounts(jobsResult.statusCounts);+ }+ }+ } catch (error) {toast({title: "Error",- description: automationResult.message || "Automation not found",+ description: "Failed to load automation details",variant: "destructive",});- router.push("/dashboard/automations");- return;- }-- if (runsResult.success && runsResult.data) {- setRuns(runsResult.data);- setTotalRuns(runsResult.total ?? 0);- setRunsPage(1);}-- if (jobsResult.success && jobsResult.data) {- setJobs(jobsResult.data);- setTotalJobs(jobsResult.total ?? 0);- setJobsPage(1);- if (jobsResult.statusCounts) {- setJobStatusCounts(jobsResult.statusCounts);- }- }- } catch (error) {- toast({- title: "Error",- description: "Failed to load automation details",- variant: "destructive",- });- }- if (showLoading) setLoading(false);- }, [automationId, router]);+ if (showLoading) setLoading(false);+ },+ [automationId, router, fetchJobs],+ );useEffect(() => {// Only the initial load shows the full-page spinner. Background refreshes@@ -244,11 +266,7 @@ export default function AutomationDetailPage() {}, [automationId]);const refreshJobs = useCallback(async () => {- const jobsResult = await getDiscoveredJobs({- automationId,- page: 1,- limit: APP_CONSTANTS.RECORDS_PER_PAGE,- });+ const jobsResult = await fetchJobs(statusFilter);if (jobsResult.success && jobsResult.data) {setJobs(jobsResult.data);setTotalJobs(jobsResult.total ?? 0);@@ -257,17 +275,13 @@ export default function AutomationDetailPage() {setJobStatusCounts(jobsResult.statusCounts);}}- }, [automationId]);+ }, [fetchJobs, statusFilter]);const loadMoreJobs = useCallback(async () => {setJobsLoadingMore(true);try {const nextPage = jobsPage + 1;- const jobsResult = await getDiscoveredJobs({- automationId,- page: nextPage,- limit: APP_CONSTANTS.RECORDS_PER_PAGE,- });+ const jobsResult = await fetchJobs(statusFilter, nextPage);if (jobsResult.success && jobsResult.data) {setJobs((prev) => [...prev, ...jobsResult.data!]);setTotalJobs(jobsResult.total ?? 0);@@ -276,7 +290,23 @@ export default function AutomationDetailPage() {} finally {setJobsLoadingMore(false);}- }, [automationId, jobsPage]);+ }, [fetchJobs, jobsPage, statusFilter]);++ const handleStatusFilterChange = useCallback(+ async (filter: DiscoveryStatus[]) => {+ setStatusFilter(filter);+ const jobsResult = await fetchJobs(filter);+ if (jobsResult.success && jobsResult.data) {+ setJobs(jobsResult.data);+ setTotalJobs(jobsResult.total ?? 0);+ setJobsPage(1);+ if (jobsResult.statusCounts) {+ setJobStatusCounts(jobsResult.statusCounts);+ }+ }+ },+ [fetchJobs],+ );const loadMoreRuns = useCallback(async () => {setRunsLoadingMore(true);@@ -641,6 +671,9 @@ export default function AutomationDetailPage() {onLoadMore={loadMoreJobs}dismissedCount={jobStatusCounts.dismissed}newCount={jobStatusCounts.new}+ acceptedCount={jobStatusCounts.accepted}+ statusFilter={statusFilter}+ onStatusFilterChange={handleStatusFilterChange}automationId={automationId}onRefresh={loadData}onViewDetails={handleViewJobDetails}diff --git a/src/components/automations/DiscoveredJobsList.tsx b/src/components/automations/DiscoveredJobsList.tsxindex 0fe1031..30a47ae 100644--- a/src/components/automations/DiscoveredJobsList.tsx+++ b/src/components/automations/DiscoveredJobsList.tsx@@ -2,13 +2,8 @@import { useState, useMemo, useEffect, useRef } from "react";import { format } from "date-fns";-import { APP_CONSTANTS } from "@/lib/constants";-import {- Card,- CardContent,- CardHeader,- CardTitle,-} from "@/components/ui/card";+import { APP_CONSTANTS, DISCOVERY_STATUSES } from "@/lib/constants";+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Button } from "@/components/ui/button";import { Badge } from "@/components/ui/badge";import {@@ -31,6 +26,14 @@ import {AlertDialogTitle,} from "@/components/ui/alert-dialog";import { buttonVariants } from "@/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuCheckboxItem,+ DropdownMenuContent,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import {Check,X,@@ -38,11 +41,12 @@ import {Briefcase,Building2,MapPin,+ ListFilter,Loader2,Sparkles,Trash2,} from "lucide-react";-import type { DiscoveredJob } from "@/models/automation.model";+import type { DiscoveredJob, DiscoveryStatus } from "@/models/automation.model";import {acceptDiscoveredJob,dismissDiscoveredJob,@@ -84,6 +88,9 @@ interface DiscoveredJobsListProps {// the clear dialog matches what clearDiscoveredJobs actually deletes.dismissedCount: number;newCount: number;+ acceptedCount: number;+ statusFilter: DiscoveryStatus[];+ onStatusFilterChange: (filter: DiscoveryStatus[]) => void;automationId: string;onRefresh: () => void;onViewDetails?: (job: DiscoveredJob) => void;@@ -101,6 +108,9 @@ export function DiscoveredJobsList({onLoadMore,dismissedCount,newCount,+ acceptedCount,+ statusFilter,+ onStatusFilterChange,automationId,onRefresh,onViewDetails,@@ -124,7 +134,11 @@ export function DiscoveredJobsList({const observer = new IntersectionObserver((entries) => {- if (entries[0].isIntersecting && !loadingMore && jobs.length < totalJobs) {+ if (+ entries[0].isIntersecting &&+ !loadingMore &&+ jobs.length < totalJobs+ ) {onLoadMore();}},@@ -151,7 +165,10 @@ export function DiscoveredJobsList({try {const result = await analyzeDiscoveredJob(jobId);if (result.success) {- toast({ title: "Match analyzed", description: "AI match score is ready." });+ toast({+ title: "Match analyzed",+ description: "AI match score is ready.",+ });onRefresh();} else {toast({@@ -161,7 +178,11 @@ export function DiscoveredJobsList({});}} catch {- toast({ title: "Error", description: "Failed to analyze job", variant: "destructive" });+ toast({+ title: "Error",+ description: "Failed to analyze job",+ variant: "destructive",+ });} finally {setLoadingAction(null);}@@ -172,7 +193,10 @@ export function DiscoveredJobsList({try {const result = await acceptDiscoveredJob(job.id);if (result.success) {- toast({ title: "Job accepted", description: "The job has been added to your tracked jobs." });+ toast({+ title: "Job accepted",+ description: "The job has been added to your tracked jobs.",+ });onRefresh();} else {toast({@@ -182,7 +206,11 @@ export function DiscoveredJobsList({});}} catch {- toast({ title: "Error", description: "Failed to accept job", variant: "destructive" });+ toast({+ title: "Error",+ description: "Failed to accept job",+ variant: "destructive",+ });} finally {setLoadingAction(null);}@@ -203,7 +231,11 @@ export function DiscoveredJobsList({});}} catch {- toast({ title: "Error", description: "Failed to dismiss job", variant: "destructive" });+ toast({+ title: "Error",+ description: "Failed to dismiss job",+ variant: "destructive",+ });} finally {setLoadingAction(null);}@@ -239,7 +271,9 @@ export function DiscoveredJobsList({return "outline";};- if (jobs.length === 0) {+ const hasAnyJobs = dismissedCount + newCount + acceptedCount > 0;++ if (!hasAnyJobs) {return (<Card><CardContent className="flex flex-col items-center justify-center py-12">@@ -253,6 +287,14 @@ export function DiscoveredJobsList({);}+ const toggleStatusFilter = (status: DiscoveryStatus, checked: boolean) => {+ onStatusFilterChange(+ checked+ ? [...statusFilter, status]+ : statusFilter.filter((s) => s !== status),+ );+ };+return (<Card><CardHeader>@@ -260,182 +302,224 @@ export function DiscoveredJobsList({<div className="space-y-1.5"><CardTitle>Discovered Jobs</CardTitle>{totalJobs > 0 && (- <RecordsCount count={jobs.length} total={totalJobs} label="jobs" />+ <RecordsCount+ count={jobs.length}+ total={totalJobs}+ label="jobs"+ />)}</div>- {dismissedCount + newCount > 0 && (- <Button- variant="outline"- size="sm"- onClick={() => {- setClearIncludeNew(false);- setClearOpen(true);- }}- >- <Trash2 className="h-4 w-4 mr-1.5" />- Clear- </Button>- )}+ <div className="flex items-center gap-2">+ {dismissedCount + newCount > 0 && (+ <Button+ variant="outline"+ size="sm"+ onClick={() => {+ setClearIncludeNew(false);+ setClearOpen(true);+ }}+ >+ <Trash2 className="h-4 w-4 mr-1.5" />+ Clear+ </Button>+ )}+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="outline" size="sm">+ <ListFilter className="h-4 w-4 mr-1.5" />+ Status+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuLabel>Filter by status</DropdownMenuLabel>+ <DropdownMenuSeparator />+ {DISCOVERY_STATUSES.map((status) => (+ <DropdownMenuCheckboxItem+ key={status.value}+ checked={statusFilter.includes(status.value)}+ onSelect={(e) => e.preventDefault()}+ onCheckedChange={(checked) =>+ toggleStatusFilter(status.value, checked)+ }+ >+ {status.label}+ </DropdownMenuCheckboxItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ </div></div></CardHeader><CardContent>- <Table>- <TableHeader>- <TableRow>- <TableHead>Job</TableHead>- <TableHead>Company</TableHead>- <TableHead>Location</TableHead>- <TableHead className="text-center">Pre-rank</TableHead>- <TableHead className="text-center">Match</TableHead>- <TableHead>Status</TableHead>- <TableHead>Discovered</TableHead>- <TableHead className="text-right">Actions</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {sortedJobs.map((job) => {- const isLoading = loadingAction === job.id;- const analyzed = isAnalyzed(job);- const prerankPercent = getPrerankPercent(job);+ {jobs.length === 0 ? (+ <div className="flex flex-col items-center justify-center py-12 text-center">+ <Briefcase className="h-12 w-12 text-muted-foreground mb-4" />+ <h3 className="text-lg font-medium">No jobs match this filter</h3>+ <p className="text-muted-foreground mt-2">+ Try selecting a different status above.+ </p>+ </div>+ ) : (+ <>+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>Job</TableHead>+ <TableHead>Company</TableHead>+ <TableHead>Location</TableHead>+ <TableHead className="text-center">Pre-rank</TableHead>+ <TableHead className="text-center">Match</TableHead>+ <TableHead>Status</TableHead>+ <TableHead>Discovered</TableHead>+ <TableHead className="text-right">Actions</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {sortedJobs.map((job) => {+ const isLoading = loadingAction === job.id;+ const analyzed = isAnalyzed(job);+ const prerankPercent = getPrerankPercent(job);- return (- <TableRow key={job.id}>- <TableCell>- <div className="flex items-center gap-2">- <span- className="font-medium hover:underline cursor-pointer"- onClick={() => onViewDetails?.(job)}- >- {job.JobTitle.label}- </span>- {job.jobUrl && (- <a- href={job.jobUrl}- target="_blank"- rel="noopener noreferrer"- className="text-muted-foreground hover:text-foreground"- >- <ExternalLink className="h-4 w-4" />- </a>- )}- </div>- </TableCell>- <TableCell>- <div className="flex items-center gap-2">- <Building2 className="h-4 w-4 text-muted-foreground" />- {job.Company.label}- </div>- </TableCell>- <TableCell>- <div className="flex items-center gap-2">- <MapPin className="h-4 w-4 text-muted-foreground" />- {job.Location?.label || "N/A"}- </div>- </TableCell>- <TableCell className="text-center">- {prerankPercent != null ? (- <span- className="font-mono text-sm text-muted-foreground"- title="Internal lexical relevance score (not an AI match)"- >- {prerankPercent}%- </span>- ) : (- <span className="text-muted-foreground">—</span>- )}- </TableCell>- <TableCell className="text-center">- {analyzed ? (- <Badge variant={getScoreBadgeVariant(job.matchScore)}>- {job.matchScore}%- </Badge>- ) : (- <Button- size="sm"- variant="outline"- onClick={() => handleAnalyze(job.id)}- disabled={isLoading || runInProgress}- title={- runInProgress- ? "A run is in progress. Wait until it completes."- : undefined- }- >- {isLoading ? (- <Loader2 className="h-4 w-4 animate-spin" />+ return (+ <TableRow key={job.id}>+ <TableCell>+ <div className="flex items-center gap-2">+ <span+ className="font-medium hover:underline cursor-pointer"+ onClick={() => onViewDetails?.(job)}+ >+ {job.JobTitle.label}+ </span>+ {job.jobUrl && (+ <a+ href={job.jobUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="text-muted-foreground hover:text-foreground"+ >+ <ExternalLink className="h-4 w-4" />+ </a>+ )}+ </div>+ </TableCell>+ <TableCell>+ <div className="flex items-center gap-2">+ <Building2 className="h-4 w-4 text-muted-foreground" />+ {job.Company.label}+ </div>+ </TableCell>+ <TableCell>+ <div className="flex items-center gap-2">+ <MapPin className="h-4 w-4 text-muted-foreground" />+ {job.Location?.label || "N/A"}+ </div>+ </TableCell>+ <TableCell className="text-center">+ {prerankPercent != null ? (+ <span+ className="font-mono text-sm text-muted-foreground"+ title="Internal lexical relevance score (not an AI match)"+ >+ {prerankPercent}%+ </span>) : (- <>- <Sparkles className="h-3.5 w-3.5 mr-1" />- Analyze- </>+ <span className="text-muted-foreground">—</span>)}- </Button>- )}- </TableCell>- <TableCell>- <Badge- variant={- job.discoveryStatus === "accepted"- ? "default"- : job.discoveryStatus === "dismissed"- ? "secondary"- : "outline"- }- >- {job.discoveryStatus}- </Badge>- </TableCell>- <TableCell>- {format(new Date(job.discoveredAt), "MMM d, yyyy")}- </TableCell>- <TableCell className="text-right">- {job.discoveryStatus === "new" && (- <div className="flex justify-end gap-2">- <Button- size="sm"- variant="outline"- onClick={() => handleAccept(job)}- disabled={isLoading}- >- {isLoading ? (- <Loader2 className="h-4 w-4 animate-spin" />- ) : (- <Check className="h-4 w-4" />- )}- </Button>- <Button- size="sm"- variant="ghost"- onClick={() => handleDismiss(job.id)}- disabled={isLoading}+ </TableCell>+ <TableCell className="text-center">+ {analyzed ? (+ <Badge variant={getScoreBadgeVariant(job.matchScore)}>+ {job.matchScore}%+ </Badge>+ ) : (+ <Button+ size="sm"+ variant="outline"+ onClick={() => handleAnalyze(job.id)}+ disabled={isLoading || runInProgress}+ title={+ runInProgress+ ? "A run is in progress. Wait until it completes."+ : undefined+ }+ >+ {isLoading ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <>+ <Sparkles className="h-3.5 w-3.5 mr-1" />+ Analyze+ </>+ )}+ </Button>+ )}+ </TableCell>+ <TableCell>+ <Badge+ variant={+ job.discoveryStatus === "accepted"+ ? "default"+ : job.discoveryStatus === "dismissed"+ ? "secondary"+ : "outline"+ }>- {isLoading ? (- <Loader2 className="h-4 w-4 animate-spin" />- ) : (- <X className="h-4 w-4" />- )}- </Button>- </div>- )}- </TableCell>- </TableRow>- );- })}- </TableBody>- </Table>- {jobs.length < totalJobs && (- <div- ref={sentinelRef}- data-testid="jobs-load-more-sentinel"- className="flex justify-center p-4"- >- {loadingMore && (- <Loader2- data-testid="jobs-load-more-spinner"- className="h-5 w-5 animate-spin text-blue-500"- />+ {job.discoveryStatus}+ </Badge>+ </TableCell>+ <TableCell>+ {format(new Date(job.discoveredAt), "MMM d, yyyy")}+ </TableCell>+ <TableCell className="text-right">+ {job.discoveryStatus === "new" && (+ <div className="flex justify-end gap-2">+ <Button+ size="sm"+ variant="outline"+ onClick={() => handleAccept(job)}+ disabled={isLoading}+ >+ {isLoading ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <Check className="h-4 w-4" />+ )}+ </Button>+ <Button+ size="sm"+ variant="ghost"+ onClick={() => handleDismiss(job.id)}+ disabled={isLoading}+ >+ {isLoading ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <X className="h-4 w-4" />+ )}+ </Button>+ </div>+ )}+ </TableCell>+ </TableRow>+ );+ })}+ </TableBody>+ </Table>+ {jobs.length < totalJobs && (+ <div+ ref={sentinelRef}+ data-testid="jobs-load-more-sentinel"+ className="flex justify-center p-4"+ >+ {loadingMore && (+ <Loader2+ data-testid="jobs-load-more-spinner"+ className="h-5 w-5 animate-spin text-blue-500"+ />+ )}+ </div>)}- </div>+ </>)}</CardContent>diff --git a/src/lib/constants.ts b/src/lib/constants.tsindex f47bf6c..bfed7ea 100644--- a/src/lib/constants.ts+++ b/src/lib/constants.ts@@ -130,6 +130,12 @@ export const JOB_STATUSES = [{ label: "Archived", value: "archived" },] as const;+export const DISCOVERY_STATUSES = [+ { label: "New", value: "new" },+ { label: "Accepted", value: "accepted" },+ { label: "Dismissed", value: "dismissed" },+] as const;+export const SIDEBAR_LINKS = [{icon: LayoutDashboard,