Skip to content

Update App.jsx#483

Open
aditisb1212-lab wants to merge 1 commit into
imDarshanGK:mainfrom
aditisb1212-lab:patch-1
Open

Update App.jsx#483
aditisb1212-lab wants to merge 1 commit into
imDarshanGK:mainfrom
aditisb1212-lab:patch-1

Conversation

@aditisb1212-lab

Copy link
Copy Markdown

📝 Description

This PR fixes a startup initialization issue in App.jsx where the saved default model from settings could be overwritten during application bootstrap.

What changed?

  • Reordered the Promise.allSettled() calls in bootstrap().
  • Moved api.getSettings() to the end of the promise array.
  • Updated the destructuring order accordingly.
  • Ensured that settings-related state updates (setSettings, setModel, and setLanguage) are applied after all other initialization state updates.

Before

The application processed settings before the Ollama status update, which could cause the saved default_model to be overwritten during initialization.

const [mRes, sRes, settRes, stRes] = await Promise.allSettled([
  api.getModels(),
  api.getSessions(),
  api.getSettings(),
  api.getOllamaStatus(),
]);

if (mRes.status === "fulfilled") setModels(mRes.value.models || []);
if (sRes.status === "fulfilled") setSessions((sRes.value || []).map(s => ({ ...s, color: getSessionColor(s.id) })));
if (settRes.status === "fulfilled") {
setSettings(settRes.value);
if (settRes.value.default_model) setModel(settRes.value.default_model);
if (settRes.value.default_language) setLanguage(settRes.value.default_language);
}
if (stRes.status === "fulfilled") {
setOllamaOk(stRes.value.ollama_running);
} else {
setOllamaOk(false);
}


### After

Settings are now applied last, ensuring that the persisted model preference takes precedence.

```js
const [mRes, sRes, stRes, settRes] = await Promise.allSettled([
  api.getModels(),
  api.getSessions(),
  api.getOllamaStatus(),
  api.getSettings(),
]);

✅ CORRECTED CODE
if (mRes.status === "fulfilled") setModels(mRes.value.models || []);
if (sRes.status === "fulfilled") setSessions((sRes.value || []).map(s => ({ ...s, color: getSessionColor(s.id) })));
if (stRes.status === "fulfilled") {
setOllamaOk(stRes.value.ollama_running);
} else {
setOllamaOk(false);
}

// ✅ Settings applied LAST to ensure defaults override initial state
if (settRes.status === "fulfilled") {
setSettings(settRes.value);
if (settRes.value.default_model) setModel(settRes.value.default_model);
if (settRes.value.default_language) setLanguage(settRes.value.default_language);
}


## ✨ Key Features

* Ensures the saved `default_model` is consistently restored on application startup.
* Eliminates initialization order issues during bootstrap.
* Prevents accidental overwriting of persisted user settings.
* Maintains reliable loading of models, sessions, and Ollama status.
* Preserves existing application behavior while improving startup consistency.

## 🔧 Type of Change

* [x] Bug fix
* [ ] New feature
* [ ] Breaking change
* [ ] Documentation update

## 🧪 Testing

* Verified that the application starts successfully after the changes.
* Confirmed that the saved default model is restored correctly across multiple launches.
* Tested model loading, session loading, and Ollama status checks.
* Ensured no regressions in existing functionality.

## 📸 Screenshots

N/A (No UI changes)

## ✅ Checklist

* [x] Code follows the existing project style.
* [x] Changes have been tested locally.
* [x] No breaking changes introduced.
* [x] Existing functionality remains unaffected.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@aditisb1212-lab is attempting to deploy a commit to the Darshan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@imDarshanGK imDarshanGK left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@aditisb1212-lab issue number?

@aditisb1212-lab

aditisb1212-lab commented Jun 30, 2026

Copy link
Copy Markdown
Author

Update App.jsx #483 is issue number

@aditisb1212-lab

Copy link
Copy Markdown
Author

Hello @imDarshanGK can you tell me mistake of there is present or please merge this as tag of completion

@imDarshanGK imDarshanGK left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@aditisb1212-lab issue number?

@aditisb1212-lab

Copy link
Copy Markdown
Author

#92

@imDarshanGK

Copy link
Copy Markdown
Owner

@aditisb1212-lab add video demo

@aditisb1212-lab

Copy link
Copy Markdown
Author

Okk

@aditisb1212-lab

Copy link
Copy Markdown
Author

Check @imDarshanGK #950 pull request added demo video

@imDarshanGK imDarshanGK added the invalid This doesn't seem right label Jul 6, 2026
@aditisb1212-lab aditisb1212-lab mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants