Skip to content

WorkBuddy、CodeBuddy 桌面端增强助手:签到猫猫旅行成长计划查询、多账号独立备份、点切即用;免打扰模式让 AI 无人值守跑长任务;跨账号会话迁移、异常中断自动续接;暂存/快捷提示词;毛玻璃主题与更多实用功能。

fix: detect shared WorkBuddy target by profile

jiqinga1ac90bdf47f7
diff --git a/scripts/cdp-targets.js b/scripts/cdp-targets.js
index 3f1c5ad..a0e5f13 100644
--- a/scripts/cdp-targets.js
+++ b/scripts/cdp-targets.js
@@ -30,10 +30,9 @@ const APP_CBINTL = /\/CodeBuddy\.app(?:\/|$)/i;
const APP_AI_LINUX = /\/workbuddy-ai\//i;
const APP_CN_LINUX = /\/opt\/WorkBuddy\//i;
// Windows 没有 .app 包,renderer URL 直接落在安装目录的 resources/app.asar 下。
-// 目录可能位于任意盘符,但官方 CN/AI 目录名仍可作为 profile 强信号。
+// AI 安装目录名可区分;通用 WorkBuddy 目录可能被 CN/AI 共用,不作强信号。
const APP_AI_WIN = /\/WorkBuddy(?:%20| )?AI\/resources\/app\.asar(?:\/|$)/i;
const APP_AI_WIN_COMPACT = /\/WorkBuddyAI\/resources\/app\.asar(?:\/|$)/i;
-const APP_CN_WIN = /\/WorkBuddy\/resources\/app\.asar(?:\/|$)/i;
const DOMAIN_WB_AI = /https?:\/\/(?:[^/]+\.)?workbuddy\.ai(?:\/|$)/i;
const DOMAIN_WB_CN = /https?:\/\/(?:[^/]+\.)?workbuddy\.cn(?:\/|$)/i;
const DOMAIN_CB_CN = /https?:\/\/(?:[^/]+\.)?codebuddy\.cn(?:\/|$)/i;
@@ -52,7 +51,7 @@ function classifyTarget(url, title, description) {
if (APP_AI_WIN.test(u) || APP_AI_WIN_COMPACT.test(u)) return 'workbuddy-ai';
if (APP_CN.test(u)) return 'workbuddy-cn';
if (APP_CN_LINUX.test(u)) return 'workbuddy-cn';
- if (APP_CN_WIN.test(u)) return 'workbuddy-cn';
+ // The generic Windows WorkBuddy install path may be shared by CN and AI.
if (APP_CBCN.test(u)) return 'codebuddy-cn';
if (APP_CBINTL.test(u)) return 'codebuddy-intl';
if (DOMAIN_WB_AI.test(u)) return 'workbuddy-ai';
@@ -113,14 +112,13 @@ function isTargetForProfile(target, profile) {
}
}
- // Windows 官方安装目录的 app.asar 路径是比标题更可靠的归属证据,必须先于
- // 标题兜底判断;自定义目标已先按所选安装目录判断。
+ // Windows AI 专属目录是可靠归属证据,必须先于标题兜底判断;通用 WorkBuddy
+ // 目录可能被 CN / AI 共用,由下方已绑定的 profile 判断。自定义目标先按所选目录判断。
const cls = classifyTarget(url, title, desc);
const normalizedUrl = normalizeTargetUrl(url);
const windowsOfficialPath = /^file:\/\/\/[A-Za-z]:\//i.test(normalizedUrl) && (
APP_AI_WIN.test(normalizedUrl)
|| APP_AI_WIN_COMPACT.test(normalizeTargetUrl(url))
- || APP_CN_WIN.test(normalizedUrl)
);
if (windowsOfficialPath) return cls === profile.id;
diff --git a/scripts/daemon.js b/scripts/daemon.js
index d40d2d2..6479999 100644
--- a/scripts/daemon.js
+++ b/scripts/daemon.js
@@ -534,8 +534,8 @@ const primaryAccountStore = createPrimaryAccountStore(DATA_DIR, (uid) => fs.exis
// 1.2.65:兼容空会话同步、自定义模型和重定向备份目录,工作目录恢复退避重试。
// 1.2.66:刷新凭据按原信封加密保存,同账号刷新去重,过期账号保留手动切换。
// 1.2.67:Windows 重启 GUI 客户端时不再请求隐藏主窗口,与冷启动保持一致。
-const DAEMON_VERSION = '1.2.78';
-const DAEMON_BUILD_ID = 'release-1.2.78-stop-historical-deletion-propagation';
+const DAEMON_VERSION = '1.2.79';
+const DAEMON_BUILD_ID = 'release-1.2.79-windows-workbuddy-shared-target';
const usageReporter = createUsageReporter({ profile: PROFILE.id, version: DAEMON_VERSION });
configureAutomationRuntime({version: DAEMON_VERSION, profileId: PROFILE.id, platform: process.platform});
const automationDiscovery = createAutomationDiscovery({
diff --git a/test/cdp-targets.test.js b/test/cdp-targets.test.js
index a8227ca..f847eee 100644
--- a/test/cdp-targets.test.js
+++ b/test/cdp-targets.test.js
@@ -34,11 +34,37 @@ test('classifyTarget 依据 app 包路径识别四客户端(含 %20 编码)'
});
test('classifyTarget 识别 Windows 安装目录中的 app.asar 页面', () => {
- assert.equal(classifyTarget(WIN_CN_URL, 'WorkBuddy'), 'workbuddy-cn');
+ // CN 与 AI 可能共用这个目录,通用安装路径不足以判定 profile。
+ assert.equal(classifyTarget(WIN_CN_URL, 'WorkBuddy'), null);
assert.equal(classifyTarget(WIN_AI_URL, 'WorkBuddy AI'), 'workbuddy-ai');
assert.equal(classifyTarget('file:///E:/WorkBuddy%20AI/resources/app.asar/renderer/index.html', 'WorkBuddy'), 'workbuddy-ai');
});
+test('Windows shared WorkBuddy path follows the bound profile and preserves AI isolation', () => {
+ const previous = process.env.WBSWITCH_PROFILE;
+ const shared = { type: 'page', url: WIN_CN_URL, title: 'WorkBuddy' };
+ const explicitAi = { type: 'page', url: WIN_AI_URL, title: 'WorkBuddy' };
+ const ai = PROFILES['workbuddy-ai'];
+ const cn = PROFILES['workbuddy-cn'];
+ try {
+ delete process.env.WBSWITCH_PROFILE;
+ assert.equal(isTargetForProfile(shared, ai), false);
+
+ process.env.WBSWITCH_PROFILE = 'workbuddy-ai';
+ assert.equal(isTargetForProfile(shared, ai), true);
+ assert.equal(selectPageTarget([shared], ai), shared);
+ assert.equal(isTargetForProfile(explicitAi, ai), true);
+ assert.equal(isTargetForProfile(explicitAi, cn), false);
+
+ process.env.WBSWITCH_PROFILE = 'workbuddy-cn';
+ assert.equal(isTargetForProfile(shared, cn), true);
+ assert.equal(selectPageTarget([shared], cn), shared);
+ } finally {
+ if (previous) process.env.WBSWITCH_PROFILE = previous;
+ else delete process.env.WBSWITCH_PROFILE;
+ }
+});
+
test('Windows custom target 按所选安装目录认领页面,允许 AI profile 显式绑定国内版', () => {
const profile = {
...PROFILES['workbuddy-ai'], customTarget: true,
@@ -134,6 +160,7 @@ test('isTargetForProfile 企业配置只接受自身域名或路径提示', () =
const enterprise = {
...PROFILES['workbuddy-cn'],
customTarget: true,
+ appPath: '',
apiHost: 'https://api.ent.example.com',
targetHints: ['workbuddy-ent'],
};
@@ -163,6 +190,7 @@ test('isTargetForProfile Linux 双实例:CN 与 AI 互不认领(两端可执
const aiProfile = {
...PROFILES['workbuddy-ai'],
customTarget: true,
+ appPath: '',
apiHost: 'https://www.workbuddy.ai',
targetHints: ['/home/u/.local/share/workbuddy-ai/app', 'workbuddy-ai'],
};