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
refactor(myjobs): split JobDetails into job-details/ with URL-backed tabs
Khuram Niaz29a02046feca
diff --git a/__tests__/JobDetails.spec.tsx b/__tests__/JobDetails.spec.tsxindex f4837e7..2ff13a6 100644--- a/__tests__/JobDetails.spec.tsx+++ b/__tests__/JobDetails.spec.tsx@@ -4,10 +4,18 @@ import { JobResponse, Tag } from "@/models/job.model";import { render, screen, act, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";+// The active tab lives in the URL, so a click only calls router.replace —+// what the user sees next comes from the re-render with the new params.+const router = { back: vi.fn(), push: vi.fn(), replace: vi.fn() };+let searchParams = new URLSearchParams();+const onTab = (tab: string) => {+ searchParams = new URLSearchParams(`tab=${tab}`);+};+vi.mock("next/navigation", () => ({- useRouter: vi.fn(() => ({ back: vi.fn(), push: vi.fn(), replace: vi.fn() })),- useSearchParams: vi.fn(() => new URLSearchParams()),- usePathname: vi.fn(() => "/dashboard/myjobs/job-1"),+ useRouter: () => router,+ useSearchParams: () => searchParams,+ usePathname: () => "/dashboard/myjobs/job-1",}));const chat = {@@ -22,7 +30,7 @@ vi.mock("@/components/agent/AgentChatProvider", () => ({}));vi.mock("@/components/myjobs/NotesSection", () => ({- NotesSection: () => null,+ NotesSection: () => <div data-testid="notes-section" />,}));vi.mock("@/components/TipTapContentViewer", () => ({@@ -146,7 +154,7 @@ describe("JobDetails – skill badges", () => {});describe("JobDetails – salary range", () => {- it("renders the salary range in the header line", () => {+ it("renders the salary range in the summary card", () => {render(<JobDetails {...baseProps} job={makeJob()} />);expect(screen.getByText(/100,000 - 110,000/)).toBeInTheDocument();@@ -174,28 +182,32 @@ describe("JobDetails – match data display", () => {beforeEach(() => {vi.clearAllMocks();chat.clear.mockResolvedValue(undefined);+ searchParams = new URLSearchParams();});- it("shows inline match analysis when job has matchData", () => {+ // The score sits in the summary card, the analysis behind the AI Match tab.+ it("shows the match analysis on the AI Match tab when the job has matchData", () => {+ onTab("match");const matchData = JSON.stringify({matchScore: 85,summary: "Good match",});render(<JobDetails {...baseProps} job={makeJob({ matchScore: 85, matchData })} />);- expect(screen.getByText("AI Match Analysis")).toBeInTheDocument();expect(screen.getByText("85%")).toBeInTheDocument();expect(screen.getByTestId("match-details")).toBeInTheDocument();});- it("does not show inline match section when job has no matchData", () => {+ it("shows the empty state on the AI Match tab when the job has no matchData", () => {+ onTab("match");render(<JobDetails {...baseProps} job={makeJob()} />);- expect(screen.queryByText("AI Match Analysis")).not.toBeInTheDocument();+ expect(screen.getByText(/no match analysis yet/i)).toBeInTheDocument();expect(screen.queryByTestId("match-details")).not.toBeInTheDocument();});it("shows the saved match score from the job prop", () => {+ onTab("match");render(<JobDetailsjob={makeJob({@@ -214,10 +226,85 @@ describe("JobDetails – match data display", () => {});});+describe("JobDetails – tabs", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ chat.approvalPending = false;+ searchParams = new URLSearchParams();+ });++ // The bar must not shift between jobs, so all four are always present.+ it("renders all four tabs regardless of what the job has", () => {+ render(<JobDetails {...baseProps} job={makeJob()} />);++ expect(screen.getByRole("tab", { name: /description/i })).toBeInTheDocument();+ expect(screen.getByRole("tab", { name: /ai match/i })).toBeInTheDocument();+ expect(screen.getByRole("tab", { name: /cover letter/i })).toBeInTheDocument();+ expect(screen.getByRole("tab", { name: /notes/i })).toBeInTheDocument();+ });++ it("opens on the Description tab", () => {+ render(<JobDetails {...baseProps} job={makeJob()} />);++ expect(screen.getByRole("tab", { name: /description/i })).toHaveAttribute(+ "data-state",+ "active",+ );+ });++ it("puts the picked tab in the URL so a refresh lands on it", async () => {+ render(<JobDetails {...baseProps} job={makeJob()} />);++ await userEvent.click(screen.getByRole("tab", { name: /ai match/i }));+ expect(router.replace).toHaveBeenCalledWith("?tab=match", { scroll: false });+ });++ // It stays mounted on every tab so the ⋮ → Add a Note trigger and the count+ // badge keep working; the panel's own inactive state is what hides it.+ it("keeps the notes section mounted while another tab is showing", () => {+ render(<JobDetails {...baseProps} job={makeJob()} />);++ expect(screen.getByTestId("notes-section")).toBeInTheDocument();+ expect(+ screen.getByTestId("notes-section").closest("[data-state]"),+ ).toHaveAttribute("data-state", "inactive");+ });++ it("shows the cover letter empty state when the job has no letter", () => {+ onTab("letter");+ render(<JobDetails {...baseProps} job={makeJob()} />);++ expect(screen.getByText(/no cover letter yet/i)).toBeInTheDocument();+ });++ it("renders the linked letter on the Cover Letter tab", () => {+ onTab("letter");+ render(+ <JobDetails+ {...baseProps}+ job={makeJob({+ coverLetterId: "cl-1",+ CoverLetter: {+ id: "cl-1",+ title: "Frontend Developer – Acme Corp",+ content: "<p>Dear Hiring Team,</p>",+ },+ })}+ />,+ );++ expect(+ screen.getByText("Frontend Developer – Acme Corp", { exact: false }),+ ).toBeInTheDocument();+ expect(screen.queryByText(/no cover letter yet/i)).not.toBeInTheDocument();+ });+});+describe("JobDetails – Match with AI", () => {beforeEach(() => {vi.clearAllMocks();chat.clear.mockResolvedValue(undefined);+ searchParams = new URLSearchParams();});it("opens the chat and asks for a match when Match with AI is clicked", async () => {@@ -258,6 +345,7 @@ describe("JobDetails cover letter action", () => {beforeEach(() => {chat.approvalPending = false;vi.clearAllMocks();+ searchParams = new URLSearchParams();});it("stays enabled when no resume is linked", () => {diff --git a/src/components/automations/AutomationDetailContainer.tsx b/src/components/automations/AutomationDetailContainer.tsxindex a660177..5a61840 100644--- a/src/components/automations/AutomationDetailContainer.tsx+++ b/src/components/automations/AutomationDetailContainer.tsx@@ -1,8 +1,8 @@"use client";import { useState } from "react";-import { useRouter, useSearchParams } from "next/navigation";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";+import { useTabQueryParam } from "@/hooks/useTabQueryParam";import { Badge } from "@/components/ui/badge";import { isRetiredBoard } from "@/models/automation.model";import { DiscoveredJobsList } from "@/components/automations/DiscoveredJobsList";@@ -20,6 +20,8 @@ import { AutomationDetailDialogs } from "./automation-detail-container/Automatioimport { useAutomationWizardData } from "./automation-detail-container/useAutomationWizardData";import { useDiscoveredJobDetail } from "./automation-detail-container/useDiscoveredJobDetail";+const AUTOMATION_DETAIL_TABS = ["logs", "jobs", "history"] as const;+interface AutomationDetailContainerProps {automationId: string;}@@ -27,13 +29,10 @@ interface AutomationDetailContainerProps {export function AutomationDetailContainer({automationId,}: AutomationDetailContainerProps) {- const router = useRouter();- const searchParams = useSearchParams();- const activeTab = searchParams.get("tab") ?? "logs";-- const handleTabChange = (tab: string) => {- router.replace(`?tab=${tab}`, { scroll: false });- };+ const [activeTab, handleTabChange] = useTabQueryParam(+ AUTOMATION_DETAIL_TABS,+ "logs",+ );const {automation,diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsxindex 5d62db3..7924a63 100644--- a/src/components/myjobs/JobDetails.tsx+++ b/src/components/myjobs/JobDetails.tsx@@ -1,10 +1,4 @@"use client";-import { format } from "date-fns";-import { Badge } from "../ui/badge";-import { StatusBadge } from "../StatusBadge";-import { getJobStatusBadgeColor } from "@/lib/badge-colors";-import { JobStatusMenuItems } from "./JobStatusMenuItems";-import { formatUrl } from "@/lib/utils";import {Company,JobLocation,@@ -13,29 +7,14 @@ import {JobStatus,JobTitle,Tag,- getWorkplaceTypeLabel,} from "@/models/job.model";import { TipTapContentViewer } from "../TipTapContentViewer";-import {- Card,- CardDescription,- CardFooter,- CardHeader,- CardTitle,-} from "../ui/card";-import { Button } from "../ui/button";-import {- ArrowLeft,- FileText,- MoreVertical,- Pencil,- Sparkles,- StickyNote,- Tags,- Trash,- Trash2,-} from "lucide-react";+import { Badge } from "../ui/badge";+import { Card } from "../ui/card";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs";+import { Sparkles } from "lucide-react";import { useRouter } from "next/navigation";+import { useTabQueryParam } from "@/hooks/useTabQueryParam";import { useAgentChat } from "@/components/agent/AgentChatProvider";import {AlertDialog,@@ -49,27 +28,18 @@ import {} from "../ui/alert-dialog";import { NotesSection } from "./NotesSection";import { useState, useMemo } from "react";-import { DownloadFileButton } from "../profile/DownloadFileButton";import { MatchDetails } from "../automations/MatchDetails";import type { JobMatchData } from "@/models/ai.schemas";-import { CircularScore } from "@/components/CircularScore";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuPortal,- DropdownMenuSeparator,- DropdownMenuSub,- DropdownMenuSubContent,- DropdownMenuSubTrigger,- DropdownMenuTrigger,-} from "../ui/dropdown-menu";import { DeleteAlertDialog } from "../DeleteAlertDialog";import { AddJob } from "./AddJob";import { deleteJobById, updateJobStatus } from "@/actions/job.actions";import { toastError, toastSuccess } from "@/lib/toast";+import { JobDetailsHeader } from "./job-details/JobDetailsHeader";+import { JobSummaryCard } from "./job-details/JobSummaryCard";+import { JobTabEmptyState } from "./job-details/JobTabEmptyState";+import { CoverLetterTab } from "./job-details/CoverLetterTab";++const JOB_DETAIL_TABS = ["description", "match", "letter", "notes"] as const;type JobDetailsProps = {job: JobResponse;@@ -104,7 +74,12 @@ function JobDetails({);const [deleteAlertOpen, setDeleteAlertOpen] = useState(false);const [noteOpenTrigger, setNoteOpenTrigger] = useState(0);+ const [notesCount, setNotesCount] = useState(0);const router = useRouter();+ const [activeTab, handleTabChange] = useTabQueryParam(+ JOB_DETAIL_TABS,+ "description",+ );const goBack = () => router.back();// Derived from the server prop, not local state: the chat saves the match@@ -144,6 +119,10 @@ function JobDetails({void startChat(text);};+ const onMatch = () => requestChat(`Match my resume to ${jobLabel}`);+ const onCoverLetter = () =>+ requestChat(`Write a cover letter for ${jobLabel}`);+const coverLetterBlockedReason =job.descriptionCompleteness === "title-only"? "Add a job description first"@@ -156,6 +135,7 @@ function JobDetails({const resetEditJob = () => setEditJobTarget(null);const onAddNote = () => {+ handleTabChange("notes");setNoteOpenTrigger((prev) => prev + 1);};@@ -179,221 +159,88 @@ function JobDetails({}};- const getJobType = (code: string) => {- switch (code) {- case "FT":- return "Full-time";- case "PT":- return "Part-time";- case "C":- return "Contract";- default:- return "Unknown";- }- };-return (<>- <div className="flex justify-between">- <Button title="Go Back" size="sm" variant="outline" onClick={goBack}>- <ArrowLeft />- </Button>- <div className="flex items-center gap-2">- <Button- size="sm"- variant="outline"- className="h-8 gap-1 cursor-pointer"- onClick={() => requestChat(`Match my resume to ${jobLabel}`)}- >- <Sparkles className="h-3.5 w-3.5" />- <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">- Match with AI- </span>- </Button>- <Button- size="sm"- variant="outline"- className="h-8 gap-1 cursor-pointer"- data-testid="generate-cover-letter-btn"- disabled={!!coverLetterBlockedReason}- title={coverLetterBlockedReason}- onClick={() => requestChat(`Write a cover letter for ${jobLabel}`)}- >- <FileText className="h-3.5 w-3.5" />- <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">- {job.coverLetterId ? "Regenerate Letter" : "Cover Letter"}- </span>- </Button>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- aria-haspopup="true"- size="icon"- variant="ghost"- data-testid="job-details-actions-menu-btn"- >- <MoreVertical className="h-4 w-4" />- <span className="sr-only">Toggle menu</span>- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" className="w-[200px]">- <DropdownMenuLabel>Actions</DropdownMenuLabel>- <DropdownMenuGroup>- <DropdownMenuItem className="cursor-pointer" onClick={onEditJob}>- <Pencil className="mr-2 h-4 w-4" />- Edit Job- </DropdownMenuItem>- <DropdownMenuItem className="cursor-pointer" onClick={onAddNote}>- <StickyNote className="mr-2 h-4 w-4" />- Add a Note- </DropdownMenuItem>- <DropdownMenuSeparator />- <DropdownMenuSub>- <DropdownMenuSubTrigger>- <Tags className="mr-2 h-4 w-4" />- Change status- </DropdownMenuSubTrigger>- <DropdownMenuPortal>- <DropdownMenuSubContent className="p-0">- <JobStatusMenuItems- jobStatuses={jobStatuses}- currentStatusId={currentStatus.id}- onSelectStatus={onChangeStatus}- />- </DropdownMenuSubContent>- </DropdownMenuPortal>- </DropdownMenuSub>- <DropdownMenuSeparator />- <DropdownMenuItem- className="text-red-600 cursor-pointer"- onClick={() => setDeleteAlertOpen(true)}- >- <Trash className="mr-2 h-4 w-4" />- Delete- </DropdownMenuItem>- </DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>- </div>- </div>- {job?.id && (- <Card className="col-span-3">- <CardHeader className="flex-row items-center justify-between relative">- <div>- {job?.Company?.label}- <CardTitle>{job?.JobTitle?.label}</CardTitle>- <CardDescription>- {job?.Location?.label && `${job.Location.label} - `}- {getJobType(job?.jobType)}- {job?.workplaceType && ` · ${getWorkplaceTypeLabel(job.workplaceType)}`}- {job?.salaryRange && ` · ${job.salaryRange}`}- </CardDescription>- </div>- <div className="flex flex-col items-end gap-2">- <div className="flex items-center gap-1">- <Button- variant="ghost"- size="sm"- className="h-8 px-2"- onClick={onEditJob}- data-testid="job-details-edit-btn"- >- <Pencil className="h-4 w-4 sm:mr-1" />- <span className="hidden sm:inline">Edit</span>- </Button>- <Button- variant="ghost"- size="sm"- className="h-8 px-2 text-destructive hover:text-destructive"- onClick={() => setDeleteAlertOpen(true)}- data-testid="job-details-delete-btn"- >- <Trash2 className="h-4 w-4 sm:mr-1" />- <span className="hidden sm:inline">Delete</span>- </Button>- </div>- {job.matchScore != null && (- <div className="flex flex-col items-center gap-1">- <CircularScore score={job.matchScore} size="md" />- {parsedMatchData?.recommendation ? (- <Badge variant="outline" className="capitalize">- {parsedMatchData.recommendation}- </Badge>- ) : (- <span className="text-xs text-muted-foreground">AI Match</span>- )}- </div>+ <div className="py-6 space-y-6">+ <JobDetailsHeader+ job={job}+ jobStatuses={jobStatuses}+ currentStatus={currentStatus}+ coverLetterBlockedReason={coverLetterBlockedReason}+ onBack={goBack}+ onMatch={onMatch}+ onCoverLetter={onCoverLetter}+ onEdit={onEditJob}+ onDelete={() => setDeleteAlertOpen(true)}+ onAddNote={onAddNote}+ onChangeStatus={onChangeStatus}+ />++ <JobSummaryCard+ job={job}+ currentStatus={currentStatus}+ matchData={parsedMatchData}+ />++ <Tabs value={activeTab} onValueChange={handleTabChange}>+ <TabsList>+ <TabsTrigger value="description">Description</TabsTrigger>+ <TabsTrigger value="match">AI Match</TabsTrigger>+ <TabsTrigger value="letter">Cover Letter</TabsTrigger>+ <TabsTrigger value="notes">+ Notes+ {notesCount > 0 && (+ <Badge variant="secondary" className="ml-2">+ {notesCount}+ </Badge>+ )}+ </TabsTrigger>+ </TabsList>+ <TabsContent value="description" className="mt-4">+ <Card className="p-6">+ <TipTapContentViewer content={job?.description} />+ </Card>+ </TabsContent>+ <TabsContent value="match" className="mt-4">+ <Card className="p-6">+ {parsedMatchData ? (+ <MatchDetails matchData={parsedMatchData} />+ ) : (+ <JobTabEmptyState+ icon={Sparkles}+ title="No match analysis yet"+ description="Run an AI match to see how your resume lines up with this posting, and where the gaps are."+ actionLabel="Match with AI"+ onAction={onMatch}+ />)}- {job?.Resume && job?.Resume?.File && job.Resume?.File?.filePath- ? DownloadFileButton(- job?.Resume?.File?.filePath,- job?.Resume?.title,- job?.Resume?.File?.fileName,- )- : null}- </div>- </CardHeader>- {job.jobUrl && (- <div className="my-3 ml-4">- <span className="font-semibold mr-2">Job URL:</span>- <a- href={formatUrl(job.jobUrl)}- target="_blank"- rel="noopener noreferrer"- >- {job.jobUrl}- </a>- </div>- )}- <h3 className="ml-4 flex flex-wrap items-center gap-2">- {job.dueDate && new Date() > job.dueDate && currentStatus?.value === "draft" ? (- <StatusBadge- label="Expired"- color="amber"- className="w-[110px] whitespace-nowrap justify-center"+ </Card>+ </TabsContent>+ <TabsContent value="letter" className="mt-4">+ <Card className="p-6">+ <CoverLetterTab+ letter={job.CoverLetter}+ blockedReason={coverLetterBlockedReason}+ onGenerate={onCoverLetter}/>- ) : (- <StatusBadge- label={currentStatus?.label ?? ""}- color={getJobStatusBadgeColor(currentStatus?.value ?? "")}- className="w-[110px] whitespace-nowrap justify-center"+ </Card>+ </TabsContent>+ {/* forceMount keeps ⋮ → Add a Note and the count badge working off-tab. */}+ <TabsContent+ value="notes"+ className="mt-4 data-[state=inactive]:hidden"+ forceMount+ >+ <Card className="p-6">+ <NotesSection+ jobId={job.id}+ openTrigger={noteOpenTrigger}+ onCountChange={setNotesCount}/>- )}- {job?.appliedDate && (- <span>{format(new Date(job.appliedDate), "PP")}</span>- )}- {job.createdVia && (- <Badge className="gap-1 bg-violet-500 dark:bg-violet-400">- <Sparkles className="h-3.5 w-3.5" />- via {job.createdVia}- </Badge>- )}- </h3>- {job.tags && job.tags.length > 0 && (- <div className="my-3 ml-4 flex flex-wrap gap-1">- {job.tags.map((tag) => (- <Badge key={tag.id} variant="secondary">- {tag.label}- </Badge>- ))}- </div>- )}- <div className="my-4 ml-4">- <TipTapContentViewer content={job?.description} />- </div>- {parsedMatchData && (- <div className="mx-4 mb-4">- <h4 className="font-medium mb-2 flex items-center gap-2">- <Sparkles className="h-4 w-4" />- AI Match Analysis- </h4>- <MatchDetails matchData={parsedMatchData} />- </div>- )}- <NotesSection jobId={job.id} openTrigger={noteOpenTrigger} />- <CardFooter></CardFooter>- </Card>- )}+ </Card>+ </TabsContent>+ </Tabs>+ </div><AddJobjobStatuses={jobStatuses}companies={companies}@@ -404,7 +251,7 @@ function JobDetails({editJob={editJobTarget}resetEditJob={resetEditJob}hideTrigger- redirectPath={`/dashboard/myjobs/${job.id}`}+ redirectPath={`/dashboard/myjobs/${job.id}?tab=${activeTab}`}/><DeleteAlertDialogpageTitle="job"diff --git a/src/components/myjobs/NotesSection.tsx b/src/components/myjobs/NotesSection.tsxindex 9c5e8af..302bf19 100644--- a/src/components/myjobs/NotesSection.tsx+++ b/src/components/myjobs/NotesSection.tsx@@ -6,23 +6,21 @@ import { NoteCard } from "./NoteCard";import { NoteDialog } from "./NoteDialog";import { DeleteAlertDialog } from "../DeleteAlertDialog";import { Button } from "../ui/button";-import { Badge } from "../ui/badge";-import { ChevronDown, PlusCircle, StickyNote } from "lucide-react";-import {- Collapsible,- CollapsibleContent,- CollapsibleTrigger,-} from "../ui/collapsible";+import { PlusCircle } from "lucide-react";import { toastActionResult } from "@/lib/toast";type NotesSectionProps = {jobId: string;openTrigger?: number;+ onCountChange?: (count: number) => void;};-export function NotesSection({ jobId, openTrigger }: NotesSectionProps) {+export function NotesSection({+ jobId,+ openTrigger,+ onCountChange,+}: NotesSectionProps) {const [notes, setNotes] = useState<NoteResponse[]>([]);- const [isOpen, setIsOpen] = useState(false);const [dialogOpen, setDialogOpen] = useState(false);const [editNote, setEditNote] = useState<NoteResponse | null>(null);const [deleteAlertOpen, setDeleteAlertOpen] = useState(false);@@ -32,9 +30,9 @@ export function NotesSection({ jobId, openTrigger }: NotesSectionProps) {const result = await getNotesByJobId(jobId);if (result.success) {setNotes(result.data);- if (result.data.length > 0) setIsOpen(true);+ onCountChange?.(result.data.length);}- }, [jobId]);+ }, [jobId, onCountChange]);useEffect(() => {loadNotes();@@ -79,20 +77,15 @@ export function NotesSection({ jobId, openTrigger }: NotesSectionProps) {return (<>- <Collapsible open={isOpen} onOpenChange={setIsOpen} className="mx-4 mb-4">+ <div><div className="flex items-center justify-between">- <CollapsibleTrigger className="flex items-center gap-2 hover:opacity-80">- <StickyNote className="h-4 w-4" />- <span className="font-medium">Notes</span>- {notes.length > 0 && (- <Badge variant="secondary" className="text-xs">- {notes.length}- </Badge>- )}- <ChevronDown- className={`h-4 w-4 transition-transform ${isOpen ? "rotate-180" : ""}`}- />- </CollapsibleTrigger>+ <span className="text-sm text-muted-foreground">+ {notes.length === 0+ ? "Notes"+ : notes.length === 1+ ? "1 note on this job"+ : `${notes.length} notes on this job`}+ </span><Buttonvariant="outline"size="sm"@@ -103,7 +96,7 @@ export function NotesSection({ jobId, openTrigger }: NotesSectionProps) {New Note</Button></div>- <CollapsibleContent className="mt-3 space-y-3">+ <div className="mt-3 space-y-3">{notes.length === 0 ? (<p className="text-sm text-muted-foreground">No notes yet.</p>) : (@@ -116,8 +109,8 @@ export function NotesSection({ jobId, openTrigger }: NotesSectionProps) {/>)))}- </CollapsibleContent>- </Collapsible>+ </div>+ </div><NoteDialogopen={dialogOpen}diff --git a/src/components/myjobs/job-details/CoverLetterTab.tsx b/src/components/myjobs/job-details/CoverLetterTab.tsxnew file mode 100644index 0000000..fc2e037--- /dev/null+++ b/src/components/myjobs/job-details/CoverLetterTab.tsx@@ -0,0 +1,60 @@+"use client";++import { format } from "date-fns";+import { FileText, Sparkles } from "lucide-react";+import { Button } from "@/components/ui/button";+import { TipTapContentViewer } from "@/components/TipTapContentViewer";+import type { CoverLetter } from "@/models/profile.model";+import { JobTabEmptyState } from "./JobTabEmptyState";++type CoverLetterTabProps = {+ letter?: CoverLetter;+ blockedReason?: string;+ onGenerate: () => void;+};++export function CoverLetterTab({+ letter,+ blockedReason,+ onGenerate,+}: CoverLetterTabProps) {+ if (!letter) {+ return (+ <JobTabEmptyState+ icon={FileText}+ title="No cover letter yet"+ description="Generate one from your resume and this posting. You can edit and export it afterwards from Profile."+ actionLabel="Generate Cover Letter"+ onAction={onGenerate}+ actionDisabled={!!blockedReason}+ actionTitle={blockedReason}+ />+ );+ }++ const generatedAt = letter.updatedAt ?? letter.createdAt;++ return (+ <div className="space-y-4">+ <div className="flex flex-wrap items-center gap-3">+ <span className="text-xs text-muted-foreground">+ {letter.title}+ {generatedAt &&+ ` · Generated ${format(new Date(generatedAt), "PP")}`}+ </span>+ <Button+ variant="outline"+ size="sm"+ className="ml-auto cursor-pointer"+ onClick={onGenerate}+ disabled={!!blockedReason}+ title={blockedReason}+ >+ <Sparkles className="h-4 w-4 mr-2" />+ Regenerate+ </Button>+ </div>+ <TipTapContentViewer content={letter.content} />+ </div>+ );+}diff --git a/src/components/myjobs/job-details/JobDetailsHeader.tsx b/src/components/myjobs/job-details/JobDetailsHeader.tsxnew file mode 100644index 0000000..6164133--- /dev/null+++ b/src/components/myjobs/job-details/JobDetailsHeader.tsx@@ -0,0 +1,177 @@+"use client";++import {+ ArrowLeft,+ FileText,+ MoreVertical,+ Pencil,+ Sparkles,+ StickyNote,+ Tags,+ Trash,+ Trash2,+} from "lucide-react";+import { Button } from "@/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuPortal,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";+import { JobStatusMenuItems } from "@/components/myjobs/JobStatusMenuItems";+import {+ JobResponse,+ JobStatus,+ getJobTypeLabel,+ getWorkplaceTypeLabel,+} from "@/models/job.model";++type JobDetailsHeaderProps = {+ job: JobResponse;+ jobStatuses: JobStatus[];+ currentStatus: JobStatus;+ coverLetterBlockedReason?: string;+ onBack: () => void;+ onMatch: () => void;+ onCoverLetter: () => void;+ onEdit: () => void;+ onDelete: () => void;+ onAddNote: () => void;+ onChangeStatus: (status: JobStatus) => void;+};++export function JobDetailsHeader({+ job,+ jobStatuses,+ currentStatus,+ coverLetterBlockedReason,+ onBack,+ onMatch,+ onCoverLetter,+ onEdit,+ onDelete,+ onAddNote,+ onChangeStatus,+}: JobDetailsHeaderProps) {+ const subtitle = [+ job.Company?.label,+ job.Location?.label,+ getJobTypeLabel(job.jobType),+ job.workplaceType ? getWorkplaceTypeLabel(job.workplaceType) : null,+ ]+ .filter(Boolean)+ .join(" · ");++ return (+ <div className="flex flex-col gap-4 @5xl/main:flex-row @5xl/main:items-center">+ <div className="flex flex-1 min-w-0 items-center gap-4">+ <Button title="Go Back" variant="ghost" size="icon" onClick={onBack}>+ <ArrowLeft className="h-4 w-4" />+ </Button>+ <div className="flex-1 min-w-0">+ <h1 className="text-2xl font-bold">{job.JobTitle?.label}</h1>+ <p className="text-muted-foreground">{subtitle}</p>+ </div>+ </div>+ <div className="flex flex-wrap justify-end gap-2">+ <Button variant="outline" className="cursor-pointer" onClick={onMatch}>+ <Sparkles className="h-4 w-4 sm:mr-2" />+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">+ Match with AI+ </span>+ </Button>+ <Button+ variant="outline"+ className="cursor-pointer"+ data-testid="generate-cover-letter-btn"+ disabled={!!coverLetterBlockedReason}+ title={coverLetterBlockedReason}+ onClick={onCoverLetter}+ >+ <FileText className="h-4 w-4 sm:mr-2" />+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">+ {job.coverLetterId ? "Regenerate Letter" : "Cover Letter"}+ </span>+ </Button>+ <Button+ variant="outline"+ onClick={onEdit}+ data-testid="job-details-edit-btn"+ >+ <Pencil className="h-4 w-4 sm:mr-2" />+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">+ Edit+ </span>+ </Button>+ <Button+ variant="outline"+ className="text-destructive hover:text-destructive"+ onClick={onDelete}+ data-testid="job-details-delete-btn"+ >+ <Trash2 className="h-4 w-4 sm:mr-2" />+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">+ Delete+ </span>+ </Button>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ aria-haspopup="true"+ size="icon"+ variant="ghost"+ data-testid="job-details-actions-menu-btn"+ >+ <MoreVertical className="h-4 w-4" />+ <span className="sr-only">Toggle menu</span>+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-[200px]">+ <DropdownMenuLabel>Actions</DropdownMenuLabel>+ <DropdownMenuGroup>+ <DropdownMenuItem className="cursor-pointer" onClick={onEdit}>+ <Pencil className="mr-2 h-4 w-4" />+ Edit Job+ </DropdownMenuItem>+ <DropdownMenuItem className="cursor-pointer" onClick={onAddNote}>+ <StickyNote className="mr-2 h-4 w-4" />+ Add a Note+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuSub>+ <DropdownMenuSubTrigger>+ <Tags className="mr-2 h-4 w-4" />+ Change status+ </DropdownMenuSubTrigger>+ <DropdownMenuPortal>+ <DropdownMenuSubContent className="p-0">+ <JobStatusMenuItems+ jobStatuses={jobStatuses}+ currentStatusId={currentStatus.id}+ onSelectStatus={onChangeStatus}+ />+ </DropdownMenuSubContent>+ </DropdownMenuPortal>+ </DropdownMenuSub>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="text-red-600 cursor-pointer"+ onClick={onDelete}+ >+ <Trash className="mr-2 h-4 w-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ </div>+ );+}diff --git a/src/components/myjobs/job-details/JobSummaryCard.tsx b/src/components/myjobs/job-details/JobSummaryCard.tsxnew file mode 100644index 0000000..6cc928c--- /dev/null+++ b/src/components/myjobs/job-details/JobSummaryCard.tsx@@ -0,0 +1,149 @@+"use client";++import { format } from "date-fns";+import { ExternalLink, Sparkles } from "lucide-react";+import { Badge } from "@/components/ui/badge";+import { Card, CardContent } from "@/components/ui/card";+import { CircularScore } from "@/components/CircularScore";+import { StatusBadge } from "@/components/StatusBadge";+import { DownloadFileButton } from "@/components/profile/DownloadFileButton";+import { getJobStatusBadgeColor } from "@/lib/badge-colors";+import { formatUrl } from "@/lib/utils";+import type { JobMatchData } from "@/models/ai.schemas";+import {+ JobResponse,+ JobStatus,+ getJobTypeLabel,+ getWorkplaceTypeLabel,+} from "@/models/job.model";++type JobSummaryCardProps = {+ job: JobResponse;+ currentStatus: JobStatus;+ matchData: JobMatchData | null;+};++export function JobSummaryCard({+ job,+ currentStatus,+ matchData,+}: JobSummaryCardProps) {+ const expired =+ job.dueDate &&+ new Date() > new Date(job.dueDate) &&+ currentStatus?.value === "draft";++ return (+ <Card>+ <CardContent className="pt-6">+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4">+ <div>+ <p className="text-sm text-muted-foreground">Status</p>+ <div className="mt-1 flex flex-wrap items-center gap-2">+ {expired ? (+ <StatusBadge label="Expired" color="amber" />+ ) : (+ <StatusBadge+ label={currentStatus?.label ?? ""}+ color={getJobStatusBadgeColor(currentStatus?.value ?? "")}+ />+ )}+ </div>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Job Type</p>+ <p className="mt-1 font-medium">+ {getJobTypeLabel(job.jobType)}+ {job.workplaceType &&+ ` · ${getWorkplaceTypeLabel(job.workplaceType)}`}+ </p>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Salary Range</p>+ <p className="mt-1 font-medium">{job.salaryRange || "-"}</p>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Source</p>+ <p className="mt-1 font-medium">{job.JobSource?.label ?? "-"}</p>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Applied</p>+ <p className="mt-1 font-medium">+ {job.appliedDate+ ? format(new Date(job.appliedDate), "PP")+ : "Not applied"}+ </p>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">AI Match</p>+ {job.matchScore != null ? (+ <div className="mt-1 flex flex-wrap items-center gap-2">+ <CircularScore score={job.matchScore} size="sm" />+ {matchData?.recommendation && (+ <Badge variant="outline" className="capitalize">+ {matchData.recommendation}+ </Badge>+ )}+ </div>+ ) : (+ <p className="mt-1 font-medium">Not matched</p>+ )}+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Resume</p>+ <div className="mt-1 font-medium">+ {job.Resume?.File?.filePath ? (+ DownloadFileButton(+ job.Resume.File.filePath,+ job.Resume.title,+ job.Resume.File.fileName,+ )+ ) : (+ <p>-</p>+ )}+ </div>+ </div>+ <div>+ <p className="text-sm text-muted-foreground">Added</p>+ <div className="mt-1 flex flex-wrap items-center gap-2">+ <span className="font-medium">+ {job.createdAt ? format(new Date(job.createdAt), "PP") : "-"}+ </span>+ {job.createdVia && (+ <Badge className="gap-1 bg-violet-500 dark:bg-violet-400">+ <Sparkles className="h-3.5 w-3.5" />+ via {job.createdVia}+ </Badge>+ )}+ </div>+ </div>+ </div>++ {(job.jobUrl || (job.tags && job.tags.length > 0)) && (+ <div className="mt-6 pt-4 border-t flex flex-wrap items-center gap-4">+ {job.jobUrl && (+ <a+ href={formatUrl(job.jobUrl)}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-1.5 text-sm hover:underline"+ >+ <ExternalLink className="h-3.5 w-3.5" />+ {job.jobUrl}+ </a>+ )}+ {job.tags && job.tags.length > 0 && (+ <div className="ml-auto flex flex-wrap gap-1">+ {job.tags.map((tag) => (+ <Badge key={tag.id} variant="secondary">+ {tag.label}+ </Badge>+ ))}+ </div>+ )}+ </div>+ )}+ </CardContent>+ </Card>+ );+}diff --git a/src/components/myjobs/job-details/JobTabEmptyState.tsx b/src/components/myjobs/job-details/JobTabEmptyState.tsxnew file mode 100644index 0000000..118bd2e--- /dev/null+++ b/src/components/myjobs/job-details/JobTabEmptyState.tsx@@ -0,0 +1,45 @@+"use client";++import type { LucideIcon } from "lucide-react";+import { Button } from "@/components/ui/button";++type JobTabEmptyStateProps = {+ icon: LucideIcon;+ title: string;+ description: string;+ actionLabel: string;+ onAction: () => void;+ actionDisabled?: boolean;+ actionTitle?: string;+};++export function JobTabEmptyState({+ icon: Icon,+ title,+ description,+ actionLabel,+ onAction,+ actionDisabled,+ actionTitle,+}: JobTabEmptyStateProps) {+ return (+ <div className="flex flex-col items-center gap-3 py-8 text-center">+ <div className="flex h-12 w-12 items-center justify-center rounded-full bg-muted text-muted-foreground">+ <Icon className="h-6 w-6" />+ </div>+ <p className="font-semibold">{title}</p>+ <p className="max-w-[40ch] text-sm text-muted-foreground">+ {description}+ </p>+ <Button+ className="mt-1 cursor-pointer"+ onClick={onAction}+ disabled={actionDisabled}+ title={actionTitle}+ >+ <Icon className="h-4 w-4 mr-2" />+ {actionLabel}+ </Button>+ </div>+ );+}diff --git a/src/hooks/useTabQueryParam.ts b/src/hooks/useTabQueryParam.tsnew file mode 100644index 0000000..60a466f--- /dev/null+++ b/src/hooks/useTabQueryParam.ts@@ -0,0 +1,17 @@+import { useRouter, useSearchParams } from "next/navigation";++export function useTabQueryParam(+ validTabs: readonly string[],+ defaultTab: string,+) {+ const router = useRouter();+ const searchParams = useSearchParams();+ const raw = searchParams.get("tab");+ const activeTab = raw && validTabs.includes(raw) ? raw : defaultTab;++ const setTab = (tab: string) => {+ router.replace(`?tab=${tab}`, { scroll: false });+ };++ return [activeTab, setTab] as const;+}diff --git a/src/models/job.model.ts b/src/models/job.model.tsindex d021c61..c98e49d 100644--- a/src/models/job.model.ts+++ b/src/models/job.model.ts@@ -169,4 +169,12 @@ export function getWorkplaceTypeLabel(return (WORKPLACE_TYPES as Record<string, string>)[code] ?? fallback;}+export function getJobTypeLabel(+ code?: string | null,+ fallback: string = "Not specified",+): string {+ if (!code) return fallback;+ return (JOB_TYPES as Record<string, string>)[code] ?? fallback;+}+export type DescriptionCompleteness = "title-only" | "partial" | "full";diff --git a/wiki/jobs.md b/wiki/jobs.mdindex d4f0efb..8a72f65 100644--- a/wiki/jobs.md+++ b/wiki/jobs.md@@ -3,7 +3,7 @@ type: how-totitle: Jobsdescription: Adding jobs by hand or by pasting a posting into AI chat, moving them through the status workflow, and finding, editing, exporting or deleting them.feature: jobs-tags: [jobs, applications, add a job, status, applied, interview, offer, offer accepted, offer declined, rejected, csv, export, paste, filter, search]+tags: [jobs, applications, add a job, status, applied, interview, offer, offer accepted, offer declined, rejected, csv, export, paste, filter, search, job details, tabs, notes, ai match, cover letter]aliases: [job tracker, application tracker, my jobs, job board, track an application, job list]status: stablestale_after: 2027-08-31@@ -35,9 +35,17 @@ There are two ways. In the Jobs list, click a row's status badge and pick the neThe Add Job dialog also has a Status field, so a status can be set when you first create the job or from **Edit Job** later.+## What is on a job's details page?++Three parts, top to bottom. A **header row** with the job title, a `Company · Location · Job Type · Workplace` line, and the actions: Match with AI, Cover Letter, Edit, Delete and a **⋮** menu. Below it a **summary card** of eight facts — Status, Job Type, Salary Range, Source, Applied, AI Match, Resume and Added — with the job URL and any skill badges on a divider row underneath. Below that, four **tabs**.++The tabs are **Description**, **AI Match**, **Cover Letter** and **Notes**, and all four are always there. AI Match and Cover Letter stay in the bar even when the job has neither, showing a short explanation and a button to run it — so the tab set never shifts between jobs. Notes carries a count badge once the job has notes. The tab you are on is kept in the address bar, so a refresh, a bookmark or the browser Back button lands you back on the same one.+## How do I edit, annotate or delete a job?-All three are in the **⋮** menu on the job details page. **Edit Job** reopens the same dialog you added it with, pre-filled. **Add a Note** attaches a note to the job. **Delete** asks for confirmation and then removes the job permanently — there is no undo and no trash, so use *Archived* status instead if you only want it out of the list.+**Edit** and **Delete** are buttons in the header row of the job details page, and both are also in the **⋮** menu next to them. **Edit** reopens the same dialog you added the job with, pre-filled. **Delete** asks for confirmation and then removes the job permanently — there is no undo and no trash, so use *Archived* status instead if you only want it out of the list.++Notes live on the **Notes** tab: **New Note** there adds one, and each note can be edited or deleted from its own card. **Add a Note** in the **⋮** menu is a shortcut to the same thing from anywhere on the page — it switches to the Notes tab and opens the editor.## How do I find a job in a long list?