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: enhance resume import functionality with improved context handling and validation

Khuram Niaz8fcd7817ccf4
diff --git a/src/app/api/ai/resume/import/route.ts b/src/app/api/ai/resume/import/route.ts
index cdedb2d..5be595e 100644
--- a/src/app/api/ai/resume/import/route.ts
+++ b/src/app/api/ai/resume/import/route.ts
@@ -118,6 +118,9 @@ export const POST = async (req: NextRequest) => {
prompt: buildResumeImportPrompt(preprocessResult.data.normalizedText),
temperature: TEMPERATURES.ANALYSIS,
abortSignal: controller.signal,
+ providerOptions: {
+ ollama: { options: { num_ctx: APP_CONSTANTS.AI_OLLAMA_NUM_CTX } },
+ },
}));
} finally {
clearTimeout(timer);
diff --git a/src/components/profile/CreateResume.tsx b/src/components/profile/CreateResume.tsx
index b3e1236..bd77b5e 100644
--- a/src/components/profile/CreateResume.tsx
+++ b/src/components/profile/CreateResume.tsx
@@ -292,7 +292,7 @@ function CreateResume({
<Button
type="reset"
variant="outline"
- className="mt-2 md:mt-0 w-full"
+ className="mt-2 md:mt-0"
onClick={closeDialog}
>
Cancel
diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsx
index 2cf1b4a..9714bd7 100644
--- a/src/components/profile/ResumeContainer.tsx
+++ b/src/components/profile/ResumeContainer.tsx
@@ -54,6 +54,16 @@ type PendingCard = {
card: ImportCardPayload;
};
+// Keywords that map to supported section types — filter these out of unrecognizedSections
+const SUPPORTED_KEYWORDS = ["contact", "summary", "experience", "education", "certification", "certifications"];
+
+function filterUnrecognizedSections(sections: string[]): string[] {
+ return sections.filter((section) => {
+ const lower = section.toLowerCase();
+ return !SUPPORTED_KEYWORDS.some((kw) => lower.includes(kw));
+ });
+}
+
function buildPendingCards(data: ResumeImportData): PendingCard[] {
const cards: PendingCard[] = [];
@@ -121,7 +131,7 @@ function PendingCardDetail({ card }: { card: ImportCardPayload }) {
if (card.type === "summary") {
return (
- <p className="text-xs text-foreground mt-1 whitespace-pre-wrap line-clamp-6">
+ <p className="text-xs text-foreground mt-1 whitespace-pre-wrap">
{card.data}
</p>
);
@@ -137,7 +147,7 @@ function PendingCardDetail({ card }: { card: ImportCardPayload }) {
<DetailRow label="Location" value={d.location} />
{dates && <DetailRow label="Dates" value={dates} />}
{d.description && (
- <p className="text-xs text-foreground mt-1 whitespace-pre-wrap line-clamp-4 pl-[5.5rem]">
+ <p className="text-xs text-foreground mt-1 whitespace-pre-wrap pl-[5.5rem]">
{d.description}
</p>
)}
@@ -156,7 +166,7 @@ function PendingCardDetail({ card }: { card: ImportCardPayload }) {
<DetailRow label="Location" value={d.location} />
{dates && <DetailRow label="Dates" value={dates} />}
{d.description && (
- <p className="text-xs text-foreground mt-1 whitespace-pre-wrap line-clamp-3 pl-[5.5rem]">
+ <p className="text-xs text-foreground mt-1 whitespace-pre-wrap pl-[5.5rem]">
{d.description}
</p>
)}
@@ -269,7 +279,7 @@ function ResumeContainer({ resume }: { resume: Resume }) {
setPendingCards(cards);
setImportMode(true);
setImportTruncated(truncated ?? false);
- setUnrecognizedSections(data.unrecognizedSections ?? []);
+ setUnrecognizedSections(filterUnrecognizedSections(data.unrecognizedSections ?? []));
}
} catch {
// Malformed sessionStorage entry — ignore
diff --git a/src/lib/ai/prompts/resume-import/system.ts b/src/lib/ai/prompts/resume-import/system.ts
index 585377e..1ea5490 100644
--- a/src/lib/ai/prompts/resume-import/system.ts
+++ b/src/lib/ai/prompts/resume-import/system.ts
@@ -12,8 +12,31 @@ Parse the resume and return:
- experience: work history entries with company, title, location, dates, description
- education: academic history with institution, degree, field, location, dates
- certifications: licenses and certifications with title, organization, dates, URL
-- unrecognizedSections: section names that appear in the document but don't map to the above (e.g. Skills, Projects, Publications)
+- unrecognizedSections: section names whose content cannot be mapped to any of the above fields (e.g. Skills, Projects, Publications, Volunteer Work, Awards). Do NOT include sections whose content was successfully parsed into contactInfo, summary, experience, education, or certifications — even if the heading combines multiple categories (e.g. "Education & Certifications" or "Experience & Projects").
+
+SUMMARY RULES:
+- Capture the FULL summary — all sentences, not just the first.
+- Return as a single plain text string. No HTML or markdown.
+
+DESCRIPTION FIELD RULES (applies to both experience and education):
+- The description field is REQUIRED. Always populate it.
+- Copy EVERY bullet point VERBATIM. Do NOT summarize, paraphrase, shorten,
+ rewrite, merge, or drop any bullet.
+- Reproduce each bullet's full original wording — not a condensed version.
+- If a position lists 6 bullets, the description MUST contain all 6, in order.
+ Never stop after the first one or two.
+- Preserve bullet symbols (•) at the start of each line. Join lines with newlines.
+- Do not use HTML or markdown.
+- If no details are listed under an entry, set description to an empty string "".
+
+Example — given this resume text:
+ Software Engineer | Acme Corp | Jan 2020 - Present
+ • Led API redesign serving 1M users
+ • Reduced latency by 40%
+ • Managed a team of 5 engineers
+
+The experience entry must be:
+ { "company": "Acme Corp", "jobTitle": "Software Engineer", "startDate": "Jan 2020", "endDate": "Present", "description": "• Led API redesign serving 1M users\\n• Reduced latency by 40%\\n• Managed a team of 5 engineers" }
For dates, return the exact string from the document (e.g. "Jan 2020", "2019", "Present").
-For descriptions, return plain text — no HTML or markdown.
-If a field is absent, omit it or leave it empty. Never fabricate information.`;
+Never fabricate information.`;
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 29dc95a..fe0395b 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -25,6 +25,11 @@ export const APP_CONSTANTS = {
AI_OLLAMA_LIST_TIMEOUT_MS: 5_000,
AI_OLLAMA_GENERATE_TIMEOUT_MS: 10_000,
+ // Ollama context window. Defaults to 2048, which a resume plus the system
+ // prompt and JSON output overflow — truncating generation mid-field (e.g.
+ // only the first few description bullets get imported).
+ AI_OLLAMA_NUM_CTX: 8192,
+
// Automation manual run rate limiting
AUTOMATION_MAX_MANUAL_RUNS_PER_HOUR: 5,
AUTOMATION_RATE_LIMIT_WINDOW_MS: 60 * 60 * 1000, // 1 hour
diff --git a/src/models/resumeImport.schema.ts b/src/models/resumeImport.schema.ts
index 5fe859f..5655ef0 100644
--- a/src/models/resumeImport.schema.ts
+++ b/src/models/resumeImport.schema.ts
@@ -20,7 +20,7 @@ export const ImportExperienceSchema = z.object({
location: z.string().optional(),
startDate: z.string().optional(),
endDate: z.string().optional(), // null / "Present" / "Current" = current job
- description: z.string().optional(),
+ description: z.string().catch(""),
confidence,
});
@@ -31,7 +31,7 @@ export const ImportEducationSchema = z.object({
location: z.string().optional(),
startDate: z.string().optional(),
endDate: z.string().optional(),
- description: z.string().optional(),
+ description: z.string().catch(""),
confidence,
});
@@ -46,7 +46,7 @@ export const ImportCertificationSchema = z.object({
export const ResumeImportSchema = z.object({
contactInfo: ImportContactInfoSchema.optional(),
- summary: z.string().optional(),
+ summary: z.string().catch(""),
experience: z.array(ImportExperienceSchema).default([]),
education: z.array(ImportEducationSchema).default([]),
certifications: z.array(ImportCertificationSchema).default([]),