WorkBuddy、CodeBuddy 桌面端增强助手:签到猫猫旅行成长计划查询、多账号独立备份、点切即用;免打扰模式让 AI 无人值守跑长任务;跨账号会话迁移、异常中断自动续接;暂存/快捷提示词;毛玻璃主题与更多实用功能。
fix: prevent duplicate sessions after account switching
[email protected]24bbe6233473
diff --git a/scripts/daemon.js b/scripts/daemon.jsindex 848088e..2aff261 100644--- a/scripts/daemon.js+++ b/scripts/daemon.js@@ -432,9 +432,9 @@ const primaryAccountStore = createPrimaryAccountStore(DATA_DIR, (uid) => fs.exis// 1.2.188:关闭主题接管时跟随 WorkBuddy AI 的原生 agent-ui-theme,避免旧快照覆盖官方浅色/深色选择。// 1.2.189:毛玻璃底色等待移至 daemon,避免后台页面定时器节流拖延开关和壁纸加载。// 1.2.191:CodeDaddy 共用完整面板,通过本机 CDP 适配通信、原生登录态和会话缓存。-// 1.2.10:合并会话、用量、启动器及 CodeBuddy IDE 注入重试与积分刷新修复。-const DAEMON_VERSION = '1.2.10';-const DAEMON_BUILD_ID = 'release-1.2.10-20260930-markdown-preview';+// 1.2.11:账号切换刷新只依赖页面重载与同步完成后的列表刷新,避免官方列表重复合并。+const DAEMON_VERSION = '1.2.11';+const DAEMON_BUILD_ID = 'release-1.2.11-20261001-account-reload-list';const usageReporter = createUsageReporter({ profile: PROFILE.id, version: DAEMON_VERSION });configureAutomationRuntime({version: DAEMON_VERSION, profileId: PROFILE.id, platform: process.platform});const automationDiscovery = createAutomationDiscovery({@@ -2511,21 +2511,9 @@ async function reloadWorkBuddyPage(options = {}) {const pending = armPendingReloadInjection(frameId);try {await withTimeout(cdpSend('Page.reload', { ignoreCache: false }), 10000, '刷新 WorkBuddy 页面');- // WorkBuddy's SQLite replacement and renderer reload do not publish the- // local collection change. Refresh after WorkDaddy has mounted so the- // official controller sees migrated/history rows before user interaction.- const refreshAfterMount = pending.ready.then((mounted) => {- if (!mounted) return false;- const uid = String((currentAccount() || {}).uid || '').trim();- return refreshWorkBuddySessionList(uid, 'account-reload');- }).catch(() => false);- if (options.waitForInjection === false) {- refreshAfterMount.catch(() => {});- return true;- }+ if (options.waitForInjection === false) return true;const mounted = await pending.ready;if (!mounted) log('[cdp] 页面重载后组件未在 5 秒内确认挂载,继续后台流程');- if (mounted) await refreshAfterMount;return mounted;} catch (error) {settlePendingReloadInjection(pending, false);diff --git a/test/session-copy-list-refresh.test.js b/test/session-copy-list-refresh.test.jsindex 88d9bbb..83c8776 100644--- a/test/session-copy-list-refresh.test.js+++ b/test/session-copy-list-refresh.test.js@@ -79,6 +79,30 @@ test('explicit migration wires the same official list refresh seam', () => {assert.match(route, /await refreshWorkBuddySessionList\(String\(\(currentAccount\(\) \|\| \{\}\)\.uid \|\| ''\)\.trim\(\), 'sessions-migrate'\)/);});+test('account reload does not refresh the official list a second time', async () => {+ const start = source.indexOf('async function reloadWorkBuddyPage(');+ const end = source.indexOf('const WORKBUDDY_TARGET', start);+ assert.ok(start >= 0 && end > start);+ let refreshes = 0;+ const calls = [];+ const ctx = {+ cdp: { connected: true },+ cdpSend: async (method) => { calls.push(method); },+ armPendingReloadInjection: () => ({ ready: Promise.resolve(true) }),+ settlePendingReloadInjection: () => {},+ currentAccount: () => ({ uid: 'target' }),+ refreshWorkBuddySessionList: async () => { refreshes++; return true; },+ log: () => {},+ setTimeout,+ clearTimeout,+ };+ vm.runInNewContext(source.slice(start, end), ctx);+ assert.equal(await ctx.reloadWorkBuddyPage({ waitForInjection: false }), true);+ await new Promise((resolve) => setImmediate(resolve));+ assert.deepEqual(calls, ['Page.getFrameTree', 'Page.reload']);+ assert.equal(refreshes, 0);+});+test('an unavailable renderer never turns a committed session copy into failure', async () => {const h = harness({ reject: true });const job = await h.run();diff --git a/test/session-sync.test.js b/test/session-sync.test.jsindex 95921a4..3b07e4e 100644--- a/test/session-sync.test.js+++ b/test/session-sync.test.js@@ -152,6 +152,25 @@ test('an activation-only session-meta append does not become an imported continuf.write('b', [...base, { ...stable, id: 'event-b', sessionId: 'b', timestamp: 200 }]);assert.equal(compareSnapshots(f.read('b'), f.read('a')).kind, 'equal');});++test('different session-meta counts do not shift the real transcript sequence', t => {+ const f = fixture(t);+ const stable = { type: 'session-meta', meta: { 'codebuddy.ai/hostKind': 'unopted' } };+ const continuation = [message('user', 'continued'), message('assistant', 'reply')];+ f.write('a', [+ ...base,+ { ...stable, id: 'a-1', sessionId: 'a', timestamp: 100 },+ { ...stable, id: 'a-2', sessionId: 'a', timestamp: 101 },+ ...continuation,+ ]);+ f.write('b', [+ ...base,+ { ...stable, id: 'b-1', sessionId: 'b', timestamp: 200 },+ ...continuation,+ ]);+ assert.equal(compareSnapshots(f.read('a'), f.read('b')).kind, 'equal');+});+test('missing payload is repairable and symlinked files are skipped without following them', async t => {const f = fixture(t); f.write('a', base);assert.equal(compareSnapshots(f.read('a'), f.read('b')).kind, 'left-extends');