4 Commits
Author SHA1 Message Date
kicer b018ba7864 feat(ui): Git 面板列表把 origin/master 标在它指向的提交上
列表只有本地历史,看不出哪条远端已经有了,也就判断不出本地领先几条。

ensureRepo 多返回 upstream(优先当前分支的 upstream,没配回退 origin/master),
列表渲染时给 id 相同的那条挂一枚 origin/master 徽章、行首加一条蓝竖线,
和 git log --decorate 一个意思。
2026-11-13 18:05:54 +08:00
kicer c07fc3be58 fix(ui): 手机端 HTML 预览底部那条白边
.fs-html-frame 是 <iframe>,默认 display:inline,作为行内元素参与行盒排版,底部会留出
4~5px 的基线间隙;#fs-body 又是 overflow:auto,这点溢出让容器能滚,手指上下滑就把底下
的背景露出来,看着像一条细白条。

display 改成 block 消掉间隙(根因),fs-bar 外层 overflow 从 auto 改成 hidden,不让它
再有滚动露底的机会——文本与源码的滚动仍由 #fs-body / #fs-src-pane 各自负责。
2026-11-13 18:03:45 +08:00
kicer a0195c710b feat(ui): Git 面板列表头显示 remote
列表只有仓库路径和分支,看不出这个仓库推到哪、也没法一眼确认有没有配远端。

ensureRepo 多读一条 git remote -v(取第一条 fetch,origin 惯例在最前),
URL 里的 user:pass 先脱敏再给前端;列表头渲染成「路径 · 分支 · origin」,
悬停看完整地址,没配 remote 时灰色标「无 remote」。
2026-11-13 18:00:56 +08:00
kicer 71f3cdb694 feat(ui): 主题切换挪到会话头部动作区,手机端进「更多」菜单
原来放在文件树头部,只有开着文件树才看得到;切到会话页/欢迎页就没有入口。

桌面放到头部动作区「新建会话」左边(.ha-icons),手机收进「更多」下拉菜单,
与切换模型/定时任务/压缩上下文同一套 data-act 分发,点完自动收起菜单。
files-tree.js 里那份按钮和主题逻辑一并删掉,统一到 sessions.js。

