Skip to content

Commit 474a1f5

Browse files
Ankit Guptaclaude
andcommitted
fix: review fixes for style inference
- Fix hardcoded "default" accountId in Gmail fallback — now passes the real account ID so cached emails get the correct accountId - Add error feedback to Learn My Style button — shows error message when inference fails instead of silently doing nothing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f50378f commit 474a1f5

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/main/ipc/settings.ipc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ export function registerSettingsIpc(): void {
581581
const syncService = getEmailSyncService();
582582
const { getAccounts: getDbAccounts } = await import("../db");
583583
const accounts = getDbAccounts();
584-
const gmailClient =
585-
accounts.length > 0 ? syncService.getClientForAccount(accounts[0].id) : null;
586-
const result = await inferStyleFromSentEmails(gmailClient);
584+
const firstAccountId = accounts.length > 0 ? accounts[0].id : undefined;
585+
const gmailClient = firstAccountId ? syncService.getClientForAccount(firstAccountId) : null;
586+
const result = await inferStyleFromSentEmails(gmailClient, firstAccountId);
587587
return { success: true, data: result };
588588
} catch (error) {
589589
return {

src/main/services/style-profiler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@ Do NOT include example phrases or quoted text from the emails.`;
381381
* their writing style using Claude Opus. Returns a style description that
382382
* can be used as the stylePrompt.
383383
*/
384-
export async function inferStyleFromSentEmails(gmailClient?: GmailClient | null): Promise<string> {
384+
export async function inferStyleFromSentEmails(
385+
gmailClient?: GmailClient | null,
386+
gmailAccountId?: string,
387+
): Promise<string> {
385388
// Fetch recent sent emails from local DB (all accounts)
386389
let emails = getRecentSentEmailsWithBody(100);
387390

@@ -392,7 +395,7 @@ export async function inferStyleFromSentEmails(gmailClient?: GmailClient | null)
392395
const gmailRows = await fetchAndCacheSentEmails(
393396
gmailClient,
394397
"from:me in:sent",
395-
"default",
398+
gmailAccountId ?? "default",
396399
100,
397400
);
398401
// Merge, dedup by ID

src/renderer/components/SettingsPanel.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ export function SettingsPanel({ onClose, initialTab }: SettingsPanelProps) {
480480

481481
const handleInferStyle = async () => {
482482
setIsInferring(true);
483+
setSaveResult(null);
483484
try {
484485
const result = (await window.api.style.infer()) as {
485486
success: boolean;
@@ -488,7 +489,11 @@ export function SettingsPanel({ onClose, initialTab }: SettingsPanelProps) {
488489
};
489490
if (result.success && result.data) {
490491
setStylePrompt(result.data);
492+
} else {
493+
setSaveResult(result.error || "Failed to infer writing style");
491494
}
495+
} catch {
496+
setSaveResult("Failed to infer writing style");
492497
} finally {
493498
setIsInferring(false);
494499
}

0 commit comments

Comments
 (0)