Skip to content

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

feat: add a per-session sync button to the session list rows

wanghc9ce7283f73ec
diff --git a/scripts/inject.js b/scripts/inject.js
index 787efbc..3eef860 100644
--- a/scripts/inject.js
+++ b/scripts/inject.js
@@ -1936,6 +1936,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
'登录文件已切换,请刷新窗口使新账号生效': 'Login file switched; refresh the window to apply the new account',
'已切换并触发窗口刷新': 'Switched and the window refresh was triggered',
'跨工作区会话请在对应项目窗口的历史中查看': 'Cross-workspace sessions appear in the history of that project window',
+ '同步到其他账号': 'Sync to another account',
'不能删除当前登录的账号(请先退出登录或切换到其他账号)': 'Cannot delete the currently logged-in account (log out or switch to another account first)',
'删除登录文件后仍然存在': 'The login file still exists after deletion',
'诊断设置由 WORKDADDY_TELEMETRY 环境变量控制': 'Diagnostics are controlled by the WORKDADDY_TELEMETRY environment variable',
@@ -9111,6 +9112,12 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
return;
}
function canEditAutoCopy(uid) { return sessionsState.uid !== '' && !!uid; }
+ // [会话单条同步] 行内即时同步按钮:无需进批量模式,点击直接打开目标账号弹窗。
+ // SVG 内联保持自包含(测试 VM 按 renderSessions 源码切片执行,闭包外变量不可见)。
+ function sessSyncButton(s) {
+ 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 autoCopyButton(kind, key, uid, enabled, inherited) {
if (sessionsState.autoCopyAll || !canEditAutoCopy(uid)) return '';
var title = inherited ? '随空间自动同步' : (enabled ? '取消自动同步' : '切换账号时自动同步');
@@ -9151,7 +9158,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 ? '' : autoCopyButton('session', s.id, s.user_id, marked, inherited)) +
+ (batch ? '' : sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) +
'<span class="wbs-sess-size" title="会话大小(消息和附件)">' + sessionCopySizeText(s.totalBytes) + '</span>' +
'</div>';
});
@@ -9184,7 +9191,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 ? '' : autoCopyButton('session', s.id, s.user_id, marked, inherited)) +
+ (batch ? '' : sessSyncButton(s) + autoCopyButton('session', s.id, s.user_id, marked, inherited)) +
'<span class="wbs-sess-size" title="会话大小(消息和附件)">' + sessionCopySizeText(s.totalBytes) + '</span>' +
'</div>';
});
@@ -9248,6 +9255,14 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
function bindSessEvents(listEl) {
listEl.onclick = function (e) {
var t = e.target;
+ // [会话单条同步] 行内同步按钮:打开单条目标账号弹窗
+ var syncBtn = t.closest ? t.closest('.wbs-sess-sync') : null;
+ if (syncBtn) {
+ e.preventDefault();
+ e.stopPropagation();
+ openCopyModal([syncBtn.getAttribute('data-id')]);
+ return;
+ }
var autoBtn = t.closest ? t.closest('.wbs-sess-auto') : null;
if (autoBtn) {
e.preventDefault();
@@ -17564,6 +17579,10 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
'.wbs-sess-auto.inherited{color:var(--wb-button-primary-bg,#1f1f1f);opacity:.62;cursor:default}',
'.wbs-sess-auto:disabled{cursor:default}',
'.wbs-sess-auto-label{font-size:11px;line-height:1;white-space:nowrap}',
+ /* [会话单条同步] 行内同步图标按钮:尺寸/圆角/交互色与自动同步按钮一致 */
+ '.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-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}',
'.wbs-sess-auto-switch.on{background:var(--wb-button-primary-bg,#1f1f1f)}',
diff --git a/test/renderer-escaping.test.js b/test/renderer-escaping.test.js
index 1b32229..66c3a4d 100644
--- a/test/renderer-escaping.test.js
+++ b/test/renderer-escaping.test.js
@@ -57,7 +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);
- assert.equal((sessions.match(/escAttr\(s\.id\)/g) || []).length, 2);
+ // 2 处勾选框 + 1 处行内单条同步按钮([会话单条同步]),均经 escAttr
+ assert.equal((sessions.match(/escAttr\(s\.id\)/g) || []).length, 3);
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\)/);