Skip to content

Fix settings state: fire event before async storage to ensure React updates - #10

Merged
danialsamiei merged 1 commit into
mainfrom
devin/1771279979-fix-settings-event
Feb 16, 2026
Merged

danialsamiei merged 1 commit into
mainfrom
devin/1771279979-fix-settings-event

Conversation

@danialsamiei

Copy link
Copy Markdown
Collaborator

Fix settings state: fire change event before async storage persistence

Summary

Reorders _onDidChangeState.fire() to execute before await _storeState() across all 7 setter methods in VoidSettingsService. Also wraps _storeState() internals in a try-catch so storage failures don't prevent the change event from firing.

Problem: In the web deployment (ide.orcest.ai), entering the OpenRouter API key in the onboarding wizard has no effect — the UI still says "Please set up at least one Chat model." The in-memory state updates correctly (this.state = _validatedModelState(newState) is synchronous), but React components only re-render when _onDidChangeState.fire() is called. Since fire() was placed after await _storeState(), if _storeState() throws (e.g. due to web-mode IndexedDB/encryption issues), the event never fires and the UI never updates.

Fix: Move fire() before the await, and wrap _storeState() in try-catch so storage failures are logged but don't block the UI.

Review & Testing Checklist for Human

  • Verify root cause hypothesis: The author did not confirm _storeState() is actually throwing — this is inferred from the symptom. Check browser console after deploying for [VoidSettingsService] Failed to store state: messages to confirm. If no such messages appear, the real root cause is elsewhere and this PR won't fix the onboarding issue.
  • Test onboarding flow end-to-end: After deploying, navigate to ide.orcest.ai, enter the OpenRouter API key in the onboarding wizard, and verify clicking "Next" proceeds (no "Please set up at least one Chat model" error).
  • Verify persistence on page reload: After entering the API key and completing onboarding, reload the page and confirm the API key and model selection are retained. The reordering means fire() succeeds even if storage fails — which is better for UX but could mask data loss.
  • Check for race conditions: With fire() before await _storeState(), rapid successive calls (e.g. typing quickly in the API key input) could cause overlapping _storeState() calls. Verify no state corruption occurs in storage.

Notes

  • There's a minor whitespace-only change on _onUpdate_syncApplyToChat() (removed space before {) — not intentional but harmless.
  • This is PR Fix settings state: fire event before async storage to ensure React updates #10 in a series fixing the web deployment of this VS Code fork. Previous PRs addressed HTTPS mixed content, React build, connection tokens, dev mode, web service stubs, and this-binding issues.

Link to Devin run: https://app.devin.ai/sessions/9a3910ef8208402b93e14fa38bb90f2b
Requested by: @danialsamiei

…pdates

Co-Authored-By: Danial Piterson <danial.samiei@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@danialsamiei
danialsamiei merged commit 5351e09 into main Feb 16, 2026
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.

1 participant