Fix model selection after anonymous usage#5503
Conversation
🦋 Changeset detectedLatest commit: babe584 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (3 files)
|
|
|
||
| // kilocode_change start: If we're updating the active profile, we need to activate it to ensure it's persisted | ||
| const currentApiConfigName = getGlobalState("currentApiConfigName") | ||
| const currentApiConfigName = getGlobalState("currentApiConfigName") || "default" |
There was a problem hiding this comment.
SUGGESTION: Prefer nullish coalescing to avoid treating falsy-but-valid values as "default"
Using || will replace any falsy value (e.g. an empty string) with "default". If currentApiConfigName is only ever string | undefined, using ?? is a safer defaulting pattern.
| const currentApiConfigName = getGlobalState("currentApiConfigName") || "default" | |
| const currentApiConfigName = getGlobalState("currentApiConfigName") ?? "default" |
|
|
||
| // kilocode_change start: If we're updating the active profile, we need to activate it to ensure it's persisted | ||
| const currentApiConfigName = getGlobalState("currentApiConfigName") | ||
| const currentApiConfigName = getGlobalState("currentApiConfigName") || "default" |
There was a problem hiding this comment.
SUGGESTION: Prefer nullish coalescing (??) over || when defaulting currentApiConfigName
Using || treats "" (empty string) as missing. If currentApiConfigName can ever be an empty string (e.g. corrupted/migrated state), this will unexpectedly fall back to "default". ?? only falls back for null/undefined.
| const currentApiConfigName = getGlobalState("currentApiConfigName") || "default" | |
| const currentApiConfigName = getGlobalState("currentApiConfigName") ?? "default" |
After https://github.com/Kilo-Org/kilocode/pull/5415/changes model changes while logged out no longer worked. This PR should hopefully fix it.
The theoretical cause:
currentApiConfigNameisundefined, soisActiveProfileevaluates tofalse, causing the profile to be saved but NOT activated.