手机菜单项按现有写法拆成主文案「切换主题」+ 副标题「浅色/深色」,与其他
动作项一致(主文案是动作,副标题才是当前值)。
2026-11-13 17:59:08 +08:00
6 changed files with 77 additions and 41 deletions
+18 -1
View File
@@ -47,7 +47,24 @@ async function ensureRepo(dir) {
let head = '';
try { branch = (await run(root, ['symbolic-ref', '--short', '-q', 'HEAD'])).trim(); } catch (_) { /* detached */ }
try { head = (await run(root, ['rev-parse', '--short', 'HEAD'])).trim(); } catch (_) { /* 空仓库 */ }
return { root, branch: branch || (head ? 'detached' : ''), head };
// remote:列表里要能看出这个仓库推到哪。只取第一条 fetch(origin 惯例在最前);
// URL 里的 user:pass 脱敏,免得面板上直接暴露凭据。
let remote = null;
try {
const first = (await run(root, ['remote', '-v'])).split('\n').filter(Boolean)[0] || '';
const m = /^(\S+)\s+(\S+)\s+\(fetch\)/.exec(first);
if (m) remote = { name: m[1], url: m[2].replace(/\/\/[^/@]+@/, '//***@') };
} catch (_) { /* 没配 remote */ }
// upstream:列表要把 origin/master 标在它指向的那条提交上,一眼看出本地领先几条。
// 优先当前分支的 upstream,没配就回退 origin/master。
let upstream = null;
try {
const ref = (await run(root, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'])).trim();
if (ref) upstream = { ref, id: (await run(root, ['rev-parse', ref])).trim() };
} catch (_) {
try { upstream = { ref: 'origin/master', id: (await run(root, ['rev-parse', 'origin/master'])).trim() }; } catch (__) { upstream = null; }
}
return { root, branch: branch || (head ? 'detached' : ''), head, remote, upstream };
}
// 把一个整段 diff 按 `diff --git` 切开,键是文件路径。
+11 -2
View File
@@ -1386,7 +1386,7 @@ body.voice-active .scroll-bottom-btn { display: none; }
/* 文件预览沉浸模式:40px 操作条 + 全宽内容。内容从条下开始,不会叠在页面自己的顶部按钮上;
宽度一点不让(手机横向最贵),只牺牲一条操作栏的高度。 */
#fs-viewer.fs-bar { display: flex; flex-direction: column; padding: 0; overflow: auto; background: var(--page); }
#fs-viewer.fs-bar { display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--page); }
#fs-viewer.fs-bar .fs-actions {
position: sticky; top: 0; z-index: 1;
flex: none; width: 100%;
@@ -1432,7 +1432,8 @@ body.voice-active .scroll-bottom-btn { display: none; }
#fs-body .tool-card pre { max-height: 65vh; }
/* HTML 预览:沙箱 iframe 铺满全屏查看器 */
.fs-html-frame { width: 100%; height: 100%; min-height: 70vh; border: 0; background: var(--bg-fff); border-radius: 12px; }
/* iframe 默认是 inline:不改成 block 会在底部留一条行盒基线间隙(手机端滑动时露出白条) */
.fs-html-frame { display: block; width: 100%; height: 100%; min-height: 70vh; border: 0; background: var(--bg-fff); border-radius: 12px; }
/* 图片预览:fs-viewer 居中缩放显示原图,大图可滚动 */
.fs-img-frame { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; border-radius: 8px; object-fit: contain; background: var(--bg-fff); }
@@ -1923,10 +1924,18 @@ body.pv-max .pv-code { max-width: none; padding-left: 16px; padding-right: 16px;
.vcs-repo { padding: 9px 16px; border-bottom: 1px solid var(--border); background: var(--drawer-bg);
font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--gray);
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 列表头里的 remote 名:悬停看 URL(已脱敏);没配 remote 时灰色注明 */
.vcs-repo .vcs-remote { color: var(--fg-0550ae); cursor: help; }
.vcs-repo .vcs-remote.none { color: var(--gray); }
.vcs-empty { padding: 44px 24px; text-align: center; font-size: 13px; color: var(--gray-light); }
.vcs-item { padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.vcs-item:hover { background: var(--surface); }
.vcs-item .t { font-size: 13.5px; font-weight: 600; color: var(--ink); word-break: break-word; line-height: 1.45; }
/* 远端分支(origin/master)指向的那条提交:标题后挂一枚小标签,一眼看出本地领先几条 */
.vcs-up { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
font: 600 10.5px/17px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
color: var(--fg-0550ae); background: var(--bg-dbeafe); vertical-align: 1px; }
.vcs-item.at-up { box-shadow: inset 3px 0 0 var(--active); }
.vcs-item .m { margin-top: 3px; font-size: 12px; color: var(--gray); }
.vcs-item .m code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
/* 「未提交的改动」入口:列表顶部单独一行,与提交行区分 */
+9
View File
@@ -193,6 +193,10 @@
桌面属性区与菜单项共用 data-act,事件统一在 sessions.js 分发。 -->
<div class="header-actions" id="header-actions">
<div class="ha-icons">
<button class="icon-btn ha-btn" data-act="theme" id="theme-toggle" data-tip="主题:浅色" aria-label="切换主题">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-theme-light"/></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24"><use href="#i-theme-dark"/></svg>
</button>
<button class="icon-btn ha-btn" data-act="new" data-tip="新建会话" aria-label="新建会话">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-plus"/></svg>
</button>
@@ -213,6 +217,11 @@
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-database"/></svg>
<span class="ha-item-main">压缩上下文</span>
</button>
<button class="ha-item" role="menuitem" data-act="theme" id="theme-toggle-mobile">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-theme-light"/></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24"><use href="#i-theme-dark"/></svg>
<span class="ha-item-main">切换主题</span><span class="ha-item-sub" id="theme-label-mobile">浅色</span>
</button>
<button class="ha-item" role="menuitem" data-act="new">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-plus"/></svg>
<span class="ha-item-main">新建会话</span>
-35
View File
@@ -18,8 +18,6 @@
const SVG_EYE = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-eye-sm"/></svg>';
const SVG_DL = '<svg viewBox="0 0 24 24"><use href="#i-download"/></svg>';
const SVG_DEL = '<svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>';
const SVG_THEME = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-theme-light"/></svg>' +
'<svg class="ic sm hidden" viewBox="0 0 24 24"><use href="#i-theme-dark"/></svg>';
const SVG_REVEAL_SM = '<svg viewBox="0 0 24 24"><use href="#i-external-b"/></svg>';
let localCapable = false; // local 启动器:才显示「在 Finder/终端中打开」
@@ -396,34 +394,6 @@
}
// local 能力探测结果回来后才把「在 Finder/终端中打开」露出来(服务器形态永远隐藏)
// ---------- 主题(auto / light / dark 三态循环)----------
// 色板全在 style.css 的变量里,这里只负责落 data-theme 与两态图标。
const THEME_ORDER = ['light', 'dark'];
const THEME_LABEL = ['主题:浅色', '主题:深色'];
function themeMode() { return document.documentElement.getAttribute('data-theme-mode') === 'dark' ? 'dark' : 'light'; }
function applyTheme(mode) {
const m = mode === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', m);
document.documentElement.setAttribute('data-theme-mode', m);
try { localStorage.setItem('agent-theme', m); } catch (_) {}
const meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute('content', m === 'dark' ? '#0d1117' : '#3964FE');
syncThemeBtn();
}
function cycleTheme() {
applyTheme(themeMode() === 'dark' ? 'light' : 'dark');
}
function syncThemeBtn() {
const btn = $('tree-theme');
if (!btn) return;
const i = themeMode() === 'dark' ? 1 : 0;
btn.title = THEME_LABEL[i];
btn.setAttribute('aria-label', THEME_LABEL[i]);
btn.querySelectorAll('svg').forEach(function (s, k) { s.classList.toggle('hidden', k !== i); });
}
window.applyTheme = applyTheme;
window.cycleTheme = cycleTheme;
window.syncThemeBtn = syncThemeBtn;
function syncLocalButtons() {
const rv = $('tree-reveal'), tm = $('tree-terminal');
@@ -455,7 +425,6 @@
'<button class="icon-btn" type="button" id="tree-vcs" title="Git 改动与历史" aria-label="Git 改动与历史">' + SVG_VCS + '</button>' +
'</span>' +
'<span class="pv-actions tree-actions-ext">' +
'<button class="icon-btn" type="button" id="tree-theme" title="主题:浅色" aria-label="切换主题">' + SVG_THEME + '</button>' +
'<button class="icon-btn hidden" type="button" id="tree-reveal" title="在 Finder 中打开" aria-label="在 Finder 中打开">' + SVG_REVEAL + '</button>' +
'<button class="icon-btn hidden" type="button" id="tree-terminal" title="在终端中打开" aria-label="在终端中打开">' + SVG_TERM + '</button>' +
'</span>';
@@ -477,9 +446,6 @@
box.appendChild(body);
box.appendChild(foot);
head.querySelector('#tree-theme').addEventListener('click', function () {
if (typeof cycleTheme === 'function') cycleTheme();
});
head.querySelector('#tree-hidden').addEventListener('click', function () {
showHidden = !showHidden;
invalidate(false);
@@ -501,7 +467,6 @@
body.addEventListener('click', onTreeClick);
syncLocalButtons();
syncThemeBtn();
}
// 侧栏底部「文件树」图标 → 切到这个面板(由 files.js 的 setDrawerPane 调用)。
+30
View File
@@ -491,8 +491,37 @@
if (act === 'model') openModelSwitch();
else if (act === 'schedule') openScheduleModal();
else if (act === 'compact') summarizeChat();
else if (act === 'theme') cycleTheme();
else if (act === 'new') newChat();
}
// ---------- 主题(浅/深两态,默认浅色;色板全在 style.css 变量里)----------
function themeMode() { return document.documentElement.getAttribute('data-theme-mode') === 'dark' ? 'dark' : 'light'; }
function applyTheme(mode) {
const m = mode === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', m);
document.documentElement.setAttribute('data-theme-mode', m);
try { localStorage.setItem('agent-theme', m); } catch (_) {}
const meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute('content', m === 'dark' ? '#0d1117' : '#3964FE');
syncThemeBtns();
}
function cycleTheme() { applyTheme(themeMode() === 'dark' ? 'light' : 'dark'); }
function syncThemeBtns() {
const dark = themeMode() === 'dark';
const lbl = dark ? '主题:深色' : '主题:浅色';
['theme-toggle', 'theme-toggle-mobile'].forEach(function (id) {
const b = $(id);
if (!b) return;
b.querySelectorAll('svg').forEach(function (s, k) { s.classList.toggle('hidden', k !== (dark ? 1 : 0)); });
});
const t = $('theme-toggle');
if (t) { t.title = lbl; t.dataset.tip = lbl; }
const lab = $('theme-label-mobile');
if (lab) lab.textContent = dark ? '深色' : '浅色'; // 副标题只写当前值,主文案是动作
}
window.applyTheme = applyTheme;
window.cycleTheme = cycleTheme;
// 桌面属性区(模型/定时任务/压缩)与移动菜单项共用同一批 data-act,事件只在这里绑一次。
(function bindHeaderActions() {
document.querySelectorAll('#header-meta [data-act], #header-actions [data-act]').forEach(el => {
@@ -505,6 +534,7 @@
if (!e.target.closest('#header-actions')) closeHeaderMenu();
});
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeHeaderMenu(); });
syncThemeBtns(); // 按钮图标/文字跟着当前主题落一次
})();
// ---------- 定时任务(弹窗改频次/提示词;无任务时同一弹窗即新建) ----------
+9 -3
View File
@@ -54,16 +54,22 @@
const parts = [];
parts.push('<div class="vcs-list">');
if (st.repo) {
parts.push('<div class="vcs-repo">' + esc(st.repo.root) + (st.repo.branch ? ' · ' + esc(st.repo.branch) : '') + '</div>');
const rm = st.repo.remote;
parts.push('<div class="vcs-repo">' + esc(st.repo.root) + (st.repo.branch ? ' · ' + esc(st.repo.branch) : '') +
' · <span class="vcs-remote' + (rm ? '' : ' none') + '" title="' + esc(rm ? rm.url : '未配置 remote') + '">' +
esc(rm ? rm.name : '无 remote') + '</span></div>');
}
if (st.worktree && st.worktree.files) {
parts.push('<div class="vcs-item wt" data-act="worktree">' +
'<div class="t">未提交的改动</div>' +
'<div class="m">' + st.worktree.files + ' 个文件有变动</div></div>');
}
const up = st.repo && st.repo.upstream;
for (const c of st.commits) {
parts.push('<div class="vcs-item" data-act="commit" data-id="' + esc(c.id) + '">' +
'<div class="t">' + esc(c.subject) + '</div>' +
const atUp = up && c.id === up.id;
parts.push('<div class="vcs-item' + (atUp ? ' at-up' : '') + '" data-act="commit" data-id="' + esc(c.id) + '">' +
'<div class="t">' + esc(c.subject) +
(atUp ? ' <span class="vcs-up" title="远端 ' + esc(up.ref) + ' 指向这里">' + esc(up.ref) + '</span>' : '') + '</div>' +
'<div class="m">' + esc(c.author) + ' · ' + esc(fmtTime(c.time)) + ' · ' + esc(c.short) + '</div></div>');
}
if (!st.commits.length && !(st.worktree && st.worktree.files)) {