4 Commits
Author SHA1 Message Date
kicer 14616e1606 feat(ui): 标签页标题直接用会话标题,不加后缀
无标题时仍回默认「Agent 任务台」。
2026-11-13 09:54:32 +08:00
kicer cf43206c98 feat(ui): 标签页标题跟随当前会话
renderHeader 是所有会话标题变化的出口(切会话/重命名/自动生成标题/首条消息临时标题),
在其中同步 document.title;回欢迎页或会话还没标题时恢复默认「Agent 任务台」。
2026-11-13 09:53:07 +08:00
kicer 0922045a38 refactor(ui): 去掉文件树多余的自动刷新触发(focus / visibilitychange)
切一下窗口就刷一次太吵;visibilitychange 那处也与 resyncSession 重复:
后台挂起回来会走 resumeStream→resyncSession 补拉并刷新,没挂起则 SSE 在线、done 已刷。
自动刷新收敛为三个:一轮跑完、断线重连补拉完、上传完成。
2026-11-13 09:51:19 +08:00
kicer 351662d18c feat(ui): 文件树在回合结束/回前台/重连后自动刷新
- 新增 reloadFileTree():保留展开与勾选,只重拉已展开的目录;250ms debounce + 1s 去重,多路触发合并
- 一轮跑完(engine 循环退出才发的 done)就地刷新;回前台 visibilitychange 与窗口重新聚焦也刷;断线重连补拉后补一次
- 修掉「切回文件树面板仍用旧缓存」:showFileTree 先失效再渲染
- 上传后改用 reloadFileTree,不再把用户已展开的目录收起来
2026-11-13 09:40:31 +08:00
5 changed files with 33 additions and 3 deletions
+7 -1
View File
@@ -208,7 +208,11 @@
function renderHeader() { function renderHeader() {
const c = $('header-center'); const c = $('header-center');
// welcome(含刚 newChat)一律清空:newChat 会停在 welcome,不重刷会残留旧会话标题 // welcome(含刚 newChat)一律清空:newChat 会停在 welcome,不重刷会残留旧会话标题
if (state.view !== 'chat' || !state.sessionId) { c.innerHTML = ''; return; } if (state.view !== 'chat' || !state.sessionId) {
c.innerHTML = '';
document.title = 'Agent 任务台'; // 回欢迎页/新建会话时标签页恢复默认
return;
}
// 顶部只显标题;助手类型 icon 早已退位(会话阶段徽标随 advising 一并移除) // 顶部只显标题;助手类型 icon 早已退位(会话阶段徽标随 advising 一并移除)
const title = document.createElement('div'); const title = document.createElement('div');
title.className = 'header-title'; title.className = 'header-title';
@@ -218,6 +222,8 @@
title.addEventListener('click', renameSession); // 点标题重命名(同步 index) title.addEventListener('click', renameSession); // 点标题重命名(同步 index)
c.innerHTML = ''; c.innerHTML = '';
c.appendChild(title); c.appendChild(title);
// 标签页标题跟着会话走:切会话/重命名/自动生成标题都会走到这里
document.title = state.sessionTitle || 'Agent 任务台';
} }
// ---------- 模式切换已移除:新建会话固定用 state.mode(secretary),助手类型不再占顶部 icon // ---------- 模式切换已移除:新建会话固定用 state.mode(secretary),助手类型不再占顶部 icon
+18
View File
@@ -452,6 +452,7 @@
// 侧栏底部「文件树」图标 → 切到这个面板(由 files.js 的 setDrawerPane 调用)。 // 侧栏底部「文件树」图标 → 切到这个面板(由 files.js 的 setDrawerPane 调用)。
window.showFileTree = function () { window.showFileTree = function () {
ensureShell(); ensureShell();
invalidate(true); // 切回面板一律重拉已展开的目录,不拿上次的缓存糊弄(后台只标脏的也在这里补上)
renderBody(); renderBody();
}; };
@@ -462,6 +463,23 @@
if (drawer && drawer.classList.contains('drawer-mode-files')) renderBody(); if (drawer && drawer.classList.contains('drawer-mode-files')) renderBody();
}; };
// 按需刷新(一轮跑完 / 回前台 / 断线重连):保留展开与勾选,只重拉已展开的目录。
// 不在文件树面板时只标脏不渲染,等切回来由 showFileTree 重新拉。
let reloadTimer = 0, reloadAt = 0, reloading = false;
window.reloadFileTree = function () {
clearTimeout(reloadTimer);
reloadTimer = setTimeout(async function () {
if (Date.now() - reloadAt < 1000) return; // 刚刷过:多路触发(done/visibility/focus/resync)合并掉
if (reloading) return; // 上一轮还在渲,跳过(它读到的就是刚清过的缓存)
reloadAt = Date.now();
invalidate(true);
const drawer = $('drawer');
if (!drawer || !drawer.classList.contains('drawer-mode-files')) return;
reloading = true;
try { await renderBody(); } finally { reloading = false; }
}, 250);
};
(function init() { (function init() {
if (!$('drawer-actions') || !$('files-tree')) return; if (!$('drawer-actions') || !$('files-tree')) return;
req('GET', '/api/local/info').then(function (info) { req('GET', '/api/local/info').then(function (info) {
+3 -2
View File
@@ -910,8 +910,9 @@
// 全部成功不再弹提示(卡片已完成态即反馈);有失败才提醒 // 全部成功不再弹提示(卡片已完成态即反馈);有失败才提醒
if (errCount) toast('已上传 ' + done + ' 个,失败 ' + errCount + ' 个'); if (errCount) toast('已上传 ' + done + ' 个,失败 ' + errCount + ' 个');
loadFiles(); loadFiles();
// 桌面端左栏文件树是新的浏览入口,上传后要同步(旧面板只在手机端用) // 桌面端左栏文件树是新的浏览入口,上传后要同步(旧面板只在手机端用);
if (typeof window.refreshFileTree === 'function') window.refreshFileTree(); // 用 reloadFileTree 保留展开与勾选,refreshFileTree 会把用户展开的目录全收起来
if (typeof window.reloadFileTree === 'function') window.reloadFileTree();
// 1.2s 后收起进度条(还有别的批次在传就不收) // 1.2s 后收起进度条(还有别的批次在传就不收)
setTimeout(() => { setTimeout(() => {
if (uploadBatches.size) return; if (uploadBatches.size) return;
+2
View File
@@ -124,6 +124,8 @@
}).catch(() => {}).then(() => { }).catch(() => {}).then(() => {
sseResyncing = false; sseResyncing = false;
if (state.sessionId === id && state.view === 'chat' && !state.es) connectStream(); if (state.sessionId === id && state.view === 'chat' && !state.es) connectStream();
// 断点期间的文件变动看不到任何 SSE,补拉完顺手重刷一次文件树
if (typeof window.reloadFileTree === 'function') window.reloadFileTree();
}); });
} }
setInterval(() => { setInterval(() => {
+3
View File
@@ -473,6 +473,9 @@
state.toolCallStreaming = {}; // 流式参数早卡映射随会话/回合重置 state.toolCallStreaming = {}; // 流式参数早卡映射随会话/回合重置
updateScrollBottomBtn(); updateScrollBottomBtn();
loadSessionList(); loadSessionList();
// 一轮完整跑完(agent 循环退出才发 done):工具/技能产物可能新增或改名,文件树就地刷新;
// 不在文件树面板时 reloadFileTree 只标脏,等切回去再重拉
if (typeof window.reloadFileTree === 'function') window.reloadFileTree();
}); });
// 服务端首次交互后自动生成的标题(finalize 后约 1s 到达):即时刷新顶栏 + 重拉会话列表(PC 常驻侧边栏/移动抽屉) // 服务端首次交互后自动生成的标题(finalize 后约 1s 到达):即时刷新顶栏 + 重拉会话列表(PC 常驻侧边栏/移动抽屉)
es.addEventListener('title', ev => { es.addEventListener('title', ev => {