feat: add gmail review actions

This commit is contained in:
2026-04-01 21:54:05 +02:00
parent 161ecb4b94
commit b87e673d38
6 changed files with 53 additions and 45 deletions
-22
View File
@@ -167,28 +167,6 @@ function initialsFrom(values: Array<string | undefined>) {
return (joined[0][0] + joined[1][0]).toUpperCase();
}
function replaceCvSection(source: string, sectionName: string, sectionDraft: string) {
const trimmedSource = source.trim();
const trimmedDraft = sectionDraft.trim();
if (!trimmedDraft) return source;
if (!trimmedSource) return `${sectionName}\n${trimmedDraft}`;
const headingPattern = /^([A-Z][A-Za-z &/]+):?\s*$/gm;
const matches = Array.from(trimmedSource.matchAll(headingPattern));
const normalizedTarget = sectionName.trim().toLowerCase();
const targetIndex = matches.findIndex((match) => match[1].trim().toLowerCase() === normalizedTarget);
if (targetIndex === -1) {
return `${trimmedSource}\n\n${sectionName}\n${trimmedDraft}`.trim();
}
const start = matches[targetIndex].index ?? 0;
const end = targetIndex + 1 < matches.length ? (matches[targetIndex + 1].index ?? trimmedSource.length) : trimmedSource.length;
const before = trimmedSource.slice(0, start).trimEnd();
const after = trimmedSource.slice(end).trimStart();
return [before, `${sectionName}\n${trimmedDraft}`, after].filter(Boolean).join("\n\n").trim();
}
function confidenceTone(confidence?: number) {
if (typeof confidence !== "number") return { label: "Review", color: "default" as const };
if (confidence >= 0.8) return { label: `High ${Math.round(confidence * 100)}%`, color: "success" as const };