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: Update job model and related components to handle optional Location and JobSource fields, fix add job mcp tool issue

Khuram Niaz0a19412c42b0
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index eea139a..bf7b086 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -143,10 +143,10 @@ export function AddJob({
userId: editJob.userId,
title: editJob.JobTitle.id,
company: editJob.Company.id,
- location: editJob.Location.id,
+ location: editJob.Location?.id,
type: editJob.jobType,
workplaceType: editJob.workplaceType ?? undefined,
- source: editJob.JobSource.id,
+ source: editJob.JobSource?.id,
status: editJob.Status.id,
dueDate: editJob.dueDate,
salaryRange: editJob.salaryRange,
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index bd35446..8a80720 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -249,7 +249,8 @@ function JobDetails({
{job?.Company?.label}
<CardTitle>{job?.JobTitle?.label}</CardTitle>
<CardDescription>
- {job?.Location?.label} - {getJobType(job?.jobType)}
+ {job?.Location?.label && `${job.Location.label} - `}
+ {getJobType(job?.jobType)}
{job?.workplaceType && ` · ${getWorkplaceTypeLabel(job.workplaceType)}`}
</CardDescription>
</div>
diff --git a/src/lib/ai/tools/preprocessing-job.ts b/src/lib/ai/tools/preprocessing-job.ts
index 13ba308..216d6f1 100644
--- a/src/lib/ai/tools/preprocessing-job.ts
+++ b/src/lib/ai/tools/preprocessing-job.ts
@@ -45,7 +45,7 @@ export const convertJobToText = (job: JobResponse): Promise<string> => {
description,
JobTitle: { label: jobTitle },
Company: { label: companyName },
- Location: { label: location },
+ Location,
workplaceType,
} = job;
@@ -53,12 +53,12 @@ export const convertJobToText = (job: JobResponse): Promise<string> => {
workplaceType && workplaceType in WORKPLACE_TYPES
? `Workplace Type: ${WORKPLACE_TYPES[workplaceType as keyof typeof WORKPLACE_TYPES]}\n`
: "";
+ const locationLine = Location ? `Location: ${Location.label}\n` : "";
const jobText = `
Job Title: ${jobTitle}
Company: ${companyName}
-Location: ${location}
-${workplaceTypeLine}Description: ${removeHtmlTags(description)}
+${locationLine}${workplaceTypeLine}Description: ${removeHtmlTags(description)}
`;
return resolve(jobText);
diff --git a/src/lib/jobs/createJobFromNames.ts b/src/lib/jobs/createJobFromNames.ts
index fc33447..79aa552 100644
--- a/src/lib/jobs/createJobFromNames.ts
+++ b/src/lib/jobs/createJobFromNames.ts
@@ -1,3 +1,4 @@
+import MarkdownIt from "markdown-it";
import prisma from "@/lib/db";
import { APP_CONSTANTS } from "@/lib/constants";
import { normalizeJobUrl } from "@/lib/scraper/utils";
@@ -14,6 +15,10 @@ import {
type ResolvedEntity,
} from "./resolve";
+// html:false escapes any raw HTML in the input; TipTapContentViewer further
+// strips unrecognized tags, so the stored/rendered description is safe.
+const md = new MarkdownIt({ html: false, linkify: false, breaks: true });
+
export interface CreateJobFromNamesInput {
company: string;
jobTitle: string;
@@ -124,7 +129,10 @@ export async function createJobFromNames(
salaryRange: salaryRange ?? null,
dueDate,
appliedDate: resolvedAppliedDate,
- description: jobDescription,
+ // Markdown-rendered here, unlike UI-created jobs which store raw
+ // Tiptap HTML directly — both are valid HTML for TipTapContentViewer,
+ // but don't assume Tiptap-specific structure when reading this field.
+ description: md.render(jobDescription),
jobType: jobTypeValue,
workplaceType: workplaceTypeValue,
userId,
diff --git a/src/lib/mock.utils.ts b/src/lib/mock.utils.ts
index 76739a5..1e06094 100644
--- a/src/lib/mock.utils.ts
+++ b/src/lib/mock.utils.ts
@@ -125,6 +125,7 @@ export function getMockList(
value = job.JobTitle.value;
createdBy = job.Company.createdBy;
} else if (type === "locations") {
+ if (!job.Location) return;
key = job.Location.id;
label = job.Location.label;
value = job.Location.value;
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index 279f0b3..1402145 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -36,8 +36,8 @@ export interface JobResponse {
JobTitle: JobTitle;
Company: Company;
Status: JobStatus;
- Location: JobLocation;
- JobSource: JobSource;
+ Location: JobLocation | null;
+ JobSource: JobSource | null;
jobType: string;
workplaceType?: string | null;
createdAt: Date;
diff --git a/src/models/mcp.schema.ts b/src/models/mcp.schema.ts
index b61952d..cb10797 100644
--- a/src/models/mcp.schema.ts
+++ b/src/models/mcp.schema.ts
@@ -5,9 +5,10 @@ import { APP_CONSTANTS } from "@/lib/constants";
export const McpAddJobInputShape = {
company: z.string().min(1, "company is required"),
jobTitle: z.string().min(1, "jobTitle is required"),
- jobDescription: z.string().min(10, "jobDescription must be at least 10 characters"),
- location: z.string().optional().describe("City, province/state, country, or 'Remote'"),
- source: z.string().optional().describe("Job board or site the listing came from, e.g. 'LinkedIn', 'Indeed', 'company website'"),
+ jobDescription: z.string().min(10, "jobDescription must be at least 10 characters")
+ .describe("The complete job posting text, copied in full — do not summarize, shorten, or paraphrase it. Markdown-formatted is supported; plain text also works."),
+ location: z.string().optional().describe("City, province/state, country, or 'Remote' — e.g. 'Calgary, AB'. Do not include a street address."),
+ source: z.string().optional().describe("Job board or site the listing came from, e.g. 'LinkedIn', 'Indeed', 'company website'. If not stated explicitly, infer it from the job posting's URL/domain when possible instead of leaving it blank."),
jobType: z.string().optional().describe("Employment type: 'Full-time', 'Part-time', or 'Contract'"),
workplaceType: z.string().optional().describe("Work arrangement: 'Remote', 'Hybrid', or 'Onsite'"),
status: z.string().optional().describe("Application status: draft, applied, interview, offer, rejected, expired, or archived. Defaults to 'draft'"),