ketannnn commited on
Commit
adfb678
·
1 Parent(s): b7d367d

feat: resolve promise racing in sessions UI and build smart background tracking loaders

Browse files
frontend/src/app/jds/[id]/candidates/[cid]/page.tsx CHANGED
@@ -2,6 +2,7 @@
2
  import { useEffect, useState, useCallback } from "react";
3
  import { useParams, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
 
5
  import { api, type CandidateDetail } from "../../../../../lib/api";
6
 
7
  const COMP_LABELS: Record<string, { label: string; color: string }> = {
@@ -13,8 +14,11 @@ const COMP_LABELS: Record<string, { label: string; color: string }> = {
13
  education: { label: "Education", color: "#34d399" },
14
  };
15
 
16
- const GAP_ICONS: Record<string, string> = {
17
- missing_skill: "🔧", yoe_gap: "📅", location_mismatch: "📍", engineer_type_mismatch: "⚙",
 
 
 
18
  };
19
 
20
  interface CandidateData {
@@ -76,8 +80,8 @@ export default function CandidateDetailPage() {
76
  <div className="flex flex-col items-center justify-center min-h-[60vh] gap-4">
77
  <div className="w-12 h-12 border-2 border-[var(--color-brand)] border-t-transparent rounded-full animate-spin" />
78
  <div>
79
- <div className="font-semibold text-center mb-1">Generating LLM explanation…</div>
80
- <div className="text-sm text-[var(--color-muted)] text-center">Groq is analyzing this candidate against the JD</div>
81
  </div>
82
  </div>
83
  );
@@ -92,9 +96,9 @@ export default function CandidateDetailPage() {
92
 
93
  return (
94
  <div className="max-w-7xl mx-auto px-6 py-10">
95
- <Link href={`/jds/${jdId}${sessionId ? `?session_id=${sessionId}` : ""}`}
96
- className="text-xs text-[var(--color-dimmer)] hover:text-[var(--color-muted)] mb-6 inline-block transition-colors">
97
- ← {jdInfo.title ?? "Job Description"}
98
  </Link>
99
 
100
  <div className="grid grid-cols-[1fr_300px] gap-6 items-start">
@@ -107,10 +111,10 @@ export default function CandidateDetailPage() {
107
  </div>
108
  <div className="flex-1">
109
  <div className="font-bold text-xl">{displayName}</div>
110
- <div className="text-sm text-[var(--color-muted)] flex gap-3 mt-1 flex-wrap">
111
- {cand.years_of_experience != null && <span>📅 {cand.years_of_experience} yrs exp</span>}
112
- {cand.engineer_type && <span>🔧 {cand.engineer_type}</span>}
113
- {cand.most_recent_company && <span>🏢 {cand.most_recent_company}</span>}
114
  </div>
115
  </div>
116
  <div className="text-center flex-shrink-0 bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] rounded-xl px-4 py-3">
@@ -137,10 +141,10 @@ export default function CandidateDetailPage() {
137
  </div>
138
 
139
  {/* LLM Explanation */}
140
- {detail.explanation && (
141
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
142
  <div className="flex items-center justify-between mb-4">
143
- <div className="font-semibold">🤖 LLM Analysis</div>
144
  <span className="text-[10px] px-2 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)]">
145
  Groq · llama-3.3-70b
146
  </span>
@@ -149,12 +153,24 @@ export default function CandidateDetailPage() {
149
  <pre className="text-sm text-[var(--color-muted)] leading-relaxed whitespace-pre-wrap font-sans">{detail.explanation}</pre>
150
  </div>
151
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
152
  )}
153
 
154
  {/* Gaps */}
155
  {detail.gaps.length > 0 && (
156
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
157
- <div className="font-semibold mb-4"> Identified Gaps</div>
158
  <div className="space-y-3">
159
  {detail.gaps.map((g, i) => (
160
  <div key={i} className="flex gap-3 p-3 bg-[var(--color-surface-2)] border border-[var(--color-border)] rounded-xl">
@@ -175,7 +191,7 @@ export default function CandidateDetailPage() {
175
  {/* Work History */}
176
  {(cand.parsed_work_experience ?? []).length > 0 && (
177
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
178
- <div className="font-semibold mb-5">💼 Work History</div>
179
  <div className="space-y-4">
180
  {(cand.parsed_work_experience ?? []).slice(0, 4).map((w, i) => (
181
  <div key={i} className="flex gap-4">
@@ -197,7 +213,7 @@ export default function CandidateDetailPage() {
197
  {/* Sidebar */}
198
  <div className="space-y-4 sticky top-20">
199
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
200
- <div className="font-semibold text-sm mb-4">📊 Score Breakdown</div>
201
  <div className="space-y-3">
202
  {Object.entries(detail.component_scores).map(([key, val]) => {
203
  const info = COMP_LABELS[key] ?? { label: key, color: "#6c63ff" };
@@ -217,7 +233,7 @@ export default function CandidateDetailPage() {
217
  </div>
218
 
219
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
220
- <div className="font-semibold text-sm mb-3">🚀 Career Trajectory</div>
221
  <div className="flex items-center gap-2 mb-2">
222
  <div className="flex-1 h-2 rounded-full bg-[var(--color-surface-2)] overflow-hidden">
223
  <div className="h-full rounded-full bg-gradient-to-r from-[var(--color-brand)] to-[var(--color-brand-light)] transition-all duration-700"
@@ -237,7 +253,7 @@ export default function CandidateDetailPage() {
237
  </div>
238
 
239
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
240
- <div className="font-semibold text-sm mb-3">📋 Details</div>
241
  <div className="space-y-2.5">
242
  {([
243
  { label: "Looking for", val: cand.looking_for },
 
2
  import { useEffect, useState, useCallback } from "react";
3
  import { useParams, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
5
+ import { Clock, Building2, Wrench, Bot, AlertTriangle, Briefcase, MapPin, Settings, SkipForward, BarChart2, Rocket, ClipboardList } from "lucide-react";
6
  import { api, type CandidateDetail } from "../../../../../lib/api";
7
 
8
  const COMP_LABELS: Record<string, { label: string; color: string }> = {
 
14
  education: { label: "Education", color: "#34d399" },
15
  };
16
 
17
+ const GAP_ICONS: Record<string, React.ReactNode> = {
18
+ missing_skill: <Wrench className="w-4 h-4 text-orange-400" />,
19
+ yoe_gap: <Clock className="w-4 h-4 text-blue-400" />,
20
+ location_mismatch: <MapPin className="w-4 h-4 text-red-500" />,
21
+ engineer_type_mismatch: <Settings className="w-4 h-4 text-slate-400" />,
22
  };
23
 
24
  interface CandidateData {
 
80
  <div className="flex flex-col items-center justify-center min-h-[60vh] gap-4">
81
  <div className="w-12 h-12 border-2 border-[var(--color-brand)] border-t-transparent rounded-full animate-spin" />
82
  <div>
83
+ <div className="font-semibold text-center mb-1">Retrieving Candidate Profile...</div>
84
+ <div className="text-sm text-[var(--color-muted)] text-center">Fetching match metrics from the backend database</div>
85
  </div>
86
  </div>
87
  );
 
96
 
97
  return (
98
  <div className="max-w-7xl mx-auto px-6 py-10">
99
+ <Link href={sessionId ? `/sessions/${sessionId}?jd_id=${jdId}` : `/pipeline`}
100
+ className="text-xs text-[var(--color-dimmer)] hover:text-[var(--color-text)] font-semibold mb-6 inline-block transition-colors">
101
+ Back to {jdInfo.title ?? "Rankings"}
102
  </Link>
103
 
104
  <div className="grid grid-cols-[1fr_300px] gap-6 items-start">
 
111
  </div>
112
  <div className="flex-1">
113
  <div className="font-bold text-xl">{displayName}</div>
114
+ <div className="text-sm text-[var(--color-muted)] flex gap-4 mt-1.5 flex-wrap">
115
+ {cand.years_of_experience != null && <span className="flex items-center gap-1.5"><Clock className="w-4 h-4 opacity-70" /> {cand.years_of_experience} yrs exp</span>}
116
+ {cand.engineer_type && <span className="flex items-center gap-1.5 capitalize"><Wrench className="w-4 h-4 opacity-70" /> {cand.engineer_type}</span>}
117
+ {cand.most_recent_company && <span className="flex items-center gap-1.5"><Building2 className="w-4 h-4 opacity-70" /> {cand.most_recent_company}</span>}
118
  </div>
119
  </div>
120
  <div className="text-center flex-shrink-0 bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] rounded-xl px-4 py-3">
 
141
  </div>
142
 
143
  {/* LLM Explanation */}
144
+ {detail.explanation ? (
145
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
146
  <div className="flex items-center justify-between mb-4">
147
+ <div className="font-semibold flex items-center gap-2"><Bot className="w-5 h-5 text-[var(--color-brand-light)]" /> LLM Analysis</div>
148
  <span className="text-[10px] px-2 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)]">
149
  Groq · llama-3.3-70b
150
  </span>
 
153
  <pre className="text-sm text-[var(--color-muted)] leading-relaxed whitespace-pre-wrap font-sans">{detail.explanation}</pre>
154
  </div>
155
  </div>
156
+ ) : (detail.rank ?? 999) <= 20 ? (
157
+ <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6 flex flex-col items-center justify-center py-10 text-[var(--color-muted)]">
158
+ <div className="w-8 h-8 border-2 border-[var(--color-brand)] border-t-transparent rounded-full animate-spin mb-4" />
159
+ <div className="font-semibold mb-1 text-[var(--color-text)]">Passively generating LLM explanation...</div>
160
+ <div className="text-xs text-center max-w-sm">This candidate is ranked Top-20! Groq is silently generating their deep-dive analysis in the background. Refresh soon.</div>
161
+ </div>
162
+ ) : (
163
+ <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6 flex flex-col items-center justify-center py-8 text-[var(--color-muted)]">
164
+ <div className="mb-3"><SkipForward className="w-8 h-8 text-[var(--color-border-strong)]" /></div>
165
+ <div className="font-semibold mb-1 text-[var(--color-text)]">LLM Generation Skipped</div>
166
+ <div className="text-xs text-center">This candidate lies outside the Top-20 ranking slice. Deep-dive generation was intentionally skipped to conserve pipeline latency.</div>
167
+ </div>
168
  )}
169
 
170
  {/* Gaps */}
171
  {detail.gaps.length > 0 && (
172
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
173
+ <div className="font-semibold mb-4 flex items-center gap-2"><AlertTriangle className="w-4 h-4 text-yellow-500" /> Identified Gaps</div>
174
  <div className="space-y-3">
175
  {detail.gaps.map((g, i) => (
176
  <div key={i} className="flex gap-3 p-3 bg-[var(--color-surface-2)] border border-[var(--color-border)] rounded-xl">
 
191
  {/* Work History */}
192
  {(cand.parsed_work_experience ?? []).length > 0 && (
193
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6">
194
+ <div className="font-semibold mb-5 flex items-center gap-2"><Briefcase className="w-4 h-4 text-blue-400" /> Work History</div>
195
  <div className="space-y-4">
196
  {(cand.parsed_work_experience ?? []).slice(0, 4).map((w, i) => (
197
  <div key={i} className="flex gap-4">
 
213
  {/* Sidebar */}
214
  <div className="space-y-4 sticky top-20">
215
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
216
+ <div className="font-semibold text-sm mb-4 flex items-center gap-2"><BarChart2 className="w-4 h-4 text-purple-400" /> Score Breakdown</div>
217
  <div className="space-y-3">
218
  {Object.entries(detail.component_scores).map(([key, val]) => {
219
  const info = COMP_LABELS[key] ?? { label: key, color: "#6c63ff" };
 
233
  </div>
234
 
235
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
236
+ <div className="font-semibold text-sm mb-3 flex items-center gap-2"><Rocket className="w-4 h-4 text-orange-400" /> Career Trajectory</div>
237
  <div className="flex items-center gap-2 mb-2">
238
  <div className="flex-1 h-2 rounded-full bg-[var(--color-surface-2)] overflow-hidden">
239
  <div className="h-full rounded-full bg-gradient-to-r from-[var(--color-brand)] to-[var(--color-brand-light)] transition-all duration-700"
 
253
  </div>
254
 
255
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-xl p-5">
256
+ <div className="font-semibold text-sm mb-3 flex items-center gap-2"><ClipboardList className="w-4 h-4 text-emerald-400" /> Details</div>
257
  <div className="space-y-2.5">
258
  {([
259
  { label: "Looking for", val: cand.looking_for },
frontend/src/app/jds/[id]/page.tsx CHANGED
@@ -2,6 +2,7 @@
2
  import { useEffect, useState, useCallback, useRef } from "react";
3
  import { useParams, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
 
5
  import { api, type JD, type MatchResponse, type SessionInfo } from "../../../lib/api";
6
 
7
  const DEFAULT_WEIGHTS = { semantic: 0.85, skill: 0.90, yoe: 0.95, company: 0.80, growth: 0.90, education: 0.75 };
@@ -112,18 +113,18 @@ export default function JDDetailPage() {
112
  <div className="flex items-start justify-between gap-4 mb-6 flex-wrap">
113
  <div>
114
  <h1 className="text-3xl font-bold tracking-tight mb-2">{jd.title}</h1>
115
- <div className="flex gap-2 flex-wrap">
116
- {jd.engineer_type && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)]">🔧 {jd.engineer_type}</span>}
117
- {jd.min_yoe && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)]">📅 {jd.min_yoe}+ yrs</span>}
118
- {jd.location && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)]">📍 {jd.location}</span>}
119
- {quality && <span className={`text-xs px-2.5 py-1 rounded-full border font-medium ${qColor}`}>{quality.overall === "good" ? "" : ""} JD {quality.overall}</span>}
120
  </div>
121
  </div>
122
  </div>
123
 
124
  {quality?.warnings?.length > 0 && (
125
  <div className="mb-6 bg-yellow-500/10 border border-yellow-500/20 rounded-xl px-5 py-4">
126
- <div className="text-sm font-semibold text-yellow-400 mb-2"> JD Quality Issues</div>
127
  {quality.warnings.map((w, i) => <div key={i} className="text-xs text-[var(--color-muted)] mt-1">• {w}</div>)}
128
  </div>
129
  )}
 
2
  import { useEffect, useState, useCallback, useRef } from "react";
3
  import { useParams, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
5
+ import { Wrench, Clock, MapPin, AlertTriangle, CheckCircle2 } from "lucide-react";
6
  import { api, type JD, type MatchResponse, type SessionInfo } from "../../../lib/api";
7
 
8
  const DEFAULT_WEIGHTS = { semantic: 0.85, skill: 0.90, yoe: 0.95, company: 0.80, growth: 0.90, education: 0.75 };
 
113
  <div className="flex items-start justify-between gap-4 mb-6 flex-wrap">
114
  <div>
115
  <h1 className="text-3xl font-bold tracking-tight mb-2">{jd.title}</h1>
116
+ <div className="flex gap-2 flex-wrap mt-2">
117
+ {jd.engineer_type && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)] font-medium flex items-center gap-1.5 capitalize"><Wrench className="w-3.5 h-3.5 opacity-80" /> {jd.engineer_type}</span>}
118
+ {jd.min_yoe && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)] font-medium flex items-center gap-1.5"><Clock className="w-3.5 h-3.5 opacity-80" /> {jd.min_yoe}+ yrs</span>}
119
+ {jd.location && <span className="text-xs px-2.5 py-1 rounded-full bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] text-[var(--color-brand-light)] font-medium flex items-center gap-1.5 capitalize"><MapPin className="w-3.5 h-3.5 opacity-80" /> {jd.location}</span>}
120
+ {quality && <span className={`text-xs px-2.5 py-1 rounded-full border font-medium flex items-center gap-1.5 ${qColor}`}>{quality.overall === "good" ? <CheckCircle2 className="w-3.5 h-3.5" /> : <AlertTriangle className="w-3.5 h-3.5" />} JD {quality.overall}</span>}
121
  </div>
122
  </div>
123
  </div>
124
 
125
  {quality?.warnings?.length > 0 && (
126
  <div className="mb-6 bg-yellow-500/10 border border-yellow-500/20 rounded-xl px-5 py-4">
127
+ <div className="text-sm font-semibold text-yellow-400 mb-2 flex items-center gap-2"><AlertTriangle className="w-4 h-4" /> JD Quality Issues</div>
128
  {quality.warnings.map((w, i) => <div key={i} className="text-xs text-[var(--color-muted)] mt-1">• {w}</div>)}
129
  </div>
130
  )}
frontend/src/app/jds/new/page.tsx DELETED
@@ -1,84 +0,0 @@
1
- "use client";
2
- import { useState, useCallback } from "react";
3
- import { useRouter } from "next/navigation";
4
- import { api } from "../../../lib/api";
5
-
6
- export default function NewJDPage() {
7
- const router = useRouter();
8
- const [title, setTitle] = useState("");
9
- const [text, setText] = useState("");
10
- const [creating, setCreating] = useState(false);
11
- const [error, setError] = useState<string | null>(null);
12
-
13
- const handleCreate = async () => {
14
- if (!title.trim() || !text.trim()) return setError("Title and description are both required");
15
- setError(null);
16
- setCreating(true);
17
- try {
18
- const jd = await api.createJD(title.trim(), text.trim());
19
- router.push(`/jds/${jd.id}`);
20
- } catch (e: unknown) {
21
- setError((e as Error).message);
22
- setCreating(false);
23
- }
24
- };
25
-
26
- return (
27
- <div className="max-w-2xl mx-auto px-6 py-12">
28
- <a href="/jds" className="text-sm text-[var(--color-dimmer)] hover:text-[var(--color-muted)] flex items-center gap-1.5 mb-8 transition-colors">
29
- ← All Job Descriptions
30
- </a>
31
-
32
- <div className="mb-8">
33
- <h1 className="text-3xl font-bold tracking-tight mb-2">Post a Job Description</h1>
34
- <p className="text-[var(--color-muted)]">Skills, YOE, location, and role type are auto-extracted. Richer JDs yield better matches.</p>
35
- </div>
36
-
37
- <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-8 space-y-6">
38
- <div className="space-y-2">
39
- <label className="text-sm font-medium text-[var(--color-muted)]">Job Title *</label>
40
- <input
41
- id="jd-title"
42
- className="w-full bg-[var(--color-surface-2)] border border-[var(--color-border-strong)] rounded-xl px-4 py-3 text-sm outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand-dim)] transition-all placeholder:text-[var(--color-dimmer)]"
43
- placeholder="e.g. Senior Backend Engineer, AI Engineer"
44
- value={title}
45
- onChange={(e) => setTitle(e.target.value)}
46
- />
47
- </div>
48
-
49
- <div className="space-y-2">
50
- <label className="text-sm font-medium text-[var(--color-muted)]">Job Description *</label>
51
- <textarea
52
- id="jd-text"
53
- className="w-full bg-[var(--color-surface-2)] border border-[var(--color-border-strong)] rounded-xl px-4 py-3 text-sm outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand-dim)] transition-all resize-none placeholder:text-[var(--color-dimmer)] min-h-[280px]"
54
- placeholder="Paste the full job description here. Include required skills, years of experience, responsibilities, and tech stack for best match quality..."
55
- value={text}
56
- onChange={(e) => setText(e.target.value)}
57
- />
58
- <div className="flex justify-between text-xs text-[var(--color-dimmer)]">
59
- <span>Include: required skills, min YOE, role type, location</span>
60
- <span>{text.split(/\s+/).filter(Boolean).length} words</span>
61
- </div>
62
- </div>
63
-
64
- {error && (
65
- <div className="text-sm text-[var(--color-danger)] bg-red-500/10 border border-red-500/20 rounded-xl px-4 py-3">
66
- ❌ {error}
67
- </div>
68
- )}
69
-
70
- <button
71
- id="post-jd-btn"
72
- onClick={handleCreate}
73
- disabled={creating}
74
- className="w-full py-3 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm disabled:opacity-50 hover:brightness-110 transition-all shadow-lg shadow-[var(--color-brand-glow)] flex items-center justify-center gap-2"
75
- >
76
- {creating
77
- ? <><div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin" /> Processing JD…</>
78
- : "⚡ Post Job Description"
79
- }
80
- </button>
81
- </div>
82
- </div>
83
- );
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
frontend/src/app/jds/page.tsx DELETED
@@ -1,79 +0,0 @@
1
- "use client";
2
- import { useState, useEffect, useCallback } from "react";
3
- import Link from "next/link";
4
- import { api, type JD } from "../../lib/api";
5
-
6
- export default function JDsListPage() {
7
- const [jds, setJDs] = useState<JD[]>([]);
8
- const [loading, setLoading] = useState(true);
9
-
10
- const load = useCallback(async () => {
11
- const j = await api.listJDs().catch(() => []);
12
- setJDs(j as JD[]);
13
- setLoading(false);
14
- }, []);
15
-
16
- useEffect(() => { load(); }, [load]);
17
-
18
- const qColor = (q: string) =>
19
- q === "good" ? "text-green-400 bg-green-400/10 border-green-400/20"
20
- : q === "fair" ? "text-yellow-400 bg-yellow-400/10 border-yellow-400/20"
21
- : "text-red-400 bg-red-400/10 border-red-400/20";
22
-
23
- return (
24
- <div className="max-w-4xl mx-auto px-6 py-12">
25
- <div className="flex items-center justify-between mb-8">
26
- <div>
27
- <h1 className="text-3xl font-bold tracking-tight mb-1">Job Descriptions</h1>
28
- <p className="text-[var(--color-muted)] text-sm">Run any JD against any candidate session</p>
29
- </div>
30
- <Link href="/jds/new" className="px-5 py-2.5 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm hover:brightness-110 transition-all shadow-lg shadow-[var(--color-brand-glow)]">
31
- + Post JD
32
- </Link>
33
- </div>
34
-
35
- {loading ? (
36
- <div className="space-y-3">{[1, 2, 3].map((i) => <div key={i} className="h-20 rounded-2xl animate-shimmer" />)}</div>
37
- ) : jds.length === 0 ? (
38
- <div className="bg-[var(--color-card)] border border-dashed border-[var(--color-border-strong)] rounded-2xl p-16 text-center">
39
- <div className="text-4xl mb-4">📋</div>
40
- <div className="text-lg font-semibold mb-2">No job descriptions yet</div>
41
- <div className="text-[var(--color-muted)] mb-6">Post a JD to start matching candidates from your sessions</div>
42
- <Link href="/jds/new" className="px-6 py-3 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm hover:brightness-110 transition-all">
43
- Post first JD
44
- </Link>
45
- </div>
46
- ) : (
47
- <div className="space-y-3">
48
- {jds.map((jd) => (
49
- <Link key={jd.id} href={`/jds/${jd.id}`}
50
- className="flex items-center gap-5 p-5 bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl hover:border-[var(--color-brand)] hover:shadow-[0_0_24px_var(--color-brand-dim)] transition-all group">
51
- <div className="flex-1 min-w-0">
52
- <div className="font-semibold text-base mb-1">{jd.title}</div>
53
- <div className="flex gap-3 text-xs text-[var(--color-muted)] flex-wrap">
54
- {jd.engineer_type && <span>🔧 {jd.engineer_type}</span>}
55
- {jd.min_yoe && <span>📅 {jd.min_yoe}+ yrs</span>}
56
- {jd.location && <span>📍 {jd.location}</span>}
57
- {jd.required_skills?.slice(0, 4).map((s) => (
58
- <span key={s} className="px-1.5 py-0.5 rounded bg-[var(--color-surface-2)] border border-[var(--color-border)]">{s}</span>
59
- ))}
60
- </div>
61
- </div>
62
- <div className="flex items-center gap-3 flex-shrink-0">
63
- {jd.jd_quality?.overall && (
64
- <span className={`text-xs px-2.5 py-1 rounded-full border font-medium ${qColor(jd.jd_quality.overall)}`}>
65
- {jd.jd_quality.overall}
66
- </span>
67
- )}
68
- <span className={`text-xs px-2.5 py-1 rounded-full border font-medium ${jd.status === "ready" ? "text-green-400 bg-green-400/10 border-green-400/20" : "text-yellow-400 bg-yellow-400/10 border-yellow-400/20"}`}>
69
- {jd.status}
70
- </span>
71
- <span className="text-[var(--color-dimmer)] group-hover:text-[var(--color-brand-light)] transition-colors">→</span>
72
- </div>
73
- </Link>
74
- ))}
75
- </div>
76
- )}
77
- </div>
78
- );
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
frontend/src/app/sessions/[id]/page.tsx CHANGED
@@ -2,6 +2,7 @@
2
  import { useState, useEffect, useCallback, use } from "react";
3
  import { useRouter, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
 
5
  import { api, type SessionInfo, type JD, type MatchResponse, type MatchedCandidate } from "../../../lib/api";
6
 
7
  const SCORE_COLORS = ["#6c63ff", "#22c55e", "#3b82f6", "#f59e0b", "#a78bfa"];
@@ -46,13 +47,14 @@ export default function SessionDetailPage({ params }: { params: Promise<{ id: st
46
  setWeights(jdInfo.custom_weights as typeof DEFAULT_WEIGHTS);
47
  }
48
 
49
- api.getMatchResults(initialJdId, sessionId).then(r => {
 
50
  setMatch(r);
51
  setBaseResults(r.results);
52
- }).catch(() => {
53
  setMatch(null);
54
  setBaseResults(null);
55
- });
56
  }
57
  } catch (e) {
58
  console.error(e);
@@ -168,7 +170,7 @@ export default function SessionDetailPage({ params }: { params: Promise<{ id: st
168
  {/* HEADER */}
169
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6 mb-6 flex justify-between items-center shadow-sm">
170
  <div>
171
- <Link href="/sessions" className="text-xs text-[var(--color-dimmer)] hover:text-[var(--color-text)] transition-colors mb-2 inline-block">← All Sessions</Link>
172
  <h1 className="text-3xl font-bold tracking-tight">📁 {session.name}</h1>
173
  <p className="text-sm text-[var(--color-muted)] mt-1">{session.description || "Generated Session Sandbox"}</p>
174
  </div>
@@ -283,8 +285,8 @@ export default function SessionDetailPage({ params }: { params: Promise<{ id: st
283
  <div>
284
  <div className="font-bold text-sm tracking-wide text-[var(--color-text)] mb-1">{c.name || "Anonymous Candidate"}</div>
285
  <div className="text-xs text-[var(--color-muted)] flex items-center gap-3">
286
- {c.years_of_experience != null && <span className="flex items-center gap-1"> {c.years_of_experience} yrs</span>}
287
- {c.most_recent_company && <span className="flex items-center gap-1">🏢 {c.most_recent_company}</span>}
288
  </div>
289
  </div>
290
  </div>
 
2
  import { useState, useEffect, useCallback, use } from "react";
3
  import { useRouter, useSearchParams } from "next/navigation";
4
  import Link from "next/link";
5
+ import { Clock, Building2 } from "lucide-react";
6
  import { api, type SessionInfo, type JD, type MatchResponse, type MatchedCandidate } from "../../../lib/api";
7
 
8
  const SCORE_COLORS = ["#6c63ff", "#22c55e", "#3b82f6", "#f59e0b", "#a78bfa"];
 
47
  setWeights(jdInfo.custom_weights as typeof DEFAULT_WEIGHTS);
48
  }
49
 
50
+ try {
51
+ const r = await api.getMatchResults(initialJdId, sessionId);
52
  setMatch(r);
53
  setBaseResults(r.results);
54
+ } catch {
55
  setMatch(null);
56
  setBaseResults(null);
57
+ }
58
  }
59
  } catch (e) {
60
  console.error(e);
 
170
  {/* HEADER */}
171
  <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-6 mb-6 flex justify-between items-center shadow-sm">
172
  <div>
173
+ <Link href="/pipeline" className="text-xs text-[var(--color-dimmer)] hover:text-[var(--color-text)] transition-colors mb-2 inline-block">← Back to Pipeline</Link>
174
  <h1 className="text-3xl font-bold tracking-tight">📁 {session.name}</h1>
175
  <p className="text-sm text-[var(--color-muted)] mt-1">{session.description || "Generated Session Sandbox"}</p>
176
  </div>
 
285
  <div>
286
  <div className="font-bold text-sm tracking-wide text-[var(--color-text)] mb-1">{c.name || "Anonymous Candidate"}</div>
287
  <div className="text-xs text-[var(--color-muted)] flex items-center gap-3">
288
+ {c.years_of_experience != null && <span className="flex items-center gap-1"><Clock className="w-3.5 h-3.5" /> {c.years_of_experience} yrs</span>}
289
+ {c.most_recent_company && <span className="flex items-center gap-1"><Building2 className="w-3.5 h-3.5" /> {c.most_recent_company}</span>}
290
  </div>
291
  </div>
292
  </div>
frontend/src/app/sessions/new/page.tsx DELETED
@@ -1,142 +0,0 @@
1
- "use client";
2
- import { useState, useCallback } from "react";
3
- import { useRouter } from "next/navigation";
4
- import { api } from "../../../lib/api";
5
-
6
- export default function NewSessionPage() {
7
- const router = useRouter();
8
- const [name, setName] = useState("");
9
- const [description, setDescription] = useState("");
10
- const [file, setFile] = useState<File | null>(null);
11
- const [creating, setCreating] = useState(false);
12
- const [uploading, setUploading] = useState(false);
13
- const [taskStatus, setTaskStatus] = useState<string | null>(null);
14
- const [error, setError] = useState<string | null>(null);
15
- const [dragOver, setDragOver] = useState(false);
16
-
17
- const handleCreate = useCallback(async () => {
18
- if (!name.trim()) return setError("Session name is required");
19
- setError(null);
20
- setCreating(true);
21
- try {
22
- const session = await api.createSession(name.trim(), description.trim() || undefined);
23
- if (file) {
24
- setUploading(true);
25
- setCreating(false);
26
- const res = await api.uploadCandidates(file, session.id);
27
- const taskId = res.task_id;
28
- setTaskStatus("PENDING");
29
- const poll = setInterval(async () => {
30
- const s = await api.taskStatus(taskId);
31
- setTaskStatus(s.status);
32
- if (s.status === "SUCCESS" || s.status === "FAILURE") {
33
- clearInterval(poll);
34
- router.push(`/sessions/${session.id}`);
35
- }
36
- }, 2000);
37
- } else {
38
- router.push(`/sessions/${session.id}`);
39
- }
40
- } catch (e: unknown) {
41
- setError((e as Error).message);
42
- setCreating(false);
43
- setUploading(false);
44
- }
45
- }, [name, description, file, router]);
46
-
47
- const handleFileDrop = (e: React.DragEvent) => {
48
- e.preventDefault();
49
- setDragOver(false);
50
- const f = e.dataTransfer.files[0];
51
- if (f) setFile(f);
52
- };
53
-
54
- return (
55
- <div className="max-w-2xl mx-auto px-6 py-12">
56
- <a href="/sessions" className="text-sm text-[var(--color-dimmer)] hover:text-[var(--color-muted)] flex items-center gap-1.5 mb-8 transition-colors">
57
- ← All Sessions
58
- </a>
59
-
60
- <div className="mb-8">
61
- <h1 className="text-3xl font-bold tracking-tight mb-2">Create a Session</h1>
62
- <p className="text-[var(--color-muted)]">A session is a named batch of candidates. Multiple JDs can be matched against the same session.</p>
63
- </div>
64
-
65
- <div className="bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl p-8 space-y-6">
66
- <div className="space-y-2">
67
- <label className="text-sm font-medium text-[var(--color-muted)]">Session Name *</label>
68
- <input
69
- id="session-name"
70
- className="w-full bg-[var(--color-surface-2)] border border-[var(--color-border-strong)] rounded-xl px-4 py-3 text-sm outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand-dim)] transition-all placeholder:text-[var(--color-dimmer)]"
71
- placeholder="e.g. Q2 2025 Backend Batch, March Internships"
72
- value={name}
73
- onChange={(e) => setName(e.target.value)}
74
- />
75
- </div>
76
-
77
- <div className="space-y-2">
78
- <label className="text-sm font-medium text-[var(--color-muted)]">Description (optional)</label>
79
- <textarea
80
- id="session-desc"
81
- className="w-full bg-[var(--color-surface-2)] border border-[var(--color-border-strong)] rounded-xl px-4 py-3 text-sm outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand-dim)] transition-all resize-none placeholder:text-[var(--color-dimmer)] min-h-[80px]"
82
- placeholder="Brief description of this candidate batch..."
83
- value={description}
84
- onChange={(e) => setDescription(e.target.value)}
85
- />
86
- </div>
87
-
88
- <div className="space-y-2">
89
- <label className="text-sm font-medium text-[var(--color-muted)]">Upload Candidates (CSV / JSON)</label>
90
- <div
91
- id="drop-zone"
92
- className={`border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all ${dragOver || file ? "border-[var(--color-brand)] bg-[var(--color-brand-dim)]" : "border-[var(--color-border-strong)] hover:border-[var(--color-brand)] hover:bg-[var(--color-brand-dim)]"}`}
93
- onClick={() => document.getElementById("cand-file")?.click()}
94
- onDragOver={(e) => { e.preventDefault(); setDragOver(true); }}
95
- onDragLeave={() => setDragOver(false)}
96
- onDrop={handleFileDrop}
97
- >
98
- <div className="text-3xl mb-2">{file ? "✅" : "📂"}</div>
99
- <div className="font-medium text-sm mb-1">
100
- {file ? file.name : "Drop your CSV or JSON file here"}
101
- </div>
102
- <div className="text-xs text-[var(--color-muted)]">
103
- {file ? `${(file.size / 1024).toFixed(0)} KB selected` : "or click to browse — supports any column schema"}
104
- </div>
105
- <input id="cand-file" type="file" accept=".csv,.json,.jsonl" className="hidden" onChange={(e) => e.target.files?.[0] && setFile(e.target.files[0])} />
106
- </div>
107
- {file && (
108
- <button className="text-xs text-[var(--color-dimmer)] hover:text-[var(--color-danger)] transition-colors" onClick={() => setFile(null)}>
109
- ✕ Remove file
110
- </button>
111
- )}
112
- </div>
113
-
114
- {error && (
115
- <div className="flex items-center gap-2 text-sm text-[var(--color-danger)] bg-red-500/10 border border-red-500/20 rounded-xl px-4 py-3">
116
- ❌ {error}
117
- </div>
118
- )}
119
-
120
- {uploading && taskStatus && (
121
- <div className="flex items-center gap-3 text-sm text-[var(--color-muted)] bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] rounded-xl px-4 py-3">
122
- <div className="w-4 h-4 border-2 border-[var(--color-brand-light)] border-t-transparent rounded-full animate-spin flex-shrink-0" />
123
- Ingesting candidates — embedding + indexing… ({taskStatus})
124
- </div>
125
- )}
126
-
127
- <button
128
- id="create-session-btn"
129
- className="w-full py-3 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:brightness-110 transition-all shadow-lg shadow-[var(--color-brand-glow)] flex items-center justify-center gap-2"
130
- onClick={handleCreate}
131
- disabled={creating || uploading}
132
- >
133
- {creating || uploading ? (
134
- <><div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin" /> {uploading ? "Uploading…" : "Creating…"}</>
135
- ) : (
136
- "⚡ Create Session" + (file ? " & Upload" : "")
137
- )}
138
- </button>
139
- </div>
140
- </div>
141
- );
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
frontend/src/app/sessions/page.tsx DELETED
@@ -1,62 +0,0 @@
1
- "use client";
2
- import { useState, useEffect, useCallback } from "react";
3
- import Link from "next/link";
4
- import { api, type SessionInfo } from "../../lib/api";
5
-
6
- export default function SessionsListPage() {
7
- const [sessions, setSessions] = useState<SessionInfo[]>([]);
8
- const [loading, setLoading] = useState(true);
9
-
10
- const load = useCallback(async () => {
11
- const s = await api.listSessions().catch(() => []);
12
- setSessions(s as SessionInfo[]);
13
- setLoading(false);
14
- }, []);
15
-
16
- useEffect(() => { load(); }, [load]);
17
-
18
- return (
19
- <div className="max-w-4xl mx-auto px-6 py-12">
20
- <div className="flex items-center justify-between mb-8">
21
- <div>
22
- <h1 className="text-3xl font-bold tracking-tight mb-1">Sessions</h1>
23
- <p className="text-[var(--color-muted)] text-sm">Each session is a batch of candidates. Run any JD against any session.</p>
24
- </div>
25
- <Link href="/sessions/new" className="px-5 py-2.5 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm hover:brightness-110 transition-all shadow-lg shadow-[var(--color-brand-glow)]">
26
- + New Session
27
- </Link>
28
- </div>
29
-
30
- {loading ? (
31
- <div className="space-y-3">{[1, 2, 3, 4].map((i) => <div key={i} className="h-20 rounded-2xl animate-shimmer" />)}</div>
32
- ) : sessions.length === 0 ? (
33
- <div className="bg-[var(--color-card)] border border-dashed border-[var(--color-border-strong)] rounded-2xl p-16 text-center">
34
- <div className="text-4xl mb-4">📁</div>
35
- <div className="text-lg font-semibold mb-2">No sessions yet</div>
36
- <div className="text-[var(--color-muted)] mb-6">Create a session to upload and group your candidate batches</div>
37
- <Link href="/sessions/new" className="px-6 py-3 rounded-xl bg-[var(--color-brand)] text-white font-semibold text-sm hover:brightness-110 transition-all">
38
- Create first session
39
- </Link>
40
- </div>
41
- ) : (
42
- <div className="space-y-3">
43
- {sessions.map((s) => (
44
- <Link key={s.id} href={`/sessions/${s.id}`}
45
- className="flex items-center gap-5 p-5 bg-[var(--color-card)] border border-[var(--color-border)] rounded-2xl hover:border-[var(--color-brand)] hover:shadow-[0_0_24px_var(--color-brand-dim)] transition-all group">
46
- <div className="w-12 h-12 rounded-xl bg-[var(--color-brand-dim)] border border-[var(--color-brand-glow)] flex items-center justify-center text-xl flex-shrink-0">📁</div>
47
- <div className="flex-1 min-w-0">
48
- <div className="font-semibold text-base">{s.name}</div>
49
- {s.description && <div className="text-sm text-[var(--color-muted)] truncate mt-0.5">{s.description}</div>}
50
- </div>
51
- <div className="text-right flex-shrink-0">
52
- <div className="text-lg font-bold text-[var(--color-brand-light)]">{s.candidate_count.toLocaleString()}</div>
53
- <div className="text-xs text-[var(--color-dimmer)]">candidates</div>
54
- </div>
55
- <span className="text-[var(--color-dimmer)] group-hover:text-[var(--color-brand-light)] transition-colors text-lg">→</span>
56
- </Link>
57
- ))}
58
- </div>
59
- )}
60
- </div>
61
- );
62
- }