fix(insights): validate localStorage model values and tighten fallback condition

- Guard against malformed localStorage values (e.g. "provider/") by
  validating both parts are non-empty before sending to the server
- Only wire settings fallback when both provider AND modelId are
  explicitly provided, preventing mismatched provider/modelId combos

Addresses ISSUE-002 and ISSUE-003 from code quality review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Timothy Laurent
2026-05-06 08:01:05 -07:00
parent 4f674f2085
commit 41af820f1d
2 changed files with 9 additions and 4 deletions

View File

@@ -130,8 +130,9 @@ async function executeInsightAttempt(params: {
const finalProvider = params.modelProvider ?? settingsProvider;
const finalModelId = params.modelId ?? settingsModelId;
const fallbackProvider = params.modelProvider ? settingsProvider : undefined;
const fallbackModelId = params.modelProvider ? settingsModelId : undefined;
const hasCustomModel = params.modelProvider && params.modelId;
const fallbackProvider = hasCustomModel ? settingsProvider : undefined;
const fallbackModelId = hasCustomModel ? settingsModelId : undefined;
const existingInsights = await readInsightsMemory(params.rootDir);
let responseText = "";