@vincentbanana/bananacli 0.8.3 → 0.8.4
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/dist/agent/loop.js +57 -11
- package/dist/server/ui-server.js +61 -15
- package/dist/ui/app.js +95 -16
- package/dist/ui/style.css +9 -0
- package/package.json +1 -1
package/dist/agent/loop.js
CHANGED
|
@@ -121,7 +121,21 @@ export async function runTurn(deps, messages, input, images, attachments, attach
|
|
|
121
121
|
if (calls.length === 0) {
|
|
122
122
|
return { messages: convo, steps, usage, stopReason: 'done', compacted };
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
// 只读工具可以并发跑,并在同一轮里复用完全相同的调用结果。
|
|
125
|
+
// 写文件 / shell 仍然串行,避免顺序和副作用被打乱。
|
|
126
|
+
const READ_ONLY_TOOLS = new Set(['read_file', 'list_dir', 'glob', 'grep']);
|
|
127
|
+
const toolCache = new Map();
|
|
128
|
+
const recordResult = (call, toolResult) => {
|
|
129
|
+
deps.onToolEnd?.(call.name, toolResult, call.id);
|
|
130
|
+
convo.push({
|
|
131
|
+
role: 'tool',
|
|
132
|
+
toolCallId: call.id,
|
|
133
|
+
name: call.name,
|
|
134
|
+
content: toolResult.content,
|
|
135
|
+
isError: !toolResult.ok,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
for (let index = 0; index < calls.length;) {
|
|
125
139
|
const call = calls[index];
|
|
126
140
|
if (deps.signal.aborted) {
|
|
127
141
|
// 为所有未执行的 tool_use 补上结果,避免下一轮协议校验失败
|
|
@@ -143,8 +157,44 @@ export async function runTurn(deps, messages, input, images, attachments, attach
|
|
|
143
157
|
ok: false,
|
|
144
158
|
content: `未知工具 "${call.name}"。可用工具: ${[...tools.keys()].join(', ')}。请改用已有工具。`,
|
|
145
159
|
};
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
recordResult(call, result);
|
|
161
|
+
index += 1;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (READ_ONLY_TOOLS.has(call.name)) {
|
|
165
|
+
// 收集连续的只读调用一起执行;保持结果顺序与模型请求一致。
|
|
166
|
+
const batch = [];
|
|
167
|
+
let cursor = index;
|
|
168
|
+
while (cursor < calls.length &&
|
|
169
|
+
READ_ONLY_TOOLS.has(calls[cursor].name) &&
|
|
170
|
+
tools.has(calls[cursor].name)) {
|
|
171
|
+
const item = calls[cursor];
|
|
172
|
+
batch.push({
|
|
173
|
+
call: item,
|
|
174
|
+
input: (item.input && typeof item.input === 'object' ? item.input : {}),
|
|
175
|
+
});
|
|
176
|
+
cursor += 1;
|
|
177
|
+
}
|
|
178
|
+
for (const item of batch)
|
|
179
|
+
deps.onToolStart?.(item.call.name, item.input, item.call.id);
|
|
180
|
+
const results = await Promise.all(batch.map(async (item) => {
|
|
181
|
+
const key = `${item.call.name}\u0000${JSON.stringify(item.input)}`;
|
|
182
|
+
const cached = toolCache.get(key);
|
|
183
|
+
if (cached)
|
|
184
|
+
return cached;
|
|
185
|
+
const itemTool = tools.get(item.call.name);
|
|
186
|
+
const callContext = {
|
|
187
|
+
...toolContext,
|
|
188
|
+
onOutput: (chunk, stream) => deps.onToolOutput?.(chunk, stream, item.call.id),
|
|
189
|
+
};
|
|
190
|
+
const result = await runTool(itemTool, item.input, callContext, permissionFor(deps.permissions, itemTool));
|
|
191
|
+
toolCache.set(key, result);
|
|
192
|
+
return result;
|
|
193
|
+
}));
|
|
194
|
+
for (let offset = 0; offset < batch.length; offset += 1) {
|
|
195
|
+
recordResult(batch[offset].call, results[offset]);
|
|
196
|
+
}
|
|
197
|
+
index = cursor;
|
|
148
198
|
continue;
|
|
149
199
|
}
|
|
150
200
|
deps.onToolStart?.(call.name, input, call.id);
|
|
@@ -153,14 +203,10 @@ export async function runTurn(deps, messages, input, images, attachments, attach
|
|
|
153
203
|
onOutput: (chunk, stream) => deps.onToolOutput?.(chunk, stream, call.id),
|
|
154
204
|
};
|
|
155
205
|
const toolResult = await runTool(tool, input, callContext, permissionFor(deps.permissions, tool));
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
name: call.name,
|
|
161
|
-
content: toolResult.content,
|
|
162
|
-
isError: !toolResult.ok,
|
|
163
|
-
});
|
|
206
|
+
recordResult(call, toolResult);
|
|
207
|
+
// 一旦发生写操作/命令,之前的只读缓存可能过期。
|
|
208
|
+
toolCache.clear();
|
|
209
|
+
index += 1;
|
|
164
210
|
}
|
|
165
211
|
}
|
|
166
212
|
return { messages: convo, steps, usage, stopReason: 'max_steps', compacted };
|
package/dist/server/ui-server.js
CHANGED
|
@@ -310,6 +310,9 @@ export async function startUiServer(options) {
|
|
|
310
310
|
// 当前会话记在服务进程内存里:新建对话后所有后续请求都认它,
|
|
311
311
|
// 不再依赖「磁盘上谁最新」这种容易串台的推断。
|
|
312
312
|
let activeId = null;
|
|
313
|
+
// 删光所有会话后保留一个“空白草稿”:它不落盘、不出现在侧栏,也不占标签。
|
|
314
|
+
// 用户发出第一条消息时才真正创建会话。
|
|
315
|
+
let blank = null;
|
|
313
316
|
// 内嵌终端:不弹外部窗口,命令在当前工作区里执行,cd 之后的工作目录会被记住
|
|
314
317
|
let terminalCwd = null;
|
|
315
318
|
let terminalChild = null;
|
|
@@ -317,7 +320,7 @@ export async function startUiServer(options) {
|
|
|
317
320
|
const provider = () => createProvider(config.current, config);
|
|
318
321
|
const backups = (sessionId) => new BackupStore(join(bananaHome(), 'backups'), sessionId);
|
|
319
322
|
const info = async (session) => ({
|
|
320
|
-
version: '0.8.
|
|
323
|
+
version: '0.8.4',
|
|
321
324
|
provider: { name: config.current, model: config.providers[config.current]?.model ?? '', protocol: config.providers[config.current]?.protocol ?? 'openai' },
|
|
322
325
|
reasoning: {
|
|
323
326
|
level: session.reasoning ?? 'standard',
|
|
@@ -344,6 +347,7 @@ export async function startUiServer(options) {
|
|
|
344
347
|
session: {
|
|
345
348
|
id: session.id,
|
|
346
349
|
title: session.title,
|
|
350
|
+
draft: blank === session,
|
|
347
351
|
// 图片 base64 和附件全文只用于请求模型,不必每次 /api/info 全量回传前端。
|
|
348
352
|
messages: session.messages.map(({ images, attachmentContext, ...message }) => ({
|
|
349
353
|
...message,
|
|
@@ -482,17 +486,23 @@ export async function startUiServer(options) {
|
|
|
482
486
|
}
|
|
483
487
|
let session = turn?.session ??
|
|
484
488
|
(activeId ? await store.load(activeId) : null) ??
|
|
485
|
-
(await store.lastActive().then(async (id) => (id ? await store.load(id) : null)));
|
|
489
|
+
(blank ? null : await store.lastActive().then(async (id) => (id ? await store.load(id) : null)));
|
|
486
490
|
if (!session) {
|
|
487
|
-
//
|
|
488
|
-
|
|
489
|
-
|
|
491
|
+
// 没有会话时用一个不落盘的草稿承接界面状态;发第一条消息才保存。
|
|
492
|
+
if (!blank)
|
|
493
|
+
blank = store.create();
|
|
494
|
+
session = blank;
|
|
495
|
+
activeId = null;
|
|
496
|
+
}
|
|
497
|
+
else if (session !== blank) {
|
|
498
|
+
blank = null;
|
|
499
|
+
activeId = session.id;
|
|
490
500
|
}
|
|
491
|
-
activeId = session.id;
|
|
492
501
|
if (path === '/api/info' && req.method === 'GET')
|
|
493
502
|
return json(res, 200, await info(session));
|
|
494
|
-
if (path === '/api/sessions' && req.method === 'GET')
|
|
495
|
-
return json(res, 200, { sessions: await listSessions(), current: session.id });
|
|
503
|
+
if (path === '/api/sessions' && req.method === 'GET') {
|
|
504
|
+
return json(res, 200, { sessions: await listSessions(), current: blank === session ? null : session.id });
|
|
505
|
+
}
|
|
496
506
|
if (path === '/api/files' && req.method === 'GET') {
|
|
497
507
|
const target = url.searchParams.get('path') ?? '.';
|
|
498
508
|
try {
|
|
@@ -577,11 +587,13 @@ export async function startUiServer(options) {
|
|
|
577
587
|
return json(res, 200, { session: found });
|
|
578
588
|
}
|
|
579
589
|
if (body.action === 'new') {
|
|
590
|
+
blank = null;
|
|
580
591
|
session = store.create(body.title?.trim() || '新对话');
|
|
581
592
|
// 用户明确指定了标题,后续自动标题不要覆盖它。
|
|
582
593
|
if (body.title?.trim())
|
|
583
594
|
session.titleSource = 'user';
|
|
584
595
|
await store.save(session);
|
|
596
|
+
activeId = session.id;
|
|
585
597
|
}
|
|
586
598
|
else if (body.action === 'rename') {
|
|
587
599
|
// 支持直接重命名侧栏里的某个会话,不必先把用户切过去。
|
|
@@ -591,12 +603,18 @@ export async function startUiServer(options) {
|
|
|
591
603
|
target.title = body.title?.trim() || target.title;
|
|
592
604
|
target.titleSource = 'user';
|
|
593
605
|
await store.save(target);
|
|
606
|
+
if (blank === target) {
|
|
607
|
+
blank = null;
|
|
608
|
+
activeId = target.id;
|
|
609
|
+
}
|
|
594
610
|
}
|
|
595
611
|
else if (body.action === 'switch') {
|
|
596
612
|
const found = body.ref ? await store.find(body.ref) : null;
|
|
597
613
|
if (!found)
|
|
598
614
|
return json(res, 404, { error: '没找到这个对话' });
|
|
615
|
+
blank = null;
|
|
599
616
|
session = found;
|
|
617
|
+
activeId = found.id;
|
|
600
618
|
}
|
|
601
619
|
else if (body.action === 'delete') {
|
|
602
620
|
const found = body.ref ? await store.find(body.ref) : null;
|
|
@@ -604,8 +622,19 @@ export async function startUiServer(options) {
|
|
|
604
622
|
await store.remove(found.id);
|
|
605
623
|
await backups(found.id).clear();
|
|
606
624
|
if (found.id === session.id) {
|
|
607
|
-
|
|
608
|
-
await store.
|
|
625
|
+
// 优先切到剩下的最近会话;一个都不剩时进入空白草稿,不强行新建对话。
|
|
626
|
+
const remaining = await store.lastActive();
|
|
627
|
+
const next = remaining ? await store.load(remaining) : null;
|
|
628
|
+
if (next) {
|
|
629
|
+
session = next;
|
|
630
|
+
activeId = next.id;
|
|
631
|
+
blank = null;
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
session = store.create();
|
|
635
|
+
blank = session;
|
|
636
|
+
activeId = null;
|
|
637
|
+
}
|
|
609
638
|
}
|
|
610
639
|
}
|
|
611
640
|
}
|
|
@@ -614,23 +643,26 @@ export async function startUiServer(options) {
|
|
|
614
643
|
session.todos = [];
|
|
615
644
|
session.plan = undefined;
|
|
616
645
|
session.usage = { inputTokens: 0, outputTokens: 0 };
|
|
617
|
-
|
|
646
|
+
if (blank !== session)
|
|
647
|
+
await store.save(session);
|
|
618
648
|
}
|
|
619
649
|
else if (body.action === 'mode') {
|
|
620
650
|
const mode = body.value === 'plan' ? 'plan' : 'build';
|
|
621
651
|
session.mode = mode;
|
|
622
652
|
if (mode === 'build' && session.plan?.status === 'cancelled')
|
|
623
653
|
session.plan = undefined;
|
|
624
|
-
|
|
654
|
+
if (blank !== session)
|
|
655
|
+
await store.save(session);
|
|
625
656
|
}
|
|
626
657
|
else if (body.action === 'reasoning') {
|
|
627
658
|
const level = body.value;
|
|
628
659
|
if (REASONING_LEVELS.includes(level)) {
|
|
629
660
|
session.reasoning = level;
|
|
630
|
-
|
|
661
|
+
if (blank !== session)
|
|
662
|
+
await store.save(session);
|
|
631
663
|
}
|
|
632
664
|
}
|
|
633
|
-
activeId = session.id;
|
|
665
|
+
activeId = blank === session ? null : session.id;
|
|
634
666
|
return json(res, 200, { session: session.id, sessions: await listSessions(), info: await info(session) });
|
|
635
667
|
}
|
|
636
668
|
if (path === '/api/complete' && req.method === 'GET') {
|
|
@@ -816,7 +848,8 @@ export async function startUiServer(options) {
|
|
|
816
848
|
try {
|
|
817
849
|
session.model = provider().model;
|
|
818
850
|
session.provider = config.current;
|
|
819
|
-
|
|
851
|
+
if (blank !== session)
|
|
852
|
+
await store.save(session);
|
|
820
853
|
}
|
|
821
854
|
catch {
|
|
822
855
|
/* provider 暂时不可用,不影响设置已保存 */
|
|
@@ -941,6 +974,12 @@ export async function startUiServer(options) {
|
|
|
941
974
|
if (found)
|
|
942
975
|
target = found;
|
|
943
976
|
}
|
|
977
|
+
// 空白草稿在第一次真正对话时才落盘。
|
|
978
|
+
if (target === blank) {
|
|
979
|
+
await store.save(target);
|
|
980
|
+
blank = null;
|
|
981
|
+
}
|
|
982
|
+
session = target;
|
|
944
983
|
activeId = target.id;
|
|
945
984
|
return chat(body, res, target);
|
|
946
985
|
}
|
|
@@ -1093,11 +1132,18 @@ export async function startUiServer(options) {
|
|
|
1093
1132
|
setSessionAndSave: async (value) => {
|
|
1094
1133
|
next = value;
|
|
1095
1134
|
await store.save(value);
|
|
1135
|
+
if (blank === value) {
|
|
1136
|
+
blank = null;
|
|
1137
|
+
activeId = value.id;
|
|
1138
|
+
}
|
|
1096
1139
|
},
|
|
1097
1140
|
setProvider: () => { },
|
|
1098
1141
|
setConfig: (value) => Object.assign(config, value),
|
|
1099
1142
|
setTools: () => { },
|
|
1100
1143
|
saveSession: async () => {
|
|
1144
|
+
// 空白草稿不因为 /provider、/system 之类的命令偷偷落盘。
|
|
1145
|
+
if (blank === next)
|
|
1146
|
+
return;
|
|
1101
1147
|
await store.save(next);
|
|
1102
1148
|
},
|
|
1103
1149
|
reloadProvider: () => { },
|
package/dist/ui/app.js
CHANGED
|
@@ -587,13 +587,14 @@ function initTabs() {
|
|
|
587
587
|
try {
|
|
588
588
|
saved = JSON.parse(localStorage.getItem(SHELL_STORAGE.tabState) || 'null');
|
|
589
589
|
} catch {}
|
|
590
|
+
const draft = Boolean(state.info?.session?.draft);
|
|
590
591
|
if (saved && Array.isArray(saved.all)) {
|
|
591
592
|
const known = new Set(state.sessions.map((item) => item.id));
|
|
592
|
-
if (state.info?.session?.id) known.add(state.info.session.id);
|
|
593
|
+
if (state.info?.session?.id && !draft) known.add(state.info.session.id);
|
|
593
594
|
state.tabs = saved.all.filter((tab) => tab && typeof tab.id === 'string' && known.has(tab.id));
|
|
594
595
|
state.activeTab = saved.active ?? null;
|
|
595
596
|
}
|
|
596
|
-
const current = state.info?.session?.id;
|
|
597
|
+
const current = draft ? null : state.info?.session?.id;
|
|
597
598
|
if (current) upsertTab(current, state.info.session.title);
|
|
598
599
|
if (!state.activeTab || !state.tabs.some((tab) => tab.id === state.activeTab)) {
|
|
599
600
|
state.activeTab = current ?? state.tabs[0]?.id ?? null;
|
|
@@ -618,6 +619,13 @@ function renderSidebar() {
|
|
|
618
619
|
const q = state.sessionQuery.trim().toLowerCase();
|
|
619
620
|
return !q || String(item.title ?? '').toLowerCase().includes(q);
|
|
620
621
|
});
|
|
622
|
+
if (!sessions.length) {
|
|
623
|
+
const hint = document.createElement('div');
|
|
624
|
+
hint.className = 'sb-empty';
|
|
625
|
+
hint.textContent = state.sessionQuery ? '没有匹配的会话' : '还没有对话';
|
|
626
|
+
list.appendChild(hint);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
621
629
|
sessions.forEach((item, index) => {
|
|
622
630
|
const label = dayOf(item.updatedAt);
|
|
623
631
|
if (label !== group) {
|
|
@@ -673,21 +681,32 @@ function renderSidebar() {
|
|
|
673
681
|
if (wasActive) {
|
|
674
682
|
state.changes = null;
|
|
675
683
|
if (result?.info) state.info = result.info;
|
|
676
|
-
saveTabs();
|
|
677
684
|
state.attachments = [];
|
|
678
685
|
renderAttachments();
|
|
679
686
|
$('input').value = '';
|
|
680
687
|
grow();
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
688
|
+
if (state.info?.session?.draft) {
|
|
689
|
+
// 删光所有会话:回到干净的空白首页,不再自动建一个「新对话」。
|
|
690
|
+
state.tabs = [];
|
|
691
|
+
state.activeTab = null;
|
|
692
|
+
saveTabs();
|
|
693
|
+
renderTabs();
|
|
694
|
+
renderHeader();
|
|
695
|
+
renderSidebar();
|
|
696
|
+
renderThread();
|
|
697
|
+
} else {
|
|
698
|
+
saveTabs();
|
|
699
|
+
renderHeader();
|
|
700
|
+
renderSidebar();
|
|
701
|
+
renderThread();
|
|
702
|
+
setActiveTab(state.info?.session?.id ?? null);
|
|
703
|
+
}
|
|
685
704
|
} else {
|
|
686
705
|
saveTabs();
|
|
687
706
|
renderSidebar();
|
|
688
707
|
renderTabs();
|
|
689
708
|
}
|
|
690
|
-
toast('已删除会话');
|
|
709
|
+
toast(state.info?.session?.draft ? '已删除最后一个会话' : '已删除会话');
|
|
691
710
|
} catch (error) {
|
|
692
711
|
toast('删除失败:' + (error?.message ?? error));
|
|
693
712
|
}
|
|
@@ -1146,8 +1165,8 @@ async function refresh(path) {
|
|
|
1146
1165
|
state.info = info;
|
|
1147
1166
|
const { sessions } = await get('sessions');
|
|
1148
1167
|
state.sessions = sessions;
|
|
1149
|
-
//
|
|
1150
|
-
if (state.info?.session?.id) {
|
|
1168
|
+
// 空白草稿不是会话:不占标签,也不出现在侧栏;发出第一条消息后才补标签。
|
|
1169
|
+
if (state.info?.session?.id && !state.info.session.draft) {
|
|
1151
1170
|
upsertTab(state.info.session.id, state.info.session.title);
|
|
1152
1171
|
state.activeTab = state.info.session.id;
|
|
1153
1172
|
} else {
|
|
@@ -1204,8 +1223,14 @@ let appDialog = null;
|
|
|
1204
1223
|
* 返回值:有输入框时是字符串或 null;纯确认时是 true 或 null。
|
|
1205
1224
|
*/
|
|
1206
1225
|
function openAppDialog({ title, body = '', value = null, placeholder = '', confirmLabel = '确定', danger = false }) {
|
|
1226
|
+
// 防止双击/连点开出两个对话框,留下一个永远不 resolve 的 Promise。
|
|
1227
|
+
if (appDialog) return Promise.resolve(null);
|
|
1207
1228
|
return new Promise((resolve) => {
|
|
1208
|
-
|
|
1229
|
+
// 任何弹层打开前先收掉选择工具条、会话菜单和模型/思考弹层,避免视觉层叠混乱。
|
|
1230
|
+
hideSelectionTools();
|
|
1231
|
+
document.querySelector('.popover')?.remove();
|
|
1232
|
+
closeModelPop?.();
|
|
1233
|
+
closeReasoningPop?.();
|
|
1209
1234
|
const wrap = document.createElement('div');
|
|
1210
1235
|
wrap.className = 'modal';
|
|
1211
1236
|
wrap.id = 'appDialog';
|
|
@@ -1213,6 +1238,7 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
|
|
|
1213
1238
|
card.className = 'modal-card dialog-card';
|
|
1214
1239
|
card.setAttribute('role', 'dialog');
|
|
1215
1240
|
card.setAttribute('aria-modal', 'true');
|
|
1241
|
+
card.setAttribute('aria-label', title);
|
|
1216
1242
|
const heading = document.createElement('div');
|
|
1217
1243
|
heading.className = 'modal-head';
|
|
1218
1244
|
heading.textContent = title;
|
|
@@ -1255,9 +1281,29 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
|
|
|
1255
1281
|
event.preventDefault();
|
|
1256
1282
|
event.stopPropagation();
|
|
1257
1283
|
finish(null);
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (event.key === 'Tab') {
|
|
1287
|
+
const focusable = [input, cancel, ok].filter((node) => !node.hidden && !node.disabled);
|
|
1288
|
+
if (!focusable.length) return;
|
|
1289
|
+
const first = focusable[0];
|
|
1290
|
+
const last = focusable[focusable.length - 1];
|
|
1291
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
1292
|
+
event.preventDefault();
|
|
1293
|
+
last.focus();
|
|
1294
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
1295
|
+
event.preventDefault();
|
|
1296
|
+
first.focus();
|
|
1297
|
+
}
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
if (event.key === 'Enter') {
|
|
1301
|
+
// 焦点在「取消」上时交给按钮自己处理,不能误确认删除。
|
|
1302
|
+
if (document.activeElement === cancel) return;
|
|
1303
|
+
if (document.activeElement === input || value === null) {
|
|
1304
|
+
event.preventDefault();
|
|
1305
|
+
confirm();
|
|
1306
|
+
}
|
|
1261
1307
|
}
|
|
1262
1308
|
};
|
|
1263
1309
|
appDialog = wrap;
|
|
@@ -1271,6 +1317,9 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
|
|
|
1271
1317
|
if (!input.hidden) {
|
|
1272
1318
|
input.focus();
|
|
1273
1319
|
input.select();
|
|
1320
|
+
} else if (danger) {
|
|
1321
|
+
// 删除/清空这类不可逆操作,默认焦点放在「取消」,避免顺手回车。
|
|
1322
|
+
cancel.focus();
|
|
1274
1323
|
} else {
|
|
1275
1324
|
ok.focus();
|
|
1276
1325
|
}
|
|
@@ -2152,6 +2201,10 @@ async function send() {
|
|
|
2152
2201
|
state.info = event.info;
|
|
2153
2202
|
if (event.todos) state.info.session.todos = event.todos;
|
|
2154
2203
|
if (event.plan) state.info.session.plan = event.plan;
|
|
2204
|
+
// 空白草稿在第一条消息完成后才真正变成一个会话标签。
|
|
2205
|
+
if (!state.info.session.draft && state.activeTab !== state.info.session.id) {
|
|
2206
|
+
setActiveTab(state.info.session.id);
|
|
2207
|
+
}
|
|
2155
2208
|
}
|
|
2156
2209
|
const { sessions } = await get('sessions');
|
|
2157
2210
|
state.sessions = sessions;
|
|
@@ -2410,7 +2463,13 @@ async function clearCurrentSession() {
|
|
|
2410
2463
|
renderSidebar();
|
|
2411
2464
|
renderThread();
|
|
2412
2465
|
renderTodos();
|
|
2413
|
-
|
|
2466
|
+
if (state.info?.session && !state.info.session.draft) setActiveTab(state.info.session.id);
|
|
2467
|
+
else {
|
|
2468
|
+
state.tabs = [];
|
|
2469
|
+
state.activeTab = null;
|
|
2470
|
+
saveTabs();
|
|
2471
|
+
renderTabs();
|
|
2472
|
+
}
|
|
2414
2473
|
toast('已清空当前对话');
|
|
2415
2474
|
} catch (error) {
|
|
2416
2475
|
toast('清空失败:' + (error?.message ?? error));
|
|
@@ -2445,7 +2504,9 @@ async function renameCurrentSession(title) {
|
|
|
2445
2504
|
if (result?.sessions) state.sessions = result.sessions;
|
|
2446
2505
|
renderHeader();
|
|
2447
2506
|
renderSidebar();
|
|
2448
|
-
|
|
2507
|
+
// 空白草稿被显式重命名后会落盘,补上标签。
|
|
2508
|
+
if (state.info?.session && !state.info.session.draft) setActiveTab(state.info.session.id);
|
|
2509
|
+
else renderTabs();
|
|
2449
2510
|
toast('已重命名');
|
|
2450
2511
|
} catch (error) {
|
|
2451
2512
|
toast('重命名失败:' + (error?.message ?? error));
|
|
@@ -2712,6 +2773,10 @@ function toggleModelPop() {
|
|
|
2712
2773
|
}
|
|
2713
2774
|
|
|
2714
2775
|
function openSettings(category) {
|
|
2776
|
+
// 设置是整页层级,先收掉所有可能悬在上面的小弹层。
|
|
2777
|
+
closeModelPop();
|
|
2778
|
+
closeReasoningPop();
|
|
2779
|
+
document.querySelector('.popover')?.remove();
|
|
2715
2780
|
if (category) state.settingsCategory = category;
|
|
2716
2781
|
state.settingsScroll = 0;
|
|
2717
2782
|
state.settingsReturn = document.activeElement;
|
|
@@ -4266,6 +4331,9 @@ function openCommandCenter() {
|
|
|
4266
4331
|
return;
|
|
4267
4332
|
}
|
|
4268
4333
|
if (!$('settingsSheet').hidden) closeSettings();
|
|
4334
|
+
closeModelPop();
|
|
4335
|
+
closeReasoningPop();
|
|
4336
|
+
document.querySelector('.popover')?.remove();
|
|
4269
4337
|
state.ccIndex = 0;
|
|
4270
4338
|
state.ccFiles = [];
|
|
4271
4339
|
$('ccInput').value = '';
|
|
@@ -4715,6 +4783,15 @@ function bind() {
|
|
|
4715
4783
|
$('jumpLatest').hidden = true;
|
|
4716
4784
|
scrollToEnd(true, true);
|
|
4717
4785
|
});
|
|
4786
|
+
// 让「回到最新」始终位于 composer 上方,输入框长高或被附件/任务撑开时不会压住按钮。
|
|
4787
|
+
const composerWrap = document.querySelector('.composer-wrap');
|
|
4788
|
+
if (composerWrap && window.ResizeObserver) {
|
|
4789
|
+
const syncJumpPosition = () => {
|
|
4790
|
+
$('chatCard').style.setProperty('--composer-h', `${Math.round(composerWrap.getBoundingClientRect().height)}px`);
|
|
4791
|
+
};
|
|
4792
|
+
new ResizeObserver(syncJumpPosition).observe(composerWrap);
|
|
4793
|
+
syncJumpPosition();
|
|
4794
|
+
}
|
|
4718
4795
|
THREAD.addEventListener(
|
|
4719
4796
|
'wheel',
|
|
4720
4797
|
(event) => {
|
|
@@ -4816,6 +4893,8 @@ function bind() {
|
|
|
4816
4893
|
|
|
4817
4894
|
$('ccInput').addEventListener('input', () => {
|
|
4818
4895
|
state.ccIndex = 0;
|
|
4896
|
+
// 清空搜索时不要把上一次的文件结果留在列表里。
|
|
4897
|
+
if (!$('ccInput').value.trim()) state.ccFiles = [];
|
|
4819
4898
|
renderCommandCenter($('ccInput').value);
|
|
4820
4899
|
scheduleCommandFiles($('ccInput').value);
|
|
4821
4900
|
});
|
package/dist/ui/style.css
CHANGED
|
@@ -4116,6 +4116,9 @@ input:focus-visible, textarea:focus-visible { outline: none; }
|
|
|
4116
4116
|
}
|
|
4117
4117
|
|
|
4118
4118
|
/* ---------- v1.2:折叠思考摘要、对话框、阅读细节 ---------- */
|
|
4119
|
+
/* 对话框必须盖住 tooltip(120) / 选择工具条(100) / 设置(80) 等所有层。 */
|
|
4120
|
+
.modal { z-index: 200; }
|
|
4121
|
+
.jump-latest { bottom: calc(var(--composer-h, 118px) + 14px); }
|
|
4119
4122
|
.think > summary .think-title { flex: none; }
|
|
4120
4123
|
.think-peek {
|
|
4121
4124
|
min-width: 0;
|
|
@@ -4128,6 +4131,12 @@ input:focus-visible, textarea:focus-visible { outline: none; }
|
|
|
4128
4131
|
}
|
|
4129
4132
|
.think-len { flex: none; margin-left: auto; }
|
|
4130
4133
|
.think .think-peek:empty { display: none; }
|
|
4134
|
+
.sb-empty {
|
|
4135
|
+
padding: 18px 10px;
|
|
4136
|
+
color: var(--text-3);
|
|
4137
|
+
font-size: 12px;
|
|
4138
|
+
line-height: 1.5;
|
|
4139
|
+
}
|
|
4131
4140
|
.table-wrap {
|
|
4132
4141
|
margin: 12px 0 16px;
|
|
4133
4142
|
max-width: 100%;
|
package/package.json
CHANGED