Ai tone grammer check#94
Conversation
|
@paratha14 is attempting to deploy a commit to the Aniruddha Adak's projects Team on Vercel. A member of the Team first needs to authorize it. |
👷 Deploy request for career-zen pending review.Visit the deploys page to approve it
|
There was a problem hiding this comment.
Pull request overview
This PR adds an optional Tone & Grammar Critique feature to the AI Resume Optimizer. When the user enables a toggle switch, the AI analyzes the resume for passive voice, weak verbs, and grammatical errors — returning a tone score, per-bullet issue breakdown with fix suggestions, and grammar corrections. The PR also updates the optimizeResume function to accept a third options parameter and adds corresponding TypeScript interfaces.
Changes:
- Adds new TypeScript interfaces (
ToneIssue,GrammarError,ToneAndGrammarAnalysis,AnalysisResult,AnalyzeResumeOptions) and extends theanalyzeResumeWithGeminifunction to optionally include tone & grammar critique in the Gemini prompt. - Adds a
ToneGrammarPanelUI component and a toggle switch in the pre-optimize pane ofResumeOptimizer.tsx, along with the plumbing to passincludeToneCritiquethrough the server action. - Updates the
/api/analyzeroute andoptimizeResumeserver action to accept and forward theincludeToneCritiqueoption.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib/gemini.ts |
New interfaces for tone/grammar analysis; extended prompt to include optional tone critique block; added return type annotation |
src/app/actions/optimize.ts |
Extended optimizeResume to accept options; added tone critique prompt injection and a parallel analyzeResumeWithGemini call |
src/app/api/analyze/route.ts |
Reads includeToneCritique from FormData and passes it to analyzeResumeWithGemini |
src/components/ResumeOptimizer.tsx |
Added ToneGrammarPanel component, toggle switch UI, updated icon imports, various formatting/comment cleanups |
package-lock.json |
Minor dependency version bumps (minimatch, ajv, underscore) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ${includeToneCritique ? ` | ||
| TONE & GRAMMAR CRITIQUE (include this extra key in your JSON output): | ||
| Also analyse the rewritten resume bullets and summary for tone and grammar issues. | ||
| Add the following key at the top level of the JSON object: | ||
| "toneAndGrammar": { | ||
| "overallToneScore": <integer 0-100>, | ||
| "passiveVoiceCount": <integer — number of passive-voice phrases found>, | ||
| "weakVerbCount": <integer — count of weak/vague verbs like "helped", "assisted", "worked on">, | ||
| "summary": "<1-2 sentence overall critique>", | ||
| "toneStrengths": ["<strength 1>", "<strength 2>"], | ||
| "toneIssues": [ | ||
| { "original": "<original phrase>", "issue": "<why it's weak>", "suggestion": "<stronger rewrite>" } | ||
| ], | ||
| "grammarErrors": [ | ||
| { "original": "<original text>", "issue": "<grammar rule broken>", "correction": "<corrected text>" } | ||
| ] | ||
| } | ||
| ` : ''} | ||
| `; | ||
|
|
||
| try { | ||
| const response = await generateContentWithRetry(ai, { | ||
| model: "gemini-3-flash-preview", | ||
| contents: prompt, | ||
| config: { | ||
| responseMimeType: "application/json", | ||
| } | ||
| }); | ||
| // Run optimization (and optionally tone analysis) in parallel | ||
| const [optimizeResponse, toneAnalysis] = await Promise.all([ | ||
| generateContentWithRetry(ai, { | ||
| model: "gemini-3-flash-preview", | ||
| contents: prompt, | ||
| config: { responseMimeType: "application/json" }, | ||
| }), | ||
| includeToneCritique | ||
| ? analyzeResumeWithGemini(resumeText, jobDescription, { includeToneCritique: true }) | ||
| : Promise.resolve(null), | ||
| ]); | ||
|
|
||
| const text = response.text; | ||
| const text = optimizeResponse.text; | ||
| if (!text) throw new Error("No response from AI"); | ||
|
|
||
| return { success: true, data: JSON.parse(text) }; | ||
| const data = JSON.parse(text); | ||
|
|
||
| // Attach tone & grammar analysis if requested | ||
| if (toneAnalysis?.toneAndGrammar) { | ||
| data.toneAndGrammar = toneAnalysis.toneAndGrammar; | ||
| } |
There was a problem hiding this comment.
When includeToneCritique is true, the optimization prompt (lines 86-103) already instructs Gemini to include toneAndGrammar in its JSON output. However, the code also makes a separate parallel call to analyzeResumeWithGemini (line 115), which is a completely different AI prompt that analyses the original resume text (not the rewritten one). This causes two problems:
- Redundant API call: Two Gemini API calls are made for tone analysis when only one is needed. This doubles the latency/cost for the tone critique feature.
- Wrong input text: The parallel
analyzeResumeWithGeminicall analyses the original resume, while the prompt in this function asks Gemini to critique the rewritten resume. Then at line 125-126, the result fromanalyzeResumeWithGeminioverwrites whatever the optimization call returned, so the user sees tone analysis of the original resume, not the optimized one.
You should either (a) remove the prompt additions at lines 86-103 and rely solely on the parallel call, or (b) remove the parallel analyzeResumeWithGemini call and use the toneAndGrammar key already returned by the optimization response. Option (b) is likely better since it analyses the rewritten resume, which matches the PR description.
| ) : ( | ||
| <FileType2 className="h-5 w-5" /> | ||
| )} | ||
| {isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileText className="h-5 w-5" />} |
There was a problem hiding this comment.
The DOCX download button previously used FileType2 as its icon but has been changed to use FileText — the same icon as the PDF button. This makes both buttons visually identical (apart from color and label), reducing the visual distinction between formats. Meanwhile, FileType2 is still imported on line 6 but is now unused. Either restore FileType2 for the DOCX button or remove the unused import.
| {isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileText className="h-5 w-5" />} | |
| {isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileType2 className="h-5 w-5" />} |
| // Tone & Grammar Results Panel | ||
| // ───────────────────────────────────────────────────────────────────────────── | ||
|
|
||
| function ToneGrammarPanel({ data }: { data: any }) { |
There was a problem hiding this comment.
ToneGrammarPanel accepts data: any, but the ToneAndGrammarAnalysis interface is already defined and exported from @/lib/gemini. Using the proper type would provide compile-time safety and autocomplete, and is consistent with the typed interfaces added in this PR. Import and use ToneAndGrammarAnalysis instead of any.
|
|
||
| original: string; | ||
|
|
||
| issue: string; | ||
|
|
There was a problem hiding this comment.
The ToneIssue interface has extra blank lines between its properties and lacks JSDoc comments, while the adjacent GrammarError interface (lines 33-40) uses JSDoc comments consistently for each property. For consistency, add JSDoc comments to ToneIssue properties and remove the extraneous blank lines.
| original: string; | |
| issue: string; | |
| /** The original text with the tone issue */ | |
| original: string; | |
| /** A plain-English explanation of the tone problem */ | |
| issue: string; | |
| /** A suggested rewrite with improved tone */ |
thank you so much @paratha14, for your wonderful contributions 🎉🎉🎊 |
|
I had a Great time working on this. Let's stay in touch for future collaborations! A follow would be much appreciated. |
sure, I just sent the LinkedIn connection request. We will be in touch there. Thanks again. If you can, you can work on other issues too or suggest an improvement and work on that also. btw, thanks again. |


Description/Context
Adds an optional Tone & Grammar Critique feature to the AI Resume Optimizer. When toggled on, the AI analyses the rewritten resume for passive voice, weak verbs, and grammatical errors — returning an overall tone score, per-bullet issue breakdown with fix suggestions, and grammar corrections. Also fixes a TypeScript bug where
optimizeResumewas being called with 3 arguments but only accepted 2.Type of Change
Visuals (if applicable)
Checklist before requesting a review
npm run lint.