@vincentbanana/banana-gui 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/ui/app.js +516 -73
- package/ui/index.html +9 -4
- package/ui/style.css +317 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincentbanana/banana-gui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Banana 的图形界面:本地服务 + 浏览器。黑白主题,自绘图标,无第三方 UI 依赖",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"electron-builder": "^25.0.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@vincentbanana/bananacli": "^0.
|
|
74
|
+
"@vincentbanana/bananacli": "^0.7.1"
|
|
75
75
|
},
|
|
76
76
|
"license": "MIT",
|
|
77
77
|
"publishConfig": {
|
package/ui/app.js
CHANGED
|
@@ -8,6 +8,7 @@ const ICONS = {
|
|
|
8
8
|
send: '<path d="M12 19V5M6 11l6-6 6 6"/>',
|
|
9
9
|
stop: '<rect x="7" y="7" width="10" height="10" rx="1.5"/>',
|
|
10
10
|
chip: '<rect x="7" y="7" width="10" height="10" rx="2"/><path d="M10 4v3M14 4v3M10 17v3M14 17v3M4 10h3M4 14h3M17 10h3M17 14h3"/>',
|
|
11
|
+
chevronDown: '<path d="M6 9l6 6 6-6"/>',
|
|
11
12
|
sliders: '<path d="M4 8h8M16 8h4M4 16h4M12 16h8"/><circle cx="14" cy="8" r="2"/><circle cx="10" cy="16" r="2"/>',
|
|
12
13
|
undo: '<path d="M9 8H4m0 0 3.5-3.5M4 8h9a6 6 0 0 1 0 12h-4"/>',
|
|
13
14
|
trash: '<path d="M5 7h14M10 7V5h4v2M7 7l1 13h8l1-13"/>',
|
|
@@ -42,6 +43,9 @@ const ICONS = {
|
|
|
42
43
|
restore: '<rect x="5" y="8" width="9" height="9" rx="1"/><path d="M9 5h9v9"/>',
|
|
43
44
|
diff: '<path d="M6 4v16M18 4v16M3 8h6M15 16h6M3 16h6M15 8h6"/>',
|
|
44
45
|
refresh: '<path d="M20 11a8 8 0 1 0-2.3 5.7"/><path d="M20 5v6h-6"/>',
|
|
46
|
+
history: '<path d="M3.5 12a8.5 8.5 0 1 0 2.8-6.3"/><path d="M3.5 4.5v5h5"/><path d="M12 8v4.5l3 1.8"/>',
|
|
47
|
+
attach: '<path d="M20 11.5l-7.8 7.8a5 5 0 0 1-7-7L13 4.5a3.4 3.4 0 0 1 4.8 4.8L10 17a1.8 1.8 0 0 1-2.5-2.5l6.7-6.7"/>',
|
|
48
|
+
arrowDown: '<path d="M12 5v14M6 13l6 6 6-6"/>',
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
const TOOL_ICON = {
|
|
@@ -181,6 +185,8 @@ const state = {
|
|
|
181
185
|
review: { open: false, mode: 'changes', width: 520 },
|
|
182
186
|
sidebar: { open: true, width: 344 },
|
|
183
187
|
sessionQuery: '',
|
|
188
|
+
status: '',
|
|
189
|
+
stickToBottom: true,
|
|
184
190
|
dock: { open: false, height: 280 },
|
|
185
191
|
changes: null,
|
|
186
192
|
changesFile: null,
|
|
@@ -221,7 +227,7 @@ function relativeTime(iso) {
|
|
|
221
227
|
|
|
222
228
|
/** 窄屏下侧边栏是覆盖层,选完会话必须收起来,否则挡住对话。 */
|
|
223
229
|
function closeSidebarIfOverlay() {
|
|
224
|
-
if (window.matchMedia('(max-width: 900px)').matches
|
|
230
|
+
if (window.matchMedia('(max-width: 900px)').matches && state.sidebar.open) setSidebar(false);
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
let switching = false;
|
|
@@ -298,8 +304,10 @@ function renderTabs() {
|
|
|
298
304
|
node.draggable = true;
|
|
299
305
|
node.dataset.id = tab.id;
|
|
300
306
|
const title = tabTitleFor(tab.id) || tab.title || '新对话';
|
|
307
|
+
const isNew = title === '新对话';
|
|
308
|
+
node.classList.toggle('is-running', state.busy && tab.id === state.activeTab);
|
|
301
309
|
node.innerHTML =
|
|
302
|
-
`<span class="tab-avatar">${escapeHtml(title.slice(0, 1))}</span>` +
|
|
310
|
+
`<span class="tab-avatar${isNew ? ' is-new' : ''}">${isNew ? '' : escapeHtml(title.slice(0, 1))}</span>` +
|
|
303
311
|
`<span class="tab-title">${escapeHtml(title)}</span>` +
|
|
304
312
|
`<span class="tab-close" title="关闭标签"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></span>`;
|
|
305
313
|
node.addEventListener('pointerdown', (event) => {
|
|
@@ -523,6 +531,50 @@ function downloadSession(format, id) {
|
|
|
523
531
|
toast(`已导出 ${format === 'json' ? 'JSON' : 'Markdown'}`);
|
|
524
532
|
}
|
|
525
533
|
|
|
534
|
+
function toolSummaryText(call) {
|
|
535
|
+
const input = call.input ?? {};
|
|
536
|
+
if (typeof input.command === 'string') return input.command;
|
|
537
|
+
return JSON.stringify(input).slice(0, 110);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function ensureToolOutput(row, initial = '', isError = false) {
|
|
541
|
+
let out = row.nextElementSibling;
|
|
542
|
+
if (!out || !out.classList.contains('tool-output')) {
|
|
543
|
+
out = document.createElement('div');
|
|
544
|
+
out.className = 'tool-output';
|
|
545
|
+
out.hidden = true;
|
|
546
|
+
row.after(out);
|
|
547
|
+
}
|
|
548
|
+
out.classList.toggle('is-error', isError);
|
|
549
|
+
if (initial) out.textContent = initial;
|
|
550
|
+
row.classList.add('is-clickable');
|
|
551
|
+
row.title = '点击展开命令输出';
|
|
552
|
+
if (!row.dataset.bound) {
|
|
553
|
+
row.dataset.bound = '1';
|
|
554
|
+
row.addEventListener('click', () => {
|
|
555
|
+
const box = row.nextElementSibling;
|
|
556
|
+
if (!box?.classList.contains('tool-output')) return;
|
|
557
|
+
const open = box.hidden;
|
|
558
|
+
box.hidden = !open;
|
|
559
|
+
row.classList.toggle('is-open', open);
|
|
560
|
+
row.title = open ? '点击收起命令输出' : '点击展开命令输出';
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
return out;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function toolRowNode(name, detail, stateHtml, ms) {
|
|
567
|
+
const row = document.createElement('div');
|
|
568
|
+
row.className = 'tool-row';
|
|
569
|
+
row.innerHTML =
|
|
570
|
+
`<span class="t-ico">${svg(TOOL_ICON[name] ?? 'file')}</span>` +
|
|
571
|
+
`<span class="t-name">${escapeHtml(name)}</span>` +
|
|
572
|
+
`<span class="t-detail">${escapeHtml(detail)}</span>` +
|
|
573
|
+
`<span class="t-state">${stateHtml}</span>` +
|
|
574
|
+
(ms ? `<span class="t-time">${(ms / 1000).toFixed(1)}s</span>` : '');
|
|
575
|
+
return row;
|
|
576
|
+
}
|
|
577
|
+
|
|
526
578
|
function toolGroup(calls, results) {
|
|
527
579
|
const wrap = document.createElement('details');
|
|
528
580
|
wrap.className = 'work-group';
|
|
@@ -537,19 +589,13 @@ function toolGroup(calls, results) {
|
|
|
537
589
|
body.className = 'tool-group-body';
|
|
538
590
|
for (const call of calls) {
|
|
539
591
|
const result = results.get(call.id);
|
|
540
|
-
const row =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
`<span class="t-state">${result ? (result.isError ? '失败' : escapeHtml(result.content?.slice(0, 40) ?? '完成')) : '已调用'}</span>`;
|
|
548
|
-
if (result?.content) {
|
|
549
|
-
row.classList.add('is-clickable');
|
|
550
|
-
row.title = '点击展开输出';
|
|
551
|
-
row.addEventListener('click', () => toggleToolOutput(row, result.content, Boolean(result.isError)));
|
|
552
|
-
}
|
|
592
|
+
const row = toolRowNode(
|
|
593
|
+
call.name,
|
|
594
|
+
toolSummaryText(call),
|
|
595
|
+
result ? (result.isError ? '失败' : '完成') : '已调用',
|
|
596
|
+
);
|
|
597
|
+
row.classList.toggle('is-error', Boolean(result?.isError));
|
|
598
|
+
if (result?.content) ensureToolOutput(row, result.content, Boolean(result.isError));
|
|
553
599
|
body.appendChild(row);
|
|
554
600
|
}
|
|
555
601
|
wrap.append(summary, body);
|
|
@@ -560,10 +606,12 @@ function reasoningDetails(text) {
|
|
|
560
606
|
const details = document.createElement('details');
|
|
561
607
|
details.className = 'think';
|
|
562
608
|
const summary = document.createElement('summary');
|
|
563
|
-
summary.innerHTML =
|
|
609
|
+
summary.innerHTML =
|
|
610
|
+
'<span class="think-title">思考</span>' +
|
|
611
|
+
`<span class="think-len">${Math.max(1, Math.round(text.length / 1000))}k 字</span>`;
|
|
564
612
|
const body = document.createElement('div');
|
|
565
613
|
body.className = 'think-body';
|
|
566
|
-
body.
|
|
614
|
+
body.innerHTML = markdown(text);
|
|
567
615
|
details.append(summary, body);
|
|
568
616
|
return details;
|
|
569
617
|
}
|
|
@@ -654,6 +702,8 @@ function renderEmpty() {
|
|
|
654
702
|
|
|
655
703
|
function renderThread() {
|
|
656
704
|
THREAD.innerHTML = '';
|
|
705
|
+
state.stickToBottom = true;
|
|
706
|
+
$('jumpLatest').hidden = true;
|
|
657
707
|
const messages = state.info?.session?.messages ?? [];
|
|
658
708
|
if (messages.length === 0) THREAD.appendChild(renderEmpty());
|
|
659
709
|
else {
|
|
@@ -673,6 +723,7 @@ function renderThread() {
|
|
|
673
723
|
|
|
674
724
|
function renderTurnMeta() {
|
|
675
725
|
const meta = $('threadMeta');
|
|
726
|
+
if (state.busy && state.status) { meta.textContent = state.status; return; }
|
|
676
727
|
const usage = state.info?.session?.usage;
|
|
677
728
|
if (!usage || (!usage.inputTokens && !usage.outputTokens)) { meta.textContent = ''; return; }
|
|
678
729
|
const parts = [`↑${usage.inputTokens} ↓${usage.outputTokens}`];
|
|
@@ -680,19 +731,37 @@ function renderTurnMeta() {
|
|
|
680
731
|
meta.textContent = parts.join(' · ');
|
|
681
732
|
}
|
|
682
733
|
|
|
683
|
-
function scrollToEnd(smooth = true) {
|
|
734
|
+
function scrollToEnd(smooth = true, force = false) {
|
|
735
|
+
if (!force && state.busy && !state.stickToBottom) return;
|
|
684
736
|
requestAnimationFrame(() => {
|
|
685
737
|
THREAD.scrollTo({ top: THREAD.scrollHeight, behavior: smooth ? 'smooth' : 'auto' });
|
|
686
738
|
});
|
|
687
739
|
}
|
|
688
740
|
|
|
741
|
+
function setStatus(text) {
|
|
742
|
+
state.status = text || '';
|
|
743
|
+
const hint = $('composerHint');
|
|
744
|
+
if (hint) {
|
|
745
|
+
hint.textContent = text || workspaceHint();
|
|
746
|
+
hint.dataset.kind = text ? 'live' : 'idle';
|
|
747
|
+
}
|
|
748
|
+
const meta = $('threadMeta');
|
|
749
|
+
if (meta && text && state.busy) meta.textContent = text;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function workspaceHint() {
|
|
753
|
+
const info = state.info;
|
|
754
|
+
if (!info) return '';
|
|
755
|
+
return `工作区 ${info.workspace} · ${info.tools.length} 个工具 · shell=${info.permissions.shell} write=${info.permissions.write} network=${info.permissions.network}`;
|
|
756
|
+
}
|
|
757
|
+
|
|
689
758
|
function renderHeader() {
|
|
690
759
|
const info = state.info;
|
|
691
760
|
if (!info) return;
|
|
692
761
|
$('threadTitle').textContent = info.session.title || '新对话';
|
|
693
762
|
$('modelLabel').textContent = `${info.provider.name} / ${info.provider.model}`;
|
|
694
|
-
$('composerHint').textContent =
|
|
695
|
-
|
|
763
|
+
if (!state.busy) $('composerHint').textContent = workspaceHint();
|
|
764
|
+
else if (state.status) $('composerHint').textContent = state.status;
|
|
696
765
|
renderTurnMeta();
|
|
697
766
|
}
|
|
698
767
|
|
|
@@ -883,14 +952,31 @@ function grow() {
|
|
|
883
952
|
const input = $('input');
|
|
884
953
|
input.style.height = 'auto';
|
|
885
954
|
input.style.height = Math.min(input.scrollHeight, 220) + 'px';
|
|
886
|
-
$('sendBtn')
|
|
955
|
+
const send = $('sendBtn');
|
|
956
|
+
if (!state.busy) send.disabled = input.value.trim() === '';
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
function stopTurn() {
|
|
960
|
+
if (!state.busy) return;
|
|
961
|
+
setStatus('正在停止…');
|
|
962
|
+
controller?.abort();
|
|
963
|
+
void post('abort').catch(() => {});
|
|
887
964
|
}
|
|
888
965
|
|
|
889
966
|
function setBusy(busy) {
|
|
890
967
|
state.busy = busy;
|
|
891
|
-
$('
|
|
892
|
-
$('
|
|
968
|
+
const send = $('sendBtn');
|
|
969
|
+
const composer = $('composer');
|
|
970
|
+
composer?.classList.toggle('is-busy', busy);
|
|
971
|
+
// 发送键在原位切换成停止键,不再让用户去右上角找
|
|
972
|
+
send.innerHTML = busy ? svg('stop') : svg('send');
|
|
973
|
+
send.title = busy ? '停止生成' : '发送';
|
|
974
|
+
send.setAttribute('aria-label', busy ? '停止生成' : '发送');
|
|
975
|
+
send.dataset.mode = busy ? 'stop' : 'send';
|
|
976
|
+
send.disabled = busy ? false : $('input').value.trim() === '';
|
|
977
|
+
$('abortBtn').hidden = true;
|
|
893
978
|
document.body.style.cursor = busy ? 'progress' : '';
|
|
979
|
+
if (state.tabs?.length) renderTabs();
|
|
894
980
|
}
|
|
895
981
|
|
|
896
982
|
function askApproval(payload) {
|
|
@@ -917,6 +1003,7 @@ async function send() {
|
|
|
917
1003
|
const input = $('input');
|
|
918
1004
|
const text = input.value.trim();
|
|
919
1005
|
if (!text || state.busy) return;
|
|
1006
|
+
if (!state.info?.session) return;
|
|
920
1007
|
input.value = '';
|
|
921
1008
|
grow();
|
|
922
1009
|
closePalette();
|
|
@@ -927,11 +1014,17 @@ async function send() {
|
|
|
927
1014
|
return;
|
|
928
1015
|
}
|
|
929
1016
|
|
|
930
|
-
|
|
1017
|
+
const messages = state.info.session.messages ?? (state.info.session.messages = []);
|
|
1018
|
+
if (messages.length === 0 && state.info.session.title === '新对话') {
|
|
931
1019
|
state.info.session.title = text.slice(0, 40);
|
|
932
1020
|
renderHeader();
|
|
933
1021
|
}
|
|
934
|
-
|
|
1022
|
+
|
|
1023
|
+
// 首页空状态整块移除,否则第一条消息会被追加在 wordmark 下面
|
|
1024
|
+
THREAD.querySelector('.empty')?.remove();
|
|
1025
|
+
$('chatCard').classList.remove('home-mode');
|
|
1026
|
+
$('homeTips').hidden = true;
|
|
1027
|
+
messages.push({ role: 'user', content: text });
|
|
935
1028
|
|
|
936
1029
|
const userMsg = document.createElement('article');
|
|
937
1030
|
userMsg.className = 'msg user enter';
|
|
@@ -940,8 +1033,12 @@ async function send() {
|
|
|
940
1033
|
userBody.className = 'msg-body';
|
|
941
1034
|
userBody.textContent = text;
|
|
942
1035
|
userMsg.appendChild(userBody);
|
|
1036
|
+
messageActions(userMsg, text, 'user');
|
|
1037
|
+
const divider = document.createElement('div');
|
|
1038
|
+
divider.className = 'thread-divider';
|
|
1039
|
+
if (!THREAD.querySelector('.thread-divider')) THREAD.appendChild(divider);
|
|
943
1040
|
THREAD.appendChild(userMsg);
|
|
944
|
-
|
|
1041
|
+
scrollToEnd(false);
|
|
945
1042
|
|
|
946
1043
|
const botMsg = document.createElement('article');
|
|
947
1044
|
botMsg.className = 'msg assistant enter';
|
|
@@ -959,38 +1056,72 @@ async function send() {
|
|
|
959
1056
|
work.append(workSummary, workBody);
|
|
960
1057
|
work.classList.add('is-running');
|
|
961
1058
|
|
|
962
|
-
//
|
|
1059
|
+
// 思考过程:流式时就保持结构化,随时可折叠
|
|
963
1060
|
const reasoning = document.createElement('details');
|
|
964
|
-
reasoning.className = 'think';
|
|
1061
|
+
reasoning.className = 'think is-live';
|
|
965
1062
|
reasoning.hidden = true;
|
|
966
1063
|
reasoning.open = true;
|
|
967
1064
|
const reasonSummary = document.createElement('summary');
|
|
968
|
-
reasonSummary.innerHTML = '<span class="think-title">思考中…</span>';
|
|
1065
|
+
reasonSummary.innerHTML = '<span class="think-title">思考中…</span><span class="think-len"></span>';
|
|
969
1066
|
const reasonBody = document.createElement('div');
|
|
970
1067
|
reasonBody.className = 'think-body';
|
|
971
1068
|
reasoning.append(reasonSummary, reasonBody);
|
|
1069
|
+
// 用户手动收起后,后续流式内容不再强行展开
|
|
1070
|
+
reasonSummary.addEventListener('click', () => {
|
|
1071
|
+
reasoning.dataset.user = '1';
|
|
1072
|
+
});
|
|
972
1073
|
|
|
973
1074
|
const body = document.createElement('div');
|
|
974
1075
|
body.className = 'msg-body caret';
|
|
1076
|
+
body.setAttribute('aria-live', 'polite');
|
|
975
1077
|
const meta = document.createElement('div');
|
|
976
1078
|
meta.className = 'turn-meta';
|
|
977
1079
|
const working = document.createElement('div');
|
|
978
1080
|
working.className = 'working-row';
|
|
979
|
-
working.innerHTML = '<span class="wg-dot"></span><span class="shimmer">Banana 正在运行</span>';
|
|
1081
|
+
working.innerHTML = '<span class="wg-dot"></span><span class="shimmer working-text">Banana 正在运行</span>';
|
|
980
1082
|
botMsg.append(working, work, reasoning, body, meta);
|
|
981
1083
|
THREAD.appendChild(botMsg);
|
|
982
1084
|
|
|
983
1085
|
let reasoningStarted = 0;
|
|
1086
|
+
let reasoningText = '';
|
|
1087
|
+
let reasonPending = 0;
|
|
984
1088
|
let toolStarted = 0;
|
|
985
1089
|
let toolCount = 0;
|
|
986
1090
|
let toolErrors = false;
|
|
1091
|
+
const toolRows = new Map();
|
|
1092
|
+
|
|
1093
|
+
const paintReasoning = (final = false) => {
|
|
1094
|
+
reasonPending = 0;
|
|
1095
|
+
const text = reasoningText;
|
|
1096
|
+
reasonBody.innerHTML = markdown(text);
|
|
1097
|
+
const len = reasonSummary.querySelector('.think-len');
|
|
1098
|
+
if (len) len.textContent = text.length > 999 ? `${(text.length / 1000).toFixed(1)}k 字` : `${text.length} 字`;
|
|
1099
|
+
if (final) reasoning.classList.remove('is-live');
|
|
1100
|
+
// 只有用户没有上滚时才跟随最新思考
|
|
1101
|
+
const nearBottom = reasonBody.scrollHeight - reasonBody.scrollTop - reasonBody.clientHeight < 40;
|
|
1102
|
+
if (nearBottom) reasonBody.scrollTop = reasonBody.scrollHeight;
|
|
1103
|
+
};
|
|
1104
|
+
const scheduleReasoning = () => {
|
|
1105
|
+
if (!reasonPending) reasonPending = requestAnimationFrame(() => paintReasoning(false));
|
|
1106
|
+
};
|
|
1107
|
+
|
|
987
1108
|
const finishReasoning = () => {
|
|
988
1109
|
if (reasoning.hidden || reasoning.dataset.done === '1') return;
|
|
989
1110
|
reasoning.dataset.done = '1';
|
|
990
|
-
reasoning.
|
|
1111
|
+
reasoning.classList.remove('is-live');
|
|
1112
|
+
if (reasonPending) cancelAnimationFrame(reasonPending);
|
|
1113
|
+
paintReasoning(true);
|
|
1114
|
+
if (reasoning.dataset.user !== '1') reasoning.open = false;
|
|
991
1115
|
const seconds = reasoningStarted ? ((Date.now() - reasoningStarted) / 1000).toFixed(1) : '0';
|
|
992
1116
|
reasonSummary.querySelector('.think-title').textContent = `思考 · ${seconds}s`;
|
|
993
1117
|
};
|
|
1118
|
+
|
|
1119
|
+
const setWorking = (text) => {
|
|
1120
|
+
const node = working.querySelector('.working-text');
|
|
1121
|
+
if (node) node.textContent = text;
|
|
1122
|
+
working.hidden = false;
|
|
1123
|
+
};
|
|
1124
|
+
|
|
994
1125
|
const finishWork = () => {
|
|
995
1126
|
if (work.hidden || work.dataset.done === '1') return;
|
|
996
1127
|
work.dataset.done = '1';
|
|
@@ -1008,17 +1139,33 @@ async function send() {
|
|
|
1008
1139
|
|
|
1009
1140
|
let buffer = '';
|
|
1010
1141
|
let pending = 0;
|
|
1142
|
+
let lastPaint = 0;
|
|
1011
1143
|
let streamEnded = false;
|
|
1144
|
+
const renderStream = () => markdown(buffer);
|
|
1145
|
+
|
|
1012
1146
|
const paint = () => {
|
|
1013
1147
|
pending = 0;
|
|
1014
|
-
|
|
1015
|
-
|
|
1148
|
+
const now = performance.now();
|
|
1149
|
+
// 流式 markdown 限制到约 12fps,避免长回答每帧重排 + 高亮
|
|
1150
|
+
if (!streamEnded && now - lastPaint < 80) {
|
|
1151
|
+
schedule();
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
lastPaint = now;
|
|
1155
|
+
const atBottom = THREAD.scrollHeight - THREAD.scrollTop - THREAD.clientHeight < 90;
|
|
1156
|
+
body.innerHTML = renderStream();
|
|
1157
|
+
// 流式过程中保持光标
|
|
1158
|
+
if (!streamEnded) body.classList.add('caret');
|
|
1159
|
+
if (atBottom) scrollToEnd(false);
|
|
1016
1160
|
};
|
|
1017
1161
|
const schedule = () => {
|
|
1018
1162
|
if (!pending) pending = requestAnimationFrame(paint);
|
|
1019
1163
|
};
|
|
1020
1164
|
|
|
1021
1165
|
setBusy(true);
|
|
1166
|
+
const composer = $('composer');
|
|
1167
|
+
composer.classList.add('is-busy');
|
|
1168
|
+
setStatus('正在连接模型…');
|
|
1022
1169
|
controller = new AbortController();
|
|
1023
1170
|
const metaLine = (label, value) => {
|
|
1024
1171
|
const span = document.createElement('span');
|
|
@@ -1053,6 +1200,7 @@ async function send() {
|
|
|
1053
1200
|
if (event.type === 'text') {
|
|
1054
1201
|
finishReasoning();
|
|
1055
1202
|
working.hidden = true;
|
|
1203
|
+
setStatus('正在输出…');
|
|
1056
1204
|
buffer += event.chunk;
|
|
1057
1205
|
schedule();
|
|
1058
1206
|
} else if (event.type === 'reasoning') {
|
|
@@ -1062,7 +1210,12 @@ async function send() {
|
|
|
1062
1210
|
reasoning.open = true;
|
|
1063
1211
|
}
|
|
1064
1212
|
reasoning.hidden = false;
|
|
1065
|
-
|
|
1213
|
+
if (reasoning.dataset.user !== '1') reasoning.open = true;
|
|
1214
|
+
reasoningText += event.chunk;
|
|
1215
|
+
setWorking('正在思考…');
|
|
1216
|
+
setStatus('思考中…');
|
|
1217
|
+
working.hidden = false;
|
|
1218
|
+
scheduleReasoning();
|
|
1066
1219
|
} else if (event.type === 'tool_start') {
|
|
1067
1220
|
if (!toolStarted) toolStarted = Date.now();
|
|
1068
1221
|
toolCount += 1;
|
|
@@ -1072,40 +1225,78 @@ async function send() {
|
|
|
1072
1225
|
workSummary.querySelector('.wg-state').textContent = '';
|
|
1073
1226
|
work.classList.add('is-updating');
|
|
1074
1227
|
setTimeout(() => work.classList.remove('is-updating'), 220);
|
|
1075
|
-
const
|
|
1076
|
-
row
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1228
|
+
const command = typeof event.input?.command === 'string' ? event.input.command : event.detail;
|
|
1229
|
+
const row = toolRowNode(
|
|
1230
|
+
event.name,
|
|
1231
|
+
command,
|
|
1232
|
+
'<span class="spin"></span>',
|
|
1233
|
+
);
|
|
1234
|
+
row.dataset.id = event.id;
|
|
1235
|
+
row.dataset.started = String(Date.now());
|
|
1236
|
+
const time = document.createElement('span');
|
|
1237
|
+
time.className = 't-time';
|
|
1238
|
+
time.textContent = '0.0s';
|
|
1239
|
+
row.appendChild(time);
|
|
1240
|
+
row._timer = setInterval(() => {
|
|
1241
|
+
const began = Number(row.dataset.started);
|
|
1242
|
+
time.textContent = `${((Date.now() - began) / 1000).toFixed(1)}s`;
|
|
1243
|
+
}, 400);
|
|
1244
|
+
toolRows.set(event.id, row);
|
|
1082
1245
|
workBody.appendChild(row);
|
|
1246
|
+
if (command) ensureToolOutput(row, `$ ${command}\n`, false);
|
|
1247
|
+
setWorking(`正在运行 ${event.name}…`);
|
|
1248
|
+
setStatus(`运行工具 ${event.name}…`);
|
|
1249
|
+
working.hidden = false;
|
|
1083
1250
|
scrollToEnd(false);
|
|
1251
|
+
} else if (event.type === 'tool_output') {
|
|
1252
|
+
const row = toolRows.get(event.id);
|
|
1253
|
+
if (row) {
|
|
1254
|
+
row._out = `${row._out ?? ''}${event.chunk}`;
|
|
1255
|
+
if (row._out.length > 12000) row._out = row._out.slice(-12000);
|
|
1256
|
+
const out = ensureToolOutput(row, row._out);
|
|
1257
|
+
if (out.hidden) {
|
|
1258
|
+
out.hidden = false;
|
|
1259
|
+
row.classList.add('is-open');
|
|
1260
|
+
}
|
|
1261
|
+
out.scrollTop = out.scrollHeight;
|
|
1262
|
+
const state = row.querySelector('.t-state');
|
|
1263
|
+
if (state && !state.querySelector('.spin')) state.innerHTML = '<span class="spin"></span>';
|
|
1264
|
+
setStatus(`输出中 · ${row.querySelector('.t-name')?.textContent ?? ''}`);
|
|
1265
|
+
}
|
|
1084
1266
|
} else if (event.type === 'tool_end') {
|
|
1085
|
-
const
|
|
1086
|
-
const row = rows[rows.length - 1];
|
|
1267
|
+
const row = toolRows.get(event.id) ?? [...toolRows.values()].pop();
|
|
1087
1268
|
if (row) {
|
|
1269
|
+
clearInterval(row._timer);
|
|
1270
|
+
row.dataset.done = '1';
|
|
1088
1271
|
row.querySelector('.t-state').innerHTML = event.ok ? svg('check') : svg('x');
|
|
1089
1272
|
row.classList.toggle('is-error', !event.ok);
|
|
1090
1273
|
if (!event.ok) toolErrors = true;
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
row.
|
|
1274
|
+
const time = row.querySelector('.t-time');
|
|
1275
|
+
if (time && event.ms) time.textContent = `${(event.ms / 1000).toFixed(1)}s`;
|
|
1276
|
+
const outText = row._out || event.detail || '';
|
|
1277
|
+
if (outText) {
|
|
1278
|
+
const out = ensureToolOutput(row, outText, !event.ok);
|
|
1279
|
+
if (!event.ok) {
|
|
1280
|
+
out.hidden = false;
|
|
1281
|
+
row.classList.add('is-open');
|
|
1282
|
+
}
|
|
1096
1283
|
}
|
|
1097
|
-
if (event.
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1284
|
+
if (!event.ok) {
|
|
1285
|
+
work.open = true;
|
|
1286
|
+
setWorking('工具执行失败,已展开输出');
|
|
1287
|
+
} else {
|
|
1288
|
+
setWorking('正在继续…');
|
|
1101
1289
|
}
|
|
1102
1290
|
}
|
|
1103
1291
|
} else if (event.type === 'step') {
|
|
1104
|
-
|
|
1292
|
+
setStatus(`第 ${event.step} 步 · 处理中`);
|
|
1293
|
+
setWorking(`第 ${event.step} 步 · 处理中`);
|
|
1294
|
+
working.hidden = false;
|
|
1105
1295
|
} else if (event.type === 'status') {
|
|
1106
1296
|
if (event.message) {
|
|
1107
|
-
|
|
1108
|
-
|
|
1297
|
+
setStatus(event.message);
|
|
1298
|
+
setWorking(event.message);
|
|
1299
|
+
working.hidden = false;
|
|
1109
1300
|
}
|
|
1110
1301
|
} else if (event.type === 'approval') {
|
|
1111
1302
|
const allowed = await askApproval(event);
|
|
@@ -1122,12 +1313,18 @@ async function send() {
|
|
|
1122
1313
|
} else if (event.type === 'done') {
|
|
1123
1314
|
finishReasoning();
|
|
1124
1315
|
finishWork();
|
|
1316
|
+
if (pending) {
|
|
1317
|
+
cancelAnimationFrame(pending);
|
|
1318
|
+
pending = 0;
|
|
1319
|
+
}
|
|
1125
1320
|
body.classList.remove('caret');
|
|
1126
1321
|
streamEnded = true;
|
|
1127
1322
|
if (event.error) body.innerHTML = markdown(`**请求失败** ${escapeHtml(event.error)}`);
|
|
1128
1323
|
else if (!buffer.trim()) body.innerHTML = markdown('这一轮没有返回内容。');
|
|
1129
1324
|
else body.innerHTML = markdown(buffer);
|
|
1130
|
-
if (buffer.trim()
|
|
1325
|
+
if (buffer.trim() && !botMsg.querySelector('.msg-actions')) {
|
|
1326
|
+
messageActions(botMsg, buffer, 'assistant');
|
|
1327
|
+
}
|
|
1131
1328
|
metaLine('步数', event.steps);
|
|
1132
1329
|
metaLine('用时', (event.ms / 1000).toFixed(1) + 's');
|
|
1133
1330
|
if (event.cost && event.cost !== '≈$0') metaLine('花费', event.cost);
|
|
@@ -1136,7 +1333,7 @@ async function send() {
|
|
|
1136
1333
|
state.info.session.messages[state.info.session.messages.length - 1] = {
|
|
1137
1334
|
role: 'assistant',
|
|
1138
1335
|
content: buffer,
|
|
1139
|
-
reasoning:
|
|
1336
|
+
reasoning: reasoningText || undefined,
|
|
1140
1337
|
};
|
|
1141
1338
|
const { sessions } = await get('sessions');
|
|
1142
1339
|
state.sessions = sessions;
|
|
@@ -1160,16 +1357,20 @@ async function send() {
|
|
|
1160
1357
|
}
|
|
1161
1358
|
} catch (error) {
|
|
1162
1359
|
body.classList.remove('caret');
|
|
1163
|
-
body.innerHTML = markdown(`**中断** ${escapeHtml(error.message)}`);
|
|
1360
|
+
if (!buffer.trim()) body.innerHTML = markdown(`**中断** ${escapeHtml(error.message)}`);
|
|
1164
1361
|
await refresh();
|
|
1165
1362
|
} finally {
|
|
1166
1363
|
finishReasoning();
|
|
1167
1364
|
finishWork();
|
|
1365
|
+
for (const row of toolRows.values()) clearInterval(row._timer);
|
|
1168
1366
|
working.hidden = true;
|
|
1367
|
+
body.classList.remove('caret');
|
|
1169
1368
|
controller = null;
|
|
1170
1369
|
setBusy(false);
|
|
1171
|
-
|
|
1370
|
+
$('composer').classList.remove('is-busy');
|
|
1371
|
+
setStatus(null);
|
|
1172
1372
|
renderHeader();
|
|
1373
|
+
scrollToEnd();
|
|
1173
1374
|
if (state.review.open && state.review.mode === 'changes') void loadChanges(true);
|
|
1174
1375
|
}
|
|
1175
1376
|
}
|
|
@@ -1417,9 +1618,130 @@ const SETTINGS_NAV = [
|
|
|
1417
1618
|
{ id: 'about', label: '关于', icon: 'info' },
|
|
1418
1619
|
];
|
|
1419
1620
|
|
|
1621
|
+
function closeModelPop() {
|
|
1622
|
+
const pop = $('modelPop');
|
|
1623
|
+
if (!pop) return;
|
|
1624
|
+
pop.remove();
|
|
1625
|
+
document.removeEventListener('click', onModelPopOutside, true);
|
|
1626
|
+
document.removeEventListener('keydown', onModelPopKey, true);
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
function onModelPopOutside(event) {
|
|
1630
|
+
if (event.target.closest('#modelPop, #modelBtn')) return;
|
|
1631
|
+
closeModelPop();
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
function onModelPopKey(event) {
|
|
1635
|
+
if (event.key === 'Escape') {
|
|
1636
|
+
event.preventDefault();
|
|
1637
|
+
closeModelPop();
|
|
1638
|
+
$('modelBtn')?.focus();
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
function toggleModelPop() {
|
|
1643
|
+
if ($('modelPop')) return closeModelPop();
|
|
1644
|
+
const info = state.info;
|
|
1645
|
+
if (!info) return;
|
|
1646
|
+
const pop = document.createElement('div');
|
|
1647
|
+
pop.className = 'model-pop';
|
|
1648
|
+
pop.id = 'modelPop';
|
|
1649
|
+
pop.setAttribute('role', 'dialog');
|
|
1650
|
+
pop.setAttribute('aria-label', '切换模型');
|
|
1651
|
+
const head = document.createElement('div');
|
|
1652
|
+
head.className = 'mp-head';
|
|
1653
|
+
head.innerHTML = '<span>模型</span><span class="mp-sub">切换后新消息生效</span>';
|
|
1654
|
+
pop.appendChild(head);
|
|
1655
|
+
|
|
1656
|
+
for (const provider of info.providers ?? []) {
|
|
1657
|
+
const row = document.createElement('button');
|
|
1658
|
+
row.type = 'button';
|
|
1659
|
+
row.className = `mp-row${provider.current ? ' is-on' : ''}`;
|
|
1660
|
+
row.innerHTML =
|
|
1661
|
+
`<span class="mp-name">${escapeHtml(provider.name)}</span>` +
|
|
1662
|
+
`<span class="mp-model">${escapeHtml(provider.model)}</span>` +
|
|
1663
|
+
(provider.current ? `<span class="mp-check">${svg('check')}</span>` : '');
|
|
1664
|
+
row.addEventListener('click', async () => {
|
|
1665
|
+
if (provider.current) return closeModelPop();
|
|
1666
|
+
try {
|
|
1667
|
+
await saveSetting('provider', { name: provider.name });
|
|
1668
|
+
await refresh(false);
|
|
1669
|
+
closeModelPop();
|
|
1670
|
+
toast(`已切换到 ${provider.name}`);
|
|
1671
|
+
} catch (error) {
|
|
1672
|
+
toast('切换失败:' + error.message);
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
pop.appendChild(row);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
const form = document.createElement('div');
|
|
1679
|
+
form.className = 'mp-form';
|
|
1680
|
+
const input = document.createElement('input');
|
|
1681
|
+
input.type = 'text';
|
|
1682
|
+
input.value = info.provider.model;
|
|
1683
|
+
input.placeholder = '模型名';
|
|
1684
|
+
input.setAttribute('aria-label', '模型名');
|
|
1685
|
+
const save = document.createElement('button');
|
|
1686
|
+
save.type = 'button';
|
|
1687
|
+
save.className = 'btn tiny primary';
|
|
1688
|
+
save.textContent = '保存';
|
|
1689
|
+
save.addEventListener('click', async () => {
|
|
1690
|
+
const value = input.value.trim();
|
|
1691
|
+
if (!value) return toast('请填写模型名');
|
|
1692
|
+
try {
|
|
1693
|
+
await saveSetting('model', { value });
|
|
1694
|
+
await refresh(false);
|
|
1695
|
+
closeModelPop();
|
|
1696
|
+
toast('模型已更新');
|
|
1697
|
+
} catch (error) {
|
|
1698
|
+
toast('保存失败:' + error.message);
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
input.addEventListener('keydown', (event) => {
|
|
1702
|
+
if (event.key === 'Enter') {
|
|
1703
|
+
event.preventDefault();
|
|
1704
|
+
save.click();
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
form.append(input, save);
|
|
1708
|
+
pop.appendChild(form);
|
|
1709
|
+
|
|
1710
|
+
const more = document.createElement('button');
|
|
1711
|
+
more.type = 'button';
|
|
1712
|
+
more.className = 'mp-more';
|
|
1713
|
+
more.textContent = '更多模型与 Key 设置';
|
|
1714
|
+
more.addEventListener('click', () => {
|
|
1715
|
+
closeModelPop();
|
|
1716
|
+
openSettings('model');
|
|
1717
|
+
});
|
|
1718
|
+
pop.appendChild(more);
|
|
1719
|
+
document.body.appendChild(pop);
|
|
1720
|
+
|
|
1721
|
+
const rect = $('modelBtn').getBoundingClientRect();
|
|
1722
|
+
const width = Math.min(340, window.innerWidth - 16);
|
|
1723
|
+
pop.style.width = `${width}px`;
|
|
1724
|
+
pop.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - width - 8))}px`;
|
|
1725
|
+
if (rect.top > 300) {
|
|
1726
|
+
pop.style.bottom = `${Math.max(8, window.innerHeight - rect.top + 8)}px`;
|
|
1727
|
+
pop.style.maxHeight = `${Math.max(180, rect.top - 16)}px`;
|
|
1728
|
+
} else {
|
|
1729
|
+
pop.style.top = `${Math.max(8, rect.bottom + 8)}px`;
|
|
1730
|
+
pop.style.maxHeight = `${Math.max(180, window.innerHeight - rect.bottom - 16)}px`;
|
|
1731
|
+
}
|
|
1732
|
+
pop.style.overflowY = 'auto';
|
|
1733
|
+
void pop.offsetHeight;
|
|
1734
|
+
pop.classList.add('is-on');
|
|
1735
|
+
setTimeout(() => {
|
|
1736
|
+
document.addEventListener('click', onModelPopOutside, true);
|
|
1737
|
+
document.addEventListener('keydown', onModelPopKey, true);
|
|
1738
|
+
}, 0);
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1420
1741
|
function openSettings(category) {
|
|
1421
1742
|
if (category) state.settingsCategory = category;
|
|
1422
1743
|
state.settingsScroll = 0;
|
|
1744
|
+
state.settingsReturn = document.activeElement;
|
|
1423
1745
|
renderSettings();
|
|
1424
1746
|
const sheet = $('settingsSheet');
|
|
1425
1747
|
sheet.classList.remove('is-closing');
|
|
@@ -1436,7 +1758,32 @@ function closeSettings() {
|
|
|
1436
1758
|
if (sheet.hidden) return;
|
|
1437
1759
|
state.settingsScroll = $('settingsBody').scrollTop;
|
|
1438
1760
|
void hideAnimated(sheet, 'is-closing', 170).then(syncOverlayState);
|
|
1439
|
-
|
|
1761
|
+
const back = state.settingsReturn;
|
|
1762
|
+
state.settingsReturn = null;
|
|
1763
|
+
if (back && back.isConnected) back.focus();
|
|
1764
|
+
else $('input')?.focus();
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
function trapSettingsFocus(event) {
|
|
1768
|
+
const sheet = $('settingsSheet');
|
|
1769
|
+
if (sheet.hidden) return false;
|
|
1770
|
+
const focusable = [...sheet.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')]
|
|
1771
|
+
.filter((node) => !node.disabled && node.offsetParent !== null);
|
|
1772
|
+
if (!focusable.length) return false;
|
|
1773
|
+
const first = focusable[0];
|
|
1774
|
+
const last = focusable[focusable.length - 1];
|
|
1775
|
+
const active = document.activeElement;
|
|
1776
|
+
if (event.shiftKey && (active === first || !sheet.contains(active))) {
|
|
1777
|
+
event.preventDefault();
|
|
1778
|
+
last.focus();
|
|
1779
|
+
return true;
|
|
1780
|
+
}
|
|
1781
|
+
if (!event.shiftKey && (active === last || !sheet.contains(active))) {
|
|
1782
|
+
event.preventDefault();
|
|
1783
|
+
first.focus();
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
return false;
|
|
1440
1787
|
}
|
|
1441
1788
|
|
|
1442
1789
|
function settingsCard() {
|
|
@@ -2000,7 +2347,7 @@ function renderAboutSettings(body) {
|
|
|
2000
2347
|
// ---------------- 外壳:侧栏 / Review / 终端 dock ----------------
|
|
2001
2348
|
const SHELL_STORAGE = {
|
|
2002
2349
|
sidebarWidth: 'banana.sidebar.width',
|
|
2003
|
-
sidebarOpen: 'banana.sidebar.open',
|
|
2350
|
+
sidebarOpen: 'banana.sidebar.open.v2',
|
|
2004
2351
|
reviewWidth: 'banana.review.width',
|
|
2005
2352
|
reviewMode: 'banana.review.mode',
|
|
2006
2353
|
tabState: 'banana.tabs.v1',
|
|
@@ -2016,16 +2363,23 @@ function applySidebarWidth(width) {
|
|
|
2016
2363
|
|
|
2017
2364
|
function setSidebar(open) {
|
|
2018
2365
|
state.sidebar.open = Boolean(open);
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2366
|
+
const narrow = window.matchMedia('(max-width: 900px)').matches;
|
|
2367
|
+
const sidebar = $('sidebar');
|
|
2368
|
+
sidebar.classList.toggle('open', state.sidebar.open && narrow);
|
|
2369
|
+
// 桌面端收起 = 真正隐藏;窄屏收起 = 平移出屏,但仍需 inert
|
|
2370
|
+
sidebar.hidden = !state.sidebar.open && !narrow;
|
|
2371
|
+
sidebar.inert = !state.sidebar.open;
|
|
2372
|
+
sidebar.setAttribute('aria-hidden', String(!state.sidebar.open));
|
|
2373
|
+
$('toggleSidebar').classList.toggle('is-on', state.sidebar.open);
|
|
2374
|
+
$('toggleSidebar').setAttribute('aria-expanded', String(state.sidebar.open));
|
|
2022
2375
|
try {
|
|
2023
2376
|
localStorage.setItem(SHELL_STORAGE.sidebarOpen, state.sidebar.open ? '1' : '0');
|
|
2024
2377
|
} catch {}
|
|
2025
2378
|
}
|
|
2026
2379
|
|
|
2027
2380
|
function toggleSidebar() {
|
|
2028
|
-
|
|
2381
|
+
const narrow = window.matchMedia('(max-width: 900px)').matches;
|
|
2382
|
+
setSidebar(!state.sidebar.open || (narrow && !$('sidebar').classList.contains('open')));
|
|
2029
2383
|
}
|
|
2030
2384
|
|
|
2031
2385
|
function applyReviewWidth(width) {
|
|
@@ -2052,13 +2406,22 @@ function setReviewMode(mode) {
|
|
|
2052
2406
|
}
|
|
2053
2407
|
}
|
|
2054
2408
|
|
|
2409
|
+
function syncReviewScrim() {
|
|
2410
|
+
const scrim = $('reviewScrim');
|
|
2411
|
+
if (!scrim) return;
|
|
2412
|
+
const overlay = window.matchMedia('(max-width: 1180px)').matches;
|
|
2413
|
+
scrim.hidden = !(state.review.open && overlay);
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2055
2416
|
function openReview(mode = 'changes') {
|
|
2056
2417
|
state.review.open = true;
|
|
2418
|
+
state.reviewRestore = document.activeElement;
|
|
2057
2419
|
const panel = $('reviewPanel');
|
|
2058
2420
|
panel.classList.remove('is-closing');
|
|
2059
2421
|
panel.hidden = false;
|
|
2060
2422
|
applyReviewWidth(state.review.width);
|
|
2061
2423
|
setReviewMode(mode);
|
|
2424
|
+
syncReviewScrim();
|
|
2062
2425
|
syncOverlayState();
|
|
2063
2426
|
}
|
|
2064
2427
|
|
|
@@ -2067,12 +2430,16 @@ function closeReview() {
|
|
|
2067
2430
|
if (!state.review.open) return;
|
|
2068
2431
|
state.review.open = false;
|
|
2069
2432
|
panel.classList.add('is-closing');
|
|
2433
|
+
$('reviewScrim').hidden = true;
|
|
2070
2434
|
setTimeout(() => {
|
|
2071
2435
|
if (state.review.open) return;
|
|
2072
2436
|
panel.hidden = true;
|
|
2073
2437
|
panel.classList.remove('is-closing');
|
|
2074
2438
|
syncOverlayState();
|
|
2075
|
-
|
|
2439
|
+
const back = state.reviewRestore;
|
|
2440
|
+
state.reviewRestore = null;
|
|
2441
|
+
if (back && back.isConnected) back.focus();
|
|
2442
|
+
else $('input')?.focus();
|
|
2076
2443
|
termFitActive();
|
|
2077
2444
|
}, 200);
|
|
2078
2445
|
}
|
|
@@ -2088,7 +2455,8 @@ function initShell() {
|
|
|
2088
2455
|
const dh = Number(localStorage.getItem(SHELL_STORAGE.dockHeight));
|
|
2089
2456
|
if (dh) state.dock.height = Math.max(120, Math.min(dh, window.innerHeight * 0.6));
|
|
2090
2457
|
const openSidebar = localStorage.getItem(SHELL_STORAGE.sidebarOpen);
|
|
2091
|
-
|
|
2458
|
+
// 历史栏默认收起:顶部标签才是主入口
|
|
2459
|
+
state.sidebar.open = openSidebar === '1';
|
|
2092
2460
|
} catch {
|
|
2093
2461
|
applySidebarWidth(344);
|
|
2094
2462
|
applyReviewWidth(520);
|
|
@@ -2097,6 +2465,7 @@ function initShell() {
|
|
|
2097
2465
|
$('reviewTabChanges').addEventListener('click', () => setReviewMode('changes'));
|
|
2098
2466
|
$('reviewTabFiles').addEventListener('click', () => setReviewMode('files'));
|
|
2099
2467
|
$('reviewClose').addEventListener('click', closeReview);
|
|
2468
|
+
$('reviewScrim').addEventListener('click', closeReview);
|
|
2100
2469
|
$('reviewRefresh').addEventListener('click', () => {
|
|
2101
2470
|
state.changes = null;
|
|
2102
2471
|
if (state.review.mode === 'changes') void loadChanges(true);
|
|
@@ -2134,6 +2503,8 @@ function initShell() {
|
|
|
2134
2503
|
});
|
|
2135
2504
|
window.addEventListener('resize', () => {
|
|
2136
2505
|
applyReviewWidth(state.review.width);
|
|
2506
|
+
syncReviewScrim();
|
|
2507
|
+
setSidebar(state.sidebar.open);
|
|
2137
2508
|
termFitActive();
|
|
2138
2509
|
});
|
|
2139
2510
|
}
|
|
@@ -2798,7 +3169,30 @@ function bindTerminal() {
|
|
|
2798
3169
|
});
|
|
2799
3170
|
$('termMore').addEventListener('click', (event) => {
|
|
2800
3171
|
event.stopPropagation();
|
|
2801
|
-
|
|
3172
|
+
const menu = $('termMenu');
|
|
3173
|
+
const willOpen = menu.hidden;
|
|
3174
|
+
menu.hidden = !willOpen;
|
|
3175
|
+
if (willOpen) {
|
|
3176
|
+
// fixed 定位:终端 dock 有 overflow:hidden,菜单贴着头部放会被裁掉
|
|
3177
|
+
const rect = $('termMore').getBoundingClientRect();
|
|
3178
|
+
const below = window.innerHeight - rect.bottom - 12;
|
|
3179
|
+
const above = rect.top - 12;
|
|
3180
|
+
menu.style.position = 'fixed';
|
|
3181
|
+
menu.style.right = `${Math.max(8, window.innerWidth - rect.right)}px`;
|
|
3182
|
+
if (below >= 150 || below >= above) {
|
|
3183
|
+
menu.style.top = `${Math.round(rect.bottom + 4)}px`;
|
|
3184
|
+
menu.style.bottom = 'auto';
|
|
3185
|
+
menu.style.maxHeight = `${Math.max(90, below)}px`;
|
|
3186
|
+
} else {
|
|
3187
|
+
menu.style.top = 'auto';
|
|
3188
|
+
menu.style.bottom = `${Math.max(8, Math.round(window.innerHeight - rect.top + 4))}px`;
|
|
3189
|
+
menu.style.maxHeight = `${Math.max(90, above)}px`;
|
|
3190
|
+
}
|
|
3191
|
+
menu.style.overflowY = 'auto';
|
|
3192
|
+
$('termMore').setAttribute('aria-expanded', 'true');
|
|
3193
|
+
} else {
|
|
3194
|
+
$('termMore').setAttribute('aria-expanded', 'false');
|
|
3195
|
+
}
|
|
2802
3196
|
});
|
|
2803
3197
|
$('termAnalyze').addEventListener('click', () => {
|
|
2804
3198
|
closeTermMenu();
|
|
@@ -3181,8 +3575,26 @@ function bind() {
|
|
|
3181
3575
|
$('searchBtn').innerHTML = svg('search');
|
|
3182
3576
|
$('sendBtn').innerHTML = svg('send');
|
|
3183
3577
|
$('abortBtn').innerHTML = svg('stop');
|
|
3184
|
-
$('toggleSidebar').innerHTML = '<svg class="brand-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4.6c2.6-.4 4.9.5 6.3 2.6M12.3 7.2c1.4-2.1 3.7-3 6.3-2.6-1.1 1.6-1.2 3.1-.4 4.6.8 1.5.8 3-.1 4.5-1.1 2-3.3 3.5-5.9 4.3-2.3.7-4.7.7-7.1 0"/><path d="M7.2 18c-1.1-2-1.2-4-.4-6 .9-2.3 2.5-3.7 4.7-4.2"/></svg>';
|
|
3185
3578
|
$('closeSettings').innerHTML = svg('x');
|
|
3579
|
+
// 左上角保留 Banana 叶子标记;点击/ Ctrl+B 仍然打开历史会话
|
|
3580
|
+
$('toggleSidebar').innerHTML =
|
|
3581
|
+
'<svg class="brand-mark" viewBox="0 0 24 24" aria-hidden="true">' +
|
|
3582
|
+
'<path d="M7 4.6c2.6-.4 4.9.5 6.3 2.6M12.3 7.2c1.4-2.1 3.7-3 6.3-2.6-1.1 1.6-1.2 3.1-.4 4.6.8 1.5.8 3-.1 4.5-1.1 2-3.3 3.5-5.9 4.3-2.3.7-4.7.7-7.1 0" />' +
|
|
3583
|
+
'<path d="M7.2 18c-1.1-2-1.2-4-.4-6 .9-2.3 2.5-3.7 4.7-4.2" />' +
|
|
3584
|
+
'</svg>';
|
|
3585
|
+
$('toggleSidebar').title = '历史会话(Ctrl+B)';
|
|
3586
|
+
$('attachBtn').innerHTML = svg('attach');
|
|
3587
|
+
$('jumpLatest').innerHTML = svg('arrowDown');
|
|
3588
|
+
$('abortBtn').addEventListener('click', stopTurn);
|
|
3589
|
+
$('modelBtn').addEventListener('click', (event) => {
|
|
3590
|
+
event.stopPropagation();
|
|
3591
|
+
toggleModelPop();
|
|
3592
|
+
});
|
|
3593
|
+
$('attachBtn').addEventListener('click', () => $('attachInput').click());
|
|
3594
|
+
$('attachInput').addEventListener('change', async () => {
|
|
3595
|
+
for (const file of $('attachInput').files ?? []) await attach(file);
|
|
3596
|
+
$('attachInput').value = '';
|
|
3597
|
+
});
|
|
3186
3598
|
$('reviewClose').innerHTML = svg('x');
|
|
3187
3599
|
$('reviewRefresh').innerHTML = svg('refresh');
|
|
3188
3600
|
$('filesBtn').innerHTML = svg('panel');
|
|
@@ -3207,14 +3619,14 @@ function bind() {
|
|
|
3207
3619
|
renderHeader();
|
|
3208
3620
|
renderSidebar();
|
|
3209
3621
|
renderThread();
|
|
3622
|
+
if (state.dock.open) termClose();
|
|
3623
|
+
closeSidebarIfOverlay();
|
|
3210
3624
|
setActiveTab(state.info?.session?.id ?? null);
|
|
3211
3625
|
$('input').focus();
|
|
3212
3626
|
} catch (error) {
|
|
3213
3627
|
toast('新建对话失败:' + (error?.message ?? error));
|
|
3214
3628
|
}
|
|
3215
3629
|
});
|
|
3216
|
-
$('abortBtn').addEventListener('click', async () => { controller?.abort(); await post('abort'); });
|
|
3217
|
-
$('modelBtn').addEventListener('click', () => openSettings());
|
|
3218
3630
|
$('openSettings').addEventListener('click', () => openSettings());
|
|
3219
3631
|
$('closeSettings').addEventListener('click', closeSettings);
|
|
3220
3632
|
$('settingsSheet').addEventListener('click', (event) => {
|
|
@@ -3270,6 +3682,20 @@ function bind() {
|
|
|
3270
3682
|
});
|
|
3271
3683
|
|
|
3272
3684
|
$('composer').addEventListener('submit', (event) => { event.preventDefault(); send(); });
|
|
3685
|
+
$('sendBtn').addEventListener('click', () => {
|
|
3686
|
+
if (state.busy) stopTurn();
|
|
3687
|
+
else send();
|
|
3688
|
+
});
|
|
3689
|
+
$('jumpLatest').addEventListener('click', () => {
|
|
3690
|
+
state.stickToBottom = true;
|
|
3691
|
+
scrollToEnd(true);
|
|
3692
|
+
});
|
|
3693
|
+
THREAD.addEventListener('scroll', () => {
|
|
3694
|
+
const atBottom = THREAD.scrollHeight - THREAD.scrollTop - THREAD.clientHeight < 90;
|
|
3695
|
+
state.stickToBottom = atBottom;
|
|
3696
|
+
const hasMessages = Boolean(THREAD.querySelector('.msg'));
|
|
3697
|
+
$('jumpLatest').hidden = atBottom || !hasMessages;
|
|
3698
|
+
});
|
|
3273
3699
|
$('input').addEventListener('input', () => {
|
|
3274
3700
|
grow();
|
|
3275
3701
|
const value = $('input').value;
|
|
@@ -3319,12 +3745,28 @@ function bind() {
|
|
|
3319
3745
|
});
|
|
3320
3746
|
|
|
3321
3747
|
document.addEventListener('keydown', (event) => {
|
|
3748
|
+
if (event.key === 'Tab' && trapSettingsFocus(event)) return;
|
|
3322
3749
|
if ((event.ctrlKey || event.metaKey) && String(event.key).toLowerCase() === 'k') {
|
|
3323
3750
|
event.preventDefault();
|
|
3324
3751
|
if ($('commandCenter').hidden) openCommandCenter();
|
|
3325
3752
|
else closeCommandCenter();
|
|
3326
3753
|
return;
|
|
3327
3754
|
}
|
|
3755
|
+
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && String(event.key).toLowerCase() === 'b') {
|
|
3756
|
+
event.preventDefault();
|
|
3757
|
+
toggleSidebar();
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
if (event.ctrlKey && event.key === 'Tab') {
|
|
3761
|
+
event.preventDefault();
|
|
3762
|
+
const list = state.tabs ?? [];
|
|
3763
|
+
if (list.length > 1) {
|
|
3764
|
+
const index = list.findIndex((tab) => tab.id === state.activeTab);
|
|
3765
|
+
const next = list[(index + (event.shiftKey ? -1 : 1) + list.length) % list.length];
|
|
3766
|
+
if (next) void switchSession(next.id);
|
|
3767
|
+
}
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3328
3770
|
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
|
|
3329
3771
|
const key = String(event.key).toLowerCase();
|
|
3330
3772
|
if (key === 'f') { event.preventDefault(); openFiles(); return; }
|
|
@@ -3345,7 +3787,7 @@ function bind() {
|
|
|
3345
3787
|
if (!window.matchMedia('(max-width: 900px)').matches) return;
|
|
3346
3788
|
if (!$('sidebar').classList.contains('open')) return;
|
|
3347
3789
|
if (event.target.closest('#sidebar, #toggleSidebar')) return;
|
|
3348
|
-
|
|
3790
|
+
setSidebar(false);
|
|
3349
3791
|
});
|
|
3350
3792
|
|
|
3351
3793
|
$('input').addEventListener('paste', (event) => {
|
|
@@ -3371,7 +3813,8 @@ async function boot() {
|
|
|
3371
3813
|
$('workspaceLabel').textContent = state.info?.workspace ?? '';
|
|
3372
3814
|
updateHomeMode();
|
|
3373
3815
|
try {
|
|
3374
|
-
|
|
3816
|
+
const hasMessages = Boolean(state.info?.session?.messages?.length);
|
|
3817
|
+
if (hasMessages && localStorage.getItem(SHELL_STORAGE.dockOpen) === '1') termOpen();
|
|
3375
3818
|
} catch {}
|
|
3376
3819
|
grow();
|
|
3377
3820
|
$('input').focus();
|
package/ui/index.html
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<title>Banana</title>
|
|
8
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%23171717'/%3E%3Cg fill='none' stroke='%23dcde8d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21c1.6-7 6-11.4 14-12 0 7.4-3.9 12.9-9.9 15'/%3E%3Cpath d='M9 27c3-6 7-10 13-13'/%3E%3C/g%3E%3C/svg%3E" />
|
|
8
9
|
<link rel="stylesheet" href="vendor/xterm.css" />
|
|
9
10
|
<link rel="stylesheet" href="style.css" />
|
|
10
11
|
</head>
|
|
@@ -86,20 +87,24 @@
|
|
|
86
87
|
<textarea id="input" rows="1" placeholder="说点什么,Banana 来动手;输入 / 调命令,@ 引文件"></textarea>
|
|
87
88
|
<div class="composer-toolbar">
|
|
88
89
|
<div class="ct-left">
|
|
89
|
-
<button class="
|
|
90
|
-
|
|
90
|
+
<button class="icon-btn attach-btn" id="attachBtn" type="button" title="添加附件" aria-label="添加附件"></button>
|
|
91
|
+
<input type="file" id="attachInput" multiple hidden />
|
|
92
|
+
<button class="model-chip" id="modelBtn" type="button" title="切换模型">
|
|
93
|
+
<span data-icon="chevronDown"></span><span id="modelLabel">—</span>
|
|
91
94
|
</button>
|
|
92
95
|
</div>
|
|
93
96
|
<div class="ct-right">
|
|
94
97
|
<span class="composer-hint" id="composerHint"></span>
|
|
95
|
-
<button class="send-btn" id="sendBtn" type="
|
|
98
|
+
<button class="send-btn" id="sendBtn" type="button" title="发送" aria-label="发送"></button>
|
|
96
99
|
</div>
|
|
97
100
|
</div>
|
|
98
101
|
</form>
|
|
102
|
+
<div class="home-tips" id="homeTips" hidden></div>
|
|
99
103
|
</div>
|
|
100
|
-
<
|
|
104
|
+
<button class="jump-latest" id="jumpLatest" type="button" hidden>回到最新</button>
|
|
101
105
|
</section>
|
|
102
106
|
|
|
107
|
+
<div class="review-scrim" id="reviewScrim" hidden></div>
|
|
103
108
|
<aside class="review" id="reviewPanel" hidden aria-label="Review">
|
|
104
109
|
<div class="review-resizer" id="reviewResizer" title="拖动调整宽度"></div>
|
|
105
110
|
<header class="review-head">
|
package/ui/style.css
CHANGED
|
@@ -3532,3 +3532,320 @@ input:focus-visible, textarea:focus-visible { outline: none; }
|
|
|
3532
3532
|
.chip-btn { border-radius: 6px; }
|
|
3533
3533
|
|
|
3534
3534
|
.tool-row .t-time { margin-left: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
|
|
3535
|
+
|
|
3536
|
+
/* ============================================================
|
|
3537
|
+
v0.9 修复层:首页流、模型弹层、实时工具输出、停止键
|
|
3538
|
+
============================================================ */
|
|
3539
|
+
|
|
3540
|
+
/* 1. 历史消息不再重放入场动画;只有真正新插入的消息有 .enter */
|
|
3541
|
+
.msg { animation: none !important; }
|
|
3542
|
+
.msg.enter { animation: rise 200ms var(--ease) both; }
|
|
3543
|
+
.empty { animation: none; }
|
|
3544
|
+
|
|
3545
|
+
/* 2. 首页:composer 与提示同一列,不再绝对拼坐标 */
|
|
3546
|
+
.chat-card.home-mode .composer-wrap {
|
|
3547
|
+
position: absolute;
|
|
3548
|
+
top: 53%;
|
|
3549
|
+
left: 0;
|
|
3550
|
+
right: 0;
|
|
3551
|
+
transform: translateY(-50%);
|
|
3552
|
+
display: flex;
|
|
3553
|
+
flex-direction: column;
|
|
3554
|
+
align-items: center;
|
|
3555
|
+
gap: 14px;
|
|
3556
|
+
padding: 0 40px;
|
|
3557
|
+
z-index: 4;
|
|
3558
|
+
background: transparent;
|
|
3559
|
+
}
|
|
3560
|
+
.chat-card.home-mode .composer { width: 100%; max-width: 720px; }
|
|
3561
|
+
.home-tips {
|
|
3562
|
+
position: static;
|
|
3563
|
+
display: none;
|
|
3564
|
+
width: 100%;
|
|
3565
|
+
max-width: 720px;
|
|
3566
|
+
flex-direction: column;
|
|
3567
|
+
align-items: center;
|
|
3568
|
+
gap: 12px;
|
|
3569
|
+
padding: 0;
|
|
3570
|
+
}
|
|
3571
|
+
.chat-card.home-mode .home-tips:not([hidden]) { display: flex; }
|
|
3572
|
+
.chat-card.home-mode .empty {
|
|
3573
|
+
padding-top: 9vh;
|
|
3574
|
+
animation: none;
|
|
3575
|
+
}
|
|
3576
|
+
@media (max-height: 640px) {
|
|
3577
|
+
.chat-card.home-mode .composer-wrap { top: 58%; }
|
|
3578
|
+
.chat-card.home-mode .empty { padding-top: 3vh; }
|
|
3579
|
+
}
|
|
3580
|
+
|
|
3581
|
+
/* 3. Composer:附件、状态、停止键 */
|
|
3582
|
+
.composer-toolbar { min-height: 38px; }
|
|
3583
|
+
.ct-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
|
|
3584
|
+
.attach-btn { flex: none; color: var(--text-3); }
|
|
3585
|
+
.attach-btn:hover { color: var(--text); background: var(--panel); }
|
|
3586
|
+
.composer-hint {
|
|
3587
|
+
max-width: 46ch;
|
|
3588
|
+
overflow: hidden;
|
|
3589
|
+
text-overflow: ellipsis;
|
|
3590
|
+
white-space: nowrap;
|
|
3591
|
+
}
|
|
3592
|
+
.composer:not(.is-busy) .composer-hint { opacity: 0; }
|
|
3593
|
+
.composer.is-busy .composer-hint { opacity: 1; color: var(--text-2); }
|
|
3594
|
+
.composer:hover .composer-hint:not(:empty) { opacity: 1; }
|
|
3595
|
+
.composer.is-busy .composer-toolbar { border-top-color: var(--line); }
|
|
3596
|
+
.composer.is-busy .send-btn {
|
|
3597
|
+
background: var(--accent);
|
|
3598
|
+
color: var(--on-accent);
|
|
3599
|
+
border-color: var(--accent);
|
|
3600
|
+
}
|
|
3601
|
+
.composer.is-busy .send-btn:hover { filter: brightness(0.97); }
|
|
3602
|
+
.composer.is-busy .send-btn svg { width: 13px; height: 13px; }
|
|
3603
|
+
|
|
3604
|
+
/* 4. 模型就地弹层 */
|
|
3605
|
+
.model-pop {
|
|
3606
|
+
position: fixed;
|
|
3607
|
+
z-index: 90;
|
|
3608
|
+
padding: 5px;
|
|
3609
|
+
border: 1px solid var(--line-strong);
|
|
3610
|
+
border-radius: 9px;
|
|
3611
|
+
background: var(--bg);
|
|
3612
|
+
box-shadow: var(--shadow-lg);
|
|
3613
|
+
opacity: 0;
|
|
3614
|
+
transform: translateY(4px) scale(0.985);
|
|
3615
|
+
transition: opacity 140ms var(--ease), transform 160ms var(--spring-banana);
|
|
3616
|
+
}
|
|
3617
|
+
.model-pop.is-on { opacity: 1; transform: none; }
|
|
3618
|
+
.mp-head {
|
|
3619
|
+
display: flex;
|
|
3620
|
+
align-items: baseline;
|
|
3621
|
+
justify-content: space-between;
|
|
3622
|
+
padding: 6px 8px 7px;
|
|
3623
|
+
font-size: 12px;
|
|
3624
|
+
font-weight: 560;
|
|
3625
|
+
color: var(--text);
|
|
3626
|
+
}
|
|
3627
|
+
.mp-sub { font-size: 10.5px; font-weight: 400; color: var(--text-3); }
|
|
3628
|
+
.mp-row {
|
|
3629
|
+
display: grid;
|
|
3630
|
+
grid-template-columns: minmax(0, 1fr) auto 16px;
|
|
3631
|
+
align-items: center;
|
|
3632
|
+
gap: 8px;
|
|
3633
|
+
width: 100%;
|
|
3634
|
+
min-height: 38px;
|
|
3635
|
+
padding: 0 8px;
|
|
3636
|
+
border: 0;
|
|
3637
|
+
border-radius: 6px;
|
|
3638
|
+
background: transparent;
|
|
3639
|
+
color: var(--text-2);
|
|
3640
|
+
text-align: left;
|
|
3641
|
+
cursor: pointer;
|
|
3642
|
+
}
|
|
3643
|
+
.mp-row:hover { background: var(--panel); }
|
|
3644
|
+
.mp-row.is-on { background: var(--panel); color: var(--text); }
|
|
3645
|
+
.mp-name { font-size: 12.5px; font-weight: 520; overflow: hidden; text-overflow: ellipsis; }
|
|
3646
|
+
.mp-model { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3647
|
+
.mp-check { display: grid; place-items: center; color: var(--accent-ink); }
|
|
3648
|
+
.mp-check svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
|
|
3649
|
+
.mp-form { display: flex; gap: 6px; padding: 8px 5px 5px; border-top: 1px solid var(--line); margin-top: 4px; }
|
|
3650
|
+
.mp-form input {
|
|
3651
|
+
flex: 1;
|
|
3652
|
+
min-width: 0;
|
|
3653
|
+
height: 28px;
|
|
3654
|
+
padding: 0 8px;
|
|
3655
|
+
border: 1px solid var(--line);
|
|
3656
|
+
border-radius: 6px;
|
|
3657
|
+
background: var(--panel);
|
|
3658
|
+
color: var(--text);
|
|
3659
|
+
font-family: var(--mono);
|
|
3660
|
+
font-size: 11.5px;
|
|
3661
|
+
outline: none;
|
|
3662
|
+
}
|
|
3663
|
+
.mp-form input:focus { border-color: var(--line-strong); }
|
|
3664
|
+
.mp-more {
|
|
3665
|
+
width: 100%;
|
|
3666
|
+
height: 30px;
|
|
3667
|
+
margin-top: 2px;
|
|
3668
|
+
border: 0;
|
|
3669
|
+
border-radius: 6px;
|
|
3670
|
+
background: transparent;
|
|
3671
|
+
color: var(--text-3);
|
|
3672
|
+
font-size: 11.5px;
|
|
3673
|
+
text-align: left;
|
|
3674
|
+
padding: 0 8px;
|
|
3675
|
+
cursor: pointer;
|
|
3676
|
+
}
|
|
3677
|
+
.mp-more:hover { background: var(--panel); color: var(--text); }
|
|
3678
|
+
|
|
3679
|
+
/* 5. 思考与工具:实时结构化输出 */
|
|
3680
|
+
.think.is-live > summary { color: var(--text-2); }
|
|
3681
|
+
.think.is-live .think-title::after {
|
|
3682
|
+
content: '';
|
|
3683
|
+
display: inline-block;
|
|
3684
|
+
width: 5px;
|
|
3685
|
+
height: 5px;
|
|
3686
|
+
margin-left: 6px;
|
|
3687
|
+
border-radius: 50%;
|
|
3688
|
+
background: var(--accent-ink);
|
|
3689
|
+
animation: bananaPulse 1.1s ease-in-out infinite;
|
|
3690
|
+
vertical-align: middle;
|
|
3691
|
+
}
|
|
3692
|
+
.think-len {
|
|
3693
|
+
margin-left: auto;
|
|
3694
|
+
font-family: var(--mono);
|
|
3695
|
+
font-size: 10px;
|
|
3696
|
+
color: var(--text-3);
|
|
3697
|
+
font-variant-numeric: tabular-nums;
|
|
3698
|
+
}
|
|
3699
|
+
.think-body { max-height: 300px; }
|
|
3700
|
+
.think-body p { margin: 0 0 8px; }
|
|
3701
|
+
.think-body p:last-child { margin-bottom: 0; }
|
|
3702
|
+
.think-body code { font-family: var(--mono); font-size: 11.5px; background: var(--panel); padding: 1px 4px; border-radius: 3px; }
|
|
3703
|
+
.think-body ul, .think-body ol { margin: 6px 0 8px; padding-left: 20px; }
|
|
3704
|
+
.think-body h1, .think-body h2, .think-body h3 { font-size: 13px; margin: 10px 0 6px; }
|
|
3705
|
+
|
|
3706
|
+
.tool-row { position: relative; flex-wrap: wrap; }
|
|
3707
|
+
.tool-row .t-time {
|
|
3708
|
+
flex: none;
|
|
3709
|
+
min-width: 34px;
|
|
3710
|
+
text-align: right;
|
|
3711
|
+
font-family: var(--mono);
|
|
3712
|
+
font-size: 10.5px;
|
|
3713
|
+
color: var(--text-3);
|
|
3714
|
+
font-variant-numeric: tabular-nums;
|
|
3715
|
+
}
|
|
3716
|
+
.tool-output {
|
|
3717
|
+
margin: 2px 0 6px;
|
|
3718
|
+
padding: 8px 10px;
|
|
3719
|
+
max-height: 260px;
|
|
3720
|
+
overflow: auto;
|
|
3721
|
+
border-radius: 6px;
|
|
3722
|
+
background: var(--bg-deep);
|
|
3723
|
+
box-shadow: inset 0 0 0 0.5px var(--line);
|
|
3724
|
+
color: var(--text-2);
|
|
3725
|
+
font-family: var(--mono);
|
|
3726
|
+
font-size: 11.5px;
|
|
3727
|
+
line-height: 1.55;
|
|
3728
|
+
white-space: pre-wrap;
|
|
3729
|
+
overflow-wrap: anywhere;
|
|
3730
|
+
}
|
|
3731
|
+
.tool-output[hidden] { display: none; }
|
|
3732
|
+
.tool-output.is-error { color: #b4453a; background: var(--diff-del); }
|
|
3733
|
+
.tool-row.is-error .t-name { color: #b4453a; }
|
|
3734
|
+
.tool-row.is-open { background: var(--panel); }
|
|
3735
|
+
|
|
3736
|
+
/* 6. 回到最新 */
|
|
3737
|
+
.jump-latest {
|
|
3738
|
+
position: absolute;
|
|
3739
|
+
left: 50%;
|
|
3740
|
+
bottom: 118px;
|
|
3741
|
+
z-index: 6;
|
|
3742
|
+
transform: translateX(-50%) translateY(4px);
|
|
3743
|
+
display: inline-flex;
|
|
3744
|
+
align-items: center;
|
|
3745
|
+
gap: 5px;
|
|
3746
|
+
height: 30px;
|
|
3747
|
+
padding: 0 10px;
|
|
3748
|
+
border: 1px solid var(--line-strong);
|
|
3749
|
+
border-radius: 999px;
|
|
3750
|
+
background: var(--bg);
|
|
3751
|
+
color: var(--text-2);
|
|
3752
|
+
font-size: 12px;
|
|
3753
|
+
box-shadow: var(--shadow-sm);
|
|
3754
|
+
cursor: pointer;
|
|
3755
|
+
opacity: 0;
|
|
3756
|
+
transition: opacity 140ms var(--ease), transform 160ms var(--spring-banana);
|
|
3757
|
+
}
|
|
3758
|
+
.jump-latest:not([hidden]) { opacity: 1; transform: translateX(-50%); }
|
|
3759
|
+
.jump-latest svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
|
|
3760
|
+
.jump-latest:hover { color: var(--text); background: var(--panel); }
|
|
3761
|
+
|
|
3762
|
+
/* 7. Review 覆盖遮罩 */
|
|
3763
|
+
.review-scrim {
|
|
3764
|
+
position: absolute;
|
|
3765
|
+
inset: 0;
|
|
3766
|
+
z-index: 24;
|
|
3767
|
+
background: rgba(10, 10, 10, 0.2);
|
|
3768
|
+
backdrop-filter: blur(1px);
|
|
3769
|
+
}
|
|
3770
|
+
.review-scrim[hidden] { display: none; }
|
|
3771
|
+
|
|
3772
|
+
/* 8. 终端:去复古边框,改成 flat 卡片 */
|
|
3773
|
+
.terminal-dock {
|
|
3774
|
+
border: 0;
|
|
3775
|
+
border-radius: 10px;
|
|
3776
|
+
background: var(--bg);
|
|
3777
|
+
box-shadow: var(--shadow-raised);
|
|
3778
|
+
}
|
|
3779
|
+
.terminal-dock .term-head {
|
|
3780
|
+
height: 34px;
|
|
3781
|
+
border-bottom: 1px solid var(--line);
|
|
3782
|
+
background: transparent;
|
|
3783
|
+
}
|
|
3784
|
+
.terminal-dock .term-body { padding: 3px 4px 2px 8px; }
|
|
3785
|
+
.terminal-dock .term-tab { color: var(--text-3); }
|
|
3786
|
+
.terminal-dock .term-tab.active { background: var(--panel); color: var(--text); }
|
|
3787
|
+
.terminal-dock .term-tab + .term-tab { margin-left: 2px; }
|
|
3788
|
+
.term-resizer::after {
|
|
3789
|
+
content: '';
|
|
3790
|
+
position: absolute;
|
|
3791
|
+
left: 50%;
|
|
3792
|
+
transform: translateX(-50%);
|
|
3793
|
+
width: 34px;
|
|
3794
|
+
height: 2px;
|
|
3795
|
+
margin-top: 3px;
|
|
3796
|
+
border-radius: 999px;
|
|
3797
|
+
background: var(--line-strong);
|
|
3798
|
+
opacity: 0;
|
|
3799
|
+
transition: opacity 140ms var(--ease);
|
|
3800
|
+
}
|
|
3801
|
+
.term-resizer:hover::after { opacity: 1; }
|
|
3802
|
+
|
|
3803
|
+
/* 9. 侧栏收起状态 */
|
|
3804
|
+
#toggleSidebar.is-on { background: var(--panel); color: var(--text); }
|
|
3805
|
+
.sidebar[hidden] { display: none; }
|
|
3806
|
+
|
|
3807
|
+
/* 10. 消息操作:触屏和键盘也能看到 */
|
|
3808
|
+
@media (hover: none) {
|
|
3809
|
+
.msg-actions { opacity: 1; pointer-events: auto; }
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
/* 11. 细滚动条补齐工具输出 */
|
|
3813
|
+
.tool-output { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
|
|
3814
|
+
.tool-output::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
3815
|
+
.tool-output::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
|
|
3816
|
+
|
|
3817
|
+
/* 状态必须始终可见:busy 时不做淡入过渡,避免后台窗口/节流下卡在 0 */
|
|
3818
|
+
.composer.is-busy .composer-hint { opacity: 1; transition: none; }
|
|
3819
|
+
|
|
3820
|
+
/* 标签头像:空会话用叶子黄点,不再显示“新” */
|
|
3821
|
+
.tab-avatar.is-new { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); position: relative; }
|
|
3822
|
+
.tab-avatar.is-new::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.16); }
|
|
3823
|
+
.tab.is-running .tab-avatar { box-shadow: inset 0 0 0 1px var(--accent-ink); }
|
|
3824
|
+
.tab.is-running .tab-avatar::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-ink); animation: bananaPulse 1.1s ease-in-out infinite; }
|
|
3825
|
+
|
|
3826
|
+
/* 标题栏收敛:插件/主题收进设置与命令中心 */
|
|
3827
|
+
.tb-right #pluginsBtn, .tb-right #themeBtn { display: none; }
|
|
3828
|
+
|
|
3829
|
+
/* 空状态提示:不再继承旧的绝对定位 */
|
|
3830
|
+
.home-tips .empty-tips { margin-top: 0; }
|
|
3831
|
+
|
|
3832
|
+
/* 历史按钮:沿用自绘图标尺寸(去掉品牌 class 后补上) */
|
|
3833
|
+
.tb-brand > svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
|
|
3834
|
+
|
|
3835
|
+
/* 12. Composer 纵向改为 stretch:否则工具栏只有内容宽度、被挤到右侧,
|
|
3836
|
+
附件按钮看起来像“跑到了中间” */
|
|
3837
|
+
.composer { align-items: stretch; }
|
|
3838
|
+
.composer-toolbar { width: 100%; }
|
|
3839
|
+
.ct-left { flex: 1 1 auto; }
|
|
3840
|
+
.ct-left > .attach-btn { order: -1; }
|
|
3841
|
+
.ct-right { flex: none; }
|
|
3842
|
+
|
|
3843
|
+
/* 13. 模型切换:用向下的箭头,不再用芯片图标 */
|
|
3844
|
+
.model-chip [data-icon] { display: inline-grid; place-items: center; flex: none; opacity: 0.7; }
|
|
3845
|
+
|
|
3846
|
+
/* 14. 终端:头部按钮不被内容层盖住,菜单从头部下方完整浮出 */
|
|
3847
|
+
.terminal-dock .term-head { z-index: 6; }
|
|
3848
|
+
.terminal-dock .term-head > .icon-btn { flex: none; position: relative; z-index: 1; }
|
|
3849
|
+
.terminal-dock .term-cwd { flex: 0 1 auto; min-width: 0; }
|
|
3850
|
+
.term-menu { top: 100%; right: 8px; z-index: 30; }
|
|
3851
|
+
.term-body, .term-pane, .xterm { position: relative; z-index: 0; }
|