Repository navigation
fix(workspace): re-read persisted workspace approvals after a failed startup read - #755
Merged
DeadWaveWave merged 1 commit intoNov 26, 2026
Conversation
Owner
|
Merged, thanks @anhnt256. Checked:
It ships in the next release. |
4 of 8 tasks
This was referenced Nov 26, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
💡 Change Scope
📝 What Does This PR Do?
Fixes #720.
When the first persistence read at startup fails (e.g. the local Worker is not up yet — "Storage is unavailable", as in the Windows CI run behind #717),
createPersistedWorkspaceApprovalGatenever registered any approved workspace roots for the whole session: thecatchonly calledonError, the persisted roots were never registered, theextraRootswere not registered either (they were computed after the read), and every laterregisterRoot/isPathApprovedawaited the same settledreadypromise — so previously approved workspaces stayed unregistered until an app restart.This restructures the gate around a retryable, single-flight
ensureHydrated():extraRootsfirst, unconditionally (guarded by a one-shot flag, so retries never re-register them) — extra roots are registered whatever the read does.onErrorfires, as today. The nextregisterRootorisPathApprovedcall starts a new attempt; concurrent calls share the one in-flight attempt. Once an attempt succeeds, the gate is hydrated and no further reads happen.{ approvedWorkspaces, ready };readystill resolves, never rejects, when the first attempt fails), soregisterIpcHandlers.tsneeds no change.Tests (TDD, red → green): three new tests in
persistedWorkspaceApproval.spec.ts— extra roots are registered and approved even when the startup read fails; a first read that rejects and a second that resolves approves the second read's roots without a restart (the issue's proposed test), withonErrorfired once and no further reads afterwards;registerRootalso triggers the re-read, and two concurrent checks share a single retry. The three new tests fail on unmodified code (3 failed / 2 passed) and pass with the fix (5/5). The adjacentbootstrapSpaceDirectorysuite passes 4/4,pnpm check(typecheck) exits 0, and prettier + oxlint are clean on both changed files.pnpm verify:quickand E2E were not run locally (this environment has no Electron binary or node-pty native build); CI is the gate for those.🏗️ Large Change Spec (Required if "Large Change" is checked)
1. Context & Business Logic
Workspace approval decides which directories OpenCove may open without asking again. The approved roots come from persisted app state, hydrated once at startup. A single transient read failure at startup permanently disabled that hydration for the session, so every previously approved workspace behaved as unapproved until a restart. This change makes hydration recover on next use instead of never.
2. State Ownership & Invariants
The gate in
PersistedWorkspaceApproval.tsowns the hydration state; the underlyingApprovedWorkspaceStoreis unchanged. Invariants: (1) a root is only ever registered from a successful read or fromextraRoots; (2) at most one persistence read is in flight at any time (single-flight); (3) after the first successful read,readAppStateis never called again.3. Verification Plan & Regression Layer
Unit layer: the three new tests in
persistedWorkspaceApproval.spec.tspin the failure-then-recovery behavior, the extra-roots-on-failure behavior, and the single-flight retry — they fail on the unmodified code and pass with the fix, so the bug cannot silently return. The adjacentbootstrapSpaceDirectorysuite (the other consumer of the gate) passes 4/4, and typecheck is clean. Full regression runs in PR CI.🔗 Co-change partners left untouched
None: this change leaves no co-change partner untouched.
Considered and intentionally not changed:
src/app/main/ipc/registerIpcHandlers.ts— the only production caller; the factory's contract is unchanged, so it needs no edit (itsonErrorlog line now also fires on a failed retry, which is the desired visibility).src/contexts/workspace/infrastructure/approval/ApprovedWorkspaceStore.tsandApprovedWorkspaceStoreCore.ts— the store is unchanged; itsregisterRootis set-based, so a retry re-registering a root is a no-op.✅ Delivery & Compliance Checklist
pnpm verify:quick/pnpm pre-commitis green; any additional focused tests are reported above.CLA.md).DEVELOPMENT.mdarchitectural boundaries.📸 Screenshots / Visual Evidence
Not applicable — no UI change; the behavior is pinned by the unit tests described above.