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): 保留当前账号的恢复阻塞提示

liugaowei519b4a987f30
diff --git a/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts b/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
index d2673bf9bf..30b3ca5c95 100644
--- a/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
+++ b/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
@@ -537,7 +537,11 @@ describe('legacy Ghost plugin recovery', () => {
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
root,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
await expect(
recoverLegacyGhostPlugins(
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
@@ -571,7 +575,11 @@ describe('legacy Ghost plugin recovery', () => {
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
root,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
await expect(
recoverLegacyGhostPlugins(
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
@@ -622,7 +630,11 @@ describe('legacy Ghost plugin recovery', () => {
false,
{ reservedCommands: new Set(['draw']) },
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
});
it('ignores tombstones from a foreign shared root during recovery planning', async () => {
@@ -733,7 +745,11 @@ describe('legacy Ghost plugin recovery', () => {
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
root,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
await expect(
recoverLegacyGhostPlugins(
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
@@ -1026,7 +1042,11 @@ describe('legacy Ghost plugin recovery', () => {
);
expect(result).toMatchObject({ status: 'partial', moved: 0, conflicts: 1 });
- expect(status).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ expect(status).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
await expect(fs.readFile(path.join(target, 'ghost.json'), 'utf-8')).resolves.toBe('scoped');
await expect(
fs.readFile(path.join(root, 'cindy-brain', 'valid-plugin', 'ghost.json'), 'utf-8'),
@@ -1151,7 +1171,11 @@ describe('legacy Ghost plugin recovery', () => {
{ mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
root,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'partial',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
await expect(
recoverLegacyGhostPlugins(
@@ -1207,7 +1231,11 @@ describe('legacy Ghost plugin recovery', () => {
{},
(pid) => pid === 4242,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'deferred',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
const result = await recoverLegacyGhostPlugins(
{ mode: 'cloud', dataOwnerId: 'cloud-a', user: { id: 'cloud-a' } },
@@ -1328,7 +1356,11 @@ describe('legacy Ghost plugin recovery', () => {
{ mode: 'cloud', dataOwnerId: 'cloud-a', user: { id: 'cloud-a' } },
root,
),
- ).toEqual({ state: 'none', legacyPluginCount: 0, canRetry: false });
+ ).toEqual({
+ state: 'deferred',
+ legacyPluginCount: 1,
+ canRetry: false,
+ });
} finally {
delete process.env.XDT_PASSIVE_SHARED_USER_DATA;
}
diff --git a/apps/desktop/src/main/ownerNamespaceMigration.ts b/apps/desktop/src/main/ownerNamespaceMigration.ts
index 4980414f15..eca88d7da9 100644
--- a/apps/desktop/src/main/ownerNamespaceMigration.ts
+++ b/apps/desktop/src/main/ownerNamespaceMigration.ts
@@ -519,9 +519,15 @@ export function getLegacyGhostRecoveryStatus(
(markerRead.invalid ||
(markerRead.marker !== null && markerRead.marker.ownerKey !== ownerKey));
if (sharedRecoveryBlocked && scopedLegacyGhosts.length === 0) {
- // 无法证明属于当前账号的共享目录不是当前账号的恢复任务:保留原文件,
- // 但不向 Renderer 暴露数量,也不展示一个用户无法处理的永久状态。
- return NO_LEGACY_GHOST_RECOVERY;
+ if (markerRead.marker && markerRead.marker.ownerKey !== ownerKey) {
+ // 已明确属于其他账号的共享目录不是当前账号的恢复任务。
+ return NO_LEGACY_GHOST_RECOVERY;
+ }
+ return {
+ state: 'partial',
+ legacyPluginCount: sharedLegacyGhosts.length,
+ canRetry: false,
+ };
}
const eligibleLegacyGhosts = sharedRecoveryBlocked
? scopedLegacyGhosts
@@ -529,15 +535,15 @@ export function getLegacyGhostRecoveryStatus(
const legacyPluginCount = eligibleLegacyGhosts.length;
if (legacyPluginCount === 0) return NO_LEGACY_GHOST_RECOVERY;
if (process.env.XDT_PASSIVE_SHARED_USER_DATA === '1') {
- return NO_LEGACY_GHOST_RECOVERY;
+ return { state: 'deferred', legacyPluginCount, canRetry: false };
}
if (hasConcurrentLiveInstanceSync(root, isPidAlive)) {
- return NO_LEGACY_GHOST_RECOVERY;
+ return { state: 'deferred', legacyPluginCount, canRetry: false };
}
const targetRoot = path.join(root, 'owners', ownerKey, 'cindy-brain');
if (!hasSafeRecoveryTargetChainSync(root, targetRoot)) {
- return NO_LEGACY_GHOST_RECOVERY;
+ return { state: 'partial', legacyPluginCount, canRetry: false };
}
const occupiedCommands = new Set(
listLegacyGhostDirsInRoots([targetRoot])
@@ -559,7 +565,7 @@ export function getLegacyGhostRecoveryStatus(
return command === null || !occupiedCommands.has(command);
});
if (!canRetry) {
- return NO_LEGACY_GHOST_RECOVERY;
+ return { state: 'partial', legacyPluginCount, canRetry: false };
}
const marker = markerRead.marker;