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(auth): 推送新登录态前清理旧灰度标记

xd-bobo7692748e882e
diff --git a/apps/desktop/src/main/__tests__/authLoginFlowReset.test.ts b/apps/desktop/src/main/__tests__/authLoginFlowReset.test.ts
index 3030ad3946..a445b5c425 100644
--- a/apps/desktop/src/main/__tests__/authLoginFlowReset.test.ts
+++ b/apps/desktop/src/main/__tests__/authLoginFlowReset.test.ts
@@ -1116,11 +1116,13 @@ describe('auth login-flow reset', () => {
const completeStart = source.indexOf('async function completeLogin(');
const completeEnd = source.indexOf('\n}\n\nasync function acceptLoginOutcome', completeStart);
const completeBody = source.slice(completeStart, completeEnd);
+ const acceptedUser = completeBody.indexOf('currentUser = nextUser;');
const ownerCommit = completeBody.indexOf('commitCloudAppSession(currentUser.id, authRealmChanged);');
- const clearPreviousFlag = completeBody.indexOf('canaryFlagStore.clear();', ownerCommit);
- expect(ownerCommit).toBeGreaterThan(-1);
- expect(clearPreviousFlag).toBeGreaterThan(ownerCommit);
- expect(completeBody.slice(ownerCommit, clearPreviousFlag)).toContain(
+ const clearPreviousFlag = completeBody.indexOf('canaryFlagStore.clear();', acceptedUser);
+ expect(acceptedUser).toBeGreaterThan(-1);
+ expect(clearPreviousFlag).toBeGreaterThan(acceptedUser);
+ expect(ownerCommit).toBeGreaterThan(clearPreviousFlag);
+ expect(completeBody.slice(acceptedUser, clearPreviousFlag)).toContain(
'if (!isPassiveSharedUserDataInstance()) {',
);
diff --git a/apps/desktop/src/main/authManager.ts b/apps/desktop/src/main/authManager.ts
index 303d0d850d..b2f3957117 100644
--- a/apps/desktop/src/main/authManager.ts
+++ b/apps/desktop/src/main/authManager.ts
@@ -5036,10 +5036,10 @@ async function completeLogin(
passiveLocalSignOut = false;
foreignDeviceLocalSignOut = false;
currentUser = nextUser;
- commitCloudAppSession(currentUser.id, authRealmChanged);
if (!isPassiveSharedUserDataInstance()) {
canaryFlagStore.clear();
}
+ commitCloudAppSession(currentUser.id, authRealmChanged);
pendingAuthRealm = null;
}),
});
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index f9ac3d5176..681a5798d9 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -123,6 +123,8 @@
均推进 owner generation,主实例与共享 userData 的被动实例一致;同区域普通刷新不推进。
区域、令牌与代次同步提交时立即发送新认证快照,不等后续迁移或投影收尾的 await;
即使同 owner 的稳定投影不进入 teardown 边界,新区域请求返回前也已发布新代次。
+ 显式登录的主实例先清理上次登录的灰度标记,再提交并推送新认证快照;被动实例
+ 继续只读共享配置,不替其他实例清理持久标记。
因此现有请求 scope 与推送 stamp 即可拒绝旧区域反馈,无需修改 wire 字段或持久账号键。
已打开的自动结果也保存 owner snapshot,在新代次的首次渲染中隐藏旧反馈;同 ID
跨区域切换不依赖按 dataOwnerId 重挂路由,普通同代次刷新仍保留当前结果。