Skip to content

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

fix: video wallpaper layer sits above the app's opaque body background

zwydef4baa5b4f2
diff --git a/scripts/daemon.js b/scripts/daemon.js
index 5d5039d..64c3e40 100644
--- a/scripts/daemon.js
+++ b/scripts/daemon.js
@@ -543,6 +543,7 @@ const primaryAccountStore = createPrimaryAccountStore(DATA_DIR, (uid) => fs.exis
// 1.2.66:刷新凭据按原信封加密保存,同账号刷新去重,过期账号保留手动切换。
// 1.2.67:Windows 重启 GUI 客户端时不再请求隐藏主窗口,与冷启动保持一致。
// 1.2.69:毛玻璃主题支持视频壁纸(MP4 / WebM),与图片壁纸共用蒙版与背景毛玻璃。
+// 1.2.70:视频壁纸层夹在 body 底色与 #root 之间,毛玻璃主题下正常显示画面。
// #507: explicit cleanup of old Windows client temp files, only before a verified cold launch.
// 1.2.81:在共享目标分支加入视频壁纸及失败重试、主题路径边界修复。
const DAEMON_VERSION = '1.2.81';
@@ -9075,8 +9076,13 @@ async function handleThemeVideoUpload(req, res, url) {
// 视频与图片随机轮换互斥:抢的是同一层背景
await wallpaperRotation.configure({ mode: 'manual' }).catch(() => {});
log(`[theme] 上传视频壁纸 -> ${meta.id}/${fileName} (${size}B)`);
- const applied = await applyThemeByCdp(meta.id).then(() => true).catch(() => false);
- return json(res, 200, { ok: true, video: fileName, size, mime: format.mime, applied, id: meta.id });
+ const info = await applyThemeByCdp(meta.id).catch(() => null);
+ // mounted 反映渲染进程是否真的把视频挂上了:解码失败或客户端未连接时为 false,
+ // 让面板能提示"存下了但没显示",而不是一律报成功。
+ return json(res, 200, {
+ ok: true, video: fileName, size, mime: format.mime,
+ applied: !!info, mounted: !!(info && info.video), id: meta.id,
+ });
}
async function handleThemeVideoDelete(res, url) {
@@ -9619,10 +9625,11 @@ async function applyThemeByCdp(id, options = {}) {
log('[theme] 应用主题失败: ' + detail);
throw new Error('应用主题失败: ' + detail);
}
- // 视频壁纸层在主题 CSS 之后挂载/摘除:此刻 #root 已经只留蒙版,视频到位即可见。
+ // 视频壁纸层在主题 CSS 之后挂载/摘除:此刻 #root 已经留出背景层,视频到位即可见。
// 同一个视频重复应用(拖蒙版、改毛玻璃)命中 key,不会重新拉流。
+ let videoMounted = null;
if (takeoverEnabled && themeVideo) {
- await applyVideoWallpaperByCdp(themeVideo, id);
+ videoMounted = await applyVideoWallpaperByCdp(themeVideo, id);
} else if (lastVideoKey && !options.videoPreflight) {
await disposeVideoWallpaperByCdp();
}
@@ -9636,6 +9643,7 @@ async function applyThemeByCdp(id, options = {}) {
startSystemThemePolling();
}
return { ok: true, applied: v.applied, dark: v.dark, bg: v.bg, text: v.text,
+ ...(videoMounted === null ? {} : { video: videoMounted }),
...(systemMode ? { system: true, resolved: id } : {}) };
}
diff --git a/scripts/inject.js b/scripts/inject.js
index 38780a6..1adb297 100644
--- a/scripts/inject.js
+++ b/scripts/inject.js
@@ -1845,7 +1845,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
'请选择壁纸文件夹': 'Choose a wallpaper folder', '壁纸模式': 'Wallpaper mode', '手动应用': 'Manual', '文件夹随机': 'Shuffle folder', '壁纸文件夹': 'Wallpaper folder', '选择或填写文件夹路径': 'Choose or enter a folder path', '选择文件夹': 'Choose folder', '切换间隔': 'Change every', '1 分钟': '1 minute', '3 分钟': '3 minutes', '5 分钟': '5 minutes', '10 分钟': '10 minutes', '30 分钟': '30 minutes', '1 小时': '1 hour', '自定义': 'Custom', '分钟': 'minutes', '自定义切换间隔(分钟)': 'Custom interval (minutes)', '立即换一张': 'Next wallpaper', '已暂停,恢复毛玻璃主题后继续': 'Paused until the frosted theme resumes', '当前:': 'Current: ', '等待应用壁纸': 'Waiting to apply wallpaper', '壁纸设置保存失败': 'Could not save wallpaper settings', '仅读取此文件夹内的 PNG / JPG / WebP,不复制或修改原文件;自动跳过超过 20MB 或 1600 万像素的图片。': 'Reads PNG / JPG / WebP from this folder without copying or modifying originals. Images over 20MB or 16 megapixels are skipped.',
'选择要查看的账号': 'Choose an account to view', '选择账号并输入密码后导出备份': 'Choose accounts and enter a password to export backups', '从加密导出文件导入账号备份': 'Import account backups from an encrypted export', '使用密码导出选中会话': 'Export selected sessions with a password', '使用密码导出选中快捷短语': 'Export selected quick phrases with a password', '从加密文件导入会话': 'Import sessions from an encrypted file', '从加密文件导入快捷短语': 'Import quick phrases from an encrypted file', '仅支持 PNG / JPG / WebP': 'PNG / JPG / WebP only', '点击或拖拽上传壁纸': 'Click or drag to upload a wallpaper', '点击选择图片,或拖拽到此处': 'Click to choose an image, or drag it here', '支持 PNG / JPG / WebP,自动压缩;可添加多张': 'PNG / JPG / WebP supported; images are compressed automatically',
// 视频壁纸(毛玻璃主题的背景层)
- '视频壁纸': 'Video wallpaper', 'MP4 / WebM · 自动静音循环': 'MP4 / WebM · muted loop', '点击或拖拽上传视频': 'Click or drag to upload a video', '点击选择视频,或拖拽到此处': 'Click to choose a video, or drag it here', '最大 128MB;选择图片壁纸会自动移除视频': 'Up to 128MB. Choosing an image wallpaper removes the video.', '移除视频壁纸': 'Remove video wallpaper', '当前视频 · ': 'Current video · ', '仅支持 MP4 / WebM 视频': 'MP4 / WebM videos only', '视频不能超过': 'Video must be under ', '正在上传视频壁纸…': 'Uploading video wallpaper…', '视频壁纸已应用': 'Video wallpaper applied', '上传视频壁纸失败': 'Video wallpaper upload failed', '已移除视频壁纸': 'Video wallpaper removed', '移除视频壁纸失败': 'Could not remove video wallpaper',
+ '视频壁纸': 'Video wallpaper', 'MP4 / WebM · 自动静音循环': 'MP4 / WebM · muted loop', '点击或拖拽上传视频': 'Click or drag to upload a video', '点击选择视频,或拖拽到此处': 'Click to choose a video, or drag it here', '最大 128MB;选择图片壁纸会自动移除视频': 'Up to 128MB. Choosing an image wallpaper removes the video.', '移除视频壁纸': 'Remove video wallpaper', '当前视频 · ': 'Current video · ', '仅支持 MP4 / WebM 视频': 'MP4 / WebM videos only', '视频不能超过': 'Video must be under ', '正在上传视频壁纸…': 'Uploading video wallpaper…', '视频壁纸已应用': 'Video wallpaper applied', '视频已保存,但没能显示在界面上;请确认编码为 H.264 / VP9,或重新应用主题': 'Video saved but not displayed. Check that it is H.264 / VP9, or reapply the theme.', '上传视频壁纸失败': 'Video wallpaper upload failed', '已移除视频壁纸': 'Video wallpaper removed', '移除视频壁纸失败': 'Could not remove video wallpaper',
'未命名账号': 'Unnamed account', '未命名模型': 'Unnamed model', '未命名': 'Unnamed', '未知错误': 'Unknown error', '未知': 'Unknown', '有效期未知': 'Expiry unknown', '未找到输入框': 'Composer not found', '输入框内容为空': 'Composer is empty', '当前输入框暂不支持引用插入': 'The current composer does not support quote insertion', '引用插入失败,请重试': 'Could not insert quote. Please try again', '短语不能为空': 'Quick phrase cannot be empty', '请输入快捷短语': 'Enter a quick phrase', '删除快捷短语': 'Delete quick phrase', '编辑快捷短语': 'Edit quick phrase', '新增快捷短语': 'Add quick phrase', '确定删除': 'Confirm deletion', '确认永久删除': 'Confirm permanent deletion',
'本机回环 CDP 注入 · 不改官方安装包': 'Local CDP injection · official app untouched', '一个基于 ': 'A ', ' 的 WorkBuddy 桌面端增强工具。零侵入、零重签名——只把界面组件注入到正在运行的 WorkBuddy 渲染进程里。': ' WorkBuddy desktop enhancement tool using Chrome DevTools Protocol (CDP). No intrusion or re-signing; UI components are injected into the running renderer.', '问题反馈': 'Report an issue',
// —— 覆盖度补齐(分区域,模板条目支持 {name} 占位,匹配时最长优先)——
@@ -13103,7 +13103,11 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
body: file,
}).then(function (r) {
if (!r || !r.ok) throw new Error((r && r.error) || '上传视频壁纸失败');
- toast('视频壁纸已应用', false, root);
+ if (r.mounted === false) {
+ toast('视频已保存,但没能显示在界面上;请确认编码为 H.264 / VP9,或重新应用主题', true, root);
+ } else {
+ toast('视频壁纸已应用', false, root);
+ }
loadWallpapers(true);
if (typeof loadWallpaperRotation === 'function') loadWallpaperRotation();
}).catch(function (e) {
diff --git a/scripts/wallpaper-video.js b/scripts/wallpaper-video.js
index 8c0f6e2..17310ad 100644
--- a/scripts/wallpaper-video.js
+++ b/scripts/wallpaper-video.js
@@ -47,12 +47,17 @@ function resolveVideoFile(themesDir, themeId, videoName) {
const safeId = String(themeId || '').replace(/[^A-Za-z0-9_-]/g, '_');
const raw = String(videoName || '').replace(/^\.\.?[/\\]/, '');
if (!safeId || !raw) return null;
- const candidates = [
- path.join(themesDir, safeId, raw),
- path.join(themesDir, raw),
- ];
+ const root = path.resolve(themesDir);
+ const candidates = [path.join(root, safeId, raw), path.join(root, raw)];
+ const isInside = (base, target) => target === base || target.startsWith(base + path.sep);
for (const c of candidates) {
- try { if (fs.existsSync(c) && fs.statSync(c).isFile()) return c; } catch (_) {}
+ try {
+ const resolved = path.resolve(c);
+ if (!isInside(root, resolved) || !fs.statSync(resolved).isFile()) continue;
+ // Reject symlinks that point outside the themes directory as well as lexical traversal.
+ if (!isInside(fs.realpathSync(root), fs.realpathSync(resolved))) continue;
+ return resolved;
+ } catch (_) {}
}
return null;
}
@@ -67,11 +72,16 @@ function videoRootBackground(mask) {
].join(',') + ' !important;}';
}
+// 视频层的定位:不能压在 z-index:-1 —— WorkBuddy 的 body 有不透明底色
+// (--vscode-editor-background),按 CSS 绘制顺序它画在负层级之上,视频会被整块盖住,
+// 表现出来就是「上传成功但界面一片黑」。所以视频停在第 0 层,由 #root 提到第 1 层,
+// 蒙版和渐变仍随 #root 的背景压在视频上方。
const VIDEO_LAYER_CSS = [
- '#wbs-video-wallpaper{position:fixed;inset:0;z-index:-1;overflow:hidden;pointer-events:none;background:transparent;opacity:0;transition:opacity .45s ease}',
+ '#wbs-video-wallpaper{position:fixed;inset:0;z-index:0;overflow:hidden;pointer-events:none;background:transparent;opacity:0;transition:opacity .45s ease}',
'#wbs-video-wallpaper.wbs-video-ready{opacity:1}',
'#wbs-video-wallpaper video{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none;background:transparent}',
'#wbs-video-wallpaper video::-webkit-media-controls,#wbs-video-wallpaper video::-webkit-media-controls-enclosure,#wbs-video-wallpaper video::-webkit-media-controls-panel{display:none!important}',
+ '#root{position:relative;z-index:1}',
].join('');
const VIDEO_HOST_ID = 'wbs-video-wallpaper';
@@ -105,7 +115,7 @@ async function updateVideoInRenderer(options) {
}
var runtime = window.__wbsVideoRuntime;
- if (runtime && runtime.key === key && runtime.host && runtime.host.isConnected) {
+ if (runtime && runtime.key === key && runtime.ready && runtime.host && runtime.host.isConnected) {
ensureStyle();
runtime.play();
return true;
@@ -152,6 +162,7 @@ async function updateVideoInRenderer(options) {
key: key,
host: host,
video: video,
+ ready: false,
play: function () {
if (document.hidden) return;
try { var p = video.play(); if (p && p.catch) p.catch(function () {}); } catch (_) {}
@@ -185,6 +196,7 @@ async function updateVideoInRenderer(options) {
var timer = setTimeout(function () { reject(new Error('视频加载超时')); }, 20000);
video.addEventListener('loadeddata', function () {
clearTimeout(timer);
+ rt.ready = true;
if (!disposed && window.__wbsVideoRuntime === rt) host.classList.add('wbs-video-ready');
resolve(true);
}, { once: true });
@@ -221,8 +233,12 @@ async function updateVideoInRenderer(options) {
};
document.addEventListener('pointerdown', onGesture, true);
try { video.load(); } catch (_) {}
- return await loaded.then(function () { return true; }).catch(function () { return false; });
+ return await loaded.then(function () { return true; }).catch(function () {
+ if (window.__wbsVideoRuntime === rt) rt.dispose();
+ return false;
+ });
} catch (_) {
+ if (window.__wbsVideoRuntime === rt) rt.dispose();
return false;
}
}
diff --git a/test/theme-video.test.js b/test/theme-video.test.js
index 4999b33..e617464 100644
--- a/test/theme-video.test.js
+++ b/test/theme-video.test.js
@@ -45,6 +45,12 @@ test('resolveVideoFile stays inside themes/ and falls back to the file name layo
assert.equal(resolveVideoFile(dir, '../nebula', 'background.mp4'), null);
// video 字段写成分散路径时只取文件名,仍落在该主题目录内
assert.equal(resolveVideoFile(dir, 'nebula', '../background.mp4'), path.join(dir, 'nebula', 'background.mp4'));
+ fs.writeFileSync(path.join(dir, 'outside.mp4'), mp4());
+ assert.equal(resolveVideoFile(dir, 'nebula', '../../../outside.mp4'), null, 'multi-level traversal cannot leave themes/');
+ try {
+ fs.symlinkSync(path.join(dir, 'outside.mp4'), path.join(dir, 'nebula', 'linked.mp4'));
+ assert.equal(resolveVideoFile(dir, 'nebula', 'linked.mp4'), null, 'symlinks cannot expose files outside themes/');
+ } catch (_) {}
assert.equal(resolveVideoFile(dir, 'nebula', 'missing.mp4'), null);
assert.equal(resolveVideoFile(dir, '', 'background.mp4'), null);
});
@@ -57,7 +63,10 @@ test('video background keeps the shared mask but drops the image layer', () => {
assert.match(videoRootBackground(0), /rgba\(0,0,0,0\)/);
assert.match(videoRootBackground(-1), /rgba\(0,0,0,0\)/);
assert.match(videoRootBackground(9), /rgba\(0,0,0,1\)/);
- assert.match(VIDEO_LAYER_CSS, /z-index:-1/);
+ // 视频层停在第 0 层、#root 提到第 1 层:body 的不透明底色画在负层级之上,
+ // 视频一旦沉到 z-index:-1 就会被整块盖住
+ assert.match(VIDEO_LAYER_CSS, /#wbs-video-wallpaper\{position:fixed;inset:0;z-index:0;/);
+ assert.match(VIDEO_LAYER_CSS, /#root\{position:relative;z-index:1\}/);
assert.match(VIDEO_LAYER_CSS, /pointer-events:none/);
});
@@ -205,6 +214,24 @@ test('renderer replaces the layer for a new key and dispose removes it completel
assert.equal(dom.env.window.__wbsVideoRuntime, undefined);
});
+test('renderer retries the same video after a failed request', async () => {
+ const dom = fakeWallpaperDom();
+ let attempts = 0;
+ dom.env.fetch = async () => {
+ attempts++;
+ if (attempts === 1) throw new Error('temporary network failure');
+ return { ok: true, blob: async () => ({ size: 1024 }) };
+ };
+ const options = { url: '/a', token: 'tok', key: 'same-video' };
+ assert.equal(await dom.env.update(options), false);
+ assert.equal(dom.env.window.__wbsVideoRuntime, undefined, 'failed runtime is disposed');
+ const retried = dom.env.update(options);
+ await settle();
+ assert.equal(await retried, true);
+ assert.equal(attempts, 2, 'retry fetches the video again');
+ dom.env.dispose();
+});
+
test('video layer pauses while the window is hidden', async () => {
const dom = fakeWallpaperDom();
const loading = dom.env.update({ url: '/a', token: 'tok', key: 'k1' });