Repository navigation
fix(webview): invalidate live sibling view state on reset and settings import (vps2 F4) - #1562
Open
easonLiangWorldedtech wants to merge 285 commits into
Open
easonLiangWorldedtech wants to merge 285 commits into
easonLiangWorldedtech wants to merge 285 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR — vps2 unit F4 (cross-instance reset and import invalidation).
Related GitHub Issue
Closes: #1561
The link is by content, not by label. Issue #1561 is open and unlabeled. It records the bug that this unit fixes: per-view state stays usable after a state reset, a profile deletion, and a settings import. This unit is unmerged. Upstream issue #980 covers the same bug and is closed as completed. Fork issue 41 is the ledger of the vps2 split; it is not the issue that this pull request closes. Issue #2488 stays open. It holds the write-ownership decision that this unit does not settle.
Description
This unit makes per-view state follow the profile that a view actually uses.
Invalidation paths:
broadcastResetToAllInstances(ClineProvider.ts:6291) after the shared reset lands, and again when the shared reset fails after it already wrote (call sites at 6400 and 6421). Every live view clears its in-memory view-local state, one queued write clears the durableviewStatesentries, and every view that did not start the reset re-posts its own state.importExport.ts:405).refreshViewLocalStateForUpdatedProfile, 4577). A profile deletion re-pins the views that named the deleted profile to the profile that replaces it (rePinViewLocalStateForDeletedProfile, 4626). A profile rename re-points them (repointViewLocalStateAfterProfileRename, 4704, called from the webview message handler). Each fan-out rewrites the durable pin, this view's live pair, the current task's API handler, and the current task's sticky profile name.Failure handling:
Newest head,
c9dd5cc6171f, adds two fixes:Promise.all.Promise.allreports the first rejection while the other legs are still running. The deletion path compensates for a failed activation by restoring the selection and the shared settings that the activation moved, so a write that lands after that restore stores on top of it. The fan-out now waits for all four legs withPromise.allSettled, keeps the first rejection as the error that the caller sees, names the failed legs in the log, keeps the rebuild in the catch, and leaves the restore order unchanged.dispose()sets_disposedbefore it awaits task eviction. A view that has begun teardown is therefore still registered while its own teardown runs. The cross-view fan-outs used to re-pin, refresh, or re-point those views, which duplicates work that their own teardown already does. Six fan-out sites now skip an instance that has begun teardown. Seven sites in the file now read!instance._disposed, counting the check that the active-instance lookup already had.Persistence integrity (error-mode review line)
Fixed in this unit: settle before decide. Measured on the parent commit
7c7556b18b0d: with the selection write rejected and the shared settings write landing two timer hops later, the durable selection read the restored profile while the durable settings read the profile that the failed switch had moved to. That mismatched pair survives a reload. The fix makes the fan-out wait for every leg and then report the first rejection. Two things are not claimed: the fix does not make every layer agree after a failed activation, and it does not undo the rule that a failed activation keeps the switch.This pull request fixes the hazard and does not land the design: it does not reconcile the layers from the committed and failed write lists, and it does not give that reconciliation cross-window authority.
Declined for this unit, on the record. The review line asks for two further things: reconcile the layers from the committed and failed write lists with cross-window authority, and persist or record the sticky profile name when a switch fails. Issue #2488 records both as undecided at the record-level write. Issue #2488 splits the work into two steps. Step 1 is the intra-window fix that this unit ships. Step 2 is the record-level write revision with cross-window authority; it is not implemented here, and #2488 owns it. The reviewer's activation test is the acceptance criterion for that follow-up unit. The advisory mutation check reports 2,531 changed executable lines against a limit of 500 for the diff that this branch carries, so a cross-window write revision does not fit inside this unit.
Lifecycle resource cleanup (warning-mode review line)
Fixed in this unit: six cross-view fan-out sites skip a view that has begun teardown. Two discriminating tests cover the re-pin after a deletion and the refresh after a save. The read-only sibling pin check is deliberately left unguarded, because skipping a disposed sibling there would change which profile a deletion reports as still referenced.
Declined for this unit: the same two asks answered above, with the same citations — issue #2488 (step 1 shipped here, step 2 not), the reviewer's activation test as the acceptance criterion for the follow-up unit, and the advisory mutation count of 2,531 against the 500 limit.
Effect stated plainly: this work clears a warning line. It does not unblock anything. Warning mode writes prose for a human reader; it cannot flip the verdict.
Regression evidence (warning-mode review line)
Four new tests carry this head, one discriminating test per finding, each paired with a negative control on the parent blob and a hash proof:
keeps a late activation write from landing on top of the state the failure path restored(provider spec).leaves a view that has begun teardown out of the re-pin after a profile deletion(provider spec).leaves a view that has begun teardown out of the sibling refresh after a profile save(provider spec).returns the in-memory state when a read throws after every write landed(webview-ui state-wrapper spec).The three provider tests fail on the parent production file and pass on this head. The wrapper case fails when the read-failure fallback is reverted and passes on this head. Clearing this warning line does not unblock anything: warning mode writes prose for a human reader.
Description and issue links
The
Closes: #1561line above satisfies the issue-assessment line, which is error mode. The description section is rewritten here. The previous description text is preserved word for word in comment 6971596076 on this pull request; content was relocated there, not deleted. That comment also carries the corrected review-verdict read.Test Procedure
Commands, run from the package directory:
node node_modules/vitest/vitest.mjs run core/webview/__tests__/ClineProvider.spec.tsfromsrc/.node node_modules/vitest/vitest.mjs runfromsrc/.node node_modules/vitest/vitest.mjs runfromwebview-ui/.tsc --noEmit -p .insrc/andwebview-ui/, andtsc --noEmit -p tsconfig.esm.jsoninapps/vscode-e2e/.eslint <file> --max-warnings=0 --no-warn-ignoredfrom the package directory, theneslint --prune-suppressions --max-warnings=0on the two touched source files.prettier --checkon the touched files.Environment: Windows 11 host, Node 25, pnpm workspace, Vitest 3.
Results at head
c9dd5cc6171f:ClineProvider.spec.ts: 512 passed of 512.dist/, and 5 need symlink creation rights (EPERM). The known local failure inShadowCheckpointServicedid not occur in this run.src/,webview-ui/, andapps/vscode-e2e/.--max-warnings=0. The--prune-suppressionsprobe changed no count, andsrc/eslint-suppressions.jsonwas restored byte-identical after it: 264 files, 264 entries, file sha256/1630b343fbffc25561.prettier --checkexit 0 on all three touched files.Negative controls, each run and then restored byte-identical:
src/core/webview/ClineProvider.tsreplaced by its parent blob37c8e5ca07a9223ad2b4305d6eade4a29f678743(sha256/16910cdbcc9b754a93): exactly the three new provider tests fail — the activation test at the assertion that the late write settled before the caller returned, and the two teardown tests at the first assertion that the sibling was not touched. Restored to sha256/16f98f5e5aedd2f1a6.webview-ui/src/utils/vscode.tschanged to return undefined: exactly the new wrapper case fails (1 failed, 20 passed). Restored byte-identical, sha256/16aad3016c5386a4c0before and after, with only the spec file modified.Pre-Submission Checklist
src/test-utils/,@/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible. This head adds no shared helper; every double and gate stays inside the test that uses it.*.visual.tsxbaseline applies. The webview-ui changes are the state wrapper and its tests.Visual Snapshots
None. This unit is extension-host state management plus the webview state wrapper. No rendered surface changes, so no committed Playwright baseline applies.
Videos (interaction / animation only)
None. No interaction or animation changes.
Documentation Updates
The diff carries 36 files, and none of them is under
docs/or a Markdown file. The behaviour is described in the code comments and in this description.Additional Notes
75a93a9d9acc), because the branch is stacked on unmerged sibling units and merges bottom-up in the order recorded in fork issue 41. The previous head measured 2,506 on the same basis. The advisory is not one of the six required contexts.c9dd5cc6171fat that read.ShadowCheckpointServicethat did not fire in this run.75a93a9d9acc2e0ade07fdb6ab6a2071fca7fd4c(Require authentication for the VS Code E2E mock server, Require authentication for the VS Code E2E mock server #2474). That trunk change touches the code-qa workflow,apps/vscode-e2e, and the TLA mock-authentication files. It does not touchClineProvider.tsor any spec that this unit touches.Get in Touch
No Discord username is recorded for the account that authors this unit. Please comment on this pull request, or reach the GitHub account easonLiangWorldedtech.