Skip to content

fix(webview): coordinate durable viewStates writes across extension hosts (F2 follow-up) #2314

Open

Description

@coderabbitai

Summary

Coordinate viewStates read-modify-write operations across independent extension hosts. This is the explicit F2 follow-up deferred from PR #1921, under parent #1536.

ClineProvider.persistedViewStateWriteQueue is static within one extension-host process. Separate VS Code windows have separate queues but share extension global state. Two hosts can read the same map, update different entries, and write competing whole-map snapshots. The later write can remove the other host's mode or profile pin.

Required changes

  • Provide a cross-host coordination or conflict-safe merge mechanism for the durable viewStates store.
  • Read authoritative state inside that mechanism before applying and committing each mutation. A lock around a stale ContextProxy or globalState cached read is not sufficient.
  • Evaluate the existing guarded-write/merge abstraction used by safeWriteJson. Reuse the established file-safety layer where compatible, or document why another storage/coordination design is necessary.
  • Route saves, clears/reset, temporary-to-stable re-keying, pruning, profile re-pointing, and rollback through the same coordinated persistence boundary so no whole-map writer bypasses it.
  • Preserve existing per-view isolation and persistence-failure behavior. Do not broaden this unit into unrelated profile-routing reconciliation between PR test(webview): F2a - profile-mutation state semantics and the mode-rollback guard #1919 and PR test(webview): ClineProvider parallelMode suite with viewStates pruning edges #1921.

Affected areas

  • src/core/webview/ClineProvider.ts: persistedViewStateWriteQueue, getPersistedViewStates, writePersistedViewStates, and all durable viewStates mutations.
  • src/core/config/ContextProxy.ts: global-state cache and persistence integration.
  • The existing safeWriteJson guarded-write/merge layer and focused cross-host regression coverage.

Acceptance criteria

  • A deterministic regression uses two independent extension hosts or processes with independently stale caches against one durable store.
  • Overlapping writes to different view IDs retain both entries and their mode/profile selections after reload.
  • A host that starts with a stale cache reads authoritative state inside the coordination boundary and preserves another host's completed write.
  • Clear/reset, re-key, prune, profile re-point, and compensation paths do not bypass coordination or overwrite unrelated committed entries.
  • Write failures, coordination failures, and retry behavior are explicit and covered; failed operations do not leave phantom cached state or silently remove another host's entries.
  • Existing same-host serialization and per-view restoration behavior remain covered.

References

The fork issue easonLiangWorldedtech/Zoo-Code#41 is a working series ledger, not the upstream parent. Upstream #41 is unrelated. This issue tracks a valid, unfixed limitation; filing it does not establish PR merge readiness.

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