Skip to content

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.

feat(timeline): add the horizontal stage stepper and the full stage history list

Khuram Niaze9683da53e51
diff --git a/__tests__/StageStepper.spec.tsx b/__tests__/StageStepper.spec.tsx
new file mode 100644
index 0000000..4660ded
--- /dev/null
+++ b/__tests__/StageStepper.spec.tsx
@@ -0,0 +1,118 @@
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { StageStepper } from "@/components/myjobs/job-details/timeline/StageStepper";
+
+const stage = (id: string, label: string, over: any = {}) => ({
+ id,
+ jobId: "j1",
+ stageTypeId: `t-${id}`,
+ occurredAt: null,
+ isCurrent: false,
+ outcome: null,
+ notes: null,
+ durationMins: null,
+ format: null,
+ location: null,
+ createdAt: new Date(2026, 8, 1),
+ updatedAt: new Date(2026, 8, 1),
+ StageType: { id: `t-${id}`, label, value: label.toLowerCase(), statusId: "s", sortOrder: 0, Status: { id: "s", label, value: "interview" } },
+ interviewers: [],
+ prepQuestions: [],
+ ...over,
+});
+
+const stages = [
+ stage("a", "New", { occurredAt: new Date(2026, 8, 1) }),
+ stage("b", "Applied", { occurredAt: new Date(2026, 8, 3) }),
+ stage("c", "Final / Onsite Interview", { occurredAt: new Date(2026, 8, 24), isCurrent: true }),
+] as any;
+
+const terminalTypes = [
+ { id: "t-off", label: "Offer", value: "offer", statusId: "s-off", sortOrder: 7, Status: { value: "offer" } },
+] as any;
+
+describe("StageStepper", () => {
+ it("renders every stage with its date, then the unreached terminal step", () => {
+ render(
+ <StageStepper
+ stages={stages}
+ selectedStageId="c"
+ currentStageId="c"
+ terminalTypes={terminalTypes}
+ onSelect={() => {}}
+ />,
+ );
+
+ expect(screen.getByText("New")).toBeInTheDocument();
+ expect(screen.getByText("Sep 1")).toBeInTheDocument();
+ expect(screen.getByText("Final / Onsite Interview")).toBeInTheDocument();
+ expect(screen.getByText("Offer")).toBeInTheDocument();
+ expect(screen.getByText("—")).toBeInTheDocument();
+ });
+
+ it("marks the current stage for assistive tech", () => {
+ render(
+ <StageStepper
+ stages={stages}
+ selectedStageId="c"
+ currentStageId="c"
+ terminalTypes={terminalTypes}
+ onSelect={() => {}}
+ />,
+ );
+
+ expect(
+ screen.getByRole("button", { name: /Final \/ Onsite Interview/ }),
+ ).toHaveAttribute("aria-current", "step");
+ });
+
+ it("selects a step on click", async () => {
+ const onSelect = vi.fn();
+ render(
+ <StageStepper
+ stages={stages}
+ selectedStageId="c"
+ currentStageId="c"
+ terminalTypes={terminalTypes}
+ onSelect={onSelect}
+ />,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: /Applied/ }));
+
+ expect(onSelect).toHaveBeenCalledWith("b");
+ });
+
+ it("renders the unreached terminal step as a non-interactive element", () => {
+ render(
+ <StageStepper
+ stages={stages}
+ selectedStageId="c"
+ currentStageId="c"
+ terminalTypes={terminalTypes}
+ onSelect={() => {}}
+ />,
+ );
+
+ expect(screen.queryByRole("button", { name: /Offer/ })).toBeNull();
+ });
+
+ // The rail truncates to one line; the full name stays reachable on hover
+ // and in the history list. Without this a long label wraps and pushes its
+ // dot out of line with the connectors either side.
+ it("keeps a long label on one line with the full name in a title", () => {
+ render(
+ <StageStepper
+ stages={stages}
+ selectedStageId="c"
+ currentStageId="c"
+ terminalTypes={terminalTypes}
+ onSelect={() => {}}
+ />,
+ );
+
+ const label = screen.getByText("Final / Onsite Interview");
+ expect(label).toHaveAttribute("title", "Final / Onsite Interview");
+ expect(label.className).toContain("truncate");
+ });
+});
diff --git a/src/components/myjobs/job-details/timeline/StageHistoryList.tsx b/src/components/myjobs/job-details/timeline/StageHistoryList.tsx
new file mode 100644
index 0000000..c2050f9
--- /dev/null
+++ b/src/components/myjobs/job-details/timeline/StageHistoryList.tsx
@@ -0,0 +1,103 @@
+"use client";
+import { Plus } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { Button } from "@/components/ui/button";
+import type { JobStage, JobStageTypeRef } from "@/models/jobStage.model";
+import { formatStageDate } from "./stageDisplay";
+
+type StageHistoryListProps = {
+ stages: JobStage[];
+ selectedStageId: string | null;
+ currentStageId: string | null;
+ terminalTypes: JobStageTypeRef[];
+ onSelect: (stageId: string) => void;
+ onAddStage: () => void;
+};
+
+export function StageHistoryList({
+ stages,
+ selectedStageId,
+ currentStageId,
+ terminalTypes,
+ onSelect,
+ onAddStage,
+}: StageHistoryListProps) {
+ return (
+ <div className="rounded-lg border bg-card p-2.5">
+ <h3 className="px-2.5 py-2 text-xs font-bold tracking-wide text-muted-foreground">
+ STAGE HISTORY
+ </h3>
+
+ {/* The complete history lives here, not in the stepper: nothing is
+ reachable only by scrolling the stepper sideways. */}
+ <ul>
+ {stages.map((stage) => {
+ const isSelected = stage.id === selectedStageId;
+ const isCurrent = stage.id === currentStageId;
+ return (
+ <li key={stage.id}>
+ <button
+ type="button"
+ onClick={() => onSelect(stage.id)}
+ aria-current={isCurrent ? "step" : undefined}
+ className={cn(
+ "flex w-full cursor-pointer items-center gap-2.5 rounded-md p-2.5 text-left",
+ "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
+ isSelected ? "bg-accent" : "hover:bg-accent/50",
+ )}
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "h-2 w-2 shrink-0 rounded-full",
+ isCurrent ? "bg-primary" : "bg-emerald-500 dark:bg-emerald-400",
+ )}
+ />
+ <span
+ className={cn(
+ "flex-1 truncate text-[13px] font-semibold",
+ isCurrent && "font-extrabold text-primary",
+ )}
+ >
+ {stage.StageType.label}
+ </span>
+ <span
+ className={cn(
+ "text-xs",
+ isCurrent ? "font-bold text-primary" : "text-muted-foreground",
+ )}
+ >
+ {formatStageDate(stage.occurredAt)}
+ </span>
+ {isCurrent && <span className="sr-only">Current stage</span>}
+ </button>
+ </li>
+ );
+ })}
+
+ {terminalTypes.map((type) => (
+ <li
+ key={type.id}
+ className="flex items-center gap-2.5 p-2.5 text-muted-foreground"
+ >
+ <span aria-hidden className="h-2 w-2 shrink-0 rounded-full border-2 border-border" />
+ <span className="flex-1 truncate text-[13px] font-semibold">
+ {type.label}
+ </span>
+ <span className="text-xs">—</span>
+ </li>
+ ))}
+ </ul>
+
+ <Button
+ variant="outline"
+ className="mt-1.5 w-full cursor-pointer border-dashed"
+ onClick={onAddStage}
+ data-testid="timeline-add-stage-btn"
+ >
+ <Plus className="mr-1.5 h-3.5 w-3.5" />
+ Add stage
+ </Button>
+ </div>
+ );
+}
diff --git a/src/components/myjobs/job-details/timeline/StageStepper.tsx b/src/components/myjobs/job-details/timeline/StageStepper.tsx
new file mode 100644
index 0000000..0a8db75
--- /dev/null
+++ b/src/components/myjobs/job-details/timeline/StageStepper.tsx
@@ -0,0 +1,109 @@
+"use client";
+import { Check } from "lucide-react";
+import { cn } from "@/lib/utils";
+import type { JobStage, JobStageTypeRef } from "@/models/jobStage.model";
+import { formatStageDate } from "./stageDisplay";
+
+type StageStepperProps = {
+ stages: JobStage[];
+ selectedStageId: string | null;
+ currentStageId: string | null;
+ terminalTypes: JobStageTypeRef[];
+ onSelect: (stageId: string) => void;
+};
+
+export function StageStepper({
+ stages,
+ selectedStageId,
+ currentStageId,
+ terminalTypes,
+ onSelect,
+}: StageStepperProps) {
+ const currentIndex = stages.findIndex((s) => s.id === currentStageId);
+
+ return (
+ // Container query, not a viewport breakpoint: the docked chat panel
+ // narrows this column without changing the viewport width.
+ <div className="@container/stepper rounded-lg border bg-card p-6">
+ <div className="flex min-w-max items-start overflow-x-auto pb-2">
+ {stages.map((stage, index) => {
+ const isCurrent = stage.id === currentStageId;
+ const isComplete = currentIndex >= 0 && index < currentIndex;
+ const isSelected = stage.id === selectedStageId;
+ return (
+ <div key={stage.id} className="flex items-start">
+ {index > 0 && (
+ <span
+ aria-hidden
+ className={cn(
+ "mt-[15px] h-0.5 w-10 shrink-0 @lg/stepper:w-14",
+ isCurrent
+ ? "bg-primary"
+ : isComplete
+ ? "bg-emerald-500 dark:bg-emerald-400"
+ : "bg-border",
+ )}
+ />
+ )}
+ <button
+ type="button"
+ aria-current={isCurrent ? "step" : undefined}
+ onClick={() => onSelect(stage.id)}
+ className={cn(
+ "flex w-24 shrink-0 flex-col items-center gap-2 px-2 text-center",
+ "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-pointer",
+ isSelected && "bg-accent/40",
+ )}
+ >
+ <span
+ className={cn(
+ "flex h-8 w-8 items-center justify-center rounded-full",
+ isCurrent
+ ? "bg-primary ring-4 ring-primary/20"
+ : isComplete
+ ? "bg-emerald-500 dark:bg-emerald-400"
+ : "border-2 border-border bg-card",
+ )}
+ >
+ {isComplete && (
+ <Check className="h-4 w-4 text-background" strokeWidth={3} />
+ )}
+ </span>
+ {/* One line, truncated: the rail's baseline breaks if a long
+ label wraps, and the history list below carries it in full. */}
+ <span
+ title={stage.StageType.label}
+ className={cn(
+ "w-full truncate text-[13px] font-semibold",
+ isCurrent && "font-extrabold text-primary",
+ )}
+ >
+ {stage.StageType.label}
+ </span>
+ <span className="text-[11px] text-muted-foreground">
+ {formatStageDate(stage.occurredAt)}
+ </span>
+ </button>
+ </div>
+ );
+ })}
+
+ {terminalTypes.map((type) => (
+ <div key={type.id} className="flex items-start">
+ <span aria-hidden className="mt-[15px] h-0.5 w-10 shrink-0 bg-border @lg/stepper:w-14" />
+ <div className="flex w-24 shrink-0 flex-col items-center gap-2 px-2 text-center">
+ <span className="h-8 w-8 rounded-full border-2 border-border bg-card" />
+ <span
+ title={type.label}
+ className="w-full truncate text-[13px] font-semibold text-muted-foreground"
+ >
+ {type.label}
+ </span>
+ <span className="text-[11px] text-muted-foreground">—</span>
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}