Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 7, 2025

Fixes #4430

Problem

When settings are saved, dynamic providers (OpenRouter, LiteLLM, DeepInfra, Roo, etc.) briefly show generic fallback model info while their model lists reload, causing a visual flicker.

Solution

Added a simple in-memory cache in ApiOptions component that:

  • Stores the last known ModelInfo when available
  • Uses cached info as fallback when selectedModelInfo temporarily becomes unavailable
  • Automatically updates when fresh model info loads

Implementation

Just 3 lines of React state:

const [lastKnownModelInfo, setLastKnownModelInfo] = useState<ModelInfo | undefined>()

useEffect(() => {
  if (selectedModelInfo) {
    setLastKnownModelInfo(selectedModelInfo)
  }
}, [selectedModelInfo])

const displayModelInfo = selectedModelInfo || lastKnownModelInfo

No persistence, no cross-window coordination, no background revalidation - just a simple bridge to prevent flicker during settings save.

Testing

Manually tested settings save flow - no flicker observed.


Important

Adds in-memory cache in ApiOptions to prevent model info flicker during settings save by using cached data as fallback.

  • Behavior:
    • Adds in-memory cache in ApiOptions to store last known ModelInfo.
    • Uses cached ModelInfo as fallback when selectedModelInfo is unavailable.
    • Updates cache when new ModelInfo is loaded.
  • Implementation:
    • Introduces lastKnownModelInfo state and useEffect to update it in ApiOptions.
    • Replaces selectedModelInfo with displayModelInfo in relevant JSX conditions.
  • Testing:
    • Manually tested settings save flow to confirm flicker is resolved.

This description was created by Ellipsis for d6a4265. You can customize this summary. It will automatically update as commits are pushed.

…act state cache

Fixes #4430

Replace complex cross-window persistence system with a minimal 3-line
React state solution that caches the last known ModelInfo and uses it
as a fallback when selectedModelInfo temporarily becomes unavailable
during settings save.

This simple in-memory approach eliminates the flicker without adding
complexity, cross-window coordination, or background revalidation.
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners November 7, 2025 16:07
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Nov 7, 2025
@roomote
Copy link

roomote bot commented Nov 7, 2025

Rooviewer Clock   See task on Roo Cloud

Review found 2 areas where the flicker fix is incomplete:

  • Line 783: SimpleThinkingBudget for "roo" provider still uses selectedModelInfo instead of displayModelInfo, causing flicker during settings save
  • Line 754: Deprecated model error check uses selectedModelInfo?.deprecated instead of displayModelInfo?.deprecated, causing the error message to flicker

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 7, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 7, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 7, 2025
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to PR [Draft / In Progress] in Roo Code Roadmap Nov 7, 2025
@daniel-lxs daniel-lxs marked this pull request as draft November 7, 2025 20:40
@daniel-lxs
Copy link
Member Author

Closing this PR as it doesn't address the root cause of #4430. The issue is not about model info flicker in the UI, but about the backend unconditionally rebuilding the API handler on Save, which triggers context condensing. Opening a new PR with the correct fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Context condensing triggers on settings Save during active task

3 participants