Skip to content

AppBuilder - Fix model selector not showing saved model on reload#4

Merged
eshurakov merged 2 commits intomainfrom
eshurakov/app-builder-fix-model-selection-on-reload
Feb 5, 2026
Merged

AppBuilder - Fix model selector not showing saved model on reload#4
eshurakov merged 2 commits intomainfrom
eshurakov/app-builder-fix-model-selection-on-reload

Conversation

@eshurakov
Copy link
Contributor

Summary

  • Fix race condition where the saved model wasn't displayed when opening or reloading an App Builder chat
  • The previous logic cleared selectedModel while waiting for the models API to load, then failed to restore it because projectModel was always truthy (defaults to anthropic/claude-sonnet-4)

Changes

  • Use a ref (initialProjectModelRef) to track the initial project model and only sync when a different project loads
  • Simplify the fallback effect to only set a default when the current selection is invalid
  • User model selections are now preserved and not overridden by the sync logic

@vercel
Copy link

vercel bot commented Feb 4, 2026

Deployment failed with the following error:

The value for maxDuration must be between 1 second and 300 seconds, in order to increase this limit upgrade your plan: https://vercel.com/pricing

Learn More: https://vercel.com/docs/functions/limitations

// Sync selectedModel when a different project loads (projectModel changes from initial)
useEffect(() => {
if (projectModel) {
if (projectModel && projectModel !== initialProjectModelRef.current) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Model sync only triggers when the model ID string changes

If you navigate to a different project that happens to use the same projectModel value as the previous project, this effect will not run, so selectedModel can incorrectly carry over a prior user selection. Consider keying this sync off a project identity (e.g., project id / manager) rather than projectModel value, or resetting selectedModel when the manager/project changes.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 4, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
src/components/app-builder/AppBuilderChat.tsx:287 287 Model sync may not run when switching projects that share the same model id
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

None.

Files Reviewed (4 files)

@eshurakov eshurakov merged commit dcb9a42 into main Feb 5, 2026
9 of 10 checks passed
@eshurakov eshurakov deleted the eshurakov/app-builder-fix-model-selection-on-reload branch February 5, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants