WorkBuddy、CodeBuddy 桌面端增强助手:签到猫猫旅行成长计划查询、多账号独立备份、点切即用;免打扰模式让 AI 无人值守跑长任务;跨账号会话迁移、异常中断自动续接;暂存/快捷提示词;毛玻璃主题与更多实用功能。
feat: refine account status badges and runtime safeguards
[email protected]d3565c27c4dc
diff --git a/scripts/inject.js b/scripts/inject.jsindex d5de4d0..0fc3fd6 100644--- a/scripts/inject.js+++ b/scripts/inject.js@@ -1295,7 +1295,14 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {api('/api/accounts').then(function (data) {if (!isCurrentAccountLoad(serial)) return;var accounts = (data && data.accounts) || [];- accounts.forEach(function (account) { account.ideCreditState = 'loading'; });+ accounts.forEach(function (account) {+ account.ideCreditState = isIdentityExpired(account) ? 'expired' : 'loading';+ if (account.ideCreditState === 'expired') {+ account.credits = null;+ account.creditSegments = [];+ account.creditUnlimited = false;+ }+ });renderAccounts(body, accounts, data && data.current && data.current.uid);// Only two queries at a time; closing/reopening the modal invalidates the// remaining queue and late responses from the previous account list.@@ -1303,6 +1310,14 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {function worker() {if (!isCurrentAccountLoad(serial) || next >= accounts.length) return Promise.resolve();var account = accounts[next++];+ if (isIdentityExpired(account) || account.creditExpired) {+ account.ideCreditState = 'expired';+ account.credits = null;+ account.creditSegments = [];+ account.creditUnlimited = false;+ if (account.ideCreditNode) account.ideCreditNode.textContent = formatIdeCredits(account);+ return worker();+ }return api('/api/credits', {method: 'POST', headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ uid: account.uid })@@ -1380,6 +1395,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {// 「24小时过期」= now+24h 内到期的段合计;「近7天过期」= now+7d 内到期的段合计(含 24h 桶)。// creditSegments 明细留给智能体窗口的完整面板(浮层保持轻量)。function formatIdeCredits(account) {+ if (isIdentityExpired(account) || account.creditExpired) return t('登录身份过期');var known = account.creditUnlimited || (typeof account.credits === 'number' && isFinite(account.credits));var summary = t('积分未查询');if (account.creditUnlimited) summary = t('积分:无限');@@ -1665,7 +1681,6 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'会话文件校验失败': 'Session file verification failed','收起': 'Collapse','输入框仍有内容,未确认发送;不会自动重发': 'The composer still contains text, so sending was not confirmed. It will not be retried automatically',- '今日已派猫': 'Buddy sent today', '今日未派猫': 'Buddy not sent today','派猫猫旅行': 'Send Buddy traveling','自动选择已拥有的 Buddy,派出旅行并领取旅行礼物。未领养 Buddy 的账号需先在官网同意协议并解锁,此任务会跳过。需要 WorkDaddy 1.2.66 或更新版本。': 'Select an owned Buddy, send it traveling, and claim travel gifts. Accounts without an adopted Buddy are skipped until the agreement is accepted and Buddy is unlocked on the official site. Requires WorkDaddy 1.2.66 or later.','账号 {account}:开始检查猫猫旅行': 'Account {account}: Checking Buddy travel', '当前 Buddy 查询失败': 'Could not load current Buddy', 'Buddy 列表查询失败': 'Could not load Buddy list',@@ -1842,6 +1857,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'会话同步完成': 'Session sync complete', '会话同步完成,已保留分叉': 'Session sync complete with conflicts', '会话同步完成,部分项目失败': 'Session sync complete with some failures', '会话同步等待中': 'Session sync waiting', '正在同步会话': 'Syncing session', '会话同步失败': 'Session sync failed', '同步等待中': 'Sync waiting', '同步失败': 'Sync failed', '同步': 'Sync', '已同步': 'Synced', ' · 新同步': ' · Newly synced ', ' · 有': ' · ', ' 项需要留意': ' item(s) need attention', ' · 请稍后重试': ' · Try again later', '会话同步进度': 'Session sync progress', ' 个会话已分叉,已保留双方内容': ' session(s) were changed on both sides; neither side was overwritten', '其他账号': 'Other account', '同步完成': 'Sync complete', '同步完成,已保留分叉': 'Sync complete with conflicts', '同步完成,部分失败': 'Sync complete with some failures', '正在把已标记的会话同步到「': 'Syncing marked sessions to “', ' 个未变化会话': ' unchanged session(s)', '同步任务未完成,请稍后重试': 'Sync did not finish. Try again later',' · 跳过': ' · Skipped', ' · 分叉': ' · Conflicts', '成功': 'Succeeded', '跳过': 'Skipped', '已跳过': 'Skipped', '部分失败': 'Partial failure', '分叉': 'Conflict', '处理中': 'Processing', '会话已分叉,已保留双方内容': 'Changed on both sides; neither side was overwritten', '部分文件失败': 'Some files failed', '当前任务未记录逐项明细。': 'No per-session details were recorded for this task.', '会话同步明细': 'Session sync details', '会话同步结果筛选': 'Filter session sync results', '当前分类没有会话。': 'No sessions in this category.', '正在把已标记的会话从「': 'Syncing marked sessions from “', '」同步到「': '” to “', '查看明细': 'View details', ' 个候选会话': ' candidate session(s)', ' 秒后自动关闭': ' seconds until automatic close','收录 GitHub 和 Gitee 公开仓库。参考 ': 'Public GitHub and Gitee repositories are indexed. See ', '。': '.', '克隆示例仓库:': 'Clone the example repository: ', '删除 ': 'Delete ', ' 目录中不需要的示例任务。': ' directory tasks you do not need.', '把你的自动化任务 JSON 放进 ': 'Put your automation task JSON in ', ' 目录。': ' directory.', '提交改动并推送到 GitHub 或 Gitee。': 'Commit and push changes to GitHub or Gitee.', '在仓库简介中加入关键词 ': 'Add the keyword ',+ '移除置顶备忘': 'Remove pinned reminder', '记住置顶会话': 'Remember pinned session','导出账号': 'Export accounts', '导入账号': 'Import accounts', '导出会话': 'Export sessions', '导入会话': 'Import sessions', '导出快捷短语': 'Export quick phrases', '导入快捷短语': 'Import quick phrases', '同步选中到其他账号': 'Sync selected to another account', '删除选中': 'Delete selected', '操作会话': 'Session actions', '连通测试': 'Test connection', '编辑模型': 'Edit model', '模型已保存': 'Model saved', '模型已启用': 'Model enabled', '模型已复制': 'Model copied', '模型配置已共用': 'Model configuration shared', '与 {name} 共用模型配置': 'Model configuration shared with {name}', '当前模型': 'Current model', '备选模型': 'Backup models', '模型加载失败:': 'Failed to load models: ', '保存模型失败:': 'Failed to save model: ', '删除当前模型失败:': 'Failed to delete current model: ', '启用模型失败:': 'Failed to enable model: ', '连通测试失败:': 'Connection test failed: ','请选择壁纸文件夹': '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',@@ -2505,8 +2521,8 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {}}(accounts || []).forEach(function (account) {- if (account.creditUnlimited) { unlimited++; return; }if (account.creditExpired || isIdentityExpired(account) || typeof account.credits !== 'number' || !isFinite(account.credits)) { unavailable++; return; }+ if (account.creditUnlimited) { unlimited++; return; }var balance = Math.max(0, account.credits);var segments = Array.isArray(account.creditSegments) ? account.creditSegments : [];var accountName = account.nickname || account.uid || '未命名账号';@@ -5398,7 +5414,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {if (next >= 0 && next < rail.children.length) { event.preventDefault(); rail.children[next].focus(); }}function onWindowChange(event) {- if (event && root && root.contains(event.target)) { positionFlyouts(); return; }+ if (event && event.target instanceof Node && root && root.contains(event.target)) { positionFlyouts(); return; }position(); scheduleActive();}@@ -5665,12 +5681,18 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'wbs-fab-bottom-' + PROFILE_ID,];+ function fabPositionKey() {+ var area = WBS_COMPAT.findConversationArea(document);+ return area && area.kind === 'new-task' ? FAB_POSITION_KEY + '-new-task' : FAB_POSITION_KEY;+ }+function readFabBottom() {try {- var raw = localStorage.getItem(FAB_POSITION_KEY);+ var key = fabPositionKey();+ var raw = localStorage.getItem(key);var value = Number(raw);if (raw !== null && raw !== '' && isFinite(value)) return value;- for (var i = 0; i < FAB_RETIRED_POSITION_KEYS.length; i++) {+ for (var i = 0; key === FAB_POSITION_KEY && i < FAB_RETIRED_POSITION_KEYS.length; i++) {// Drop retired coordinates so a downgrade/reinjection cannot restore// a position whose reference point the anchor no longer means.localStorage.removeItem(FAB_RETIRED_POSITION_KEYS[i]);@@ -9829,6 +9851,30 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {});}+ var rememberedSessionsKey = 'wbs-remembered-sessions-' + (typeof PROFILE_ID === 'undefined' ? 'workbuddy-cn' : PROFILE_ID);+ function rememberedSessions() {+ try {+ var value = JSON.parse(localStorage.getItem(rememberedSessionsKey) || '{}');+ return value && typeof value === 'object' ? value : {};+ } catch (_) { return {}; }+ }+ function isSessionRemembered(session) {+ var uid = String(session && session.user_id || sessionsState.uid || sessionsState.currentUid || '');+ var records = rememberedSessions()[uid];+ return !!(uid && Array.isArray(records) && records.some(function (item) { return item && String(item.id) === String(session.id); }));+ }+ function toggleRememberedSession(session) {+ var uid = String(session && session.user_id || sessionsState.uid || sessionsState.currentUid || '');+ if (!uid || !session || !session.id) return;+ var recordsByUid = rememberedSessions();+ var records = Array.isArray(recordsByUid[uid]) ? recordsByUid[uid].slice() : [];+ var existing = records.findIndex(function (item) { return item && String(item.id) === String(session.id); });+ if (existing >= 0) records.splice(existing, 1);+ else records.unshift({ id:String(session.id), title:String(session.custom_title || session.title || '(无标题)'), savedAt:Date.now() });+ recordsByUid[uid] = records.slice(0, 500);+ try { localStorage.setItem(rememberedSessionsKey, JSON.stringify(recordsByUid)); } catch (_) {}+ }+// 按空间分组渲染:每个空间默认显示 INIT 条,可一次展开全部。function renderSessions() {var listEl = sessionsPane.querySelector('#wbs-sess-list');@@ -9848,6 +9894,11 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {return '<button class="wbs-sess-sync" type="button" data-id="' + escAttr(s.id) + '" title="同步到其他账号" aria-label="同步到其他账号">' +'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 3l4 4-4 4"/><path d="M20 7H8"/><path d="M8 21l-4-4 4-4"/><path d="M4 17h12"/></svg></button>';}+ function rememberSessionButton(s) {+ var remembered = isSessionRemembered(s);+ var title = remembered ? '移除置顶备忘' : '记住置顶会话';+ return '<button class="wbs-sess-remember' + (remembered ? ' active' : '') + '" type="button" data-id="' + escAttr(s.id) + '" aria-label="' + title + '" title="' + title + '" aria-pressed="' + (remembered ? 'true' : 'false') + '"><svg viewBox="0 0 24 24" width="16" height="16" fill="' + (remembered ? 'currentColor' : 'none') + '" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m12 3 2.7 5.5 6.1.9-4.4 4.3 1 6.1-5.4-2.9-5.4 2.9 1-6.1-4.4-4.3 6.1-.9L12 3z"/></svg></button>';+ }function autoCopyButton(kind, key, uid, enabled, inherited) {if (sessionsState.autoCopyAll || !canEditAutoCopy(uid)) return '';var title = inherited ? '随空间自动同步' : (enabled ? '取消自动同步' : '切换账号时自动同步');@@ -9888,7 +9939,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {(batch ? '<input type="checkbox" class="wbs-sess-check" data-id="' + escAttr(s.id) + '"' + sel + '>' : '') +'<span class="wbs-sess-main"><span class="wbs-sess-title">' + esc(title) + '</span>' +'<span class="wbs-sess-meta">' + esc(fmtHumanTime(s.last_activity_at || s.updated_at || s.created_at)) + '</span></span>' +- (batch ? '' : sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) ++ (batch ? '' : rememberSessionButton(s) + sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) +'<span class="wbs-sess-size" title="会话大小(消息和附件)">' + sessionCopySizeText(s.totalBytes) + '</span>' +'</div>';});@@ -9921,7 +9972,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {(batch ? '<input type="checkbox" class="wbs-sess-check" data-id="' + escAttr(s.id) + '"' + sel + '>' : '') +'<span class="wbs-sess-main"><span class="wbs-sess-title">' + esc(title) + '</span>' +'<span class="wbs-sess-meta">' + esc(fmtHumanTime(s.last_activity_at || s.updated_at || s.created_at)) + '</span></span>' +- (batch ? '' : sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) ++ (batch ? '' : rememberSessionButton(s) + sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) +'<span class="wbs-sess-size" title="会话大小(消息和附件)">' + sessionCopySizeText(s.totalBytes) + '</span>' +'</div>';});@@ -10017,6 +10068,17 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {function bindSessEvents(listEl) {listEl.onclick = function (e) {var t = e.target;+ var rememberBtn = t.closest ? t.closest('.wbs-sess-remember') : null;+ if (rememberBtn) {+ e.preventDefault();+ e.stopPropagation();+ var rememberedSession = sessionsState.list.find(function (item) { return String(item.id) === String(rememberBtn.getAttribute('data-id')); });+ if (rememberedSession) {+ toggleRememberedSession(rememberedSession);+ renderSessions();+ }+ return;+ }// [会话单条同步] 行内同步按钮:打开单条目标账号弹窗var syncBtn = t.closest ? t.closest('.wbs-sess-sync') : null;if (syncBtn) {@@ -12550,7 +12612,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {fab.classList.add('is-snapping');applyFabPosition(fab, fabAnchorOffsets().right, bottom);syncAutomationStopPosition();- try { localStorage.setItem(FAB_POSITION_KEY, String(Math.round(bottom))); } catch (_) {}+ try { localStorage.setItem(fabPositionKey(), String(Math.round(bottom))); } catch (_) {}fabDrag = null;fabQuietMode.wake();fabSnapTimer = setBuildTimeout(function () {@@ -16220,27 +16282,6 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {return tag ? '<span class="wbs-checkin-slot">' + tag + '</span>' : '';}- // 「今日是否已派猫」只取官方 /travel/status 的当日配额与行程状态。- // 领取可能跨天,「今天领过奖」与「今天派过猫」不是同一个问题,这里不做领取日推断。- // 数据来自 fetchDailyProgressForAccounts() 已有的批量快照,本函数不发起任何请求。- function isTodayBeijing(ts) {- var value = Number(ts);- if (!isFinite(value) || value <= 0) return false;- var offset = 8 * 3600000;- return new Date(value + offset).toISOString().slice(0, 10) === new Date(Date.now() + offset).toISOString().slice(0, 10);- }-- function travelBadgeHtml(a) {- if (WBS_PROFILE_IS_AI || CAPS.growthDaily === false) return '';- var progress = a && a.dailyProgress;- if (!progress || progress.status !== 'ready' || !isTodayBeijing(progress.fetchedAt)) return '';- var cat = progress.cat || {};- if (cat.available === false || cat.state === 'locked' || cat.state === 'unknown') return '';- var sent = cat.dailyLimitReached === true || cat.state === 'traveling' || cat.state === 'arrived';- var label = wbsTranslateString(sent ? '今日已派猫' : '今日未派猫', WBS_LANGUAGE);- return '<span class="wbs-travel-slot"><span class="wbs-ck wbs-checkin-tag ' + (sent ? 'ok' : 'pending') + '" title="' + escAttr(label) + '">' + esc(label) + '</span></span>';- }-function modelLimitKind(record) {return Number(record && record.reasonCode) === 6000? wbsTranslateString('用量限制', WBS_LANGUAGE)@@ -16345,15 +16386,19 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {return nearest;}- function sortAccountsByCreditExpiry() {+ function sortAccountsByCreditExpiry(preserveOrder) {state.accounts = state.accounts.map(function (account, index) {return {account: account,index: index,isCurrent: !!(state.current && account && account.uid === state.current.uid),+ expired: !!(isIdentityExpired(account) || account.creditExpired),expiresAt: nearestCreditExpiry(account),};}).sort(function (a, b) {+ // 身份过期始终排在有效账号后;后台刷新仅调整分组,避免积分变化导致跳动。+ if (a.expired !== b.expired) return a.expired ? 1 : -1;+ if (preserveOrder) return a.index - b.index;if (state.accountOrder && state.accountOrder.mode === 'fixed') {var left = Number(a.account.sort) > 0 ? Number(a.account.sort) : Infinity;var right = Number(b.account.sort) > 0 ? Number(b.account.sort) : Infinity;@@ -16419,11 +16464,17 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {}function dailyRingsSvg(account) {- // Credit check-in and login alone do not complete growth activity.- // Only the official heatmap's record for today may fill the cat vessel.- var checkedToday = isGrowthActiveToday(account);+ var cat = account && account.dailyProgress && account.dailyProgress.cat;+ return dailyCatVessel(isDailyCatSent(cat));+ }++ function isDailyCatSent(cat) {+ return !!cat && (cat.dailyLimitReached === true || cat.state === 'traveling' || cat.state === 'arrived');+ }++ function dailyCatVessel(checkedToday, small) {var level = checkedToday ? '100.00%' : '0.00%';- return '<span class="wbs-daily-vessel' + (checkedToday ? ' is-checked-in' : ' is-empty') + '" aria-hidden="true" style="--wbs-liquid-level:' + level + ';--wbs-workbuddy-cat:url(' + WORKBUDDY_CAT_MARK + ')">' ++ return '<span class="wbs-daily-vessel' + (small ? ' wbs-daily-cat-status-icon' : '') + (checkedToday ? ' is-checked-in' : ' is-empty') + '" aria-hidden="true" style="--wbs-liquid-level:' + level + ';--wbs-workbuddy-cat:url(' + WORKBUDDY_CAT_MARK + ')">' +'<span class="wbs-daily-liquid"></span><span class="wbs-daily-cat-mark"></span></span>';}@@ -16431,7 +16482,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {if (!CAPS.growthDaily || WBS_PROFILE_IS_AI) return '';var progress = account && account.dailyProgress;var label = dailyProgressLabel(progress);- return '<button type="button" class="wbs-daily-rings" tabindex="0" aria-label="' + escAttr(label) + '" aria-controls="wbs-status-popover" aria-expanded="false" data-uid="' + escAttr(account.uid) + '">' ++ return '<button type="button" class="wbs-daily-rings' + (isGrowthActiveToday(account) ? ' is-login-today' : '') + '" tabindex="0" aria-label="' + escAttr(label) + '" aria-controls="wbs-status-popover" aria-expanded="false" data-uid="' + escAttr(account.uid) + '">' +dailyRingsSvg(account) + activityStreakHtml(account) + '</button>';}@@ -16471,6 +16522,10 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {return '未派出';}+ function dailyCatTravelIcon(cat) {+ return dailyCatVessel(isDailyCatSent(cat), true);+ }+function formatGrowthTaskDeadline(value) {if (!value) return '长期有效';var date = new Date(value);@@ -16599,7 +16654,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {: '';return head +taskListHtml +- '<div class="wbs-daily-detail cat-row"><i class="cat"></i><span>Buddy 旅行</span><div class="wbs-daily-cat-value"><b' + countdownAttr + '>' + esc(dailyCatDetail(cat)) + '</b>' + buddyUnlockButton + travelClaimButton + travelDepartButton + '</div></div>' + buddyPicker ++ '<div class="wbs-daily-detail cat-row"><i class="cat"></i><span>Buddy 旅行</span><div class="wbs-daily-cat-value">' + dailyCatTravelIcon(cat) + '<b' + countdownAttr + '>' + esc(dailyCatDetail(cat)) + '</b>' + buddyUnlockButton + travelClaimButton + travelDepartButton + '</div></div>' + buddyPicker +actionHtml + loginRewards + refreshError;}@@ -16614,6 +16669,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {var existing = cards[i].querySelector('.wbs-daily-rings');if (existing) {existing.setAttribute('aria-label', dailyProgressLabel(account.dailyProgress));+ existing.classList.toggle('is-login-today', isGrowthActiveToday(account));existing.innerHTML = dailyRingsSvg(account) + activityStreakHtml(account);}else if (nameGroup) {@@ -16621,17 +16677,6 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {if (checkinSlot) checkinSlot.insertAdjacentHTML('beforebegin', dailyRingsHtml(account));else nameGroup.insertAdjacentHTML('beforeend', dailyRingsHtml(account));}- // 派猫徽章依赖异步到达的 dailyProgress,随成长数据一起局部刷新。- var travelSlot = nameGroup && nameGroup.querySelector('.wbs-travel-slot');- var travelBadge = typeof travelBadgeHtml === 'function' ? travelBadgeHtml(account) : '';- if (travelSlot) {- if (travelBadge) travelSlot.outerHTML = travelBadge;- else travelSlot.remove();- } else if (travelBadge && nameGroup) {- var checkinSlotAfter = nameGroup.querySelector('.wbs-checkin-slot');- if (checkinSlotAfter) checkinSlotAfter.insertAdjacentHTML('afterend', travelBadge);- else nameGroup.insertAdjacentHTML('beforeend', travelBadge);- }}}@@ -17190,6 +17235,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {state.accountSortPending = true;}if (!previous.length || !state.open || currentChanged) sortAccountsByCreditExpiry();+ else sortAccountsByCreditExpiry(true);state.creditRemaining = state.accounts.length;updateAccountSummary();var list = accountsPane.querySelector('.wbs-acct-list');@@ -17219,7 +17265,6 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {var editionBadge = a.type === 'personal' ? '个人版' : (a.enterpriseName ? a.enterpriseName : (a.type ? '企业' : ''));var badge = editionBadge ? '<span class="wbs-badge">' + esc(editionBadge) + '</span>' : '';var checkinBadge = checkinBadgeHtml(a);- var travelBadge = typeof travelBadgeHtml === 'function' ? travelBadgeHtml(a) : '';var modelRateLimitBadge = typeof modelRateLimitBadgeHtml === 'function' ? modelRateLimitBadgeHtml(a) : '';var invalidAuthBadge = a.authValid === false ? '<span class="wbs-badge wbs-auth-invalid">认证数据无效</span>' : '';// 过期账号仍可手动切换检查登录状态;仅损坏的认证备份禁止切换。@@ -17239,7 +17284,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {var idVal = accountDisplayId(a, state.mask);card.innerHTML ='<div class="wbs-info">' +- '<div class="wbs-row1"><div class="wbs-name-group"><button type="button" class="wbs-account-name" data-uid="' + escAttr(a.uid) + '" aria-label="查看或编辑账号备注" aria-haspopup="dialog" aria-controls="wbs-account-note-popover" aria-expanded="false"><span class="wbs-name">' + esc(nameVal) + '</span><span class="wbs-account-name-edit" aria-hidden="true">' + MODEL_EDIT_SVG + '</span></button>' + badge + dailyRingsHtml(a) + checkinBadge + travelBadge + modelRateLimitBadge + invalidAuthBadge + '</div>' + ops + '</div>' ++ '<div class="wbs-row1"><div class="wbs-name-group"><button type="button" class="wbs-account-name" data-uid="' + escAttr(a.uid) + '" aria-label="查看或编辑账号备注" aria-haspopup="dialog" aria-controls="wbs-account-note-popover" aria-expanded="false"><span class="wbs-name">' + esc(nameVal) + '</span><span class="wbs-account-name-edit" aria-hidden="true">' + MODEL_EDIT_SVG + '</span></button>' + badge + dailyRingsHtml(a) + checkinBadge + modelRateLimitBadge + invalidAuthBadge + '</div>' + ops + '</div>' +'<div class="wbs-meta wbs-secondary-row">' +'<div class="wbs-mi wbs-phone-cell' + (isUinMode ? ' wbs-uin-cell' : '') + '"><span class="wbs-lbl">' + idLbl + '</span><span class="wbs-val">' + esc(idVal) + '</span></div>' +'<div class="wbs-mi wbs-token-cell"><span class="wbs-lbl">有效期至</span><span class="wbs-val' + (ts.warn ? ' wbs-warn' : '') + '">' + esc(ts.label) + '</span></div>' +@@ -17480,17 +17525,28 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {total.textContent = fmtCredits(0);return;}+ var hasExpiredAccount = false;// 初次打开时如果接口带有缓存积分,先把它作为已知值;后续刷新期间始终保留上一次完整结果。if (state.creditSummaryValue === null) {var cachedSum = 0;var cachedCount = 0;state.accounts.forEach(function (a) {+ if (isIdentityExpired(a) || a.creditExpired) { hasExpiredAccount = true; return; }if (typeof a.credits === 'number' && isFinite(a.credits)) {cachedSum += a.credits;cachedCount++;}});if (cachedCount) state.creditSummaryValue = cachedSum;+ } else {+ // 账号元数据刷新可能先标记身份过期,而积分批次尚未开始;立即移除+ // 该账号的旧缓存,避免总额在刷新窗口继续统计过期账号。+ var eligibleCachedSum = 0;+ state.accounts.forEach(function (a) {+ if (isIdentityExpired(a) || a.creditExpired) { hasExpiredAccount = true; return; }+ if (typeof a.credits === 'number' && isFinite(a.credits)) eligibleCachedSum += a.credits;+ });+ if (hasExpiredAccount) state.creditSummaryValue = eligibleCachedSum;}total.textContent = state.creditSummaryValue === null ? '查询中…' : fmtCredits(state.creditSummaryValue);}@@ -17750,7 +17806,10 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {var slot = card.querySelector('.wbs-checkin-slot');if (slot) slot.outerHTML = checkinBadgeHtml(current);var growthControl = card.querySelector('.wbs-daily-rings');- if (growthControl) growthControl.innerHTML = dailyRingsSvg(current) + activityStreakHtml(current);+ if (growthControl) {+ growthControl.classList.toggle('is-login-today', isGrowthActiveToday(current));+ growthControl.innerHTML = dailyRingsSvg(current) + activityStreakHtml(current);+ }});}).then(worker);}@@ -17805,6 +17864,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {function updateCreditSummaryFromAccounts() {var sum = 0;state.accounts.forEach(function (account) {+ if (isIdentityExpired(account) || account.creditExpired) return;if (typeof account.credits === 'number' && isFinite(account.credits)) sum += account.credits;});state.creditSummaryValue = sum;@@ -17814,6 +17874,16 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {function refreshCreditForAccount(uid) {uid = String(uid || '').trim();if (!uid || !alive || !state.accounts.some(function (account) { return account.uid === uid; })) return Promise.resolve();+ var knownAccount = state.accounts.find(function (account) { return account.uid === uid; });+ if (isIdentityExpired(knownAccount) || knownAccount.creditExpired) {+ knownAccount.credits = null;+ knownAccount.creditSegments = [];+ knownAccount.creditUnlimited = false;+ knownAccount.creditExpired = true;+ updateCreditCell(uid, null, []);+ updateCreditSummaryFromAccounts();+ return Promise.resolve();+ }var generation = (state.creditRefreshGeneration[uid] || 0) + 1;state.creditRefreshGeneration[uid] = generation;return requestCredit(uid).then(function (result) {@@ -17853,14 +17923,30 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {if (state.accountSortPending) {state.accountSortPending = false;sortAccountsByCreditExpiry();- reorderAccountCards();+ } else {+ sortAccountsByCreditExpiry(true);}- // 后续后台批次只更新缓存,下次打开前再排序,避免逐条响应导致账号反复移动。+ reorderAccountCards();+ // 后续后台批次仅将新过期账号移到末尾,积分到期顺序等下次打开时更新。updateCreditSummaryFromAccounts();}function queryAccount(a) {if (runId !== state.creditRunId || !state.open) return;var generation = state.creditRefreshGeneration[a.uid] || 0;+ if (isIdentityExpired(a) || a.creditExpired) {+ for (var skipped = 0; skipped < state.accounts.length; skipped++) {+ if (state.accounts[skipped].uid !== a.uid) continue;+ state.accounts[skipped].credits = null;+ state.accounts[skipped].creditSegments = [];+ state.accounts[skipped].creditUnlimited = false;+ state.accounts[skipped].creditExpired = true;+ break;+ }+ updateCreditCell(a.uid, null, []);+ state.creditRemaining = Math.max(0, state.creditRemaining - 1);+ settleBatch();+ return;+ }// 无论成功、HTTP 错误、身份过期还是超时,都必须进入 finally。Promise.resolve().then(function () { return requestCredit(a.uid); }).then(function (r) {@@ -18350,7 +18436,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'.wbs-ava{width:34px;height:34px;border-radius:50%;background:var(--wb-bg-tertiary,#f0f0f0);color:var(--wb-icon-secondary,#555);display:flex;align-items:center;justify-content:center;font-weight:600;flex-shrink:0;font-size:14px}','.wbs-info{min-width:0}','.wbs-row1{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:7px;min-height:26px}',- '.wbs-name-group{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}.wbs-checkin-slot,.wbs-travel-slot{display:inline-flex;align-items:center;flex-wrap:wrap;gap:5px}',+ '.wbs-name-group{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}.wbs-checkin-slot{display:inline-flex;align-items:center;flex-wrap:wrap;gap:5px}','.wbs-name{font-size:14px;font-weight:600;color:var(--wb-color-text-primary,#1f1f1f)}','.wbs-account-name{position:relative;display:inline-flex;align-items:center;min-width:0;max-width:100%;margin:0;padding:0;border:0;background:transparent;font:inherit;text-align:left;cursor:pointer;isolation:isolate}.wbs-account-name .wbs-name{position:relative;z-index:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wbs-account-name:before{content:"";position:absolute;inset:-4px -5px;border:1px solid var(--wb-border-subtle,#e5e7eb);border-radius:7px;background:var(--wb-bg-popover,#fff);box-shadow:0 2px 7px rgba(0,0,0,.08);opacity:0;transition:opacity 200ms ease;pointer-events:none}.wbs-account-name-edit{position:absolute;right:0;top:50%;z-index:2;display:flex;align-items:center;justify-content:center;width:20px;max-width:100%;height:20px;border-radius:3px;background:var(--wb-bg-popover,#fff);color:var(--wb-icon-secondary,#666);opacity:0;transform:translateY(-50%);transition:opacity 200ms ease;pointer-events:none}.wbs-account-name-edit svg{width:13px;height:13px}.wbs-account-name:hover,.wbs-account-name:focus-visible,.wbs-account-name[aria-expanded="true"]{z-index:2}.wbs-account-name:hover:before,.wbs-account-name:focus-visible:before,.wbs-account-name[aria-expanded="true"]:before{opacity:1}.wbs-account-name:hover .wbs-account-name-edit,.wbs-account-name:focus-visible .wbs-account-name-edit,.wbs-account-name[aria-expanded="true"] .wbs-account-name-edit{opacity:1;pointer-events:auto}.wbs-account-name-edit:hover{color:var(--wb-color-text-primary,#1f1f1f)}.wbs-root.wbs-acct-note-hover-off .wbs-account-name:hover:not(:focus-visible):not([aria-expanded="true"]) .wbs-account-name-edit{opacity:0;pointer-events:none}.wbs-root.wbs-acct-note-hover-off .wbs-account-name:hover:not(:focus-visible):not([aria-expanded="true"]):before{opacity:0}.wbs-account-name:focus-visible{outline:2px solid var(--wb-accent-primary,var(--wb-color-text-primary,#1f1f1f));outline-offset:4px;border-radius:4px}','.wbs-account-note-popover{position:fixed;z-index:2147483647;box-sizing:border-box;width:280px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:auto;padding:10px;border:1px solid var(--wb-border-subtle,#e5e7eb);border-radius:12px;background:color-mix(in srgb,var(--wb-bg-popover,#fff) 94%,transparent);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 10px 30px rgba(0,0,0,.16);color:var(--wb-color-text-primary,#1f1f1f);font:12px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;overscroll-behavior:contain}.wbs-account-note-popover[hidden]{display:none}.wbs-account-note-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:7px;font-weight:600}.wbs-account-note-head .wbs-icon-btn{width:22px;height:22px}.wbs-account-note-popover textarea{display:block;box-sizing:border-box;width:100%;min-height:86px;max-height:180px;resize:vertical;padding:8px;border:1px solid var(--wb-border-default,#ddd);border-radius:8px;background:var(--wb-bg-secondary,#f7f8fa);color:inherit;font:inherit;line-height:1.6;overflow-wrap:anywhere;user-select:text}.wbs-account-note-popover textarea::placeholder{color:var(--wb-color-text-secondary,#777)}.wbs-account-note-popover textarea:focus-visible,.wbs-account-note-popover button:focus-visible{outline:2px solid var(--wb-accent-primary,var(--wb-color-text-primary,#1f1f1f));outline-offset:2px}.wbs-account-note-footer{display:flex;align-items:center;gap:6px;margin-top:9px}.wbs-account-note-footer [role="status"]{flex:1;min-width:0;overflow-wrap:anywhere;font-size:11px;color:var(--wb-color-text-secondary,#666)}.wbs-account-note-footer .wbs-modal-btn{flex:none;padding:4px 9px;font-size:11px}.wbs-account-note-footer .primary{background:var(--wb-button-primary-bg,#1f1f1f);border-color:var(--wb-button-primary-bg,#1f1f1f);color:var(--wb-button-primary-fg,#fff)}.wbs-account-note-footer .primary:hover:not(:disabled){background:var(--wb-button-primary-bg-hover,var(--wb-button-primary-bg,#333))}.wbs-account-note-footer button:disabled{opacity:.45;cursor:default}',@@ -18362,14 +18448,14 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'.wbs-daily-vessel{position:relative;display:block;width:20px;height:20px;flex:0 0 20px;overflow:hidden;border-radius:50%;background:var(--wbs-liquid-bg);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--wbs-liquid-fill) 20%,transparent),0 1px 3px rgba(20,32,29,.12);isolation:isolate}','.wbs-daily-liquid{position:absolute;inset:auto 0 0;height:var(--wbs-liquid-level,0%);min-height:2px;background:var(--wbs-liquid-fill);box-shadow:inset 0 1px 0 rgba(255,255,255,.38);transition:height .35s ease}.wbs-daily-vessel.is-empty .wbs-daily-liquid{min-height:0}.wbs-daily-vessel.is-checked-in{--wbs-liquid-ink:var(--wb-button-primary-fg);background:var(--wbs-liquid-fill);box-shadow:none}.wbs-daily-vessel.is-checked-in .wbs-daily-liquid{border-radius:inherit;box-shadow:none}','.wbs-daily-cat-mark{position:absolute;z-index:1;inset:2px;background:var(--wbs-liquid-ink);-webkit-mask-image:var(--wbs-workbuddy-cat);mask-image:var(--wbs-workbuddy-cat);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:contain;mask-size:contain;transform:rotate(30deg) scale(.82);transform-origin:center}',- '.wbs-daily-streak-label{font-size:10.5px;line-height:1;font-weight:600;white-space:nowrap;font-variant-numeric:tabular-nums;color:inherit}.wbs-daily-streak-label.is-pending{color:var(--wb-icon-tertiary,#7c818b);font-weight:500}',+ '.wbs-daily-streak-label{font-size:11px;line-height:1;font-weight:600;white-space:nowrap;font-variant-numeric:tabular-nums;color:inherit}.wbs-daily-streak-label.is-pending{color:inherit}','.wbs-status-popover{position:fixed;z-index:2147483647;width:306px;box-sizing:border-box;padding:12px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.14));border-radius:11px;background:color-mix(in srgb,var(--wb-bg-popover,#fff) 96%,transparent);color:var(--wb-color-text-primary,#1f1f1f);box-shadow:0 16px 42px rgba(20,24,32,.16),inset 0 1px 0 rgba(255,255,255,.5);backdrop-filter:blur(20px) saturate(1.08);-webkit-backdrop-filter:blur(20px) saturate(1.08);font:12px/1.45 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;pointer-events:auto}.wbs-status-popover.is-daily{width:620px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}','.wbs-status-popover.is-daily::-webkit-scrollbar,.wbs-growth-task-list::-webkit-scrollbar{display:none}','.wbs-status-popover.is-passive{pointer-events:none}.wbs-status-popover.is-credit{height:auto;min-height:0;max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere}.wbs-status-popover[hidden]{display:none!important}.wbs-daily-popover-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:9px}.wbs-daily-popover-head strong{font-size:13px;font-weight:700;white-space:nowrap}.wbs-daily-popover-head span{color:var(--wb-icon-tertiary,#7c818b);font-size:10px;font-variant-numeric:tabular-nums}.wbs-daily-refresh-time{display:inline-flex;align-items:center;gap:5px;white-space:nowrap}','.wbs-daily-popover-head-actions{display:inline-flex;min-width:0;align-items:center;justify-content:flex-end;gap:6px}.wbs-daily-popover-close{display:inline-flex;width:22px;height:22px;flex:0 0 22px;align-items:center;justify-content:center;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--wb-icon-secondary,var(--wb-color-text-secondary,#666));cursor:pointer}.wbs-daily-popover-close:hover{background:var(--wb-bg-hover,rgba(127,127,127,.12));color:var(--wb-color-text-primary,#1f1f1f)}.wbs-daily-popover-close:focus-visible{outline:2px solid var(--wb-accent-blue,var(--wb-color-text-primary,#1f1f1f));outline-offset:1px}.wbs-daily-popover-close svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round}','.wbs-daily-refresh-spinner{width:9px;height:9px;box-sizing:border-box;border:1.5px solid color-mix(in srgb,var(--wbs-ring-growth) 25%,transparent);border-top-color:var(--wbs-ring-growth);border-radius:50%;animation:wbs-daily-spin .72s linear infinite}@keyframes wbs-daily-spin{to{transform:rotate(360deg)}}','.wbs-daily-detail{display:grid;grid-template-columns:8px 72px minmax(0,1fr);align-items:center;gap:7px;min-height:31px;margin-top:5px;padding:0 9px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:8px;background:color-mix(in srgb,var(--wb-bg-secondary,#f6f7f8) 72%,transparent)}',- '.wbs-daily-detail i,.wbs-credit-tip-value i{display:block;width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 2px color-mix(in srgb,currentColor 17%,transparent)}.wbs-daily-detail i.growth{color:var(--wbs-ring-growth)}.wbs-daily-detail i.cat{color:var(--wbs-ring-cat)}.wbs-daily-detail i.credit{color:var(--wbs-tip-credit)}.wbs-daily-detail>span{color:var(--wb-color-text-secondary,#5f6368);white-space:nowrap}.wbs-daily-detail b{min-width:0;text-align:right;font-size:11px;font-weight:650;overflow-wrap:anywhere}.wbs-daily-detail.cat-row b{white-space:nowrap;font-variant-numeric:tabular-nums}.wbs-daily-cat-value{display:flex;min-width:0;align-items:center;justify-content:flex-end;gap:8px}.wbs-travel-claim{flex:0 0 auto}',+ '.wbs-daily-detail i,.wbs-credit-tip-value i{display:block;width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 2px color-mix(in srgb,currentColor 17%,transparent)}.wbs-daily-detail i.growth{color:var(--wbs-ring-growth)}.wbs-daily-detail i.cat{color:var(--wbs-ring-cat)}.wbs-daily-detail i.credit{color:var(--wbs-tip-credit)}.wbs-daily-detail>span{color:var(--wb-color-text-secondary,#5f6368);white-space:nowrap}.wbs-daily-detail b{min-width:0;text-align:right;font-size:11px;font-weight:650;overflow-wrap:anywhere}.wbs-daily-detail.cat-row b{white-space:nowrap;font-variant-numeric:tabular-nums}.wbs-daily-cat-value{display:flex;min-width:0;align-items:center;justify-content:flex-end;gap:8px}.wbs-daily-cat-status-icon{width:16px;height:16px;flex:0 0 16px}.wbs-daily-vessel.is-empty{background:var(--wb-icon-tertiary,#7c818b)}.wbs-daily-cat-status-icon .wbs-daily-cat-mark{inset:1.6px}.wbs-travel-claim{flex:0 0 auto}','.wbs-daily-detail i,.wbs-credit-tip-value i{display:block;width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 2px color-mix(in srgb,currentColor 17%,transparent)}.wbs-daily-detail i.growth{color:var(--wbs-ring-growth)}.wbs-daily-detail i.cat{color:var(--wbs-ring-cat)}.wbs-daily-detail i.credit{color:var(--wbs-tip-credit)}.wbs-daily-detail>span{color:var(--wb-color-text-secondary,#5f6368);white-space:nowrap}.wbs-daily-detail b{min-width:0;text-align:right;font-size:11px;font-weight:650;overflow-wrap:anywhere}.wbs-daily-detail.cat-row b{white-space:nowrap;font-variant-numeric:tabular-nums}.wbs-daily-cat-value{display:flex;min-width:0;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px}.wbs-daily-cat-value>b{white-space:normal!important}.wbs-travel-claim{flex:0 0 auto}','.wbs-growth-task-section{margin:7px 0 9px;padding:9px 10px 7px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:9px;background:color-mix(in srgb,var(--wb-bg-secondary,#f6f7f8) 38%,var(--wb-bg-popover,#fff))}.wbs-growth-task-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding-bottom:5px}.wbs-growth-task-head span{font-size:10.5px;font-weight:650;color:var(--wb-color-text-secondary,#5f6368)}.wbs-growth-task-head em{font-size:10px;font-style:normal;color:var(--wbs-ring-growth);font-variant-numeric:tabular-nums}.wbs-growth-task-list{max-height:360px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}.wbs-growth-task-row{padding:9px 0;border-top:1px solid color-mix(in srgb,var(--wb-border-subtle,rgba(20,24,32,.1)) 72%,transparent);font-size:10.5px}.wbs-growth-task-row:first-child{border-top:0}.wbs-growth-task-title{display:grid;grid-template-columns:6px minmax(0,1fr) 42px 62px;align-items:center;gap:7px;min-height:22px}.wbs-growth-task-title>i{width:6px;height:6px;border-radius:50%;background:var(--wb-border-default,var(--wb-bg-tertiary,#d9dadd))}.wbs-growth-task-row.is-completed .wbs-growth-task-title>i,.wbs-growth-task-row.is-claimed .wbs-growth-task-title>i{background:var(--wbs-ring-growth)}.wbs-growth-task-title>span{min-width:0;color:var(--wb-color-text-primary,#1f1f1f);font-weight:620;line-height:1.4;overflow-wrap:anywhere}.wbs-growth-task-title>em{font-style:normal;text-align:right;color:var(--wb-icon-tertiary,#7c818b);font-variant-numeric:tabular-nums;white-space:nowrap}.wbs-growth-task-state{display:flex;min-width:62px;align-items:center;justify-content:flex-end}.wbs-growth-task-title b{text-align:right;color:var(--wb-color-text-secondary,#5f6368);font-size:10px;font-weight:600;white-space:nowrap}.wbs-growth-task-row.is-completed .wbs-growth-task-title b,.wbs-growth-task-row.is-claimed .wbs-growth-task-title b{color:var(--wbs-ring-growth)}.wbs-growth-task-action{display:inline-flex;min-width:60px;height:22px;box-sizing:border-box;align-items:center;justify-content:center;gap:4px;padding:0 7px;border:1px solid var(--wb-button-primary-bg,#1f1f1f);border-radius:6px;background:var(--wb-button-primary-bg,#1f1f1f);color:var(--wb-button-primary-fg,#fff);font:600 10px/1 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;white-space:nowrap;cursor:pointer;transition:background-color .16s,border-color .16s,box-shadow .16s}.wbs-growth-task-action:hover:not([disabled]){background:var(--wb-button-primary-bg-hover,var(--wb-button-primary-bg,#1f1f1f));border-color:var(--wb-button-primary-bg-hover,var(--wb-button-primary-bg,#1f1f1f))}.wbs-growth-task-action:focus-visible{outline:0;box-shadow:0 0 0 2px color-mix(in srgb,var(--wb-button-primary-bg,#1f1f1f) 34%,transparent)}.wbs-growth-task-action[disabled]{opacity:.72;cursor:default}.wbs-growth-task-action-spinner{width:9px;height:9px;box-sizing:border-box;border:1.5px solid color-mix(in srgb,currentColor 28%,transparent);border-top-color:currentColor;border-radius:50%;animation:wbs-daily-spin .72s linear infinite}.wbs-growth-task-meta{display:flex;align-items:flex-start;gap:16px;margin:5px 0 0 13px;color:var(--wb-color-text-secondary,#5f6368);font-size:10px}.wbs-growth-task-meta>span{display:flex;min-width:0;align-items:flex-start;gap:6px;overflow-wrap:anywhere}.wbs-growth-task-meta>span:last-child{flex:1}.wbs-growth-task-meta label{flex:0 0 auto;color:var(--wb-icon-tertiary,#7c818b);font-size:10px;white-space:nowrap}.wbs-growth-reward-tags{display:flex;min-width:0;flex-wrap:wrap;gap:4px}.wbs-growth-reward-tag{display:inline-flex;align-items:center;min-height:16px;box-sizing:border-box;padding:1px 5px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:999px;background:color-mix(in srgb,var(--wb-bg-tertiary,#f2f3f4) 72%,transparent);color:var(--wb-color-text-secondary,#5f6368);font-size:9px;font-weight:500;line-height:1.2;white-space:nowrap}.wbs-growth-reward-tag.is-empty{color:var(--wb-icon-tertiary,#7c818b)}','.wbs-growth-task-head>span{display:inline-flex;align-items:center;gap:7px}.wbs-growth-task-head i.growth{width:8px;height:8px;flex:none;border-radius:50%;background:var(--wbs-ring-growth);box-shadow:0 0 0 2px color-mix(in srgb,var(--wbs-ring-growth) 17%,transparent)}.wbs-growth-task-head em{color:var(--wb-icon-tertiary,#7c818b)}.wbs-growth-task-title{grid-template-columns:6px minmax(0,1fr) auto minmax(78px,auto)}.wbs-growth-task-title>span{font-size:11px}.wbs-growth-task-tag{display:inline-flex!important;min-height:17px;box-sizing:border-box;align-items:center;padding:1px 6px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:999px;background:color-mix(in srgb,var(--wb-bg-tertiary,#f2f3f4) 72%,transparent);color:var(--wb-color-text-secondary,#5f6368)!important;font-size:9px!important;font-weight:550!important;white-space:nowrap}.wbs-growth-task-state{grid-column:4;min-width:78px}.wbs-growth-task-action{min-width:74px}.wbs-growth-task-guide{margin:4px 78px 0 13px;color:var(--wb-color-text-secondary,#5f6368);font-size:10px;line-height:1.5;overflow-wrap:anywhere}.wbs-growth-task-meta{flex-wrap:wrap;gap:5px 14px;margin-top:6px}.wbs-growth-task-meta>span:last-child{flex:0 1 auto}.wbs-growth-task-reward{flex:1 1 150px!important}.wbs-growth-task-progress{font-variant-numeric:tabular-nums}.wbs-growth-reward-tag{opacity:.76}.wbs-growth-claimed-toggle{display:flex;width:100%;align-items:center;justify-content:center;margin:3px 0 0;padding:6px 0 2px;border:0;border-top:1px solid color-mix(in srgb,var(--wb-border-subtle,rgba(20,24,32,.1)) 72%,transparent);background:transparent;color:var(--wb-icon-secondary,#667085);font:600 10px/1.4 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;cursor:pointer}.wbs-growth-claimed-toggle em{font-style:normal;font-weight:500;color:var(--wb-icon-tertiary,#7c818b)}.wbs-growth-claimed-toggle:hover{color:var(--wb-color-text-primary,#1f1f1f)}.wbs-growth-claimed-toggle:focus-visible{outline:2px solid color-mix(in srgb,var(--wbs-primary) 40%,transparent);outline-offset:2px}',@@ -18428,13 +18514,17 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {'.wbs-ck{font-size:11px;font-weight:600}','.wbs-checkin-tag{display:inline-flex;align-items:center;height:22px;min-height:22px;box-sizing:border-box;padding:1px 7px;border:1px solid transparent;border-radius:999px;white-space:nowrap}','.wbs-checkin-tag.pending{background:var(--wb-bg-tertiary,#f0f0f0);color:var(--wb-icon-tertiary,#999)}',- '.wbs-daily-rings,.wbs-checkin-tag.ok{--wbs-badge-bg:var(--wb-color-text-primary,#1f1f1f);--wbs-badge-fg:var(--wb-bg-popover,#fff);background:var(--wbs-badge-bg);border-color:transparent;color:var(--wbs-badge-fg);box-shadow:none}.wbs-daily-rings{--wbs-liquid-fill:color-mix(in srgb,var(--wb-button-primary-bg) 55%,var(--wb-button-primary-fg));--wbs-liquid-bg:rgba(255,255,255,.14);--wbs-liquid-ink:#fff}.wbs-daily-rings .wbs-daily-streak-label.is-pending{color:inherit;opacity:.75}.wbs-daily-rings:hover,.wbs-daily-rings[aria-expanded="true"]{background:color-mix(in srgb,var(--wbs-badge-bg) 84%,white);box-shadow:0 2px 8px rgba(0,0,0,.14)}',+ '.wbs-daily-rings,.wbs-checkin-tag.ok{--wbs-badge-bg:var(--wb-color-text-primary,#1f1f1f);--wbs-badge-fg:var(--wb-bg-popover,#fff);background:var(--wbs-badge-bg);border-color:transparent;color:var(--wbs-badge-fg);box-shadow:none}:is(.wbs-daily-rings,.wbs-daily-cat-status-icon){--wbs-liquid-fill:color-mix(in srgb,var(--wb-button-primary-bg) 55%,var(--wb-button-primary-fg));--wbs-liquid-bg:rgba(255,255,255,.14);--wbs-liquid-ink:#fff}.wbs-daily-rings .wbs-daily-streak-label.is-pending{color:inherit}.wbs-daily-rings:hover,.wbs-daily-rings[aria-expanded="true"]{background:color-mix(in srgb,var(--wbs-badge-bg) 84%,white);box-shadow:0 2px 8px rgba(0,0,0,.14)}',// Keep the theme hue, but lift dark fills above the empty gray vessel.- '@supports (color:oklch(from black l c h)){.wbs-daily-rings{--wbs-liquid-fill:oklch(from var(--wb-button-primary-bg) max(l,.62) c h / 1)}}',- 'html:not(.cb-dark):not([data-theme="dark"]):is([data-wbs-theme-id="default"],:not([data-wbs-theme-id])) body:not([data-vscode-theme-name*="dark" i]) .wbs-daily-rings{--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',+ '@supports (color:oklch(from black l c h)){:is(.wbs-daily-rings,.wbs-daily-cat-status-icon){--wbs-liquid-fill:oklch(from var(--wb-button-primary-bg) max(l,.62) c h / 1)}}',+ 'html:not(.cb-dark):not([data-theme="dark"]):is([data-wbs-theme-id="default"],:not([data-wbs-theme-id])) body:not([data-vscode-theme-name*="dark" i]) :is(.wbs-daily-rings,.wbs-daily-cat-status-icon){--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',// CodeBuddy's light panel must not inherit the host renderer's dark badge palette.- '.wbs-panel-light .wbs-daily-rings,[data-wbs-appearance="light"] .wbs-daily-rings{--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',+ '.wbs-panel-light :is(.wbs-daily-rings,.wbs-daily-cat-status-icon),[data-wbs-appearance="light"] :is(.wbs-daily-rings,.wbs-daily-cat-status-icon){--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',':is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)),:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-checkin-tag.ok:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)){--wbs-badge-bg:rgba(255,255,255,.085);--wbs-badge-fg:var(--wb-color-text-primary,#f6f5ff);background:var(--wbs-badge-bg);border:1px solid rgba(255,255,255,.12);color:var(--wbs-badge-fg);box-shadow:inset 0 1px 0 rgba(255,255,255,.08);backdrop-filter:blur(12px) saturate(1.08);-webkit-backdrop-filter:blur(12px) saturate(1.08)}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)){--wbs-liquid-bg:rgba(255,255,255,.12);--wbs-liquid-ink:#f6f5ff}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)):hover,:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *))[aria-expanded="true"]{background:rgba(255,255,255,.14);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 3px 10px rgba(0,0,0,.12)}',+ // Today's login controls the pill; Buddy travel independently controls the cat.+ '.wbs-root .wbs-daily-rings.is-login-today{--wbs-badge-bg:var(--wb-color-text-primary,#1f1f1f);--wbs-badge-fg:var(--wb-bg-popover,#fff);background:var(--wbs-badge-bg);color:var(--wbs-badge-fg);border-color:transparent;box-shadow:none}.wbs-root .wbs-daily-rings.is-login-today:hover,.wbs-root .wbs-daily-rings.is-login-today[aria-expanded="true"]{background:var(--wbs-badge-bg);box-shadow:none}',+ '.wbs-root .wbs-daily-rings:not(.is-login-today){--wbs-badge-bg:var(--wb-bg-tertiary,#f0f0f0);--wbs-badge-fg:var(--wb-icon-tertiary,#999);background:var(--wbs-badge-bg);color:var(--wbs-badge-fg);border-color:transparent;box-shadow:none}.wbs-root .wbs-daily-rings:not(.is-login-today):hover,.wbs-root .wbs-daily-rings:not(.is-login-today)[aria-expanded="true"]{background:var(--wbs-badge-bg);box-shadow:none}',+ '.wbs-root .wbs-daily-rings:focus-visible{outline:2px solid var(--wb-icon-secondary,#666);outline-offset:2px}','.wbs-checkin-tag.fail{background:rgba(239,68,68,.1);color:#dc2626}','.wbs-model-rate-limit-slot{display:inline-flex;align-items:center;min-width:0}.wbs-model-rate-limit{appearance:none;-webkit-appearance:none;font:inherit;cursor:pointer;transition:background-color .15s,box-shadow .15s,color .15s}.wbs-model-rate-limit:hover,.wbs-model-rate-limit[aria-expanded="true"]{background:color-mix(in srgb,var(--wbs-badge-bg) 84%,white);box-shadow:0 2px 8px rgba(0,0,0,.14)}.wbs-model-rate-limit:focus-visible{outline:2px solid color-mix(in srgb,var(--wbs-badge-bg) 45%,transparent);outline-offset:2px}','.wbs-status-popover.is-rate-limit{width:500px;max-width:calc(100vw - 16px);overflow-x:auto}.wbs-status-popover.is-rate-limit-summary{width:360px;max-width:calc(100vw - 16px);overflow-x:auto}.wbs-model-rate-limit-detail{grid-template-columns:8px auto minmax(0,1fr) auto auto;gap:7px}.wbs-model-rate-limit-detail b{white-space:nowrap;overflow-wrap:normal}.wbs-model-rate-limit-detail .wbs-model-rate-limit-model{text-align:left}.wbs-model-rate-limit-detail i.rate-limit{color:var(--wb-color-text-primary,#1f1f1f)}.wbs-model-rate-limit-account-group{padding:7px 0 2px;border-top:1px solid var(--wb-border-subtle,rgba(20,24,32,.1))}.wbs-model-rate-limit-account-group:first-of-type{padding-top:0;border-top:0}.wbs-model-rate-limit-account-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 2px 2px}.wbs-model-rate-limit-account-head strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.wbs-model-rate-limit-account-head span{flex:0 0 auto;color:var(--wb-icon-tertiary,#7c818b);font-size:10px;white-space:nowrap}.wbs-model-rate-limit-summary-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto minmax(0,auto);align-items:center;gap:7px;min-height:28px;margin-top:4px;padding:0 8px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:8px;background:color-mix(in srgb,var(--wb-bg-secondary,#f6f7f8) 72%,transparent)}.wbs-model-rate-limit-summary-row>span{color:var(--wb-color-text-secondary,#5f6368);white-space:nowrap}.wbs-model-rate-limit-summary-row>b{min-width:0;font-size:11px;font-weight:650;white-space:nowrap;overflow-wrap:normal}.wbs-model-rate-limit-summary-row .wbs-model-rate-limit-model{text-align:left}.wbs-model-rate-limit-summary-row .wbs-model-rate-limit-reset{text-align:right}',@@ -18842,6 +18932,9 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {/* [会话单条同步] 行内同步图标按钮:尺寸/圆角/交互色与自动同步按钮一致 */'.wbs-sess-sync{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:26px;height:26px;margin-top:-2px;border:1px solid transparent;border-radius:7px;background:transparent;color:var(--wb-icon-tertiary,#999);cursor:pointer;padding:0;transition:background .15s,color .15s;font:inherit}','.wbs-sess-sync:hover{background:var(--wb-bg-hover,#f5f5f5);color:var(--wb-color-text-primary,#1f1f1f)}',+ '.wbs-sess-remember{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:26px;height:26px;margin-top:-2px;border:1px solid transparent;border-radius:7px;background:transparent;color:var(--wb-icon-tertiary,#999);cursor:pointer;padding:0;transition:background .15s,color .15s;font:inherit}',+ '.wbs-sess-remember:hover,.wbs-sess-remember.active{background:var(--wb-bg-hover,#f5f5f5);color:var(--wb-accent-primary,var(--wb-color-text-primary,#1f1f1f))}',+ '.wbs-sess-remember:focus-visible{outline:2px solid color-mix(in srgb,var(--wb-color-text-primary,#1f1f1f) 50%,transparent);outline-offset:1px}','.wbs-sess-sync:focus-visible{outline:2px solid color-mix(in srgb,var(--wb-color-text-primary,#1f1f1f) 50%,transparent);outline-offset:1px}','.wbs-sess-auto-switch{position:relative;display:inline-flex;align-items:center;width:24px;height:14px;flex:0 0 24px;border-radius:999px;background:var(--wb-bg-tertiary,#dedede);transition:background .15s}','.wbs-sess-auto-switch span{width:10px;height:10px;margin-left:2px;border-radius:50%;background:var(--wb-bg-popover,#fff);box-shadow:0 1px 2px rgba(0,0,0,.18);transition:transform .15s}',diff --git a/scripts/win-launcher.js b/scripts/win-launcher.jsindex 98a7abe..71dc523 100644--- a/scripts/win-launcher.js+++ b/scripts/win-launcher.js@@ -1687,28 +1687,32 @@ async function waitForWorkBuddyCdpNative(binary) {}const installation = readWorkBuddyInstallation(binary);installationChanged = installationChanged || installation.signature !== launchInstallation.signature;- if (nativeLaunchFailed(nativeLaunchState)) {- if (installationChanged && !retriedAfterUpdate) {- retriedAfterUpdate = true;- // A changed executable/archive during this attempt is evidence of an- // installation write, not proof of the crash cause. Bound recovery by- // the original startup deadline and retain exact-process checks.- log('启动期间安装文件发生变化,等待稳定后重试一次');- await waitForStableWorkBuddyInstallation(binary, deadline);- // The official updater may have already restarted a usable instance.- // Reuse its verified CDP endpoint instead of stopping it again.- for (const port of cdpPortCandidates()) {- if (await isWorkBuddyCdpAt(port)) {- CDP_PORT = port;- process.env.WBSWITCH_CDP_PORT = String(port);- writeCdpPortFile(port);- return true;- }+ const launchFailed = nativeLaunchFailed(nativeLaunchState);+ const handoffExited = Number.isInteger(nativeLaunchState && nativeLaunchState.exitCode) &&+ Date.now() - launchStartedAt >= 5000;+ if (installationChanged && !retriedAfterUpdate && (launchFailed || handoffExited)) {+ retriedAfterUpdate = true;+ // A changed executable/archive during this attempt is evidence of an+ // installation write, even when the launching child exits successfully+ // after a single-instance handoff. Keep the original startup deadline+ // and exact-process checks for both exit paths.+ log('启动期间安装文件发生变化,等待稳定后重试一次');+ await waitForStableWorkBuddyInstallation(binary, deadline);+ // The official updater may have already restarted a usable instance.+ // Reuse its verified CDP endpoint instead of stopping it again.+ for (const port of cdpPortCandidates()) {+ if (await isWorkBuddyCdpAt(port)) {+ CDP_PORT = port;+ process.env.WBSWITCH_CDP_PORT = String(port);+ writeCdpPortFile(port);+ return true;}- if (nativeWorkBuddyRunning()) stopNativeWorkBuddy();- start();- continue;}+ if (nativeWorkBuddyRunning()) stopNativeWorkBuddy();+ start();+ continue;+ }+ if (launchFailed) {if (!restartedAfterHandoff && !retriedAfterUpdate && nativeWorkBuddyRunning()) {restartedAfterHandoff = true;log('WorkBuddy 启动进程异常退出但同 profile 进程仍在运行,精确停止后重试一次');@@ -1729,8 +1733,7 @@ async function waitForWorkBuddyCdpNative(binary) {};throw error;}- if (!restartedAfterHandoff && !retriedAfterUpdate && Number.isInteger(nativeLaunchState && nativeLaunchState.exitCode) &&- Date.now() - launchStartedAt >= 5000 && nativeWorkBuddyRunning()) {+ if (!restartedAfterHandoff && !retriedAfterUpdate && handoffExited && nativeWorkBuddyRunning()) {restartedAfterHandoff = true;log('WorkBuddy 启动请求已被无 CDP 的单实例接管,精确停止后重试一次');stopNativeWorkBuddy();diff --git a/scripts/windows-native/main.go b/scripts/windows-native/main.goindex a4aa6a7..a811369 100644--- a/scripts/windows-native/main.go+++ b/scripts/windows-native/main.go@@ -829,7 +829,7 @@ func inspectExactProcess(pid int, expectedPath string, label string) (bool, int,if !present {return false, 0, nil}- return false, exitAccessDenied, fmt.Errorf("PID %d cannot be inspected at standard privilege", pid)+ return false, exitAccessDenied, fmt.Errorf("PID %d cannot be inspected with the current launcher permissions: %w", pid, err)}return false, exitFailure, err}@@ -860,7 +860,7 @@ func terminateExactProcess(pid int, expectedPath string, label string) (bool, inhandle, err := openProcess(uint32(pid), processTerminate|synchronize|processQueryLimitedInformation)if err != nil {if errors.Is(err, syscall.ERROR_ACCESS_DENIED) {- return false, exitAccessDenied, fmt.Errorf("PID %d %s cannot be terminated at standard privilege", pid, label)+ return false, exitAccessDenied, fmt.Errorf("PID %d %s cannot be terminated with the current launcher permissions: %w", pid, label, err)}return false, exitFailure, err}@@ -871,7 +871,7 @@ func terminateExactProcess(pid int, expectedPath string, label string) (bool, inresult, _, callErr := procTerminateProcess.Call(uintptr(handle), 0)if result == 0 {if errors.Is(callErr, syscall.ERROR_ACCESS_DENIED) {- return false, exitAccessDenied, fmt.Errorf("PID %d %s cannot be terminated at standard privilege", pid, label)+ return false, exitAccessDenied, fmt.Errorf("PID %d %s cannot be terminated with the current launcher permissions: %w", pid, label, callErr)}return false, exitFailure, callErr}diff --git a/scripts/workbuddy-compat.js b/scripts/workbuddy-compat.jsindex 1953176..4a1ceec 100644--- a/scripts/workbuddy-compat.js+++ b/scripts/workbuddy-compat.js@@ -71,6 +71,22 @@}var own = preferred && preferred.closest && preferred.closest('.conversation-shell');var shells = own ? [own] : Array.from(doc.querySelectorAll('.conversation-shell'));+ // The teams New Task page has no conversation shell until its first+ // message is sent. Anchor to the route body; the tab is in the left sidebar+ // and the composer is only a small part of the page.+ if (!shells.length && doc.querySelector) {+ var tabs = Array.from(doc.querySelectorAll('button.conversation-list-tab-button'));+ for (var t = 0; t < tabs.length; t++) {+ var tab = tabs[t];+ var label = (tab.innerText || tab.textContent || tab.getAttribute('aria-label') || '').trim();+ var selected = tab.getAttribute('aria-selected') === 'true' ||+ /(^|\s)active(\s|$)/.test(String(tab.className || ''));+ if (!selected || !/^(新建任务|New Task)$/i.test(label)) continue;+ var homeBody = doc.querySelector('main.wb-home-route > .wb-home-route__body');+ var homeBodyRect = visibleRect(homeBody);+ if (homeBodyRect) return { element:homeBody, rect:homeBodyRect, kind:'new-task' };+ }+ }// Only old clients may use the legacy chat host. A missing modern shell// must not fall back to the teams grid or the whole application window.if (!shells.length && !doc.querySelector('.teams-container,.conversation-page-chrome')) {diff --git a/test/account-list-stability.test.js b/test/account-list-stability.test.jsindex 72ce07c..84ed7a2 100644--- a/test/account-list-stability.test.js+++ b/test/account-list-stability.test.js@@ -137,6 +137,23 @@ test('temporary credit failures retain the cached value but expired identity cleassert.equal(h.ctx.state.accounts.find(a => a.uid === 'expired').creditExpired, true);});+test('known expired accounts clear cached credits and are skipped by the next batch', async () => {+ const h = harness();+ h.ctx.render({ accounts: [+ { ...account('expired', 100), identityExpired: true },+ { ...account('valid', 200), identityExpired: false },+ ] });+ h.ctx.fetchCreditsForAccounts(); await tick();+ assert.deepEqual(h.requests.filter(request => request.route === '/api/credits')+ .map(request => JSON.parse(request.options.body).uid), ['valid']);+ h.requests.find(request => request.route === '/api/credits').resolve({ credits: 20, segments: [] });+ await tick();+ const expired = h.ctx.state.accounts.find(a => a.uid === 'expired');+ assert.equal(expired.credits, null);+ assert.equal(expired.creditExpired, true);+ assert.equal(h.ctx.state.accounts.find(a => a.uid === 'valid').credits, 20);+});+test('account refresh errors retain the cached list', async () => {const h = harness(); h.ctx.render({ accounts: [account('a', 100)] });const before = h.cards()[0];@@ -175,9 +192,9 @@ test('fresh current-account and identity changes update card controls', () => {const h = harness(); h.ctx.render({ accounts: [account('a', 100), account('b', 200)] });const before = h.cards();h.ctx.render({ current: { uid: 'b' }, accounts: [{ ...account('a', 100), identityExpired: true }, account('b', 200)] });- assert.deepEqual(h.order(), ['a', 'b']);- assert.notEqual(h.cards()[0], before[0]);- assert.equal(h.cards()[1].className, 'wbs-card cur');+ assert.deepEqual(h.order(), ['b', 'a']);+ assert.notEqual(h.cards()[1], before[0]);+ assert.equal(h.cards()[0].className, 'wbs-card cur');});test('expired identities retain a manual switch while malformed backups remain blocked', () => {@@ -186,9 +203,9 @@ test('expired identities retain a manual switch while malformed backups remain b{ ...account('expired', 100), identityExpired: true },{ ...account('invalid', 200), authValid: false },] });- assert.match(h.cards()[0].innerHTML, /wbs-acc-switch/);- assert.match(h.cards()[0].innerHTML, /可能需要重新登录/);- assert.doesNotMatch(h.cards()[1].innerHTML, /wbs-acc-switch/);+ assert.match(h.cards()[1].innerHTML, /wbs-acc-switch/);+ assert.match(h.cards()[1].innerHTML, /可能需要重新登录/);+ assert.doesNotMatch(h.cards()[0].innerHTML, /wbs-acc-switch/);});test('a background credit expiry response does not hide the manual switch', () => {@@ -231,3 +248,36 @@ test('fixed sort remains stable through credit refresh and appends new accountsh.ctx.sortAccountsByCreditExpiry();assert.deepEqual(h.order(), ['b','a','c','d']);});++for (const mode of ['expiry', 'fixed']) {+ test(mode + ' order puts all expired identities last, including the current account', () => {+ const h = harness();+ h.ctx.render({ accountOrder: { mode }, current: { uid: 'expired' }, accounts: [+ { ...account('expired', 1), identityExpired: true, sort: 1 },+ { ...account('credit-expired', 2), creditExpired: true, sort: 2 },+ { ...account('valid-later', 20), sort: 4 },+ { ...account('valid-soon', 10), sort: 3 },+ ] });+ assert.deepEqual(h.order(), ['valid-soon', 'valid-later', 'expired', 'credit-expired']);+ });+}++test('visible metadata refresh moves expired accounts behind new valid accounts', () => {+ const h = harness();+ h.ctx.render({ accounts: [account('a', 100), account('b', 200)] });+ h.ctx.render({ accounts: [{ ...account('a', 100), identityExpired: true }, account('b', 200), account('new', 1)] });+ assert.deepEqual(h.order(), ['b', 'new', 'a']);+});++test('background expiry detection moves the existing card once the batch settles', async () => {+ const h = harness();+ h.ctx.render({ accounts: [account('a', 100), account('b', 200), account('c', 300)] });+ const before = h.cards();+ h.ctx.fetchCreditsForAccounts(); await tick();+ h.requests[0].reject({ payload: { expired: true } }); await tick();+ assert.deepEqual(h.order(), ['a', 'b', 'c']);+ h.requests[1].resolve({ credits: 10, segments: [{ remaining: 10, expiresAt: 500 }] });+ h.requests[2].resolve({ credits: 10, segments: [{ remaining: 10, expiresAt: 1 }] }); await tick();+ assert.deepEqual(h.order(), ['b', 'c', 'a']);+ assert.equal(h.cards()[2], before[0]);+});diff --git a/test/account-sort.test.js b/test/account-sort.test.jsindex c409779..7b78bd2 100644--- a/test/account-sort.test.js+++ b/test/account-sort.test.js@@ -11,7 +11,7 @@ const inject = fs.readFileSync(path.join(__dirname, '..', 'scripts', 'inject.js'test('account list sorts by credit expiry without pinning the current account', () => {// sortAccountsByCreditExpiry:置顶条件必须移除,只保留到期时间 + 稳定序- const start = inject.indexOf('function sortAccountsByCreditExpiry()');+ const start = inject.indexOf('function sortAccountsByCreditExpiry(preserveOrder)');assert.ok(start >= 0, 'sortAccountsByCreditExpiry must exist');const body = inject.slice(start, inject.indexOf('function reorderAccountCards', start));assert.ok(body.indexOf('a.isCurrent ? -1 : 1') === -1,diff --git a/test/account-travel-badge.test.js b/test/account-travel-badge.test.jsindex 744d86a..802ac88 100644--- a/test/account-travel-badge.test.js+++ b/test/account-travel-badge.test.js@@ -6,115 +6,33 @@ const fs = require('node:fs');const path = require('node:path');const vm = require('node:vm');-const uiPath = path.join(__dirname, '../scripts/inject.js');-const ui = fs.readFileSync(uiPath, 'utf8');-const HELPERS_START = ui.indexOf(' function isTodayBeijing');-const HELPERS_END = ui.indexOf(' function modelLimitKind', HELPERS_START);+const ui = fs.readFileSync(path.join(__dirname, '../scripts/inject.js'), 'utf8');-function badgeContext(overrides = {}) {- assert.ok(HELPERS_START > 0 && HELPERS_END > HELPERS_START, 'travel badge helpers must stay extractable');- const ctx = Object.assign({- WBS_PROFILE_IS_AI: false,- CAPS: { growthDaily: true },- WBS_LANGUAGE: 'zh',- wbsTranslateString: (value) => value,- esc: (value) => String(value),- escAttr: (value) => String(value),- }, overrides);- vm.createContext(ctx);- vm.runInContext(ui.slice(HELPERS_START, HELPERS_END), ctx);- return ctx;-}--function account(cat, progressOverrides = {}) {- return {- dailyProgress: Object.assign({- status: 'ready',- fetchedAt: Date.now(),- cat,- }, progressOverrides),- };-}--test('official travel status decides "sent today" without inferring claim dates', () => {- const ctx = badgeContext();- const cases = [- [{ state: 'idle', dailyLimitReached: false, available: true }, 'pending', '今日未派猫'],- [{ state: 'needs_selection', dailyLimitReached: false, available: true }, 'pending', '今日未派猫'],- [{ state: 'traveling', dailyLimitReached: false, available: true }, 'ok', '今日已派猫'],- [{ state: 'arrived', dailyLimitReached: false, available: true }, 'ok', '今日已派猫'],- [{ state: 'idle', dailyLimitReached: true, available: true }, 'ok', '今日已派猫'],- ];- for (const [cat, cls, label] of cases) {- const html = ctx.travelBadgeHtml(account(cat));- assert.match(html, /wbs-travel-slot/);- assert.match(html, new RegExp('wbs-checkin-tag ' + cls));- assert.match(html, new RegExp(label));- assert.doesNotMatch(html, /领取|领过奖/, 'the badge must not claim anything about reward claiming');- }+test('account cards no longer render the separate daily travel label', () => {+ assert.doesNotMatch(ui, /今日已派猫|今日未派猫|travelBadgeHtml|wbs-travel-slot/);+ assert.match(ui, /dailyRingsHtml\(a\) \+ checkinBadge \+ modelRateLimitBadge/);});-test('missing, non-ready and yesterday snapshots never claim a result for today', () => {- const ctx = badgeContext();- const idle = { state: 'idle', dailyLimitReached: false, available: true };- assert.equal(ctx.travelBadgeHtml({}), '');- assert.equal(ctx.travelBadgeHtml(account(idle, { status: 'unavailable' })), '');- assert.equal(ctx.travelBadgeHtml({ dailyProgress: { status: 'ready', cat: idle } }), '');- assert.equal(ctx.travelBadgeHtml(account(idle, { fetchedAt: Date.now() - 2 * 86400000 })), '');- assert.equal(ctx.travelBadgeHtml(account(idle, { fetchedAt: 0 })), '');- assert.equal(ctx.isTodayBeijing(Date.now()), true);- assert.equal(ctx.isTodayBeijing(Date.now() - 2 * 86400000), false);-});+test('the daily popup marks travel status with a dim or highlighted cat icon', () => {+ const start = ui.indexOf(' function dailyCatTravelIcon(cat)');+ const end = ui.indexOf(' function formatGrowthTaskDeadline', start);+ assert.ok(start >= 0 && end > start, 'daily travel icon helper must stay extractable');+ const ctx = { WORKBUDDY_CAT_MARK: '__CAT_MARK__' };+ vm.createContext(ctx);+ const vesselStart = ui.indexOf(' function dailyRingsSvg(');+ const vesselEnd = ui.indexOf(' function dailyRingsHtml(', vesselStart);+ vm.runInContext(ui.slice(vesselStart, vesselEnd) + ui.slice(start, end), ctx);-test('accounts without an unlocked Buddy show no travel badge instead of a misleading pending state', () => {- const ctx = badgeContext();+ assert.match(ctx.dailyCatTravelIcon({ state: 'idle' }), /wbs-daily-vessel wbs-daily-cat-status-icon is-empty/);for (const cat of [- { state: 'locked', available: false },- { state: 'idle', available: false },- { state: 'unknown', available: true },+ { state: 'traveling' },+ { state: 'arrived' },+ { state: 'idle', dailyLimitReached: true },]) {- assert.equal(ctx.travelBadgeHtml(account(cat)), '');+ assert.match(ctx.dailyCatTravelIcon(cat), /wbs-daily-vessel wbs-daily-cat-status-icon is-checked-in/);}-});--test('AI profiles and clients without growthDaily stay untouched', () => {- assert.equal(badgeContext({ WBS_PROFILE_IS_AI: true })- .travelBadgeHtml(account({ state: 'traveling', available: true })), '');- assert.equal(badgeContext({ CAPS: { growthDaily: false } })- .travelBadgeHtml(account({ state: 'traveling', available: true })), '');-});--test('English UI uses the shared dictionary entries', () => {- const dictionary = {- '今日已派猫': 'Buddy sent today',- '今日未派猫': 'Buddy not sent today',- };- const ctx = badgeContext({- WBS_LANGUAGE: 'en',- wbsTranslateString: (value) => dictionary[value] || value,- });- assert.match(ctx.travelBadgeHtml(account({ state: 'traveling', available: true })), /Buddy sent today/);- assert.match(ctx.travelBadgeHtml(account({ state: 'idle', available: true })), /Buddy not sent today/);- assert.match(ui, /'今日已派猫': 'Buddy sent today', '今日未派猫': 'Buddy not sent today'/);-});--test('the badge is a pure renderer: no new API calls or endpoints', () => {- const helpers = ui.slice(HELPERS_START, HELPERS_END);- assert.doesNotMatch(helpers, /\bapi\(|fetch\(|XMLHttpRequest/);- // The existing single-account refresh and the existing batch refresh remain the only callers.- assert.equal((ui.match(/api\('\/api\/growth\/daily-progress'/g) || []).length, 2);- assert.match(helpers, /dailyProgress/, 'the badge must consume the existing batch snapshot');-});--test('badge is wired into card rendering, incremental refresh and shared slot CSS', () => {- assert.match(ui, /\+ checkinBadge \+ travelBadge \+ modelRateLimitBadge/);- const updater = ui.slice(- ui.indexOf(' function updateDailyProgressCells()'),- ui.indexOf(' function accountCardLayoutKey()'),- );- assert.ok(updater.length > 0);- assert.match(updater, /wbs-travel-slot/);- assert.match(updater, /travelBadgeHtml\(account\)/);- assert.match(ui, /\.wbs-checkin-slot,\.wbs-travel-slot\{/);- assert.doesNotMatch(ui, /DAEMON_BUILD_ID/, 'inject.js is re-read on every injection; daemon.js needs no version bump');+ assert.match(ui, /dailyCatTravelIcon\(cat\).*dailyCatDetail\(cat\)/);+ assert.match(ctx.dailyCatTravelIcon({ state: 'idle' }), /wbs-daily-liquid.*wbs-daily-cat-mark/);+ assert.match(ui, /return dailyCatVessel\(isDailyCatSent\(cat\)/);+ assert.match(ui, /\.wbs-daily-cat-status-icon\{width:16px;height:16px;flex:0 0 16px/);});diff --git a/test/activity-refresh.test.js b/test/activity-refresh.test.jsindex 17829bf..17f2376 100644--- a/test/activity-refresh.test.js+++ b/test/activity-refresh.test.js@@ -79,19 +79,28 @@ test('reinjection stops the old activity queue after its in-flight requests finitest('activity refresh reads the official today record independently of the streak and clears failed reads', async () => {const h = harness({ manualToday: true });h.ctx.state.accounts = [{ uid: 'a', checkin: { ok: true } }];+ const classes = new Set();+ const button = { classList: { toggle(name, on) { if (on) classes.add(name); else classes.delete(name); } } };+ h.ctx.accountsPane.querySelectorAll = () => [{ getAttribute: () => 'a', querySelector: selector => selector === '.wbs-daily-rings' ? button : null }];+ const todayStart = source.indexOf(' function isGrowthActiveToday(');+ vm.runInContext(source.slice(todayStart, source.indexOf(' function activityStreakHtml(', todayStart)), h.ctx);+ h.ctx.dailyRingsSvg = () => '';h.ctx.fetchActivityForAccounts();h.requests[0].resolve({ activityStreak: { days: 5, status: 'ready' } }); await tick();assert.equal(h.todayRequests.length, 1);h.todayRequests[0].resolve({ ok: true, date: '1970-01-01', is_active: false }); await tick();assert.equal(h.ctx.state.accounts[0].growthTodayActive.is_active, false);+ assert.equal(classes.has('is-login-today'), false);h.ctx.fetchActivityForAccounts();h.requests[1].reject(new Error('streak unavailable')); await tick();h.todayRequests[1].resolve({ ok: true, date: '1970-01-01', is_active: true }); await tick();assert.equal(h.ctx.state.accounts[0].growthTodayActive.is_active, true);+ assert.equal(classes.has('is-login-today'), true);h.ctx.fetchActivityForAccounts();h.requests[2].resolve({ activityStreak: { days: 5, status: 'ready' } }); await tick();h.todayRequests[2].reject(new Error('today unavailable')); await tick();assert.equal(h.ctx.state.accounts[0].growthTodayActive, null);+ assert.equal(classes.has('is-login-today'), false);});test('closing during the today query discards the late result and stops the queue', async () => {diff --git a/test/codebuddy-badge-contrast.test.js b/test/codebuddy-badge-contrast.test.jsindex b10ea3b..0e187c1 100644--- a/test/codebuddy-badge-contrast.test.js+++ b/test/codebuddy-badge-contrast.test.js@@ -27,9 +27,9 @@ test('host dark edition and growth badge overrides respect the panel appearance'test('forced light growth badges retain the light credit color in any host theme', () => {const fill = '--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))';const rule = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].find(([, selector, body]) =>- selector.includes('[data-wbs-appearance="light"] .wbs-daily-rings') && body.includes(fill));+ selector.includes('[data-wbs-appearance="light"] :is(.wbs-daily-rings,.wbs-daily-cat-status-icon)') && body.includes(fill));assert.ok(rule, 'explicit light appearance gets the same liquid highlight as the default light theme');- assert.ok(rule[1].includes('.wbs-panel-light .wbs-daily-rings'));+ assert.ok(rule[1].includes('.wbs-panel-light :is(.wbs-daily-rings,.wbs-daily-cat-status-icon)'));assert.match(css, /\.wbs-badge\{[^}]*color:var\(--wb-color-text-secondary/);assert.match(css, /\.wbs-daily-cat-mark\{[^}]*background:var\(--wbs-liquid-ink\)/);});diff --git a/test/codebuddy-ide-credits.test.js b/test/codebuddy-ide-credits.test.jsindex 1f1c7a8..4782de1 100644--- a/test/codebuddy-ide-credits.test.js+++ b/test/codebuddy-ide-credits.test.js@@ -25,7 +25,7 @@ function harness(accounts) {const document = { body, head, createElement: tag => new Element(tag), getElementById: id => body.querySelector('#' + id), addEventListener() {}, removeEventListener() {} };const window = {};const context = { document, window, CAPS: {}, PROFILE_ID: 'codebuddy-cn', WBS_BRAND: 'WorkDaddy', WBS_LANGUAGE: 'zh',- wbsTranslateString: s => s, api: (path, opts) => {+ wbsTranslateString: s => s, isIdentityExpired: account => !!account.expired, api: (path, opts) => {calls.push(path);if (path === '/api/accounts') return Promise.resolve({ accounts: accounts.map(a => ({ ...a })), current: { uid: 'a' } });return new Promise((resolve, reject) => pending.push({ uid: JSON.parse(opts.body).uid, resolve, reject }));@@ -46,6 +46,17 @@ test('unknown credits do not become zero; opening queries fresh balances includiassert.match(h.credits()[0], /积分 0/); assert.doesNotMatch(h.credits()[0], /上次查询/);assert.match(h.credits()[1], /无限/);});++test('IDE skips expired identities and does not show their cached balance', async () => {+ const h = harness([+ { uid: 'expired', credits: 90, creditSegments: [], expired: true },+ { uid: 'valid', credits: 50, creditSegments: [] },+ ]);+ await h.open();+ assert.equal(h.pending.length, 1);+ assert.match(h.credits()[0], /登录身份过期/);+ assert.doesNotMatch(h.credits()[0], /90/);+});test('failed refresh retains labeled cache and manual refresh retries', async () => {const h = harness([{ uid: 'a', credits: 50, creditSegments: [] }]); await h.open();assert.equal(h.pending.length, 1); h.pending[0].reject(new Error('offline')); await tick();diff --git a/test/conversation-area.test.js b/test/conversation-area.test.jsindex 76f5674..e9b0eca 100644--- a/test/conversation-area.test.js+++ b/test/conversation-area.test.js@@ -53,6 +53,43 @@ test('hidden ancestors, zero size and unmounted chat never fall back to teams mah.doc.querySelectorAll=()=>[];assert.equal(compat.findConversationArea(h.doc),null);});+test('selected New Task page anchors the robot to the home route body without a conversation shell', () => {+ const h = harness();+ const tab = element(12, 120, 255, 32);+ tab.innerText = '新建任务';+ tab.getAttribute = name => name === 'aria-selected' ? 'true' : null;+ const homeBody = element(280, 64, 1232, 793);+ homeBody.className = 'wb-home-route__body';+ h.doc.querySelector = selector => selector === 'main.wb-home-route > .wb-home-route__body' ? homeBody : null;+ h.doc.querySelectorAll = selector => selector === '.conversation-shell' ? [] :+ selector === 'button.conversation-list-tab-button' ? [tab] : [];+ const area = compat.findConversationArea(h.doc);+ assert.equal(area.element, homeBody);+ assert.equal(area.rect.left, 280);+ assert.equal(area.rect.right, 1400);+ assert.equal(area.rect.bottom, 857);+ assert.equal(area.kind, 'new-task');+});+test('New Task page without its route body never anchors the robot to the left tab', () => {+ const h = harness();+ const tab = element(12, 120, 255, 32);+ tab.innerText = '新建任务';+ tab.getAttribute = name => name === 'aria-selected' ? 'true' : null;+ h.doc.querySelector = () => null;+ h.doc.querySelectorAll = selector => selector === '.conversation-shell' ? [] :+ selector === 'button.conversation-list-tab-button' ? [tab] : [];+ assert.equal(compat.findConversationArea(h.doc), null);+});+test('teams pages without a selected New Task tab do not use a mounted home route body', () => {+ const h = harness();+ const tab = element(12, 120, 255, 32);+ tab.innerText = '新建任务';+ tab.getAttribute = name => name === 'aria-selected' ? 'false' : null;+ h.doc.querySelector = selector => selector === 'main.wb-home-route > .wb-home-route__body' ? element(280, 64, 1232, 793) : null;+ h.doc.querySelectorAll = selector => selector === '.conversation-shell' ? [] :+ selector === 'button.conversation-list-tab-button' ? [tab] : [];+ assert.equal(compat.findConversationArea(h.doc), null);+});test('message navigation selects its own shell when several conversations are mounted', () => {const h=harness(), other=element(20,64,300,836), viewport=element(240,64,700,700);viewport.shell=h.shell;@@ -79,3 +116,21 @@ test('robot stays on pages without a chat shell and hides only a covered chat',classes.delete('hidden');ctx.positionFab();assert.equal(positions,1);area=null;ctx.positionFab();assert.equal(classes.has('is-area-hidden'),false,'无会话壳的页面沿用旧版常显');});++test('New Task robot position uses a separate saved offset from conversation pages', () => {+ const start = source.indexOf(" var FAB_POSITION_KEY = 'wbs-fab-bottom-v3-' + PROFILE_ID;");+ const end = source.indexOf(' function clampFabBottom', start);+ assert.ok(start >= 0 && end > start);+ const values = new Map([['wbs-fab-bottom-v3-test', '410']]);+ const context = {+ PROFILE_ID: 'test', document: {},+ WBS_COMPAT: { findConversationArea: () => ({ kind: 'new-task' }) },+ localStorage: { getItem: key => values.has(key) ? values.get(key) : null,+ removeItem: key => values.delete(key) },+ };+ vm.runInNewContext(source.slice(start, end), context);+ assert.equal(context.fabPositionKey(), 'wbs-fab-bottom-v3-test-new-task');+ assert.equal(context.readFabBottom(), null);+ values.set('wbs-fab-bottom-v3-test-new-task', '72');+ assert.equal(context.readFabBottom(), 72);+});diff --git a/test/credit-summary.test.js b/test/credit-summary.test.jsindex d8c332d..e14b079 100644--- a/test/credit-summary.test.js+++ b/test/credit-summary.test.js@@ -21,6 +21,31 @@ test('zero, expired, malformed and stale oversized segments cannot inflate the tassert.equal(ctx.summarizeCreditDays([], 1).rows.length, 0);});+test('expired unlimited accounts are excluded from the summary counters', () => {+ const result = ctx.summarizeCreditDays([+ { credits: 0, creditUnlimited: true, expired: true },+ { credits: 0, creditUnlimited: true },+ ], 1);+ assert.equal(result.unlimited, 1);+ assert.equal(result.unavailable, 1);+});++test('credit totals exclude expired identities even when they have cached balances', () => {+ const start = source.indexOf(' function updateCreditSummaryFromAccounts()');+ const end = source.indexOf(' function refreshCreditForAccount(', start);+ const context = {+ state: { accounts: [+ { uid: 'expired', credits: 100, identityExpired: true },+ { uid: 'valid', credits: 20 },+ ], creditSummaryValue: null },+ isIdentityExpired: account => !!account.identityExpired,+ updateAccountSummary() {},+ };+ vm.runInNewContext(source.slice(start, end), context);+ context.updateCreditSummaryFromAccounts();+ assert.equal(context.state.creditSummaryValue, 20);+});+test('summary scrollbars appear only while scrolling and reset on close or reinjection', () => {const listeners = new Map(), timers = new Map(); let serial = 0;const element = () => { const classes = new Set(); return { hidden: true, classes,diff --git a/test/growth-credit-refresh.test.js b/test/growth-credit-refresh.test.jsindex 08a127c..ce04a93 100644--- a/test/growth-credit-refresh.test.js+++ b/test/growth-credit-refresh.test.js@@ -34,6 +34,7 @@ test('a reward refresh updates one credit cell and ignores older batch results',const context = vm.createContext({state: { accounts, open: true, creditRunId: 1, creditRefreshGeneration: {}, creditRemaining: 0 },alive: true,+ isIdentityExpired: () => false,setTimeout: () => 1, clearTimeout() {},api(route, options) {return new Promise((resolve, reject) => calls.push({ route, uid: JSON.parse(options.body).uid, resolve, reject }));@@ -63,6 +64,7 @@ test('a pending batch cannot overwrite the result of a completed reward refresh'const context = vm.createContext({state: { accounts: [account], open: true, creditRunId: 0, creditRefreshGeneration: {}, creditRemaining: 0 },alive: true,+ isIdentityExpired: () => false,setTimeout: () => 1, clearTimeout() {}, setBuildTimeout: fn => fn(),api(route, options) {return new Promise((resolve, reject) => calls.push({ route, uid: JSON.parse(options.body).uid, resolve, reject }));@@ -87,7 +89,7 @@ test('a temporary reward credit refresh failure preserves cached credits', asynclet rejectRequest;const context = vm.createContext({state: { accounts: [account], open: true, creditRunId: 0, creditRefreshGeneration: {}, creditRemaining: 0 },- alive: true, setTimeout: () => 1, clearTimeout() {},+ alive: true, isIdentityExpired: () => false, setTimeout: () => 1, clearTimeout() {},api() { return new Promise((resolve, reject) => { rejectRequest = reject; }); },updateCreditCell() { throw new Error('cached value should be left alone'); },updateAccountSummary() {},diff --git a/test/growth-rings-ui.test.js b/test/growth-rings-ui.test.jsindex 7ebf3de..dfffb99 100644--- a/test/growth-rings-ui.test.js+++ b/test/growth-rings-ui.test.js@@ -8,7 +8,7 @@ const path = require('node:path');const inject = fs.readFileSync(path.join(__dirname, '../scripts/inject.js'), 'utf8');const daemon = fs.readFileSync(path.join(__dirname, '../scripts/daemon.js'), 'utf8');-test('account cards render today check-in as a full or empty cat liquid badge', () => {+test('account cards render travel as a full or empty cat liquid badge', () => {assert.match(inject, /wbs-daily-rings/);assert.match(inject, /wbs-daily-vessel/);assert.match(inject, /wbs-daily-liquid/);@@ -43,32 +43,52 @@ test('account cards render today check-in as a full or empty cat liquid badge',assert.doesNotMatch(hoverRule[0], /border(?:-color)?:/);});-test('cat water requires the official growth record for today, not credit check-in or streak totals', () => {+test('cat highlight follows travel while the button background independently follows today login', () => {const start = inject.indexOf(' function dailyRingsSvg(account)');- const end = inject.indexOf('\n function dailyRingsHtml', start);+ const end = inject.indexOf(' function formatDailyTravelCountdown', start);const vm = require('node:vm');const context = {- WORKBUDDY_CAT_MARK: '__WBS_BUDDY_MARK__',+ WORKBUDDY_CAT_MARK: '__WBS_BUDDY_MARK__', CAPS: { growthDaily: true }, WBS_PROFILE_IS_AI: false,+ escAttr: String, activityStreakHtml: () => '<span>连续登录 5 天</span>', dailyProgressLabel: () => '',Date: class extends Date { static now() { return Date.parse('2026-09-30T02:00:00Z'); } },};const checkedStart = inject.indexOf(' function isCheckedInToday(');vm.runInNewContext(inject.slice(checkedStart, inject.indexOf(' function activityStreakHtml(', checkedStart)), context);vm.runInNewContext(inject.slice(start, end), context);+ const refreshStart = inject.indexOf(' function updateDailyProgressCells()');+ vm.runInNewContext(inject.slice(refreshStart, inject.indexOf(' function refreshDailyProgressAccount(', refreshStart)), context);+ const classes = new Set();+ const button = { setAttribute() {}, classList: { toggle(name, on) { if (on) classes.add(name); else classes.delete(name); } } };+ context.accountsPane = { querySelectorAll: () => [{ getAttribute: () => 'a', querySelector: selector => selector === '.wbs-daily-rings' ? button : null }] };const record = (is_active, date = '2026-09-30') => ({ ok: true, is_active, date });+ for (const login of [false, true]) {+ for (const sent of [false, true]) {+ const account = { uid: 'a', growthTodayActive: record(login), dailyProgress: { cat: { state: sent ? 'traveling' : 'idle' } } };+ const html = context.dailyRingsHtml(account);+ assert.equal(/class="wbs-daily-rings is-login-today"/.test(html), login);+ assert.equal(/wbs-daily-vessel is-checked-in/.test(html), sent);+ context.state = { accounts: [account] };+ context.updateDailyProgressCells();+ assert.equal(classes.has('is-login-today'), login, 'existing button refreshes its background');+ assert.equal(/wbs-daily-vessel is-checked-in/.test(button.innerHTML), sent, 'existing button refreshes its cat');+ }+ }for (const account of [{ checkin: { ok: true } },- { checkin: { ok: true }, growthTodayActive: record(false) },- { checkin: { ok: true }, growthTodayActive: record(true, '2026-09-29') },+ { growthTodayActive: record(true) },{ activityStreak: { days: 5, status: 'ready' }, dailyProgress: { growth: { ratio: 1 } } },- { growthTodayActive: { ok: false, is_active: true, date: '2026-09-30' } },- { growthTodayActive: record('true') },{}, null,- ]) assert.match(context.dailyRingsSvg(account), /is-empty/, JSON.stringify(account));- const completed = { checkin: { ok: false }, growthTodayActive: record(true) };- assert.match(context.dailyRingsSvg(completed), /is-checked-in/);- assert.match(context.dailyRingsSvg(completed), /--wbs-liquid-level:100\.00%/);+ ]) assert.match(context.dailyRingsSvg(account), /is-empty/);+ for (const cat of [{ state: 'traveling' }, { state: 'arrived' }, { state: 'idle', dailyLimitReached: true }]) {+ assert.match(context.dailyRingsSvg({ dailyProgress: { cat } }), /is-checked-in/);+ }+ for (const growthTodayActive of [record(false), record(true, '2026-09-29'), { ...record(true), ok: false }, record('true')]) {+ assert.doesNotMatch(context.dailyRingsHtml({ uid: 'a', growthTodayActive }), /is-login-today/);+ }+ const completed = { uid: 'a', growthTodayActive: record(true) };+ assert.match(context.dailyRingsHtml(completed), /is-login-today/);context.Date = class extends Date { static now() { return Date.parse('2026-09-30T16:00:00Z'); } };- assert.match(context.dailyRingsSvg(completed), /is-empty/, 'yesterday must become empty at Beijing midnight');+ assert.doesNotMatch(context.dailyRingsHtml(completed), /is-login-today/, 'yesterday login resets at Beijing midnight');});test('daily activity and credit nodes reuse one theme-aware colored popover', () => {@@ -342,7 +362,7 @@ test('daily labels share a black light treatment and one glass dark treatment',});test('cat water follows the credit or button palette for the selected theme', () => {- const badgeRules = [...inject.matchAll(/\.wbs-daily-rings\{([^}]+)\}/g)]+ const badgeRules = [...inject.matchAll(/:is\(\.wbs-daily-rings,\.wbs-daily-cat-status-icon\)\{([^}]+)\}/g)].map(match => match[1]).filter(rule => rule.includes('--wbs-liquid-fill:'));assert.ok(badgeRules.length);for (const rule of badgeRules) {@@ -397,10 +417,10 @@ test('growth plan primary actions use WorkBuddy button theme tokens', () => {test('full water remains visibly brighter than the empty vessel in monochrome themes', () => {assert.match(inject, /--wbs-liquid-fill:color-mix\(in srgb,var\(--wb-button-primary-bg\) 55%,var\(--wb-button-primary-fg\)\)/);- assert.match(inject, /@supports \(color:oklch\(from black l c h\)\)\{\.wbs-daily-rings\{--wbs-liquid-fill:oklch\(from var\(--wb-button-primary-bg\) max\(l,\.62\) c h \/ 1\)/);+ assert.match(inject, /@supports \(color:oklch\(from black l c h\)\)\{:is\(\.wbs-daily-rings,\.wbs-daily-cat-status-icon\)\{--wbs-liquid-fill:oklch\(from var\(--wb-button-primary-bg\) max\(l,\.62\) c h \/ 1\)/);});test('default light cat highlight shares the credit progress color and excludes dark themes', () => {- assert.ok(inject.includes('html:not(.cb-dark):not([data-theme="dark"]):is([data-wbs-theme-id="default"],:not([data-wbs-theme-id])) body:not([data-vscode-theme-name*="dark" i]) .wbs-daily-rings{--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}'));+ assert.ok(inject.includes('html:not(.cb-dark):not([data-theme="dark"]):is([data-wbs-theme-id="default"],:not([data-wbs-theme-id])) body:not([data-vscode-theme-name*="dark" i]) :is(.wbs-daily-rings,.wbs-daily-cat-status-icon){--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}'));});diff --git a/test/message-navigation.test.js b/test/message-navigation.test.jsindex 2cf9706..f48313e 100644--- a/test/message-navigation.test.js+++ b/test/message-navigation.test.js@@ -73,6 +73,30 @@ test('moving between a marker, prompt list and detail keeps the hover surface opassert.equal(closes, 2);});+test('window-level scroll and resize targets bypass Node.contains and still refresh navigation', () => {+ const source = fs.readFileSync(path.join(__dirname, '../scripts/inject.js'), 'utf8');+ const start = source.indexOf(' function onWindowChange(event) {');+ const end = source.indexOf('\n }', start) + 8;+ assert.ok(start >= 0 && end > start);+ let positions = 0, scheduled = 0, flyouts = 0;+ class NodeLike {}+ const root = { contains(target) {+ assert.ok(target instanceof NodeLike, 'contains only receives a DOM Node');+ return true;+ } };+ const context = { Node: NodeLike, root, position: () => { positions++; },+ scheduleActive: () => { scheduled++; }, positionFlyouts: () => { flyouts++; } };+ vm.runInNewContext(source.slice(start, end), context);++ context.onWindowChange({ target: {} });+ context.onWindowChange({ target: null });+ assert.deepEqual([positions, scheduled, flyouts], [2, 2, 0]);++ const node = new NodeLike();+ context.onWindowChange({ target: node });+ assert.deepEqual([positions, scheduled, flyouts], [2, 2, 1]);+});+test('every prompt remains reachable when the rail is capped, including unsampled turns', () => {const element = (tag, className, textContent = '') => ({tag, className, textContent, children: [], attributes: {},diff --git a/test/renderer-escaping.test.js b/test/renderer-escaping.test.jsindex e42b00f..011861c 100644--- a/test/renderer-escaping.test.js+++ b/test/renderer-escaping.test.js@@ -57,8 +57,8 @@ test('session and account selectors escape every text and attribute sink', () =>const sessions = sourceBetween('function renderSessions()', 'function activeAutoCopyCount()');assert.equal((sessions.match(/escAttr\(key\)/g) || []).length, 1);assert.equal((sessions.match(/escAttr\(uid\)/g) || []).length, 1);- // 2 处勾选框 + 1 处行内单条同步按钮([会话单条同步]),均经 escAttr- assert.equal((sessions.match(/escAttr\(s\.id\)/g) || []).length, 3);+ // 2 处勾选框 + 同步按钮 + 置顶备忘按钮,均经 escAttr+ assert.equal((sessions.match(/escAttr\(s\.id\)/g) || []).length, 4);assert.equal((sessions.match(/esc\(title\)/g) || []).length, 2);assert.equal((sessions.match(/esc\(fmtHumanTime\(/g) || []).length, 2);assert.match(sessions, /title="' \+ escAttr\(group\.cwd\)/);diff --git a/test/session-remembered.test.js b/test/session-remembered.test.jsnew file mode 100644index 0000000..fd98a15--- /dev/null+++ b/test/session-remembered.test.js@@ -0,0 +1,32 @@+'use strict';+const test = require('node:test');+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');+const vm = require('node:vm');++const source = fs.readFileSync(path.join(__dirname, '../scripts/inject.js'), 'utf8');+const start = source.indexOf(' var rememberedSessionsKey =');+const end = source.indexOf(' // 按空间分组渲染', start);++test('remembered sessions persist by profile and account UID and can be removed', () => {+ const values = new Map();+ const context = vm.createContext({+ PROFILE_ID: 'workbuddy-cn',+ localStorage: {+ getItem: key => values.has(key) ? values.get(key) : null,+ setItem: (key, value) => values.set(key, value),+ },+ sessionsState: { uid: 'account-a', currentUid: 'account-a' },+ });+ vm.runInContext(source.slice(start, end), context);+ const sessionA = { id: 'session-1', user_id: 'account-a', title: 'Pinned task' };+ const sessionB = { id: 'session-1', user_id: 'account-b', title: 'Different task' };++ assert.equal(context.isSessionRemembered(sessionA), false);+ context.toggleRememberedSession(sessionA);+ assert.equal(context.isSessionRemembered(sessionA), true);+ assert.equal(context.isSessionRemembered(sessionB), false);+ context.toggleRememberedSession(sessionA);+ assert.equal(context.isSessionRemembered(sessionA), false);+});diff --git a/test/session-size-filter.test.js b/test/session-size-filter.test.jsindex e99fb6f..5ef3ce4 100644--- a/test/session-size-filter.test.js+++ b/test/session-size-filter.test.js@@ -10,6 +10,8 @@ function harness() {const control = id => controls[id] ||= { innerHTML: '', textContent: '', style: {}, disabled: false, addEventListener(type, callback) { this[type] = callback; }, querySelectorAll: () => [] };const ctx = vm.createContext({CAPS: {},+ PROFILE_ID: 'workbuddy-cn',+ localStorage: { getItem: () => null, setItem() {} },sessionsState: { list: [{ id: 'small', totalBytes: 10 * 1024 ** 2, title: 'small' }, { id: 'large', totalBytes: 100 * 1024 ** 2 + 1, title: '<unsafe>', is_playground: 1 }, { id: 'unknown', totalBytes: null }], selected: {}, wsExpanded: {}, totalBytes: 2 * 1024 ** 3, minBytes: 10 * 1024 ** 2 },sessionsPane: { querySelector: id => id === '#wbs-sess-export-progress' ? null : control(id), querySelectorAll: () => [] },sessState: { themeTakeover: true }, syncSessionModule() {},@@ -19,6 +21,7 @@ function harness() {});vm.runInContext([section(' function filteredSessions()', ' // 按空间分组渲染'),+ section(' var rememberedSessionsKey =', ' // 按空间分组渲染'),section(' function renderSessions()', ' function updateAutoCopyAllButton()'),section(' function bindSessEvents(', ' function updateSessCount()'),section(' function updateSessCount()', ' // 人性化时间'),diff --git a/test/update-layout.test.js b/test/update-layout.test.jsindex 90a1fef..82444e6 100644--- a/test/update-layout.test.js+++ b/test/update-layout.test.js@@ -1053,8 +1053,8 @@ test('account cards sort by credit expiry without pinning the current account',assert.doesNotMatch(script, /state\.accounts\.sort\(function \(left, right\) \{[\s\S]*left\.uid === state\.current\.uid[\s\S]*right\.uid === state\.current\.uid[\s\S]*return leftIsCurrent \? -1 : 1;[\s\S]*\}\);/);assert.match(script, /function render\(data\) \{[\s\S]*if \(!previous\.length \|\| !state\.open \|\| currentChanged\) sortAccountsByCreditExpiry\(\);/);// sortAccountsByCreditExpiry:去掉当前账号置顶,仅按到期时间 + 稳定序- assert.match(script, /function sortAccountsByCreditExpiry\(\) \{[\s\S]*isCurrent:[\s\S]*a\.expiresAt !== b\.expiresAt[\s\S]*a\.expiresAt - b\.expiresAt[\s\S]*a\.index - b\.index/);- assert.doesNotMatch(script, /function sortAccountsByCreditExpiry\(\) \{[\s\S]*if \(a\.isCurrent !== b\.isCurrent\) return a\.isCurrent \? -1 : 1;/);+ assert.match(script, /function sortAccountsByCreditExpiry\(preserveOrder\) \{[\s\S]*isCurrent:[\s\S]*a\.expiresAt !== b\.expiresAt[\s\S]*a\.expiresAt - b\.expiresAt[\s\S]*a\.index - b\.index/);+ assert.doesNotMatch(script, /function sortAccountsByCreditExpiry\(preserveOrder\) \{[\s\S]*if \(a\.isCurrent !== b\.isCurrent\) return a\.isCurrent \? -1 : 1;/);});test('quick-phrase layering does not reposition WorkBuddy native chat toolbar', () => {@@ -1115,7 +1115,8 @@ test('robot button anchors to the conversation area bottom-right and snaps rightassert.match(script, /fabDrag\.startRight - deltaX/);assert.match(script, /fabDrag\.startBottom - deltaY/);assert.match(script, /applyFabPosition\(fab, fabAnchorOffsets\(\)\.right, bottom\)/);- assert.match(script, /localStorage\.setItem\(FAB_POSITION_KEY/);+ assert.match(script, /area && area\.kind === 'new-task' \? FAB_POSITION_KEY \+ '-new-task' : FAB_POSITION_KEY/);+ assert.match(script, /localStorage\.setItem\(fabPositionKey\(\), String\(Math\.round\(bottom\)\)\)/);assert.match(script, /touchAction = 'none'/);assert.match(script, /is-snapping/);assert.match(script, /cubic-bezier\(\.22,1\.35,\.36,1\)/);diff --git a/test/windows-privilege-boundary.test.js b/test/windows-privilege-boundary.test.jsindex d3978ea..000acd4 100644--- a/test/windows-privilege-boundary.test.js+++ b/test/windows-privilege-boundary.test.js@@ -197,6 +197,13 @@ test('Windows native entry point enforces standard privilege and exposes daemonassert.doesNotMatch(readmeSource, /右键以管理员身份运行 WorkDaddy/);});+test('access-denied diagnostics do not infer that the native helper has standard privilege', () => {+ const start = nativeSource.indexOf('func inspectExactProcess(');+ const end = nativeSource.indexOf('\nfunc terminateExactNode(', start);+ assert.ok(start >= 0 && end > start);+ assert.doesNotMatch(nativeSource.slice(start, end), /at standard privilege/);+});+test('Windows installer stops the verified profile lifecycle before replacing or launching files', () => {const stopIndex = installerSource.indexOf('Stop-VerifiedWorkDaddyLifecycle');const copyIndex = installerSource.indexOf('& robocopy @copyArgs');diff --git a/test/windows-startup-recovery.test.js b/test/windows-startup-recovery.test.jsindex 3df55e1..89b8fe5 100644--- a/test/windows-startup-recovery.test.js+++ b/test/windows-startup-recovery.test.js@@ -7,7 +7,7 @@ const os = require('node:os');const vm = require('node:vm');const source = fs.readFileSync(path.join(__dirname, '../scripts/win-launcher.js'), 'utf8');-function harness({ changed = false, running = false, stable = true, recovered = true } = {}) {+function harness({ changed = false, running = false, stable = true, recovered = true, exitCode = 3221226505 } = {}) {let now = 0, launches = 0, stops = 0, waits = 0;const context = {DATA_DIR: '/fixture', runPendingClientTempCleanup: async () => ({}),@@ -15,7 +15,7 @@ function harness({ changed = false, running = false, stable = true, recovered =Date: { now: () => now }, process: { env: {} }, log() {}, writeCdpPortFile() {},sleep: async ms => { now += ms; }, cdpPortCandidates: () => [9222],isWorkBuddyCdpAt: async () => launches > 1 && recovered,- launchWorkBuddy: () => { launches++; return { exitCode: 3221226505 }; },+ launchWorkBuddy: () => { launches++; return { exitCode }; },nativeWorkBuddyRunning: () => running, stopNativeWorkBuddy: () => { stops++; },nativeWorkBuddyProcessSummary: () => ({}), nativeWorkBuddyDiscoverySummary: () => ({}),readWorkBuddyInstallation: () => ({ signature: changed && launches ? 'new' : 'old', ready: true }),@@ -30,6 +30,30 @@ test('installation changed during a failed launch: wait for stability then retryassert.equal(await h.run(), true);assert.deepEqual(h.counts(), { launches: 2, stops: 0, waits: 1 });});+test('update handoff with a successful child exit still waits for installation stability before restarting', async () => {+ const h = harness({ changed: true, running: true, exitCode: 0 });+ assert.equal(await h.run(), true);+ assert.deepEqual(h.counts(), { launches: 2, stops: 1, waits: 1 });+});+test('successful update handoff does not stop or respawn while installation remains unstable', async () => {+ const h = harness({ changed: true, running: true, stable: false, exitCode: 0 });+ await assert.rejects(h.run(), error => error.exitCode === 15);+ assert.deepEqual(h.counts(), { launches: 1, stops: 0, waits: 1 });+});+test('successful update handoff preserves termination denial without another launch', async () => {+ const h = harness({ changed: true, running: true, exitCode: 0 });+ h.context.stopNativeWorkBuddy = () => { const e = Error('boundary'); e.exitCode = 11; throw e; };+ await assert.rejects(h.run(), error => error.exitCode === 11);+ assert.deepEqual(h.counts(), { launches: 1, stops: 0, waits: 1 });+});+test('successful update handoff reuses CDP that becomes ready during the stability wait', async () => {+ const h = harness({ changed: true, running: true, exitCode: 0 });+ let ready = false;+ h.context.waitForStableWorkBuddyInstallation = async () => { ready = true; };+ h.context.isWorkBuddyCdpAt = async () => ready;+ assert.equal(await h.run(), true);+ assert.deepEqual(h.counts(), { launches: 1, stops: 0, waits: 0 });+});test('an unexplained crash fails without retry and keeps decimal/hex exit details', async () => {const h = harness();await assert.rejects(h.run(), error => error.exitCode === 14 && /3221226505.*0xC0000409/.test(error.message));