Skip to content

refactor(cloud): unify session scope resolution - #773

Closed
beruro wants to merge 1 commit into
developfrom
junyu/unify-cloud-session-scope-resolver
Closed

refactor(cloud): unify session scope resolution#773
beruro wants to merge 1 commit into
developfrom
junyu/unify-cloud-session-scope-resolver

Conversation

@beruro

@beruro beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Problem

The cloud share dialog duplicated the sync engine’s session-to-repository-scope resolution. Both copies currently followed the same persisted-import fallback, repo-path check, resolver-cache peek, and cache-prime sequence, but they could drift and make UI eligibility disagree with synchronization.

Solution

Reuse the sync engine’s exported getSessionScopeKeys function from the share-dialog hook and remove the local copy. The shared invariant remains: prefer persisted imported-session scope keys, return null without a repository path, otherwise read the bounded resolver cache and prime exactly once on a miss. The existing useSyncExternalStore subscription remains the UI change signal.

Potential risks

The main risk is an import cycle between the dialog and sync engine modules. The shared resolver lives in the lower-level repo-scope sync module and does not import the dialog, so the dependency remains one-way. Runtime cache ownership, async work, subscriptions, and rendering triggers are unchanged. Rollback is a single-commit revert.

Architecture and performance

  • Covered ownership/boundaries, dependency direction, state flow, async resolution, and lifecycle behavior.
  • Kept the bounded LRU resolver cache and its single-flight in-progress maps unchanged.
  • Kept the external-store subscription and its unsubscribe cleanup unchanged.
  • Added no polling, timers, retries, retained state, or new render triggers.
  • Effects: none added or modified.

Verification

  • pnpm exec vitest run src/features/TeamCollaboration/repoScopeResolver.test.ts src/features/Org2Cloud/org2CloudSyncEngine.sessions.test.ts src/features/Org2Cloud/org2CloudSyncEngine.scopeConfirmation.test.ts src/features/Org2Cloud/CloudSessionShareDialog/shareEligibility.test.ts — 4 files, 93 tests passed after rebasing onto the latest develop.
  • pnpm exec eslint src/features/Org2Cloud/CloudSessionShareDialog/useCloudSessionShareDialog.ts — passed.
  • pnpm typecheck — full TypeScript check executed and passed after the rebase.
  • git diff --check origin/develop...HEAD — passed.
  • The repository snapshot does not provide verify:quick or verify:final, so the equivalent focused tests/lint and full typecheck entry point were used.
  • No visual evidence: this changes no rendered UI or user-visible behavior.

@beruro

beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #780, which preserves this change as an independent commit and has passed the consolidated CI suite. The source branch is retained for recovery.

@beruro beruro closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant