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(timeline): add the stage detail panel with interviewers, prep list, inline asked toggles and in-place notes
Khuram Niazc1a88843b087
diff --git a/__tests__/StageDetailPanel.spec.tsx b/__tests__/StageDetailPanel.spec.tsxnew file mode 100644index 0000000..d3f9ff4--- /dev/null+++ b/__tests__/StageDetailPanel.spec.tsx@@ -0,0 +1,147 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { StageDetailPanel } from "@/components/myjobs/job-details/timeline/StageDetailPanel";+import {+ setPrepQuestionAsked,+ setStageNotes,+} from "@/actions/jobStage.actions";++vi.mock("@/actions/jobStage.actions", () => ({+ setPrepQuestionAsked: vi.fn().mockResolvedValue({ success: true }),+ removeStagePrepQuestion: vi.fn().mockResolvedValue({ success: true }),+ unlinkStageInterviewer: vi.fn().mockResolvedValue({ success: true }),+ setStageNotes: vi.fn().mockResolvedValue({ success: true }),+}));+vi.mock("@/lib/toast", () => ({+ toastActionResult: vi.fn(),+ toastSuccess: vi.fn(),+ toastError: vi.fn(),+}));++const interviewStage = {+ id: "st1",+ jobId: "j1",+ stageTypeId: "t-int",+ occurredAt: new Date(2026, 8, 24, 10, 0),+ isCurrent: true,+ outcome: "scheduled",+ notes: "Bring laptop",+ durationMins: 90,+ format: "On-site",+ location: "Acme HQ, Bldg 3",+ createdAt: new Date(2026, 8, 2),+ updatedAt: new Date(2026, 8, 2),+ StageType: {+ id: "t-int",+ label: "Final / Onsite Interview",+ value: "final / onsite interview",+ statusId: "s-int",+ sortOrder: 6,+ Status: { id: "s-int", label: "Interview", value: "interview" },+ },+ interviewers: [+ {+ id: "iv1",+ stageId: "st1",+ contactId: "c1",+ Contact: { id: "c1", name: "Priya Nair", title: "VP Engineering", email: null, phone: null, linkedinUrl: null, Company: null },+ },+ ],+ prepQuestions: [+ { id: "p1", stageId: "st1", questionId: "q1", asked: true, askedAt: new Date(), Question: { id: "q1", question: "Walk through your caching strategy", tags: [{ id: "tg1", label: "System Design", value: "system design", createdBy: "u1" }] } },+ { id: "p2", stageId: "st1", questionId: "q2", asked: false, askedAt: null, Question: { id: "q2", question: "Tell me about a conflict with a teammate", tags: [] } },+ ],+} as any;++const nonInterviewStage = {+ ...interviewStage,+ id: "st2",+ interviewers: [],+ prepQuestions: [],+ StageType: {+ ...interviewStage.StageType,+ label: "Applied",+ Status: { id: "s-app", label: "Applied", value: "applied" },+ },+};++const noop = () => {};++describe("StageDetailPanel", () => {+ beforeEach(() => vi.clearAllMocks());++ it("shows the stage name, the current-stage marker and the scheduled line", () => {+ render(+ <StageDetailPanel stage={interviewStage} isCurrent onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ expect(screen.getByRole("heading", { name: "Final / Onsite Interview" })).toBeInTheDocument();+ expect(screen.getByText("CURRENT STAGE")).toBeInTheDocument();+ expect(screen.getByText(/Sep 24, 2026 · 10:00 AM · 90 min/)).toBeInTheDocument();+ });++ it("shows interviewers, format, location and the asked tally for an interview stage", () => {+ render(+ <StageDetailPanel stage={interviewStage} isCurrent onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ expect(screen.getByText("Priya Nair")).toBeInTheDocument();+ expect(screen.getByText(/On-site/)).toBeInTheDocument();+ expect(screen.getByText(/Acme HQ, Bldg 3/)).toBeInTheDocument();+ expect(screen.getByText("1 of 2 asked")).toBeInTheDocument();+ expect(screen.getByText("System Design")).toBeInTheDocument();+ });++ it("hides interviewers and the prep list on a non-interview stage", () => {+ render(+ <StageDetailPanel stage={nonInterviewStage} isCurrent={false} onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ expect(screen.queryByText(/INTERVIEWERS/)).toBeNull();+ expect(screen.queryByText(/PREP LIST/)).toBeNull();+ // Notes are a live textarea, so this is a value, not page text.+ expect(screen.getByLabelText("NOTES")).toHaveValue("Bring laptop");+ });++ it("marks a question asked inline, with no dialog and no save step", async () => {+ render(+ <StageDetailPanel stage={interviewStage} isCurrent onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ await userEvent.click(+ screen.getByRole("checkbox", { name: /Tell me about a conflict with a teammate/ }),+ );++ expect(setPrepQuestionAsked).toHaveBeenCalledWith("p2", true);+ });++ // The artboard's inline notes editor. Save appears only once the text has+ // actually changed, so the resting panel is not cluttered with dead buttons.+ it("edits notes in place, showing Save only once the text changes", async () => {+ render(+ <StageDetailPanel stage={interviewStage} isCurrent onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ expect(screen.queryByRole("button", { name: "Save Changes" })).toBeNull();++ await userEvent.type(screen.getByLabelText("NOTES"), " Ask about on-call.");+ await userEvent.click(screen.getByRole("button", { name: "Save Changes" }));++ expect(setStageNotes).toHaveBeenCalledWith(+ "st1",+ "Bring laptop Ask about on-call.",+ );+ });++ it("reverts the draft on Cancel without calling the action", async () => {+ render(+ <StageDetailPanel stage={interviewStage} isCurrent onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ await userEvent.type(screen.getByLabelText("NOTES"), " scratch");+ await userEvent.click(screen.getByRole("button", { name: "Cancel" }));++ expect(screen.getByLabelText("NOTES")).toHaveValue("Bring laptop");+ expect(setStageNotes).not.toHaveBeenCalled();+ });+});diff --git a/src/components/myjobs/job-details/timeline/StageDetailPanel.tsx b/src/components/myjobs/job-details/timeline/StageDetailPanel.tsxnew file mode 100644index 0000000..ed9350d--- /dev/null+++ b/src/components/myjobs/job-details/timeline/StageDetailPanel.tsx@@ -0,0 +1,169 @@+"use client";+import { useTransition } from "react";+import { CalendarDays, Monitor, Pencil, UserPlus, X } from "lucide-react";+import { Badge } from "@/components/ui/badge";+import { Button } from "@/components/ui/button";+import { toastActionResult } from "@/lib/toast";+import { unlinkStageInterviewer } from "@/actions/jobStage.actions";+import { STAGE_OUTCOMES } from "@/lib/constants";+import type { JobStage } from "@/models/jobStage.model";+import {+ formatStageDateTime,+ isInterviewStage,+ stageInitials,+} from "./stageDisplay";+import { StagePrepList } from "./StagePrepList";+import { StageNotes } from "./StageNotes";++type StageDetailPanelProps = {+ stage: JobStage;+ isCurrent: boolean;+ onEdit: () => void;+ onLinkInterviewers: () => void;+ onAddPrepQuestions: () => void;+ onChanged: () => void;+};++export function StageDetailPanel({+ stage,+ isCurrent,+ onEdit,+ onLinkInterviewers,+ onAddPrepQuestions,+ onChanged,+}: StageDetailPanelProps) {+ const [, startTransition] = useTransition();+ const interview = isInterviewStage(stage);+ const outcomeLabel = STAGE_OUTCOMES.find((o) => o.value === stage.outcome)?.label;++ const unlink = (linkId: string) => {+ startTransition(async () => {+ const res = await unlinkStageInterviewer(linkId);+ toastActionResult(res, {+ success: "Interviewer unlinked from this stage",+ onSuccess: onChanged,+ });+ });+ };++ return (+ <div className="flex-1 rounded-lg border bg-card p-6">+ <div className="flex items-start justify-between gap-2">+ <div className="flex flex-wrap items-center gap-2.5">+ <h3 className="text-lg font-bold">{stage.StageType.label}</h3>+ {isCurrent && (+ <span className="rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground">+ CURRENT STAGE+ </span>+ )}+ </div>+ <Button+ variant="outline"+ size="icon"+ className="h-8 w-8 cursor-pointer"+ aria-label={`Edit ${stage.StageType.label}`}+ onClick={onEdit}+ >+ <Pencil className="h-3.5 w-3.5" />+ </Button>+ </div>++ <p className="mt-1.5 flex items-center gap-1.5 text-[13px] text-muted-foreground">+ <CalendarDays className="h-3.5 w-3.5" />+ {formatStageDateTime(stage.occurredAt, stage.durationMins)}+ </p>++ {interview && (+ <>+ <hr className="my-4" />+ <div className="grid gap-5 @lg/timeline:grid-cols-2">+ <div>+ <div className="flex items-center justify-between gap-2">+ <span className="text-[11px] font-bold tracking-wide text-muted-foreground">+ INTERVIEWERS+ </span>+ <Button+ variant="ghost"+ size="sm"+ className="h-6 cursor-pointer gap-1 px-2 text-xs"+ onClick={onLinkInterviewers}+ >+ <UserPlus className="h-3 w-3" />+ Link+ </Button>+ </div>+ {stage.interviewers.length === 0 ? (+ <p className="mt-2 text-sm text-muted-foreground">+ No interviewers linked yet.+ </p>+ ) : (+ <ul className="mt-2 space-y-2">+ {stage.interviewers.map((link) => (+ <li key={link.id} className="flex items-center gap-2.5">+ <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-[13px] font-bold text-primary-foreground">+ {stageInitials(link.Contact.name)}+ </span>+ <span className="min-w-0 flex-1">+ <span className="block truncate text-sm font-bold">+ {link.Contact.name}+ </span>+ {link.Contact.title && (+ <span className="block truncate text-xs text-muted-foreground">+ {link.Contact.title}+ </span>+ )}+ </span>+ <Button+ variant="ghost"+ size="icon"+ className="h-7 w-7 cursor-pointer"+ aria-label={`Unlink ${link.Contact.name}`}+ onClick={() => unlink(link.id)}+ >+ <X className="h-3.5 w-3.5" />+ </Button>+ </li>+ ))}+ </ul>+ )}+ </div>++ <div>+ <span className="text-[11px] font-bold tracking-wide text-muted-foreground">+ FORMAT+ </span>+ <p className="mt-2 flex items-center gap-2 text-sm">+ <Monitor className="h-3.5 w-3.5 shrink-0" />+ {[stage.format, stage.location].filter(Boolean).join(" · ") || "Not set"}+ </p>+ </div>+ </div>++ <hr className="my-4" />+ <StagePrepList+ stage={stage}+ onAddPrepQuestions={onAddPrepQuestions}+ onChanged={onChanged}+ />+ </>+ )}++ <hr className="my-4" />+ <div className="space-y-3">+ <div>+ <span className="text-[11px] font-bold tracking-wide text-muted-foreground">+ OUTCOME+ </span>+ <p className="mt-1.5 text-sm">+ {outcomeLabel ? (+ <Badge variant="secondary">{outcomeLabel}</Badge>+ ) : (+ <span className="text-muted-foreground">Not recorded</span>+ )}+ </p>+ </div>+ <StageNotes stage={stage} onChanged={onChanged} />+ </div>+ </div>+ );+}diff --git a/src/components/myjobs/job-details/timeline/StageNotes.tsx b/src/components/myjobs/job-details/timeline/StageNotes.tsxnew file mode 100644index 0000000..258e9c8--- /dev/null+++ b/src/components/myjobs/job-details/timeline/StageNotes.tsx@@ -0,0 +1,72 @@+"use client";+import { useEffect, useState, useTransition } from "react";+import { Button } from "@/components/ui/button";+import { Textarea } from "@/components/ui/textarea";+import { toastActionResult } from "@/lib/toast";+import { setStageNotes } from "@/actions/jobStage.actions";+import type { JobStage } from "@/models/jobStage.model";++type StageNotesProps = {+ stage: JobStage;+ onChanged: () => void;+};++export function StageNotes({ stage, onChanged }: StageNotesProps) {+ const [draft, setDraft] = useState(stage.notes ?? "");+ const [saving, startTransition] = useTransition();++ // Selecting another stage in the history list re-renders this component+ // with a different stage, so the draft has to follow the id, not mount.+ useEffect(() => {+ setDraft(stage.notes ?? "");+ }, [stage.id, stage.notes]);++ const dirty = draft !== (stage.notes ?? "");++ const save = () => {+ startTransition(async () => {+ const res = await setStageNotes(stage.id, draft);+ toastActionResult(res, { success: "Note saved", onSuccess: onChanged });+ });+ };++ return (+ <div>+ <label+ htmlFor={`stage-notes-${stage.id}`}+ className="text-[11px] font-bold tracking-wide text-muted-foreground"+ >+ NOTES+ </label>+ <Textarea+ id={`stage-notes-${stage.id}`}+ value={draft}+ onChange={(e) => setDraft(e.target.value)}+ placeholder="What happened, what to prepare next time…"+ className="mt-2 min-h-18 resize-none text-sm"+ />+ {/* Only once there is something to save: the artboard shows the edit+ state, not the resting state. */}+ {dirty && (+ <div className="mt-2 flex justify-end gap-2">+ <Button+ variant="outline"+ size="sm"+ className="cursor-pointer"+ onClick={() => setDraft(stage.notes ?? "")}+ >+ Cancel+ </Button>+ <Button+ size="sm"+ className="cursor-pointer"+ disabled={saving}+ onClick={save}+ >+ Save Changes+ </Button>+ </div>+ )}+ </div>+ );+}diff --git a/src/components/myjobs/job-details/timeline/StagePrepList.tsx b/src/components/myjobs/job-details/timeline/StagePrepList.tsxnew file mode 100644index 0000000..9750a01--- /dev/null+++ b/src/components/myjobs/job-details/timeline/StagePrepList.tsx@@ -0,0 +1,140 @@+"use client";+import { useState, useTransition } from "react";+import { Plus, X } from "lucide-react";+import { cn } from "@/lib/utils";+import { Badge } from "@/components/ui/badge";+import { Button } from "@/components/ui/button";+import { toastActionResult } from "@/lib/toast";+import {+ removeStagePrepQuestion,+ setPrepQuestionAsked,+} from "@/actions/jobStage.actions";+import type { JobStage } from "@/models/jobStage.model";+import { askedTally } from "./stageDisplay";++type StagePrepListProps = {+ stage: JobStage;+ onAddPrepQuestions: () => void;+ onChanged: () => void;+};++export function StagePrepList({+ stage,+ onAddPrepQuestions,+ onChanged,+}: StagePrepListProps) {+ const [, startTransition] = useTransition();+ // Optimistic so the checkbox never lags the click; the reload below is what+ // makes it durable.+ const [pending, setPending] = useState<Record<string, boolean>>({});+ const rows = stage.prepQuestions ?? [];+ const { asked, total } = askedTally(stage);++ const toggle = (linkId: string, next: boolean) => {+ setPending((prev) => ({ ...prev, [linkId]: next }));+ startTransition(async () => {+ const res = await setPrepQuestionAsked(linkId, next);+ toastActionResult(res, {+ success: next ? "Marked as asked" : "Marked as not asked",+ onSuccess: onChanged,+ });+ });+ };++ const remove = (linkId: string) => {+ startTransition(async () => {+ const res = await removeStagePrepQuestion(linkId);+ toastActionResult(res, {+ success: "Question removed from the prep list",+ onSuccess: onChanged,+ });+ });+ };++ return (+ <div>+ <div className="flex flex-wrap items-center justify-between gap-2">+ <div className="flex items-center gap-2">+ <span className="text-[11px] font-bold tracking-wide text-muted-foreground">+ PREP LIST · INTERVIEW QUESTIONS · {total}+ </span>+ {total > 0 && (+ <span className="rounded-full bg-emerald-500/15 px-2 py-0.5 text-[11px] font-bold text-emerald-700 dark:text-emerald-300">+ {asked} of {total} asked+ </span>+ )}+ </div>+ <Button+ variant="outline"+ size="sm"+ className="h-7 cursor-pointer gap-1"+ onClick={onAddPrepQuestions}+ >+ <Plus className="h-3 w-3" />+ Add to Prep List+ </Button>+ </div>+ <p className="mt-1 text-xs text-muted-foreground">+ Check off a question once your interviewer actually asks it.+ </p>++ {total === 0 ? (+ <p className="mt-2.5 rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground">+ No questions on this prep list yet.+ </p>+ ) : (+ <ul className="mt-2.5 overflow-hidden rounded-lg border">+ {rows.map((row, index) => {+ const isAsked = pending[row.id] ?? row.asked;+ return (+ <li+ key={row.id}+ className={cn(+ "flex items-center gap-2.5 px-3.5 py-2.5",+ index > 0 && "border-t",+ isAsked && "bg-emerald-500/10",+ )}+ >+ <label className="flex flex-1 cursor-pointer items-center gap-2.5">+ <input+ type="checkbox"+ className="h-4 w-4 shrink-0 accent-emerald-600"+ checked={isAsked}+ onChange={(e) => toggle(row.id, e.target.checked)}+ />+ <span+ className={cn(+ "flex-1 text-[13px]",+ !isAsked && "text-muted-foreground",+ )}+ >+ {row.Question.question}+ </span>+ </label>+ {isAsked && (+ <span className="text-[11px] font-bold text-emerald-700 dark:text-emerald-300">+ Asked+ </span>+ )}+ {row.Question.tags?.map((tag) => (+ <Badge key={tag.id} variant="secondary" className="text-[11px]">+ {tag.label}+ </Badge>+ ))}+ <Button+ variant="ghost"+ size="icon"+ className="h-7 w-7 cursor-pointer"+ aria-label={`Remove ${row.Question.question} from the prep list`}+ onClick={() => remove(row.id)}+ >+ <X className="h-3.5 w-3.5" />+ </Button>+ </li>+ );+ })}+ </ul>+ )}+ </div>+ );+}