Skip to content

[BUG] New editor tab briefly flashes the previous view's mode/apiConfig before per-view state loads (vps2 F7; upstream #915) #1566

Description

@easonLiangWorldedtech

Gap

When a new editor tab (view) opens, the webview renders before that view's per-view state has been hydrated: ModesView briefly shows the previous view's (or the global default's) mode and API configuration ??the flash of incorrect mode/apiConfig ??before the extension posts the hydrated state. The webview has no signal that the per-view view state has loaded, so it cannot withhold the mode UI until then.

Upstream provenance

Fix unit

vps2 F7 of the durable per-view state series (fork tracking issue easonLiangWorldedtech#41). Draft PR: #1567 (branch vps2/f7-viewstate-loaded, stacked on the F6 head f42c571; head c00ffc3) — #1567

Fix scope (6 files, all under webview-ui/, 96 insertions / 5 deletions = a+d 101 measured vs the F6 head)

  1. src/context/ExtensionStateContext.tsx ??the viewStateLoaded: boolean + setViewStateLoaded wiring (interface field, useState, setViewStateLoaded(true) after setDidHydrateState(true) in the state-message handler, context value).
  2. src/components/modes/ModesView.tsx ??the loading skeleton (data-testid modes-view-loading-skeleton, aria-busy) rendered while viewStateLoaded === false.
  3. src/components/modes/tests/ModesView.spec.tsx ??the mock fields + the new "shows a loading skeleton while view-local state is initializing" test.
  4. src/context/tests/ExtensionStateContext.spec.tsx ??the TestComponent wiring + 3 new tests (initializes false; true after the first state message; setViewStateLoaded).
  5. src/App.tsx ??the -3 deletion of the bare webviewDidLaunch useEffect (the F1c-owned hunk from fix(webview): add loading skeleton for view state initialization #928, folded into this unit because F1c shipped without it; the payload-carrying post already lives in ExtensionStateContext.tsx).
  6. src/tests/App.spec.tsx ??the getViewStateId mock field (+1; absent at the base, added in this unit).

Series note

Draft PR; this unit is the 9th of the merge chain (F1a to F1b to F1c to F2 to F3 to F4 to F5 to F6 to F7) and the final vps2 unit. The PR body documents the #928 port fidelity (including the #928 files deliberately NOT ported, per unit), the folded App.tsx hunk, the budget measurement, and the mutation-diff gate. No Closes/Fixes/Resolves linkage ??this issue is the series gap record for the unit.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions