@vincentbanana/banana-gui 0.9.1 → 1.0.0
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 +3 -2
- package/ui/app.js +481 -46
- package/ui/index.html +37 -2
- package/ui/style.css +147 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincentbanana/banana-gui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Banana 的图形界面:本地服务 + 浏览器。黑白主题,自绘图标,无第三方 UI 依赖",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"sync": "node ../scripts/sync-gui.mjs",
|
|
31
31
|
"test": "node test/gui-package.test.mjs",
|
|
32
|
+
"prepublishOnly": "npm run sync && node ../scripts/check-gui-sync.mjs && node test/gui-package.test.mjs",
|
|
32
33
|
"desktop": "electron desktop/main.cjs",
|
|
33
34
|
"pack": "electron-builder --dir",
|
|
34
35
|
"dist": "electron-builder",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"electron-builder": "^25.0.0"
|
|
72
73
|
},
|
|
73
74
|
"dependencies": {
|
|
74
|
-
"@vincentbanana/bananacli": "^0.
|
|
75
|
+
"@vincentbanana/bananacli": "^0.8.0"
|
|
75
76
|
},
|
|
76
77
|
"license": "MIT",
|
|
77
78
|
"publishConfig": {
|
package/ui/app.js
CHANGED
|
@@ -190,6 +190,8 @@ const state = {
|
|
|
190
190
|
dock: { open: false, height: 280 },
|
|
191
191
|
changes: null,
|
|
192
192
|
changesFile: null,
|
|
193
|
+
todoOpen: true,
|
|
194
|
+
attachmentPath: '',
|
|
193
195
|
};
|
|
194
196
|
|
|
195
197
|
const THREAD = $('thread');
|
|
@@ -641,6 +643,14 @@ function renderMessage(message) {
|
|
|
641
643
|
body.className = 'msg-body';
|
|
642
644
|
if (message.role === 'user') {
|
|
643
645
|
body.textContent = message.content;
|
|
646
|
+
if (message.attachments?.length) {
|
|
647
|
+
const chips = document.createElement('div');
|
|
648
|
+
chips.className = 'attachments msg-attachments';
|
|
649
|
+
renderAttachmentChips(chips, message.attachments);
|
|
650
|
+
node.append(role, body, chips);
|
|
651
|
+
if (message.content?.trim()) messageActions(node, message.content, message.role);
|
|
652
|
+
return node;
|
|
653
|
+
}
|
|
644
654
|
} else {
|
|
645
655
|
body.innerHTML = markdown(message.content || '');
|
|
646
656
|
if (message.reasoning && state.info?.showReasoning !== false) {
|
|
@@ -715,7 +725,10 @@ function renderThread() {
|
|
|
715
725
|
const node = renderMessage(message);
|
|
716
726
|
if (node) THREAD.appendChild(node);
|
|
717
727
|
}
|
|
728
|
+
const plan = state.info?.session?.plan;
|
|
729
|
+
if (plan && plan.status !== 'cancelled') THREAD.appendChild(planCardNode(plan));
|
|
718
730
|
renderTurnMeta();
|
|
731
|
+
renderTodos();
|
|
719
732
|
updateHomeMode();
|
|
720
733
|
// 切换会话时瞬间定位到底部;平滑滚动只用于新消息
|
|
721
734
|
scrollToEnd(false);
|
|
@@ -760,6 +773,21 @@ function renderHeader() {
|
|
|
760
773
|
if (!info) return;
|
|
761
774
|
$('threadTitle').textContent = info.session.title || '新对话';
|
|
762
775
|
$('modelLabel').textContent = `${info.provider.name} / ${info.provider.model}`;
|
|
776
|
+
const mode = info.session?.mode ?? 'build';
|
|
777
|
+
const modeButtons = $('modeSwitch')?.querySelectorAll('[data-mode]') ?? [];
|
|
778
|
+
modeButtons.forEach((button) => {
|
|
779
|
+
const on = button.dataset.mode === mode;
|
|
780
|
+
button.classList.toggle('is-on', on);
|
|
781
|
+
button.setAttribute('aria-pressed', String(on));
|
|
782
|
+
});
|
|
783
|
+
$('modeBadge').hidden = mode !== 'plan';
|
|
784
|
+
const level = info.session?.reasoning ?? 'standard';
|
|
785
|
+
$('reasoningLabel').textContent = REASONING_LABELS[level] ?? '标准';
|
|
786
|
+
$('reasoningBtn').classList.toggle('is-unsupported', info.reasoning?.supported === false);
|
|
787
|
+
$('reasoningBtn').setAttribute('aria-disabled', String(info.reasoning?.supported === false));
|
|
788
|
+
$('reasoningBtn').title = info.reasoning?.supported === false
|
|
789
|
+
? '当前模型不支持显式思考强度'
|
|
790
|
+
: `思考强度:${REASONING_LABELS[level] ?? '标准'}`;
|
|
763
791
|
if (!state.busy) $('composerHint').textContent = workspaceHint();
|
|
764
792
|
else if (state.status) $('composerHint').textContent = state.status;
|
|
765
793
|
renderTurnMeta();
|
|
@@ -813,6 +841,7 @@ async function refresh(path) {
|
|
|
813
841
|
renderHeader();
|
|
814
842
|
renderSidebar();
|
|
815
843
|
renderTabs();
|
|
844
|
+
renderTodos();
|
|
816
845
|
if (path) renderThread();
|
|
817
846
|
}
|
|
818
847
|
|
|
@@ -840,6 +869,7 @@ function syncOverlayState() {
|
|
|
840
869
|
const open =
|
|
841
870
|
!$('commandCenter').hidden ||
|
|
842
871
|
!$('codeViewer').hidden ||
|
|
872
|
+
!$('attachmentViewer').hidden ||
|
|
843
873
|
!$('settingsSheet').hidden ||
|
|
844
874
|
!$('approvalModal').hidden;
|
|
845
875
|
document.body.classList.toggle('has-overlay', open);
|
|
@@ -848,6 +878,11 @@ function syncOverlayState() {
|
|
|
848
878
|
function closeTopOverlay() {
|
|
849
879
|
if (!$('selectionTools').hidden) return hideSelectionTools();
|
|
850
880
|
if (!$('commandCenter').hidden) return closeCommandCenter();
|
|
881
|
+
if (!$('attachmentViewer').hidden) {
|
|
882
|
+
$('attachmentViewer').hidden = true;
|
|
883
|
+
syncOverlayState();
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
851
886
|
if (!$('codeViewer').hidden) return closeViewer();
|
|
852
887
|
if (!$('settingsSheet').hidden) return closeSettings();
|
|
853
888
|
if (!$('approvalModal').hidden) return closeApproval(false);
|
|
@@ -945,6 +980,321 @@ function renderCode(container, code, path) {
|
|
|
945
980
|
}
|
|
946
981
|
|
|
947
982
|
|
|
983
|
+
// ---------------- 任务清单 / 计划 / 附件 ----------------
|
|
984
|
+
const REASONING_LABELS = { fast: '快', standard: '标准', deep: '深入' };
|
|
985
|
+
const REASONING_HINTS = {
|
|
986
|
+
fast: '低推理,响应快、消耗少',
|
|
987
|
+
standard: '日常默认,速度和准确率平衡',
|
|
988
|
+
deep: '高推理,更慢但更适合复杂任务',
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
function formatFileSize(bytes) {
|
|
992
|
+
if (!bytes) return '';
|
|
993
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
994
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
995
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function attachmentIcon(kind) {
|
|
999
|
+
return kind === 'image' ? 'image' : kind === 'text' ? 'file' : 'file';
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function renderAttachmentChips(container, items, removable = false, index = 0) {
|
|
1003
|
+
if (!items?.length) return;
|
|
1004
|
+
container.classList.add('is-message-attachments');
|
|
1005
|
+
for (const item of items) {
|
|
1006
|
+
const chip = document.createElement('button');
|
|
1007
|
+
chip.type = 'button';
|
|
1008
|
+
chip.className = 'att';
|
|
1009
|
+
chip.title = item.path ?? '';
|
|
1010
|
+
chip.innerHTML =
|
|
1011
|
+
`<span class="att-ico">${svg(attachmentIcon(item.kind))}</span>` +
|
|
1012
|
+
`<span class="att-name">${escapeHtml(item.name ?? '附件')}</span>` +
|
|
1013
|
+
(removable
|
|
1014
|
+
? `<span class="att-remove" data-remove="${index}" aria-label="移除">${svg('x')}</span>`
|
|
1015
|
+
: `<span class="att-size">${escapeHtml(formatFileSize(item.size))}</span>`);
|
|
1016
|
+
chip.addEventListener('click', (event) => {
|
|
1017
|
+
if (event.target.closest('[data-remove]')) return;
|
|
1018
|
+
openAttachmentPreview(item);
|
|
1019
|
+
});
|
|
1020
|
+
if (removable) {
|
|
1021
|
+
chip.querySelector('[data-remove]')?.addEventListener('click', (event) => {
|
|
1022
|
+
event.stopPropagation();
|
|
1023
|
+
state.attachments.splice(index, 1);
|
|
1024
|
+
renderAttachments();
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
container.appendChild(chip);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function renderAttachments() {
|
|
1032
|
+
const box = $('attachments');
|
|
1033
|
+
box.hidden = state.attachments.length === 0;
|
|
1034
|
+
box.innerHTML = '';
|
|
1035
|
+
state.attachments.forEach((item, index) => renderAttachmentChips(box, [item], true, index));
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
async function openAttachmentPreview(item) {
|
|
1039
|
+
if (!item?.path) return;
|
|
1040
|
+
state.attachmentPath = item.path;
|
|
1041
|
+
$('attachmentName').textContent = item.name ?? '附件';
|
|
1042
|
+
$('attachmentMeta').textContent = `${formatFileSize(item.size)}${item.mime ? ` · ${item.mime}` : ''}`;
|
|
1043
|
+
const body = $('attachmentBody');
|
|
1044
|
+
body.innerHTML = '<div class="hint" style="padding:16px">读取中…</div>';
|
|
1045
|
+
$('attachmentViewer').hidden = false;
|
|
1046
|
+
document.body.classList.add('has-overlay');
|
|
1047
|
+
try {
|
|
1048
|
+
const data = await get(`attachment?path=${encodeURIComponent(item.path)}`);
|
|
1049
|
+
if (data.dataUrl && data.kind === 'image') {
|
|
1050
|
+
body.innerHTML = `<div class="attachment-image"><img alt="${escapeHtml(item.name)}" src="${data.dataUrl}" /></div>`;
|
|
1051
|
+
} else if (data.dataUrl && data.kind === 'pdf') {
|
|
1052
|
+
body.innerHTML = `<iframe class="attachment-pdf" title="PDF 预览" src="${data.dataUrl}"></iframe>`;
|
|
1053
|
+
} else if (typeof data.content === 'string') {
|
|
1054
|
+
renderCode(body, data.content, item.name);
|
|
1055
|
+
if (data.truncated) body.insertAdjacentHTML('beforeend', '<div class="hint" style="padding:8px 12px">内容较长,只预览了前 120000 字符。</div>');
|
|
1056
|
+
} else {
|
|
1057
|
+
body.innerHTML =
|
|
1058
|
+
`<div class="attachment-info"><strong>${escapeHtml(item.name ?? '附件')}</strong>` +
|
|
1059
|
+
`<span>${escapeHtml(data.kind ?? item.kind ?? '文件')} · ${escapeHtml(formatFileSize(data.bytes ?? item.size))}</span>` +
|
|
1060
|
+
`<span class="mono">${escapeHtml(item.path)}</span>` +
|
|
1061
|
+
'<span>这类文件不解析正文;发送时会只把路径和元信息交给模型。</span></div>';
|
|
1062
|
+
}
|
|
1063
|
+
} catch (error) {
|
|
1064
|
+
body.innerHTML = `<div class="hint" style="padding:16px">${escapeHtml(error.message)}</div>`;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
function todoMark(status) {
|
|
1069
|
+
if (status === 'done') return svg('check');
|
|
1070
|
+
if (status === 'in_progress') return '<span class="todo-pulse"></span>';
|
|
1071
|
+
return '';
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function renderTodos() {
|
|
1075
|
+
const todos = state.info?.session?.todos ?? [];
|
|
1076
|
+
const done = todos.filter((item) => item.status === 'done').length;
|
|
1077
|
+
const dock = $('todoDock');
|
|
1078
|
+
if (!dock) return;
|
|
1079
|
+
dock.hidden = todos.length === 0;
|
|
1080
|
+
dock.classList.toggle('is-open', state.todoOpen);
|
|
1081
|
+
$('todoSummary').setAttribute('aria-expanded', String(state.todoOpen));
|
|
1082
|
+
$('todoCount').textContent = `${done}/${todos.length}`;
|
|
1083
|
+
$('todoBarFill').style.width = todos.length ? `${Math.round((done / todos.length) * 100)}%` : '0%';
|
|
1084
|
+
const list = $('todoList');
|
|
1085
|
+
list.innerHTML = '';
|
|
1086
|
+
todos.forEach((item) => {
|
|
1087
|
+
const row = document.createElement('div');
|
|
1088
|
+
row.className = `todo-item is-${item.status}`;
|
|
1089
|
+
row.innerHTML = `<span class="todo-mark">${todoMark(item.status)}</span><span>${escapeHtml(item.text)}</span>`;
|
|
1090
|
+
list.appendChild(row);
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
const panelList = $('tasksList');
|
|
1094
|
+
if (panelList) {
|
|
1095
|
+
panelList.innerHTML = '';
|
|
1096
|
+
$('tasksEmpty').hidden = todos.length > 0;
|
|
1097
|
+
todos.forEach((item, index) => {
|
|
1098
|
+
const row = document.createElement('div');
|
|
1099
|
+
row.className = `task-row is-${item.status}`;
|
|
1100
|
+
row.innerHTML =
|
|
1101
|
+
`<span class="task-index">${index + 1}</span>` +
|
|
1102
|
+
`<span class="task-mark">${todoMark(item.status)}</span>` +
|
|
1103
|
+
`<span class="task-text">${escapeHtml(item.text)}</span>` +
|
|
1104
|
+
`<span class="task-state">${item.status === 'done' ? '完成' : item.status === 'in_progress' ? '进行中' : '待办'}</span>`;
|
|
1105
|
+
panelList.appendChild(row);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
function planCardNode(plan) {
|
|
1111
|
+
const card = document.createElement('div');
|
|
1112
|
+
card.className = `plan-card is-${plan.status ?? 'pending'}`;
|
|
1113
|
+
const title =
|
|
1114
|
+
plan.status === 'approved' ? '计划已批准' : plan.status === 'cancelled' ? '计划已取消' : '计划 · 等你批准';
|
|
1115
|
+
card.innerHTML =
|
|
1116
|
+
`<div class="plan-head"><span class="plan-dot"></span><span>${title}</span>` +
|
|
1117
|
+
(plan.status === 'pending' ? '<span class="plan-hint">Plan 模式不会改动文件</span>' : '') +
|
|
1118
|
+
'</div>';
|
|
1119
|
+
const list = document.createElement('div');
|
|
1120
|
+
list.className = 'plan-list';
|
|
1121
|
+
const items = plan.items ?? [];
|
|
1122
|
+
if (!items.length) {
|
|
1123
|
+
list.innerHTML = '<div class="plan-empty">这一轮没有生成结构化清单,可以直接批准后按上面的计划执行。</div>';
|
|
1124
|
+
} else {
|
|
1125
|
+
items.forEach((item, index) => {
|
|
1126
|
+
const row = document.createElement('div');
|
|
1127
|
+
row.className = `plan-item is-${item.status}`;
|
|
1128
|
+
row.innerHTML =
|
|
1129
|
+
`<span class="plan-index">${index + 1}</span>` +
|
|
1130
|
+
`<span class="plan-mark">${todoMark(item.status)}</span>` +
|
|
1131
|
+
`<span>${escapeHtml(item.text)}</span>`;
|
|
1132
|
+
list.appendChild(row);
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
card.appendChild(list);
|
|
1136
|
+
if (plan.status === 'pending') {
|
|
1137
|
+
const actions = document.createElement('div');
|
|
1138
|
+
actions.className = 'plan-actions';
|
|
1139
|
+
const approve = document.createElement('button');
|
|
1140
|
+
approve.className = 'btn primary';
|
|
1141
|
+
approve.textContent = '批准并执行';
|
|
1142
|
+
approve.addEventListener('click', () => approvePlan(card));
|
|
1143
|
+
const revise = document.createElement('button');
|
|
1144
|
+
revise.className = 'btn';
|
|
1145
|
+
revise.textContent = '修改计划';
|
|
1146
|
+
revise.addEventListener('click', () => revisePlan());
|
|
1147
|
+
const cancel = document.createElement('button');
|
|
1148
|
+
cancel.className = 'btn ghost';
|
|
1149
|
+
cancel.textContent = '取消';
|
|
1150
|
+
cancel.addEventListener('click', () => cancelPlan(card));
|
|
1151
|
+
actions.append(approve, revise, cancel);
|
|
1152
|
+
card.appendChild(actions);
|
|
1153
|
+
}
|
|
1154
|
+
return card;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
function renderThreadPlan() {
|
|
1158
|
+
THREAD.querySelector('.plan-card')?.remove();
|
|
1159
|
+
const plan = state.info?.session?.plan;
|
|
1160
|
+
if (!plan || plan.status === 'cancelled') return;
|
|
1161
|
+
THREAD.appendChild(planCardNode(plan));
|
|
1162
|
+
scrollToEnd(false);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function renderPendingPlan(plan) {
|
|
1166
|
+
THREAD.querySelector('.plan-card')?.remove();
|
|
1167
|
+
if (!plan || plan.status === 'cancelled') return;
|
|
1168
|
+
THREAD.appendChild(planCardNode(plan));
|
|
1169
|
+
scrollToEnd();
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
async function approvePlan(card) {
|
|
1173
|
+
if (state.busy) return;
|
|
1174
|
+
try {
|
|
1175
|
+
const result = await post('plan', { action: 'approve' });
|
|
1176
|
+
if (result?.info) state.info = result.info;
|
|
1177
|
+
card.remove();
|
|
1178
|
+
renderHeader();
|
|
1179
|
+
renderTodos();
|
|
1180
|
+
renderTabs();
|
|
1181
|
+
const input = $('input');
|
|
1182
|
+
input.value = '计划已批准,按清单执行。';
|
|
1183
|
+
await send();
|
|
1184
|
+
} catch (error) {
|
|
1185
|
+
toast('批准失败:' + error.message);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
async function revisePlan() {
|
|
1190
|
+
try {
|
|
1191
|
+
const result = await post('plan', { action: 'revise' });
|
|
1192
|
+
if (result?.info) state.info = result.info;
|
|
1193
|
+
renderHeader();
|
|
1194
|
+
const input = $('input');
|
|
1195
|
+
input.value = '请修改计划:';
|
|
1196
|
+
input.focus();
|
|
1197
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
1198
|
+
grow();
|
|
1199
|
+
} catch (error) {
|
|
1200
|
+
toast('操作失败:' + error.message);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
async function cancelPlan(card) {
|
|
1205
|
+
try {
|
|
1206
|
+
const result = await post('plan', { action: 'cancel' });
|
|
1207
|
+
if (result?.info) state.info = result.info;
|
|
1208
|
+
card.remove();
|
|
1209
|
+
renderHeader();
|
|
1210
|
+
renderTodos();
|
|
1211
|
+
toast('计划已取消');
|
|
1212
|
+
} catch (error) {
|
|
1213
|
+
toast('取消失败:' + error.message);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
let reasoningPop = null;
|
|
1218
|
+
function closeReasoningPop() {
|
|
1219
|
+
reasoningPop?.remove();
|
|
1220
|
+
reasoningPop = null;
|
|
1221
|
+
document.removeEventListener('click', onReasoningOutside, true);
|
|
1222
|
+
document.removeEventListener('keydown', onReasoningKey, true);
|
|
1223
|
+
}
|
|
1224
|
+
function onReasoningOutside(event) {
|
|
1225
|
+
if (event.target.closest('#reasoningPop, #reasoningBtn')) return;
|
|
1226
|
+
closeReasoningPop();
|
|
1227
|
+
}
|
|
1228
|
+
function onReasoningKey(event) {
|
|
1229
|
+
if (event.key === 'Escape') {
|
|
1230
|
+
event.preventDefault();
|
|
1231
|
+
closeReasoningPop();
|
|
1232
|
+
$('reasoningBtn')?.focus();
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
function toggleReasoningPop() {
|
|
1236
|
+
if (reasoningPop) return closeReasoningPop();
|
|
1237
|
+
const info = state.info;
|
|
1238
|
+
if (!info) return;
|
|
1239
|
+
const supported = info.reasoning?.supported !== false;
|
|
1240
|
+
const current = info.session?.reasoning ?? info.reasoning?.level ?? 'standard';
|
|
1241
|
+
const pop = document.createElement('div');
|
|
1242
|
+
pop.className = 'model-pop reasoning-pop';
|
|
1243
|
+
pop.id = 'reasoningPop';
|
|
1244
|
+
pop.setAttribute('role', 'dialog');
|
|
1245
|
+
pop.setAttribute('aria-label', '思考强度');
|
|
1246
|
+
pop.innerHTML = '<div class="mp-head"><span>思考强度</span><span class="mp-sub">下一轮生效</span></div>';
|
|
1247
|
+
for (const level of ['fast', 'standard', 'deep']) {
|
|
1248
|
+
const row = document.createElement('button');
|
|
1249
|
+
row.type = 'button';
|
|
1250
|
+
row.className = `mp-row reasoning-row${level === current ? ' is-on' : ''}`;
|
|
1251
|
+
row.disabled = !supported;
|
|
1252
|
+
row.innerHTML =
|
|
1253
|
+
`<span class="reasoning-text"><span class="mp-name">${REASONING_LABELS[level]}</span>` +
|
|
1254
|
+
`<span class="reasoning-desc">${REASONING_HINTS[level]}</span></span>` +
|
|
1255
|
+
(level === current ? `<span class="mp-check">${svg('check')}</span>` : '<span></span>');
|
|
1256
|
+
row.addEventListener('click', async () => {
|
|
1257
|
+
if (!supported) return;
|
|
1258
|
+
try {
|
|
1259
|
+
const result = await post('session', { action: 'reasoning', value: level });
|
|
1260
|
+
if (result?.info) state.info = result.info;
|
|
1261
|
+
renderHeader();
|
|
1262
|
+
closeReasoningPop();
|
|
1263
|
+
toast(`思考强度:${REASONING_LABELS[level]}`);
|
|
1264
|
+
} catch (error) {
|
|
1265
|
+
toast('保存失败:' + error.message);
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
pop.appendChild(row);
|
|
1269
|
+
}
|
|
1270
|
+
if (!supported) {
|
|
1271
|
+
const note = document.createElement('div');
|
|
1272
|
+
note.className = 'reasoning-note';
|
|
1273
|
+
note.textContent = '当前模型不支持显式思考强度,选择会被忽略。';
|
|
1274
|
+
pop.appendChild(note);
|
|
1275
|
+
}
|
|
1276
|
+
document.body.appendChild(pop);
|
|
1277
|
+
reasoningPop = pop;
|
|
1278
|
+
const rect = $('reasoningBtn').getBoundingClientRect();
|
|
1279
|
+
const width = Math.min(320, window.innerWidth - 16);
|
|
1280
|
+
pop.style.width = `${width}px`;
|
|
1281
|
+
pop.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - width - 8))}px`;
|
|
1282
|
+
if (rect.top > 260) {
|
|
1283
|
+
pop.style.bottom = `${Math.max(8, window.innerHeight - rect.top + 8)}px`;
|
|
1284
|
+
pop.style.maxHeight = `${Math.max(160, rect.top - 16)}px`;
|
|
1285
|
+
} else {
|
|
1286
|
+
pop.style.top = `${Math.max(8, rect.bottom + 8)}px`;
|
|
1287
|
+
pop.style.maxHeight = `${Math.max(160, window.innerHeight - rect.bottom - 16)}px`;
|
|
1288
|
+
}
|
|
1289
|
+
pop.style.overflowY = 'auto';
|
|
1290
|
+
void pop.offsetHeight;
|
|
1291
|
+
pop.classList.add('is-on');
|
|
1292
|
+
setTimeout(() => {
|
|
1293
|
+
document.addEventListener('click', onReasoningOutside, true);
|
|
1294
|
+
document.addEventListener('keydown', onReasoningKey, true);
|
|
1295
|
+
}, 0);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
948
1298
|
// ---------------- 聊天流 ----------------
|
|
949
1299
|
let controller = null;
|
|
950
1300
|
|
|
@@ -974,7 +1324,6 @@ function setBusy(busy) {
|
|
|
974
1324
|
send.setAttribute('aria-label', busy ? '停止生成' : '发送');
|
|
975
1325
|
send.dataset.mode = busy ? 'stop' : 'send';
|
|
976
1326
|
send.disabled = busy ? false : $('input').value.trim() === '';
|
|
977
|
-
$('abortBtn').hidden = true;
|
|
978
1327
|
document.body.style.cursor = busy ? 'progress' : '';
|
|
979
1328
|
if (state.tabs?.length) renderTabs();
|
|
980
1329
|
}
|
|
@@ -1015,16 +1364,14 @@ async function send() {
|
|
|
1015
1364
|
}
|
|
1016
1365
|
|
|
1017
1366
|
const messages = state.info.session.messages ?? (state.info.session.messages = []);
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
renderHeader();
|
|
1021
|
-
}
|
|
1367
|
+
const files = state.attachments.map((item) => ({ ...item }));
|
|
1368
|
+
const images = files.filter((item) => item.kind === 'image').map((item) => item.path);
|
|
1022
1369
|
|
|
1023
1370
|
// 首页空状态整块移除,否则第一条消息会被追加在 wordmark 下面
|
|
1024
1371
|
THREAD.querySelector('.empty')?.remove();
|
|
1025
1372
|
$('chatCard').classList.remove('home-mode');
|
|
1026
1373
|
$('homeTips').hidden = true;
|
|
1027
|
-
messages.push({ role: 'user', content: text });
|
|
1374
|
+
messages.push({ role: 'user', content: text, ...(files.length ? { attachments: files } : {}) });
|
|
1028
1375
|
|
|
1029
1376
|
const userMsg = document.createElement('article');
|
|
1030
1377
|
userMsg.className = 'msg user enter';
|
|
@@ -1033,6 +1380,12 @@ async function send() {
|
|
|
1033
1380
|
userBody.className = 'msg-body';
|
|
1034
1381
|
userBody.textContent = text;
|
|
1035
1382
|
userMsg.appendChild(userBody);
|
|
1383
|
+
if (files.length) {
|
|
1384
|
+
const chips = document.createElement('div');
|
|
1385
|
+
chips.className = 'attachments msg-attachments';
|
|
1386
|
+
renderAttachmentChips(chips, files);
|
|
1387
|
+
userMsg.appendChild(chips);
|
|
1388
|
+
}
|
|
1036
1389
|
messageActions(userMsg, text, 'user');
|
|
1037
1390
|
const divider = document.createElement('div');
|
|
1038
1391
|
divider.className = 'thread-divider';
|
|
@@ -1133,7 +1486,6 @@ async function send() {
|
|
|
1133
1486
|
if (!toolErrors) work.open = false;
|
|
1134
1487
|
};
|
|
1135
1488
|
|
|
1136
|
-
const images = state.attachments.map((item) => item.path);
|
|
1137
1489
|
state.attachments = [];
|
|
1138
1490
|
renderAttachments();
|
|
1139
1491
|
|
|
@@ -1177,7 +1529,12 @@ async function send() {
|
|
|
1177
1529
|
const res = await fetch(API + 'chat', {
|
|
1178
1530
|
method: 'POST',
|
|
1179
1531
|
headers: { 'content-type': 'application/json' },
|
|
1180
|
-
body: JSON.stringify({
|
|
1532
|
+
body: JSON.stringify({
|
|
1533
|
+
message: text,
|
|
1534
|
+
images,
|
|
1535
|
+
attachments: files,
|
|
1536
|
+
session: state.info?.session?.id,
|
|
1537
|
+
}),
|
|
1181
1538
|
signal: controller.signal,
|
|
1182
1539
|
});
|
|
1183
1540
|
if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error ?? res.statusText);
|
|
@@ -1298,6 +1655,9 @@ async function send() {
|
|
|
1298
1655
|
setWorking(event.message);
|
|
1299
1656
|
working.hidden = false;
|
|
1300
1657
|
}
|
|
1658
|
+
} else if (event.type === 'todos') {
|
|
1659
|
+
if (state.info?.session) state.info.session.todos = event.todos ?? [];
|
|
1660
|
+
renderTodos();
|
|
1301
1661
|
} else if (event.type === 'approval') {
|
|
1302
1662
|
const allowed = await askApproval(event);
|
|
1303
1663
|
await post('approve', { id: event.id, allowed });
|
|
@@ -1329,17 +1689,15 @@ async function send() {
|
|
|
1329
1689
|
metaLine('用时', (event.ms / 1000).toFixed(1) + 's');
|
|
1330
1690
|
if (event.cost && event.cost !== '≈$0') metaLine('花费', event.cost);
|
|
1331
1691
|
state.info = event.info;
|
|
1332
|
-
state.info.session.
|
|
1333
|
-
|
|
1334
|
-
role: 'assistant',
|
|
1335
|
-
content: buffer,
|
|
1336
|
-
reasoning: reasoningText || undefined,
|
|
1337
|
-
};
|
|
1692
|
+
if (event.todos) state.info.session.todos = event.todos;
|
|
1693
|
+
if (event.plan) state.info.session.plan = event.plan;
|
|
1338
1694
|
const { sessions } = await get('sessions');
|
|
1339
1695
|
state.sessions = sessions;
|
|
1340
1696
|
renderSidebar();
|
|
1341
1697
|
renderTabs();
|
|
1342
1698
|
renderHeader();
|
|
1699
|
+
renderTodos();
|
|
1700
|
+
if (event.plan?.status === 'pending') renderPendingPlan(event.plan);
|
|
1343
1701
|
if (state.review.open && state.review.mode === 'changes') void loadChanges(true);
|
|
1344
1702
|
}
|
|
1345
1703
|
}
|
|
@@ -1357,12 +1715,30 @@ async function send() {
|
|
|
1357
1715
|
}
|
|
1358
1716
|
} catch (error) {
|
|
1359
1717
|
body.classList.remove('caret');
|
|
1360
|
-
|
|
1718
|
+
const aborted = controller?.signal.aborted || /abort/i.test(String(error?.message ?? ''));
|
|
1719
|
+
if (aborted) {
|
|
1720
|
+
body.innerHTML = markdown(buffer.trim() || '已停止生成。');
|
|
1721
|
+
metaLine('状态', '已停止');
|
|
1722
|
+
streamEnded = true;
|
|
1723
|
+
} else if (!buffer.trim()) {
|
|
1724
|
+
body.innerHTML = markdown(`**中断** ${escapeHtml(error.message)}`);
|
|
1725
|
+
}
|
|
1361
1726
|
await refresh();
|
|
1362
1727
|
} finally {
|
|
1363
1728
|
finishReasoning();
|
|
1729
|
+
for (const row of toolRows.values()) {
|
|
1730
|
+
clearInterval(row._timer);
|
|
1731
|
+
if (!row.dataset.done) {
|
|
1732
|
+
row.dataset.done = '1';
|
|
1733
|
+
row.classList.remove('is-open');
|
|
1734
|
+
row.classList.add('is-error');
|
|
1735
|
+
const stateNode = row.querySelector('.t-state');
|
|
1736
|
+
if (stateNode) stateNode.innerHTML = svg('x');
|
|
1737
|
+
row.querySelector('.t-time')?.remove();
|
|
1738
|
+
toolErrors = true;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1364
1741
|
finishWork();
|
|
1365
|
-
for (const row of toolRows.values()) clearInterval(row._timer);
|
|
1366
1742
|
working.hidden = true;
|
|
1367
1743
|
body.classList.remove('caret');
|
|
1368
1744
|
controller = null;
|
|
@@ -1578,34 +1954,46 @@ async function runCommand(text) {
|
|
|
1578
1954
|
}
|
|
1579
1955
|
|
|
1580
1956
|
// ---------------- 附件 ----------------
|
|
1581
|
-
function
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
});
|
|
1593
|
-
box.appendChild(chip);
|
|
1594
|
-
});
|
|
1957
|
+
function attachmentKindOf(file) {
|
|
1958
|
+
const name = String(file.name ?? '').toLowerCase();
|
|
1959
|
+
if (/^image\//.test(file.type) && !name.endsWith('.svg')) return 'image';
|
|
1960
|
+
if (file.type === 'application/pdf' || name.endsWith('.pdf')) return 'pdf';
|
|
1961
|
+
if (
|
|
1962
|
+
/^text\//.test(file.type) ||
|
|
1963
|
+
/\.(txt|md|json|js|mjs|cjs|ts|tsx|jsx|css|html?|xml|ya?ml|toml|py|go|rs|java|c|h|cpp|hpp|sh|bash|ps1|sql|ini|conf|env|lock)$/i.test(name)
|
|
1964
|
+
) {
|
|
1965
|
+
return 'text';
|
|
1966
|
+
}
|
|
1967
|
+
return 'binary';
|
|
1595
1968
|
}
|
|
1596
1969
|
|
|
1597
1970
|
async function attach(file) {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1971
|
+
const kind = attachmentKindOf(file);
|
|
1972
|
+
const limit = kind === 'image' ? 4 * 1024 * 1024 : 20 * 1024 * 1024;
|
|
1973
|
+
if (file.size > limit) {
|
|
1974
|
+
toast(`${file.name} 超过 ${formatFileSize(limit)}`);
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
try {
|
|
1978
|
+
const base64 = await new Promise((resolve, reject) => {
|
|
1979
|
+
const reader = new FileReader();
|
|
1980
|
+
reader.onload = () => resolve(String(reader.result).split(',')[1]);
|
|
1981
|
+
reader.onerror = () => reject(reader.error ?? new Error('读取文件失败'));
|
|
1982
|
+
reader.readAsDataURL(file);
|
|
1983
|
+
});
|
|
1984
|
+
const result = await post('attach?name=' + encodeURIComponent(file.name), { data: base64 });
|
|
1985
|
+
state.attachments.push({
|
|
1986
|
+
name: file.name,
|
|
1987
|
+
path: result.path,
|
|
1988
|
+
size: result.bytes ?? file.size,
|
|
1989
|
+
mime: result.mime ?? file.type,
|
|
1990
|
+
kind: result.kind ?? kind,
|
|
1991
|
+
});
|
|
1992
|
+
renderAttachments();
|
|
1993
|
+
toast('已附加 ' + file.name);
|
|
1994
|
+
} catch (error) {
|
|
1995
|
+
toast('附加失败:' + (error?.message ?? error));
|
|
1996
|
+
}
|
|
1609
1997
|
}
|
|
1610
1998
|
|
|
1611
1999
|
// ---------------- 控制中心 ----------------
|
|
@@ -2389,16 +2777,19 @@ function applyReviewWidth(width) {
|
|
|
2389
2777
|
}
|
|
2390
2778
|
|
|
2391
2779
|
function setReviewMode(mode) {
|
|
2392
|
-
if (!['changes', 'files'].includes(mode)) mode = 'changes';
|
|
2780
|
+
if (!['changes', 'files', 'tasks'].includes(mode)) mode = 'changes';
|
|
2393
2781
|
state.review.mode = mode;
|
|
2394
2782
|
try {
|
|
2395
2783
|
localStorage.setItem(SHELL_STORAGE.reviewMode, mode);
|
|
2396
2784
|
} catch {}
|
|
2397
2785
|
$('reviewTabChanges').classList.toggle('is-on', mode === 'changes');
|
|
2398
2786
|
$('reviewTabFiles').classList.toggle('is-on', mode === 'files');
|
|
2787
|
+
$('reviewTabTasks').classList.toggle('is-on', mode === 'tasks');
|
|
2399
2788
|
$('changesPanel').classList.toggle('is-on', mode === 'changes');
|
|
2400
2789
|
$('filesPanel').classList.toggle('is-on', mode === 'files');
|
|
2790
|
+
$('tasksPanel').classList.toggle('is-on', mode === 'tasks');
|
|
2401
2791
|
if (mode === 'changes') void loadChanges();
|
|
2792
|
+
else if (mode === 'tasks') renderTodos();
|
|
2402
2793
|
else {
|
|
2403
2794
|
applyFilesLayout();
|
|
2404
2795
|
$('filesTitle').textContent = `工作区文件 · ${state.info?.workspace ?? ''}`;
|
|
@@ -2464,11 +2855,13 @@ function initShell() {
|
|
|
2464
2855
|
setSidebar(state.sidebar.open);
|
|
2465
2856
|
$('reviewTabChanges').addEventListener('click', () => setReviewMode('changes'));
|
|
2466
2857
|
$('reviewTabFiles').addEventListener('click', () => setReviewMode('files'));
|
|
2858
|
+
$('reviewTabTasks').addEventListener('click', () => setReviewMode('tasks'));
|
|
2467
2859
|
$('reviewClose').addEventListener('click', closeReview);
|
|
2468
2860
|
$('reviewScrim').addEventListener('click', closeReview);
|
|
2469
2861
|
$('reviewRefresh').addEventListener('click', () => {
|
|
2470
2862
|
state.changes = null;
|
|
2471
2863
|
if (state.review.mode === 'changes') void loadChanges(true);
|
|
2864
|
+
else if (state.review.mode === 'tasks') renderTodos();
|
|
2472
2865
|
else $('filesTree').innerHTML = '', void loadTree('.');
|
|
2473
2866
|
});
|
|
2474
2867
|
$('sbResizer').addEventListener('pointerdown', (event) => {
|
|
@@ -3574,7 +3967,6 @@ function bind() {
|
|
|
3574
3967
|
$('newTab').innerHTML = svg('plus');
|
|
3575
3968
|
$('searchBtn').innerHTML = svg('search');
|
|
3576
3969
|
$('sendBtn').innerHTML = svg('send');
|
|
3577
|
-
$('abortBtn').innerHTML = svg('stop');
|
|
3578
3970
|
$('closeSettings').innerHTML = svg('x');
|
|
3579
3971
|
// 左上角保留 Banana 叶子标记;点击/ Ctrl+B 仍然打开历史会话
|
|
3580
3972
|
$('toggleSidebar').innerHTML =
|
|
@@ -3585,7 +3977,26 @@ function bind() {
|
|
|
3585
3977
|
$('toggleSidebar').title = '历史会话(Ctrl+B)';
|
|
3586
3978
|
$('attachBtn').innerHTML = svg('attach');
|
|
3587
3979
|
$('jumpLatest').innerHTML = svg('arrowDown');
|
|
3588
|
-
$('
|
|
3980
|
+
$('attachmentClose').innerHTML = svg('x');
|
|
3981
|
+
$('reasoningBtn').addEventListener('click', (event) => {
|
|
3982
|
+
event.stopPropagation();
|
|
3983
|
+
toggleReasoningPop();
|
|
3984
|
+
});
|
|
3985
|
+
$('modeSwitch').addEventListener('click', async (event) => {
|
|
3986
|
+
const button = event.target.closest('[data-mode]');
|
|
3987
|
+
if (!button) return;
|
|
3988
|
+
const mode = button.dataset.mode;
|
|
3989
|
+
if (mode === state.info?.session?.mode) return;
|
|
3990
|
+
try {
|
|
3991
|
+
const result = await post('session', { action: 'mode', value: mode });
|
|
3992
|
+
if (result?.info) state.info = result.info;
|
|
3993
|
+
renderHeader();
|
|
3994
|
+
renderTodos();
|
|
3995
|
+
toast(mode === 'plan' ? 'Plan 模式:只读调研,先出计划' : 'Build 模式:可以改文件和执行命令');
|
|
3996
|
+
} catch (error) {
|
|
3997
|
+
toast('切换模式失败:' + error.message);
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
3589
4000
|
$('modelBtn').addEventListener('click', (event) => {
|
|
3590
4001
|
event.stopPropagation();
|
|
3591
4002
|
toggleModelPop();
|
|
@@ -3642,8 +4053,11 @@ function bind() {
|
|
|
3642
4053
|
});
|
|
3643
4054
|
$('filesBtn').addEventListener('click', toggleFiles);
|
|
3644
4055
|
$('reviewBtn').addEventListener('click', () => {
|
|
3645
|
-
if (state.review.open
|
|
3646
|
-
else
|
|
4056
|
+
if (state.review.open) closeReview();
|
|
4057
|
+
else {
|
|
4058
|
+
openReview(state.review.mode || 'changes');
|
|
4059
|
+
if (state.review.mode === 'changes') void loadChanges(true);
|
|
4060
|
+
}
|
|
3647
4061
|
});
|
|
3648
4062
|
$('searchBtn').addEventListener('click', openCommandCenter);
|
|
3649
4063
|
$('openSettingsFoot').addEventListener('click', () => openSettings());
|
|
@@ -3686,6 +4100,22 @@ function bind() {
|
|
|
3686
4100
|
if (state.busy) stopTurn();
|
|
3687
4101
|
else send();
|
|
3688
4102
|
});
|
|
4103
|
+
$('todoSummary').addEventListener('click', () => {
|
|
4104
|
+
state.todoOpen = !state.todoOpen;
|
|
4105
|
+
$('todoDock').classList.toggle('is-open', state.todoOpen);
|
|
4106
|
+
$('todoSummary').setAttribute('aria-expanded', String(state.todoOpen));
|
|
4107
|
+
});
|
|
4108
|
+
$('attachmentClose').addEventListener('click', () => {
|
|
4109
|
+
$('attachmentViewer').hidden = true;
|
|
4110
|
+
syncOverlayState();
|
|
4111
|
+
});
|
|
4112
|
+
$('attachmentViewer').addEventListener('mousedown', (event) => {
|
|
4113
|
+
if (event.target === $('attachmentViewer')) {
|
|
4114
|
+
$('attachmentViewer').hidden = true;
|
|
4115
|
+
syncOverlayState();
|
|
4116
|
+
}
|
|
4117
|
+
});
|
|
4118
|
+
$('attachmentCopyPath').addEventListener('click', () => copyText(state.attachmentPath ?? '', '已复制附件路径'));
|
|
3689
4119
|
$('jumpLatest').addEventListener('click', () => {
|
|
3690
4120
|
state.stickToBottom = true;
|
|
3691
4121
|
scrollToEnd(true);
|
|
@@ -3777,6 +4207,11 @@ function bind() {
|
|
|
3777
4207
|
// 终端里的 Esc 属于 shell,不要把工作台一起关掉
|
|
3778
4208
|
const inTerminal = event.target instanceof Element && event.target.closest('#terminalPanel');
|
|
3779
4209
|
if (inTerminal && $('settingsSheet').hidden && $('codeViewer').hidden && $('commandCenter').hidden && $('approvalModal').hidden) return;
|
|
4210
|
+
if (state.busy && $('commandCenter').hidden && $('settingsSheet').hidden && $('codeViewer').hidden && $('attachmentViewer').hidden && $('approvalModal').hidden) {
|
|
4211
|
+
event.preventDefault();
|
|
4212
|
+
stopTurn();
|
|
4213
|
+
return;
|
|
4214
|
+
}
|
|
3780
4215
|
if (closeTopOverlay()) return;
|
|
3781
4216
|
if ($('sidebar').classList.contains('open')) $('sidebar').classList.remove('open');
|
|
3782
4217
|
}
|
package/ui/index.html
CHANGED
|
@@ -72,15 +72,24 @@
|
|
|
72
72
|
<div class="chat-sub" id="threadMeta"></div>
|
|
73
73
|
</div>
|
|
74
74
|
<div class="chat-actions">
|
|
75
|
+
<span class="mode-badge" id="modeBadge" hidden>Plan</span>
|
|
75
76
|
<button class="icon-btn" id="filesBtn" title="工作区文件" aria-label="工作区文件"></button>
|
|
76
|
-
<button class="icon-btn" id="reviewBtn" title="
|
|
77
|
-
<button class="icon-btn" id="abortBtn" title="停止" aria-label="停止" hidden></button>
|
|
77
|
+
<button class="icon-btn" id="reviewBtn" title="查看改动 / 文件 / 任务(Review)" aria-label="查看 Review"></button>
|
|
78
78
|
</div>
|
|
79
79
|
</header>
|
|
80
80
|
|
|
81
81
|
<div class="thread" id="thread"></div>
|
|
82
82
|
|
|
83
83
|
<div class="composer-wrap">
|
|
84
|
+
<div class="todo-dock" id="todoDock" hidden>
|
|
85
|
+
<button class="todo-summary" id="todoSummary" type="button" aria-expanded="true">
|
|
86
|
+
<span class="todo-title">任务</span>
|
|
87
|
+
<span class="todo-count" id="todoCount">0/0</span>
|
|
88
|
+
<span class="todo-bar"><i id="todoBarFill"></i></span>
|
|
89
|
+
<span class="todo-caret" data-icon="chevronDown"></span>
|
|
90
|
+
</button>
|
|
91
|
+
<div class="todo-list" id="todoList"></div>
|
|
92
|
+
</div>
|
|
84
93
|
<div class="attachments" id="attachments" hidden></div>
|
|
85
94
|
<form class="composer" id="composer">
|
|
86
95
|
<div class="command-palette" id="commandPalette" hidden></div>
|
|
@@ -89,9 +98,16 @@
|
|
|
89
98
|
<div class="ct-left">
|
|
90
99
|
<button class="icon-btn attach-btn" id="attachBtn" type="button" title="添加附件" aria-label="添加附件"></button>
|
|
91
100
|
<input type="file" id="attachInput" multiple hidden />
|
|
101
|
+
<div class="mode-switch" id="modeSwitch" role="group" aria-label="工作模式">
|
|
102
|
+
<button type="button" data-mode="plan" title="只读调研,先出计划等你批准">Plan</button>
|
|
103
|
+
<button type="button" data-mode="build" title="允许改文件和执行命令">Build</button>
|
|
104
|
+
</div>
|
|
92
105
|
<button class="model-chip" id="modelBtn" type="button" title="切换模型">
|
|
93
106
|
<span data-icon="chevronDown"></span><span id="modelLabel">—</span>
|
|
94
107
|
</button>
|
|
108
|
+
<button class="model-chip reasoning-chip" id="reasoningBtn" type="button" title="思考强度">
|
|
109
|
+
<span data-icon="chevronDown"></span><span id="reasoningLabel">标准</span>
|
|
110
|
+
</button>
|
|
95
111
|
</div>
|
|
96
112
|
<div class="ct-right">
|
|
97
113
|
<span class="composer-hint" id="composerHint"></span>
|
|
@@ -111,6 +127,7 @@
|
|
|
111
127
|
<div class="review-tabs">
|
|
112
128
|
<button class="review-tab is-on" data-mode="changes" id="reviewTabChanges">Review</button>
|
|
113
129
|
<button class="review-tab" data-mode="files" id="reviewTabFiles">文件</button>
|
|
130
|
+
<button class="review-tab" data-mode="tasks" id="reviewTabTasks">任务</button>
|
|
114
131
|
</div>
|
|
115
132
|
<div class="review-actions">
|
|
116
133
|
<span class="review-stats" id="reviewStats"></span>
|
|
@@ -125,6 +142,10 @@
|
|
|
125
142
|
<div class="hint">选择上面的文件查看改动。</div>
|
|
126
143
|
</div>
|
|
127
144
|
</div>
|
|
145
|
+
<div class="review-pane" data-pane="tasks" id="tasksPanel">
|
|
146
|
+
<div class="tasks-empty" id="tasksEmpty">这一轮还没有任务清单。</div>
|
|
147
|
+
<div class="tasks-list" id="tasksList"></div>
|
|
148
|
+
</div>
|
|
128
149
|
<div class="review-pane" data-pane="files" id="filesPanel">
|
|
129
150
|
<div class="files-head">
|
|
130
151
|
<span id="filesTitle">工作区文件</span>
|
|
@@ -219,6 +240,20 @@
|
|
|
219
240
|
</div>
|
|
220
241
|
</div>
|
|
221
242
|
|
|
243
|
+
<div class="viewer attachment-viewer" id="attachmentViewer" hidden>
|
|
244
|
+
<div class="viewer-panel" role="dialog" aria-modal="true" aria-label="附件预览">
|
|
245
|
+
<header class="viewer-head">
|
|
246
|
+
<span class="viewer-path" id="attachmentName"></span>
|
|
247
|
+
<div class="viewer-actions">
|
|
248
|
+
<span class="attachment-meta" id="attachmentMeta"></span>
|
|
249
|
+
<button class="btn tiny" id="attachmentCopyPath">路径</button>
|
|
250
|
+
<button class="icon-btn" id="attachmentClose" aria-label="关闭"></button>
|
|
251
|
+
</div>
|
|
252
|
+
</header>
|
|
253
|
+
<div class="viewer-body attachment-body" id="attachmentBody"></div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
222
257
|
<div class="modal" id="approvalModal" hidden>
|
|
223
258
|
<div class="modal-card">
|
|
224
259
|
<div class="modal-head">
|
package/ui/style.css
CHANGED
|
@@ -3849,3 +3849,150 @@ input:focus-visible, textarea:focus-visible { outline: none; }
|
|
|
3849
3849
|
.terminal-dock .term-cwd { flex: 0 1 auto; min-width: 0; }
|
|
3850
3850
|
.term-menu { top: 100%; right: 8px; z-index: 30; }
|
|
3851
3851
|
.term-body, .term-pane, .xterm { position: relative; z-index: 0; }
|
|
3852
|
+
|
|
3853
|
+
/* ---------- v1.0:隐藏兜底 / Plan / 任务 / 附件 ---------- */
|
|
3854
|
+
[hidden] { display: none !important; }
|
|
3855
|
+
|
|
3856
|
+
.mode-badge {
|
|
3857
|
+
height: 20px;
|
|
3858
|
+
padding: 0 7px;
|
|
3859
|
+
display: inline-flex;
|
|
3860
|
+
align-items: center;
|
|
3861
|
+
border: 1px solid color-mix(in srgb, var(--accent-ink) 28%, var(--line));
|
|
3862
|
+
border-radius: 5px;
|
|
3863
|
+
background: color-mix(in srgb, var(--accent) 24%, transparent);
|
|
3864
|
+
color: var(--text-2);
|
|
3865
|
+
font-family: var(--mono);
|
|
3866
|
+
font-size: 10px;
|
|
3867
|
+
letter-spacing: 0.04em;
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
.mode-switch {
|
|
3871
|
+
height: 28px;
|
|
3872
|
+
display: inline-flex;
|
|
3873
|
+
align-items: center;
|
|
3874
|
+
padding: 2px;
|
|
3875
|
+
border: 1px solid var(--line);
|
|
3876
|
+
border-radius: 7px;
|
|
3877
|
+
background: var(--panel);
|
|
3878
|
+
flex: none;
|
|
3879
|
+
}
|
|
3880
|
+
.mode-switch button {
|
|
3881
|
+
height: 22px;
|
|
3882
|
+
padding: 0 7px;
|
|
3883
|
+
border: 0;
|
|
3884
|
+
border-radius: 5px;
|
|
3885
|
+
background: transparent;
|
|
3886
|
+
color: var(--text-3);
|
|
3887
|
+
font-family: var(--sans);
|
|
3888
|
+
font-size: 11px;
|
|
3889
|
+
font-weight: 500;
|
|
3890
|
+
cursor: pointer;
|
|
3891
|
+
transition: background 140ms var(--ease), color 140ms var(--ease);
|
|
3892
|
+
}
|
|
3893
|
+
.mode-switch button:hover { color: var(--text); }
|
|
3894
|
+
.mode-switch button.is-on { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
|
|
3895
|
+
.mode-switch button[data-mode='plan'].is-on { color: var(--accent-ink); }
|
|
3896
|
+
|
|
3897
|
+
.reasoning-chip { max-width: 110px; }
|
|
3898
|
+
.reasoning-chip:disabled, .reasoning-chip.is-unsupported { opacity: 0.45; }
|
|
3899
|
+
.reasoning-pop .reasoning-row { grid-template-columns: minmax(0, 1fr) 16px; min-height: 44px; }
|
|
3900
|
+
.reasoning-row:disabled { opacity: 0.42; cursor: default; }
|
|
3901
|
+
.reasoning-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
3902
|
+
.reasoning-desc { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3903
|
+
.reasoning-note { padding: 7px 8px; border-top: 1px solid var(--line); margin-top: 4px; color: var(--text-3); font-size: 10.5px; line-height: 1.5; }
|
|
3904
|
+
|
|
3905
|
+
.todo-dock {
|
|
3906
|
+
max-width: 720px;
|
|
3907
|
+
margin: 0 auto 6px;
|
|
3908
|
+
border: 1px solid var(--line);
|
|
3909
|
+
border-radius: 9px;
|
|
3910
|
+
background: var(--bg);
|
|
3911
|
+
overflow: hidden;
|
|
3912
|
+
}
|
|
3913
|
+
.todo-summary {
|
|
3914
|
+
width: 100%;
|
|
3915
|
+
height: 30px;
|
|
3916
|
+
display: flex;
|
|
3917
|
+
align-items: center;
|
|
3918
|
+
gap: 8px;
|
|
3919
|
+
padding: 0 9px;
|
|
3920
|
+
border: 0;
|
|
3921
|
+
background: transparent;
|
|
3922
|
+
color: var(--text-2);
|
|
3923
|
+
cursor: pointer;
|
|
3924
|
+
text-align: left;
|
|
3925
|
+
}
|
|
3926
|
+
.todo-summary:hover { background: var(--panel); }
|
|
3927
|
+
.todo-title { font-size: 11.5px; font-weight: 560; }
|
|
3928
|
+
.todo-count { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
|
|
3929
|
+
.todo-bar { flex: 1; height: 3px; max-width: 140px; border-radius: 99px; background: var(--line); overflow: hidden; }
|
|
3930
|
+
.todo-bar i { display: block; width: 0; height: 100%; background: var(--accent-ink); transition: width 260ms var(--ease); }
|
|
3931
|
+
.todo-caret { margin-left: auto; display: grid; place-items: center; color: var(--text-3); transition: transform 160ms var(--ease); }
|
|
3932
|
+
.todo-caret svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
|
|
3933
|
+
.todo-dock.is-open .todo-caret { transform: rotate(180deg); }
|
|
3934
|
+
.todo-list { display: none; padding: 0 9px 7px; }
|
|
3935
|
+
.todo-dock.is-open .todo-list { display: block; }
|
|
3936
|
+
.todo-item { min-height: 22px; display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px; color: var(--text-2); line-height: 18px; }
|
|
3937
|
+
.todo-item + .todo-item { margin-top: 2px; }
|
|
3938
|
+
.todo-item.is-done > span:last-child { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-strong); }
|
|
3939
|
+
.todo-item.is-in_progress > span:last-child { color: var(--text); }
|
|
3940
|
+
.todo-mark { width: 13px; height: 18px; display: grid; place-items: center; flex: none; color: var(--text-3); }
|
|
3941
|
+
.todo-mark svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; }
|
|
3942
|
+
.todo-pulse { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-ink); animation: bananaPulse 1.1s ease-in-out infinite; }
|
|
3943
|
+
.todo-item.is-done .todo-mark { color: var(--accent-ink); }
|
|
3944
|
+
|
|
3945
|
+
.att { max-width: 220px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; cursor: pointer; }
|
|
3946
|
+
.att:hover { border-color: var(--line-strong); color: var(--text); }
|
|
3947
|
+
.att-ico { display: grid; place-items: center; color: var(--text-3); }
|
|
3948
|
+
.att-ico svg, .att-remove svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; }
|
|
3949
|
+
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3950
|
+
.att-size { color: var(--text-3); font-family: var(--mono); font-size: 10px; }
|
|
3951
|
+
.att-remove { display: grid; place-items: center; color: var(--text-3); margin-left: 2px; }
|
|
3952
|
+
.att-remove:hover { color: var(--text); }
|
|
3953
|
+
.msg-attachments { margin-top: 7px; max-width: none; }
|
|
3954
|
+
.msg-attachments .att { height: 26px; font-size: 11px; }
|
|
3955
|
+
|
|
3956
|
+
.plan-card { width: 100%; max-width: 744px; margin: 2px auto 14px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent-ink) 24%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
|
|
3957
|
+
.plan-card.is-approved { border-color: var(--line); background: var(--panel); }
|
|
3958
|
+
.plan-card.is-cancelled { opacity: 0.6; }
|
|
3959
|
+
.plan-head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text); }
|
|
3960
|
+
.plan-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); }
|
|
3961
|
+
.plan-hint { margin-left: auto; font-size: 10.5px; font-weight: 400; color: var(--text-3); }
|
|
3962
|
+
.plan-list { margin-top: 9px; display: flex; flex-direction: column; gap: 3px; }
|
|
3963
|
+
.plan-item { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 19px; color: var(--text-2); }
|
|
3964
|
+
.plan-index { width: 16px; flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); padding-top: 1px; }
|
|
3965
|
+
.plan-mark { width: 13px; flex: none; display: grid; place-items: center; padding-top: 3px; color: var(--text-3); }
|
|
3966
|
+
.plan-mark svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; }
|
|
3967
|
+
.plan-empty { color: var(--text-3); font-size: 11.5px; line-height: 1.6; }
|
|
3968
|
+
.plan-actions { display: flex; gap: 7px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
|
|
3969
|
+
.plan-actions .btn { height: 28px; font-size: 11.5px; }
|
|
3970
|
+
|
|
3971
|
+
.tasks-empty { padding: 18px 14px; color: var(--text-3); font-size: 12px; }
|
|
3972
|
+
.tasks-list { padding: 8px; overflow: auto; }
|
|
3973
|
+
.task-row { min-height: 34px; display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 7px; font-size: 12.5px; color: var(--text-2); }
|
|
3974
|
+
.task-row:hover { background: var(--panel); }
|
|
3975
|
+
.task-index { width: 16px; flex: none; font-family: var(--mono); font-size: 10px; color: var(--text-3); }
|
|
3976
|
+
.task-mark { width: 13px; flex: none; display: grid; place-items: center; color: var(--text-3); }
|
|
3977
|
+
.task-mark svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; }
|
|
3978
|
+
.task-row.is-done .task-mark { color: var(--accent-ink); }
|
|
3979
|
+
.task-row.is-done .task-text { color: var(--text-3); text-decoration: line-through; }
|
|
3980
|
+
.task-text { min-width: 0; flex: 1; }
|
|
3981
|
+
.task-state { font-size: 10px; color: var(--text-3); }
|
|
3982
|
+
|
|
3983
|
+
.attachment-body { display: flex; flex-direction: column; overflow: auto; }
|
|
3984
|
+
.attachment-image { flex: 1; display: grid; place-items: center; padding: 18px; min-height: 0; background: var(--panel); }
|
|
3985
|
+
.attachment-image img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
|
|
3986
|
+
.attachment-pdf { flex: 1; width: 100%; min-height: 60vh; border: 0; background: var(--panel); }
|
|
3987
|
+
.attachment-info { display: flex; flex-direction: column; gap: 7px; padding: 20px; color: var(--text-2); font-size: 12.5px; }
|
|
3988
|
+
.attachment-info strong { color: var(--text); font-size: 14px; }
|
|
3989
|
+
.attachment-info .mono { font-family: var(--mono); font-size: 11px; color: var(--text-3); word-break: break-all; }
|
|
3990
|
+
.attachment-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-right: 4px; }
|
|
3991
|
+
|
|
3992
|
+
@media (max-width: 720px) {
|
|
3993
|
+
.reasoning-chip { display: none; }
|
|
3994
|
+
.mode-switch button { padding: 0 5px; font-size: 10.5px; }
|
|
3995
|
+
.plan-hint { display: none; }
|
|
3996
|
+
.plan-actions { flex-wrap: wrap; }
|
|
3997
|
+
}
|
|
3998
|
+
.msg.user .msg-attachments { align-self: flex-end; justify-content: flex-end; max-width: 100%; margin: 7px 0 0; }
|