mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-17 02:25:57 +00:00
fix: resolve stale closure bug in LLM Hub provider management (#333)
* chore: baseline setup * fix: resolve stale closure bug in LLM Hub provider management saveProvider and deleteProvider were wrapped in useCallback with [providers] dependency, building updated arrays from the closure-captured providers state. When adding a provider then deleting another, the delete callback could have a stale providers array that didn't include the newly added one — causing the new provider to be lost when written to storage. Fix: read current state from persistent storage via loadProviders() before every mutation, matching the pattern used in useLlmProviders.ts. Remove useCallback wrappers since they no longer depend on providers state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: inject stop button to pages controlled by agent (#334) * chore: baseline setup * feat(agent): When the agent is running, right now we inject an orange glow. See the `apps/age Task ID: TOiaMuDz * fix: clean up agent storage * fix: improve the stop button style * fix: type issues with stopAgentStorage --------- Co-authored-by: BrowserOS Coding Agent <coding-agent@browseros.com> Co-authored-by: Dani Akash <DaniAkash@users.noreply.github.com> * fix: resolve stale closure bug in LLM Hub provider management saveProvider and deleteProvider were wrapped in useCallback with [providers] dependency, building updated arrays from the closure-captured providers state. When adding a provider then deleting another, the delete callback could have a stale providers array that didn't include the newly added one — causing the new provider to be lost when written to storage. Fix: read current state from persistent storage via loadProviders() before every mutation, matching the pattern used in useLlmProviders.ts. Remove useCallback wrappers since they no longer depend on providers state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: BrowserOS Coding Agent <coding-agent@browseros.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Dani Akash <DaniAkash@users.noreply.github.com>
This commit is contained in:
@@ -43,7 +43,10 @@ export function useLlmHubProviders(): UseLlmHubProvidersReturn {
|
||||
|
||||
setProviders(updatedProviders)
|
||||
const success = await saveProviders(updatedProviders)
|
||||
if (!success) setProviders(currentProviders)
|
||||
if (!success) {
|
||||
const reloaded = await loadProviders()
|
||||
setProviders(reloaded)
|
||||
}
|
||||
}
|
||||
|
||||
const deleteProvider = async (index: number) => {
|
||||
@@ -54,7 +57,10 @@ export function useLlmHubProviders(): UseLlmHubProvidersReturn {
|
||||
|
||||
setProviders(updatedProviders)
|
||||
const success = await saveProviders(updatedProviders)
|
||||
if (!success) setProviders(currentProviders)
|
||||
if (!success) {
|
||||
const reloaded = await loadProviders()
|
||||
setProviders(reloaded)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user