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
fix(timeline): date the stage a status change appends, confine format/duration/location to interview stages, and unblock future dates in the stage pickers
Khuram Niazf575a658eaa1
diff --git a/__tests__/AddStageDialog.spec.tsx b/__tests__/AddStageDialog.spec.tsxindex f698a7b..9ced9f8 100644--- a/__tests__/AddStageDialog.spec.tsx+++ b/__tests__/AddStageDialog.spec.tsx@@ -85,7 +85,9 @@ describe("AddStageDialog", () => {expect(screen.getByText(/PARENT STATUS/i)).toBeInTheDocument();});- it("saves with the picked type, no date, and set-as-current", async () => {+ // Adding a stage records something that just happened, so the date and time+ // open on now rather than empty.+ it("saves with the picked type, today's date and time, and set-as-current", async () => {render(<AddStageDialog {...props} />);await openStageTypePicker();@@ -97,6 +99,8 @@ describe("AddStageDialog", () => {jobId: "j1",stageTypeId: "t-off",setAsCurrent: true,+ date: expect.any(Date),+ time: expect.stringMatching(/^(0[1-9]|1[0-2]):[0-5][0-9] (AM|PM)$/),}),);});diff --git a/__tests__/StageDetailPanel.spec.tsx b/__tests__/StageDetailPanel.spec.tsxindex 65d2e77..a1ba9f8 100644--- a/__tests__/StageDetailPanel.spec.tsx+++ b/__tests__/StageDetailPanel.spec.tsx@@ -134,6 +134,20 @@ describe("StageDetailPanel", () => {expect(screen.getByLabelText("NOTES")).toHaveValue("Bring laptop");});+ // Location, format and duration are interview-only in the Add Stage dialog,+ // so a legacy row carrying them must not surface them here either.+ it("hides location, format and duration on a non-interview stage", () => {+ render(+ <StageDetailPanel stage={nonInterviewStage} isCurrent={false} onEdit={noop} onLinkInterviewers={noop} onAddPrepQuestions={noop} onChanged={noop} />,+ );++ expect(screen.queryByText("LOCATION")).toBeNull();+ expect(screen.queryByText("FORMAT")).toBeNull();+ expect(screen.queryByText("DURATION")).toBeNull();+ expect(screen.queryByText(/90 min/)).toBeNull();+ expect(screen.getByText("OUTCOME")).toBeInTheDocument();+ });+// Nothing remounts when another stage is selected, so the tab has to be// reset by hand or an interview tab survives onto a stage that has none.it("returns to Overview when another stage is selected", async () => {diff --git a/__tests__/jobStage.actions.spec.ts b/__tests__/jobStage.actions.spec.tsindex efc439b..0772740 100644--- a/__tests__/jobStage.actions.spec.ts+++ b/__tests__/jobStage.actions.spec.ts@@ -105,6 +105,10 @@ describe("addJobStage", () => {label: "Panel Interview",created: true,});+ db.jobStageType.findFirst.mockResolvedValue({+ id: "t-new",+ Status: { value: "interview" },+ });db.jobStage.create.mockResolvedValue({ id: "st1" });db.jobStage.findFirst.mockResolvedValue({id: "st1",@@ -128,6 +132,32 @@ describe("addJobStage", () => {expect(db.jobStage.create.mock.calls[0][0].data.stageTypeId).toBe("t-new");});+ // The dialog hides format/duration/location for a non-interview type, so a+ // value typed before switching the type must not reach the row.+ it("blanks the interview-only fields for a non-interview stage", async () => {+ db.jobStageType.findFirst.mockResolvedValue({+ id: "t-rej",+ Status: { value: "rejected" },+ });+ db.jobStage.create.mockResolvedValue({ id: "st-rej" });+ db.jobStage.findFirst.mockResolvedValue({ id: "st-rej" });++ const res = await addJobStage({+ jobId: "j1",+ stageTypeId: "t-rej",+ format: "Video",+ durationMins: 45,+ location: "Zoom",+ setAsCurrent: false,+ } as any);++ expect(res.success).toBe(true);+ const data = db.jobStage.create.mock.calls[0][0].data;+ expect(data.format).toBeNull();+ expect(data.durationMins).toBeNull();+ expect(data.location).toBeNull();+ });+it("clears the old current stage and rewrites the job status when set as current", async () => {db.jobStageType.findFirst.mockResolvedValue(interviewType);db.jobStage.create.mockResolvedValue({ id: "st2" });diff --git a/__tests__/jobStatusStage.spec.ts b/__tests__/jobStatusStage.spec.tsindex 69cb021..1eba300 100644--- a/__tests__/jobStatusStage.spec.ts+++ b/__tests__/jobStatusStage.spec.ts@@ -62,7 +62,7 @@ describe("updateJobStatus", () => {});});- it("appends an undated current stage when the status genuinely changes", async () => {+ it("appends a current stage dated now when the status genuinely changes", async () => {db.jobStage.findFirst.mockResolvedValue({id: "st-app",StageType: { statusId: "s-app", Status: { value: "applied" } },@@ -75,7 +75,7 @@ describe("updateJobStatus", () => {expect(db.jobStage.create.mock.calls[0][0].data).toEqual({jobId: "j1",stageTypeId: "t-int",- occurredAt: null,+ occurredAt: expect.any(Date),isCurrent: false,});// D8: the helper scopes its own writes rather than trusting the caller.diff --git a/src/actions/job/shared.ts b/src/actions/job/shared.tsindex 5ebed15..3b1b950 100644--- a/src/actions/job/shared.ts+++ b/src/actions/job/shared.ts@@ -44,7 +44,7 @@ export async function appendStatusStage(if (current?.StageType.statusId === statusId) return;const stage = await tx.jobStage.create({- data: { jobId, stageTypeId, occurredAt: null, isCurrent: false },+ data: { jobId, stageTypeId, occurredAt: new Date(), isCurrent: false },});await promoteStage(tx, jobId, stage.id, userId);}diff --git a/src/actions/jobStage/mutations.ts b/src/actions/jobStage/mutations.tsindex fd96498..63c3aad 100644--- a/src/actions/jobStage/mutations.ts+++ b/src/actions/jobStage/mutations.ts@@ -17,28 +17,32 @@ import {} from "./shared";// Either the picked type (checked for ownership) or a resolved custom name.-const resolveStageTypeId = async (+// The parent status rides back out because format, duration and location are+// interview-only.+const resolveStageType = async (values: AddJobStageValues,userId: string,-): Promise<string> => {+): Promise<{ id: string; isInterview: boolean }> => {const custom = values.customLabel?.trim();- if (custom) {- const resolved = await resolveJobStageType(- custom,- userId,- values.customStatusId!,- );- return resolved.id;- }+ const id = custom+ ? (await resolveJobStageType(custom, userId, values.customStatusId!)).id+ : values.stageTypeId!;const owned = await prisma.jobStageType.findFirst({- where: { id: values.stageTypeId!, createdBy: userId },- select: { id: true },+ where: { id, createdBy: userId },+ select: { id: true, Status: { select: { value: true } } },});if (!owned) throw new Error("Stage type not found");- return owned.id;+ return { id: owned.id, isInterview: owned.Status.value === "interview" };};-const stageDataFrom = (values: AddJobStageValues, stageTypeId: string) => ({+// The dialog hides format, duration and location for a non-interview stage+// and the detail panel never renders them, so a type change has to blank+// them rather than leave values saved where nothing can show or clear them.+const stageDataFrom = (+ values: AddJobStageValues,+ stageTypeId: string,+ isInterview: boolean,+) => ({stageTypeId,occurredAt: values.date? values.time@@ -47,9 +51,9 @@ const stageDataFrom = (values: AddJobStageValues, stageTypeId: string) => ({: null,outcome: values.outcome ?? null,notes: values.notes?.trim() || null,- durationMins: values.durationMins ?? null,- format: values.format?.trim() || null,- location: values.location?.trim() || null,+ durationMins: isInterview ? (values.durationMins ?? null) : null,+ format: isInterview ? values.format?.trim() || null : null,+ location: isInterview ? values.location?.trim() || null : null,});export const addJobStage = async (@@ -64,11 +68,14 @@ export const addJobStage = async (});if (job === 0) throw new Error("Job not found");- const stageTypeId = await resolveStageTypeId(parsed, user.id);+ const stageType = await resolveStageType(parsed, user.id);const created = await prisma.$transaction(async (tx: any) => {const stage = await tx.jobStage.create({- data: { jobId: parsed.jobId, ...stageDataFrom(parsed, stageTypeId) },+ data: {+ jobId: parsed.jobId,+ ...stageDataFrom(parsed, stageType.id, stageType.isInterview),+ },});if (parsed.setAsCurrent) {await promoteStage(tx, parsed.jobId, stage.id, user.id);@@ -96,12 +103,12 @@ export const updateJobStage = async (const parsed = AddJobStageFormSchema.parse(values);const existing = await assertStageOwned(values.id, user.id);- const stageTypeId = await resolveStageTypeId(parsed, user.id);+ const stageType = await resolveStageType(parsed, user.id);const updated = await prisma.$transaction(async (tx: any) => {await tx.jobStage.update({where: { id: values.id },- data: stageDataFrom(parsed, stageTypeId),+ data: stageDataFrom(parsed, stageType.id, stageType.isInterview),});if (parsed.setAsCurrent) {await promoteStage(tx, existing.jobId, values.id!, user.id);diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsxindex 29ed0d0..f14e026 100644--- a/src/components/DatePicker.tsx+++ b/src/components/DatePicker.tsx@@ -1,6 +1,6 @@"use client";-import { addDays, format } from "date-fns";+import { addDays, addYears, format } from "date-fns";import { Calendar as CalendarIcon } from "lucide-react";import { cn } from "@/lib/utils";@@ -27,6 +27,8 @@ interface DatePickerProps {field: ControllerRenderProps<any, any>;presets: boolean;isEnabled: boolean;+ // Swaps the caption for month/year dropdowns, which need a bounded range:+ // left to itself the year dropdown stops at the end of the current year.captionLayout?: boolean;// Opt out of the default fixed trigger width when the field sits in a gridfullWidth?: boolean;@@ -84,7 +86,13 @@ export function DatePicker({mode="single"captionLayout={captionLayout ? "dropdown" : "label"}startMonth={captionLayout ? new Date(1970, 0) : undefined}- endMonth={captionLayout ? new Date() : undefined}+ endMonth={+ captionLayout+ ? disableFuture+ ? new Date()+ : addYears(new Date(), 10)+ : undefined+ }selected={field.value}disabled={disableFuture ? { after: new Date() } : undefined}onSelect={(value) => {diff --git a/src/components/TimePicker.tsx b/src/components/TimePicker.tsxindex 0ce4761..dd5fa76 100644--- a/src/components/TimePicker.tsx+++ b/src/components/TimePicker.tsx@@ -92,9 +92,10 @@ function TimeColumn({ label, options, selected, onSelect }: TimeColumnProps) {interface TimePickerProps {field: ControllerRenderProps<any, any>;+ fullWidth?: boolean;}-export function TimePicker({ field }: TimePickerProps) {+export function TimePicker({ field, fullWidth }: TimePickerProps) {const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);const { hour, minute, meridiem } = parseTime(field.value);@@ -117,7 +118,12 @@ export function TimePicker({ field }: TimePickerProps) {};return (- <div className="flex md:w-[240px] lg:w-[280px]">+ <div+ className={cn(+ "flex",+ fullWidth ? "w-full" : "md:w-[240px] lg:w-[280px]",+ )}+ ><Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen} modal><PopoverTrigger asChild><FormControl>diff --git a/src/components/myjobs/job-details/timeline/AddStageDialog.tsx b/src/components/myjobs/job-details/timeline/AddStageDialog.tsxindex 99a30c9..a14f762 100644--- a/src/components/myjobs/job-details/timeline/AddStageDialog.tsx+++ b/src/components/myjobs/job-details/timeline/AddStageDialog.tsx@@ -54,13 +54,16 @@ const OUTCOME_OPTIONS = STAGE_OUTCOMES.map((o) => ({label: o.label,}));+// Adding a stage is almost always recording something that just happened, so+// the pickers open on now. Clear the date (click the selected day again) for+// a stage whose date isn't known yet.const emptyValues = (jobId: string): AddJobStageValues => ({jobId,stageTypeId: "",customLabel: "",customStatusId: "",- date: null,- time: "",+ date: new Date(),+ time: format(new Date(), "hh:mm a"),notes: "",outcome: null,durationMins: null,@@ -224,7 +227,7 @@ export function AddStageDialog({render={({ field }) => (<FormItem className="flex flex-col"><FormLabel>TIME</FormLabel>- <TimePicker field={field} />+ <TimePicker field={field} fullWidth /><FormMessage /></FormItem>)}diff --git a/src/components/myjobs/job-details/timeline/StageDetailPanel.tsx b/src/components/myjobs/job-details/timeline/StageDetailPanel.tsxindex 018bad4..79920cc 100644--- a/src/components/myjobs/job-details/timeline/StageDetailPanel.tsx+++ b/src/components/myjobs/job-details/timeline/StageDetailPanel.tsx@@ -146,7 +146,10 @@ export function StageDetailPanel({<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)}+ {formatStageDateTime(+ stage.occurredAt,+ interview ? stage.durationMins : null,+ )}</p>{/* A one-tab bar is a control that does nothing, so a non-interviewdiff --git a/src/components/myjobs/job-details/timeline/StageOverviewTab.tsx b/src/components/myjobs/job-details/timeline/StageOverviewTab.tsxindex 1bc020c..88ec5b4 100644--- a/src/components/myjobs/job-details/timeline/StageOverviewTab.tsx+++ b/src/components/myjobs/job-details/timeline/StageOverviewTab.tsx@@ -4,6 +4,7 @@ import type { LucideIcon } from "lucide-react";import { Badge } from "@/components/ui/badge";import { STAGE_OUTCOMES } from "@/lib/constants";import type { JobStage } from "@/models/jobStage.model";+import { isInterviewStage } from "./stageDisplay";import { StageNotes } from "./StageNotes";type StageOverviewTabProps = {@@ -53,15 +54,17 @@ export function StageOverviewTab({ stage, onChanged }: StageOverviewTabProps) {</p></div>- <div className="grid gap-4 @lg/timeline:grid-cols-3">- <StageFact label="LOCATION" value={stage.location} icon={MapPin} />- <StageFact label="FORMAT" value={stage.format} icon={Monitor} />- <StageFact- label="DURATION"- value={stage.durationMins ? `${stage.durationMins} min` : null}- icon={Clock}- />- </div>+ {isInterviewStage(stage) && (+ <div className="grid gap-4 @lg/timeline:grid-cols-3">+ <StageFact label="LOCATION" value={stage.location} icon={MapPin} />+ <StageFact label="FORMAT" value={stage.format} icon={Monitor} />+ <StageFact+ label="DURATION"+ value={stage.durationMins ? `${stage.durationMins} min` : null}+ icon={Clock}+ />+ </div>+ )}<StageNotes stage={stage} onChanged={onChanged} /></div>diff --git a/wiki/timeline.md b/wiki/timeline.mdindex e4cd884..97a93d1 100644--- a/wiki/timeline.md+++ b/wiki/timeline.md@@ -25,9 +25,9 @@ Use **Add stage** at the bottom of the Stage History list, or the **Update StatuPick a **stage** from the list — *New*, *Draft*, *Applied*, *Interview*, *1st Screening Interview*, *2nd Technical Interview*, *Final / Onsite Interview*, *Offer*, *Offer Accepted*, *Offer Declined*, *Rejected*, *Expired*, *Archived* and *Withdrawn* are set up for you — or type your own name into **Or enter a custom stage name** and choose the **parent status** it means. A custom name is saved to your Library, so the second job that reaches your *Panel Interview* just picks it from the list.-**Date** and **Time** are optional, and **Notes** is free text. If the stage's parent status is *Interview*, three more fields appear: **Format**, **Duration** and **Location** — use Location for a meeting link as happily as for a street address. **Set as current stage** is ticked by default; leave it ticked when you are recording where the job is now, and untick it when you are backfilling something that already happened.+**Date** and **Time** start on today and the current time, since a stage you add is usually one that just happened; click the selected day again to clear the date if you don't know it yet. **Notes** is free text. If the stage's parent status is *Interview*, three more fields appear: **Format**, **Duration** and **Location** — use Location for a meeting link as happily as for a street address. **Set as current stage** is ticked by default; leave it ticked when you are recording where the job is now, and untick it when you are backfilling something that already happened.-Editing a stage later opens the same dialog with one extra field, **Outcome**: *Scheduled*, *Completed*, *Passed*, *Failed*, *No-show* or *Cancelled*. Outcome, location, format and duration all read back on the stage's **Overview** tab, above the notes box.+Editing a stage later opens the same dialog with one extra field, **Outcome**: *Scheduled*, *Completed*, *Passed*, *Failed*, *No-show* or *Cancelled*. Outcome reads back on the stage's **Overview** tab, above the notes box, and location, format and duration join it there on an interview stage. Switching a stage away from *Interview* clears those three, since nothing shows them on a non-interview stage.## How do I delete a stage?@@ -39,7 +39,7 @@ Deleting the **current** stage moves the job back to the stage before it, and thThe current stage sets the job's status: whatever parent status that stage's type carries becomes the job's status, everywhere the job is shown. Adding a stage with **Set as current stage** ticked moves the status; ticking the box on an older stage moves it back.-It works the other way round too. Changing the status from **Update Status → Change status**, from a row's status badge in the Jobs list, or from the Status field in the **Edit Job** dialog appends a new stage for that status and makes it current — so a status change never leaves the timeline behind. The appended stage has no date, because none of those places asks you for one; open it from the Timeline tab and add the date if you know it.+It works the other way round too. Changing the status from **Update Status → Change status**, from a row's status badge in the Jobs list, or from the Status field in the **Edit Job** dialog appends a new stage for that status and makes it current — so a status change never leaves the timeline behind. The appended stage is dated the moment you made the change; open it from the Timeline tab and edit the date if the step actually happened earlier.Re-picking a status the job already holds does nothing at all. If the current stage is *2nd Technical Interview* and you pick **Interview** from a dropdown, you already are at Interview, so no second stage is added.