Repository navigation
Description
Summary
Add cross-store compensation for the activation batch in ClineProvider.persistProviderProfile. Add concurrent-view failure tests. Deliver this work as a separate change from PR #2237.
Requested by @easonLiangWorldedtech.
Current behavior and rationale
persistProviderProfile saves the profile through ProviderSettingsManager.saveConfig before activation. Its activation batch uses Promise.allSettled for:
- Profile-list metadata in
ContextProxy. setValue("currentApiConfigName", name), including durable per-view selection persistence.ProviderSettingsManager.setModeConfig(mode, id).ContextProxy.setProviderSettings(providerSettings).- The view-local
apiConfigurationoverlay.
If a member rejects, the function throws the first rejection after all members settle. Successful members remain committed. The throw skips updateTaskApiHandlerIfNeeded and persistStickyProviderProfileToCurrentTask. The stored profile, selected profile, shared settings, view overlay, and running task can therefore disagree.
The batch's partial-commit semantics predate PR #2237. That PR routes the selected-profile write through setValue and adds the view overlay update. With only apiConfiguration, _saveViewLocalStateFromMutation does not write durable viewStates. The added durable-write failure surface comes through setValue("currentApiConfigName", name).
Required changes
- Define the previous activation state across
ProviderSettingsManagersecret-backed storage, mode mappings,ContextProxy, durable per-view selections, and view-local overlays. - Choose a single compensation owner:
persistProviderProfile, or an explicit caller contract applied consistently. - Capture the previous state before writes and compensate committed changes after an activation failure. Include an explicit policy for the preceding
saveConfigwrite, covering both existing and newly created profiles. - Cover the currently unguarded
ContextProxy.setProviderSettingsandProviderSettingsManager.setModeConfigwrites. - Preserve newer writes from another view during compensation. Do not restore a stale whole-store snapshot.
- Build on
_restoreSharedValuesAfterFailedViewWriteandContextProxy.getStateWriteGenerationwhere applicable. These guards cover ContextProxy keys only; define equivalent ownership or serialization for the other state. - Reconcile
updateProfileModel, which attempts profile restoration, withupsertProviderProfile, which currently logs errors, shows an error message, and returnsundefined. - Define error reporting and recovery when compensation itself fails. Preserve the original activation failure and expose any incomplete recovery without logging credentials.
Affected areas and anchors
Line numbers are anchors supplied in the originating discussion and can move:
src/core/webview/ClineProvider.ts:persistProviderProfile, supplied Lines 2916–2941.src/core/webview/ClineProvider.ts:_restoreSharedValuesAfterFailedViewWrite, supplied Lines 6396–6428.src/core/webview/ClineProvider.ts:upsertProviderProfile,updateProfileModel,setValue,_saveViewLocalStateFromMutation,updateTaskApiHandlerIfNeeded, andpersistStickyProviderProfileToCurrentTask.src/core/config/ContextProxy.ts: provider-settings writes and per-key write generations.src/core/config/ProviderSettingsManager.ts: profile persistence and mode mappings.src/core/webview/__tests__/ClineProvider.spec.ts: focused activation and concurrent-view regression tests.- Relevant storage-manager tests where compensation requires new contracts.
Acceptance criteria
- Inject a failure in each durable activation write after other writes have succeeded. Verify that compensation settles before the mutation finishes.
- Verify consistency of profile storage, profile-list metadata, shared selection, shared provider settings, mode mapping, durable per-view selection, and view-local overlay after failure.
- Verify that failed activation does not leave the task handler or sticky task profile inconsistent with the recovered state.
- Test existing-profile updates and newly created profiles.
- Test a second live view saving or activating a profile while the first view compensates. Newer valid writes must survive, including same-value writes with a newer generation.
- Test delayed writes and different completion orders. Compensation must not race an unsettled activation write.
- Test compensation failure and subsequent retry. Incomplete recovery must be reported explicitly.
- Verify consistent compensation behavior for
upsertProviderProfileandupdateProfileModel, without duplicate or conflicting restoration. - Retain successful activation behavior and sibling-view synchronization.
- Keep provider credentials out of diagnostics and failure messages.
Source context
- PR: feat(webview): per-view ack, history and profile restore writes (N5, split 5/5 of #1546) #2237
- Review discussion and follow-up authorization: feat(webview): per-view ack, history and profile restore writes (N5, split 5/5 of #1546) #2237 (comment)
This issue records deferred work. Creating it does not establish that the review finding is fixed or decide the PR's merge status.
Activity
easonLiangWorldedtech commentedon Nov 23, 2026
Scope boundary for #2237, and a request that the split be confirmed here
A review of #2237 (check run
137486035981, verdict2026-11-23T04:36:12Z, head1701f9b13aff7e06035ab2544e0b324388d05309) marks theCloses:link to this issue as an error and offers two paths verbatim:We are taking (b), and this comment is the confirmation request. What #2237 does land, measured from its own diff: the per-view state claim and restore path, the write ordering between the per-view map and the shared keys, and the rollback counting when a per-view write fails. What it does not land, and what this issue keeps as its own deliverable: the owner of the compensation, failure injection after each durable activation write, compensation-failure reporting, and credential-free diagnostics.
compensationappears 0 times in #2237's diff, and this issue's own text already says to deliver that work as a separate change from PR #2237 - so the split follows what is written here, not a preference we are introducing.Two things we would like from whoever owns this issue:
Refs:rather thanCloses:.extension has 608 changed executable lines (limit 500)against merge base7d8053fefa1c1b489866aece98d4c12691c4c9fa, printed three times at that head - runs137472021248,137473986727,137475245368). If the answer to that budget is a split of feat(webview): per-view ack, history and profile restore writes (N5, split 5/5 of #1546) #2237, this issue should be resolved by the replacement PR, not by feat(webview): per-view ack, history and profile restore writes (N5, split 5/5 of #1546) #2237 as it stands.#2316 is the same finding filed separately 22 seconds later; the boundary above covers both.