Compare commits
4
Commits
76297a8978
...
b018ba7864
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b018ba7864 | ||
|
|
c07fc3be58 | ||
|
|
a0195c710b | ||
|
|
71f3cdb694 |
+18
-1
@@ -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` 切开,键是文件路径。
|
||||
|
||||
@@ -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; }
|
||||
/* 「未提交的改动」入口:列表顶部单独一行,与提交行区分 */
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 调用)。
|
||||
|
||||
@@ -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(); // 按钮图标/文字跟着当前主题落一次
|
||||
})();
|
||||
|
||||
// ---------- 定时任务(弹窗改频次/提示词;无任务时同一弹窗即新建) ----------
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user