[UX] Flash of incorrect mode/apiConfig when opening new editor tab
Problem
When a user opens a new Roo Code editor tab, the webview briefly displays stale global state before loadViewState() completes and updates to the correct view-local state. This causes a visible "flash" or flicker.
Evidence
Code locations:
Reproduction:
1. Tab A (sidebar) has mode = "architect" saved in view-local state
2. Open new Tab B (editor) — it starts with global default mode = "code"
3. Webview displays "code" briefly
4. loadViewState() completes → viewLocalState.mode = "code" (or whatever was persisted for this tab)
5. postStateToWebview() updates UI to correct value
6. User sees a flash/flicker between step 3 and step 5
Root Cause
loadViewState() is an async operation that runs after the webview has already been mounted and received its first state push via postStateToWebview(). There's no loading indicator or skeleton UI to mask this transition.
Proposed Fix
-
Add a viewStateLoaded flag to ExtensionStateContext:
interface ExtensionStateContextType {
// ... existing fields
viewStateLoaded: boolean // New field
setViewStateLoaded: (value: boolean) => void
}
-
Set viewStateLoaded = true after loadViewState() completes in setViewStateId().
-
In SettingsView or mode selector, show a loading skeleton or spinner when !viewStateLoaded:
{!viewStateLoaded ? (
<Skeleton className="h-8 w-24" />
) : (
<ModeSelector value={mode} onChange={setMode} />
)}
-
Alternatively: Debounce the initial postStateToWebview() call until after loadViewState() completes, but this may delay UI rendering.
Scope
- Impact: All new tab openings — especially noticeable when view-local state differs from global default
- Risk: Low-Medium — adding loading skeleton is safe; debouncing may affect perceived responsiveness
- Priority: Medium (affects first impression of parallel mode)
Related
[UX] Flash of incorrect mode/apiConfig when opening new editor tab
Problem
When a user opens a new Roo Code editor tab, the webview briefly displays stale global state before
loadViewState()completes and updates to the correct view-local state. This causes a visible "flash" or flicker.Evidence
Code locations:
ClineProvider.ts:456:await this.loadViewState()— async operation in constructorClineProvider.ts:3079:postStateToWebview()called in constructor beforeloadViewState()completesExtensionStateContext.tsx:492-496:webviewDidLaunchhandshake triggerssetViewStateId(), which callsloadViewState()Reproduction:
Root Cause
loadViewState()is an async operation that runs after the webview has already been mounted and received its first state push viapostStateToWebview(). There's no loading indicator or skeleton UI to mask this transition.Proposed Fix
Add a
viewStateLoadedflag toExtensionStateContext:Set
viewStateLoaded = trueafterloadViewState()completes insetViewStateId().In SettingsView or mode selector, show a loading skeleton or spinner when
!viewStateLoaded:Alternatively: Debounce the initial
postStateToWebview()call until afterloadViewState()completes, but this may delay UI rendering.Scope
Related