Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 1x 1x 1x 1x 1x 1x 1x 26x 26x 26x 26x 14x 14x 26x 26x 12x 26x 26x 26x 1x 1x 1x 26x 26x 1x 1x 1x 26x 26x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 10x 10x 10x 4x 4x 4x 4x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 4x 4x 4x 4x 4x 4x 4x 4x 4x 26x 26x 26x 26x 1x 114x 114x 114x 114x 114x 114x 114x 114x 114x 114x 114x 13x 13x 13x 13x 3x 3x 3x 12x 13x 1x 1x 13x 114x 114x 12x 12x 114x 114x 114x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 114x 114x 1x 1x 1x 1x 1x 1x 1x 1x 114x 114x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 36x 36x 36x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 42x 42x 42x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 112x 2x 2x 2x 114x 114x 1x 1x 1x 114x 114x 114x 114x 114x 114x | import { useEffect, useState } from "react";
import { AccountBar } from "../../components/AccountBar";
import { AuthGate } from "../../components/AuthGate";
import {
getProfile,
setProfile,
clearProfile,
PROFILE_TEXT_MAX,
} from "../../services/profileStorage";
import { learnedSelectors } from "../../services/learnedSelectors";
import type { LearnedHostSelector } from "../../services/learnedSelectors";
export function OptionsApp() {
return (
<AuthGate showSignOut={false}>
<div className="flex h-full min-h-0 flex-col overflow-y-auto">
<AccountBar />
<ProfileEditor />
<LearnedRegionsSection />
</div>
</AuthGate>
);
}
/**
* "Clear region for this site" / "Clear all site regions" (spec FR-031).
* Clearing is immediate with no confirmation dialog — a cleared site simply
* falls back to automatic extraction, and a future correction re-teaches it
* in one action (FR-026b), so the action is low-stakes and reversible.
*/
function LearnedRegionsSection() {
const [hosts, setHosts] = useState<LearnedHostSelector[] | null>(null);
const refresh = async () => {
setHosts(await learnedSelectors.list());
};
useEffect(() => {
void refresh();
}, []);
const handleClear = async (host: string) => {
await learnedSelectors.clear(host);
await refresh();
};
const handleClearAll = async () => {
await learnedSelectors.clearAll();
await refresh();
};
if (hosts === null) return null;
return (
<section className="mx-auto w-full max-w-4xl shrink-0 border-t border-gray-200/70 px-8 py-6 dark:border-gray-800">
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100">
Always-analyzed regions
</h2>
<p className="mt-1 text-sm text-gray-500 dark:text-gray-400">
Sites where you taught the extension which part of the page to
analyze. Stored only on this device (spec FR-033).
</p>
{hosts.length === 0 ? (
<p className="mt-3 text-sm text-gray-400 dark:text-gray-500">
No sites are set to always analyze a specific region yet.
</p>
) : (
<>
<ul className="mt-3 divide-y divide-gray-200 dark:divide-gray-800">
{hosts.map((h) => (
<li key={h.host} className="flex items-center justify-between py-2">
<span className="text-sm text-gray-700 dark:text-gray-200">{h.host}</span>
<button
onClick={() => void handleClear(h.host)}
aria-label={`Clear region for ${h.host}`}
className="rounded-md px-2.5 py-1 text-xs font-medium text-gray-500 hover:bg-gray-100 hover:text-red-600 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-red-400"
>
Clear
</button>
</li>
))}
</ul>
<button
onClick={() => void handleClearAll()}
className="mt-3 rounded-md px-3 py-1.5 text-xs font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40"
>
Clear all site regions
</button>
</>
)}
</section>
);
}
function ProfileEditor() {
const [text, setText] = useState("");
const [dealbreakers, setDealbreakers] = useState("");
const [feedback, setFeedback] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
const [loaded, setLoaded] = useState(false);
// Server-backed profile: a failed load must show as a failure with Retry,
// never as an empty form that looks like the profile is gone (FR-015).
const [loadFailed, setLoadFailed] = useState(false);
const load = async () => {
setLoadFailed(false);
try {
const profile = await getProfile();
if (profile) {
setText(profile.text);
setDealbreakers(profile.dealbreakers.join("\n"));
}
setLoaded(true);
} catch {
setLoadFailed(true);
}
};
useEffect(() => {
void load();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleSave = async () => {
try {
await setProfile({
text,
dealbreakers: dealbreakers.split("\n"),
});
setError(null);
setFeedback("Profile saved.");
} catch (err) {
setFeedback(null);
setError(
err instanceof Error
? err.message
: "The profile could not be saved. Try again."
);
}
};
const handleClear = async () => {
try {
await clearProfile();
setText("");
setDealbreakers("");
setError(null);
setFeedback("Profile deleted.");
} catch (err) {
setFeedback(null);
setError(
err instanceof Error
? err.message
: "The profile could not be cleared. Try again."
);
}
};
if (loadFailed) {
return (
<main className="min-h-0 flex-1 bg-gray-50 px-6 py-8 dark:bg-gray-950">
<div
role="alert"
className="mx-auto max-w-xl rounded-lg border border-red-200 bg-red-50 p-4 text-center dark:border-red-900/60 dark:bg-red-950/40"
>
<p className="text-sm font-medium text-red-700 dark:text-red-300">
Your profile could not be loaded.
</p>
<p className="mt-1 text-xs text-red-600/80 dark:text-red-400/80">
Check your connection — nothing has been lost.
</p>
<button
onClick={() => void load()}
className="mt-3 rounded-md bg-red-600 px-3 py-1 text-xs font-semibold text-white hover:bg-red-700"
>
Retry
</button>
</div>
</main>
);
}
return (
// Full-height column (inside AuthGate's flex body): the resume editor
// absorbs all spare height and scrolls internally, so the action buttons
// in the footer never leave the viewport no matter how long the pasted
// resume is.
<main className="flex min-h-0 flex-1 flex-col bg-gray-50 dark:bg-gray-950">
<div className="mx-auto flex h-full w-full max-w-4xl min-h-0 flex-col px-8 py-6">
<div className="shrink-0">
<h1 className="text-xl font-semibold text-gray-800 dark:text-gray-100">
Candidate profile
</h1>
<p className="mt-1 text-sm text-gray-500 dark:text-gray-400">
Used to compute the fit score when you analyze a job posting.
Stored in your account and sent only with analysis requests.
</p>
</div>
<label
htmlFor="profile-text"
className="mt-5 block shrink-0 text-sm font-medium text-gray-700 dark:text-gray-200"
>
Your background — paste your entire resume here
</label>
<textarea
id="profile-text"
value={text}
maxLength={PROFILE_TEXT_MAX}
onChange={(e) => {
setText(e.target.value);
setFeedback(null);
}}
placeholder="Paste your full resume, or describe your background: skills, seniority, domains, preferences."
className="mt-1 min-h-48 w-full flex-1 resize-none overflow-y-auto rounded-lg border border-gray-200 bg-white p-4 text-sm leading-relaxed text-gray-700 placeholder:text-gray-400 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200"
disabled={!loaded}
/>
<p className="mt-1 shrink-0 text-right text-xs text-gray-400 dark:text-gray-500">
{text.length.toLocaleString()} / {PROFILE_TEXT_MAX.toLocaleString()}
</p>
<div className="shrink-0">
<label
htmlFor="profile-dealbreakers"
className="mt-2 block text-sm font-medium text-gray-700 dark:text-gray-200"
>
Dealbreakers (one per line)
</label>
<p className="text-xs text-gray-400 dark:text-gray-500">
A posting that violates a dealbreaker is capped at a fit score of 20.
</p>
<textarea
id="profile-dealbreakers"
value={dealbreakers}
onChange={(e) => {
setDealbreakers(e.target.value);
setFeedback(null);
}}
rows={3}
placeholder={"no fully on-site roles\nno defense industry"}
className="mt-1 w-full resize-none rounded-lg border border-gray-200 bg-white p-3 text-sm text-gray-700 placeholder:text-gray-400 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200"
disabled={!loaded}
/>
</div>
<div className="mt-4 flex shrink-0 items-center gap-3 border-t border-gray-200/70 pt-4 dark:border-gray-800">
<button
onClick={() => void handleSave()}
className="rounded-lg bg-blue-600 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700"
>
Save profile
</button>
<button
onClick={() => void handleClear()}
className="rounded-lg px-5 py-2.5 text-sm font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40"
>
Delete profile
</button>
{feedback && (
<span role="status" className="text-sm text-green-700 dark:text-green-400">
{feedback}
</span>
)}
{error && (
<span role="alert" className="text-sm text-red-600 dark:text-red-400">
{error}
</span>
)}
</div>
</div>
</main>
);
}
|