Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): bump owner generation for same-owner account-free repairs

Yuewei-LL901183f1f756
diff --git a/apps/desktop/src/main/authManager.ts b/apps/desktop/src/main/authManager.ts
index f1d4c59864..8f1f972f7b 100644
--- a/apps/desktop/src/main/authManager.ts
+++ b/apps/desktop/src/main/authManager.ts
@@ -881,6 +881,11 @@ async function withAccountFreeOwnerCommit(opts: {
}): Promise<void> {
let authCleared = opts.authAlreadyCleared ?? false;
let releaseBoundary: (() => void) | null = null;
+ // Same-owner account-free repair tears down the owner-bound Ghost runtime but
+ // keeps the same mode/owner, so commitActiveAppSession's same-owner early
+ // return would NOT advance the owner generation — stale async work that
+ // captured the pre-repair scope key would then pass the post-release guard.
+ let forceBumpGeneration = false;
const notify = opts.notify ?? true;
const previousOwnerId = getActiveAppSession().dataOwnerId;
if (isPassiveSharedUserDataInstance()) {
@@ -923,6 +928,7 @@ async function withAccountFreeOwnerCommit(opts: {
if (!projectionRepairTeardown) {
throw new Error('account-free projection repair requires a teardown hook');
}
+ forceBumpGeneration = true;
await projectionRepairTeardown(opts.reason);
}
},
@@ -946,6 +952,12 @@ async function withAccountFreeOwnerCommit(opts: {
authCleared = true;
}
commitActiveAppSession(opts.nextMode);
+ // Same-owner account-free repair: advance the owner generation after the
+ // real commit so activeOwnerScopeKey() changes and stale captured scopes
+ // are rejected across the teardown.
+ if (forceBumpGeneration) {
+ commitActiveAppSession(opts.nextMode, undefined, true);
+ }
},
});
} catch (error) {