@vincentbanana/bananacli 0.8.2 → 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.
@@ -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
- for (let index = 0; index < calls.length; index += 1) {
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
- deps.onToolEnd?.(call.name, result, call.id);
147
- convo.push({ role: 'tool', toolCallId: call.id, name: call.name, content: result.content, isError: true });
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
- deps.onToolEnd?.(call.name, toolResult, call.id);
157
- convo.push({
158
- role: 'tool',
159
- toolCallId: call.id,
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 };
@@ -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.2',
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,7 +347,12 @@ export async function startUiServer(options) {
344
347
  session: {
345
348
  id: session.id,
346
349
  title: session.title,
347
- messages: session.messages,
350
+ draft: blank === session,
351
+ // 图片 base64 和附件全文只用于请求模型,不必每次 /api/info 全量回传前端。
352
+ messages: session.messages.map(({ images, attachmentContext, ...message }) => ({
353
+ ...message,
354
+ ...(images?.length ? { imageCount: images.length } : {}),
355
+ })),
348
356
  todos: session.todos ?? [],
349
357
  usage: session.usage ?? { inputTokens: 0, outputTokens: 0 },
350
358
  mode: session.mode ?? 'build',
@@ -478,17 +486,23 @@ export async function startUiServer(options) {
478
486
  }
479
487
  let session = turn?.session ??
480
488
  (activeId ? await store.load(activeId) : null) ??
481
- (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)));
482
490
  if (!session) {
483
- // 空会话也立刻落盘:否则每个请求都会重新 create,会话 id 一直变
484
- session = store.create();
485
- await store.save(session);
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;
486
500
  }
487
- activeId = session.id;
488
501
  if (path === '/api/info' && req.method === 'GET')
489
502
  return json(res, 200, await info(session));
490
- if (path === '/api/sessions' && req.method === 'GET')
491
- 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
+ }
492
506
  if (path === '/api/files' && req.method === 'GET') {
493
507
  const target = url.searchParams.get('path') ?? '.';
494
508
  try {
@@ -573,11 +587,13 @@ export async function startUiServer(options) {
573
587
  return json(res, 200, { session: found });
574
588
  }
575
589
  if (body.action === 'new') {
590
+ blank = null;
576
591
  session = store.create(body.title?.trim() || '新对话');
577
592
  // 用户明确指定了标题,后续自动标题不要覆盖它。
578
593
  if (body.title?.trim())
579
594
  session.titleSource = 'user';
580
595
  await store.save(session);
596
+ activeId = session.id;
581
597
  }
582
598
  else if (body.action === 'rename') {
583
599
  // 支持直接重命名侧栏里的某个会话,不必先把用户切过去。
@@ -587,12 +603,18 @@ export async function startUiServer(options) {
587
603
  target.title = body.title?.trim() || target.title;
588
604
  target.titleSource = 'user';
589
605
  await store.save(target);
606
+ if (blank === target) {
607
+ blank = null;
608
+ activeId = target.id;
609
+ }
590
610
  }
591
611
  else if (body.action === 'switch') {
592
612
  const found = body.ref ? await store.find(body.ref) : null;
593
613
  if (!found)
594
614
  return json(res, 404, { error: '没找到这个对话' });
615
+ blank = null;
595
616
  session = found;
617
+ activeId = found.id;
596
618
  }
597
619
  else if (body.action === 'delete') {
598
620
  const found = body.ref ? await store.find(body.ref) : null;
@@ -600,8 +622,19 @@ export async function startUiServer(options) {
600
622
  await store.remove(found.id);
601
623
  await backups(found.id).clear();
602
624
  if (found.id === session.id) {
603
- session = store.create();
604
- await store.save(session);
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
+ }
605
638
  }
606
639
  }
607
640
  }
@@ -610,23 +643,26 @@ export async function startUiServer(options) {
610
643
  session.todos = [];
611
644
  session.plan = undefined;
612
645
  session.usage = { inputTokens: 0, outputTokens: 0 };
613
- await store.save(session);
646
+ if (blank !== session)
647
+ await store.save(session);
614
648
  }
615
649
  else if (body.action === 'mode') {
616
650
  const mode = body.value === 'plan' ? 'plan' : 'build';
617
651
  session.mode = mode;
618
652
  if (mode === 'build' && session.plan?.status === 'cancelled')
619
653
  session.plan = undefined;
620
- await store.save(session);
654
+ if (blank !== session)
655
+ await store.save(session);
621
656
  }
622
657
  else if (body.action === 'reasoning') {
623
658
  const level = body.value;
624
659
  if (REASONING_LEVELS.includes(level)) {
625
660
  session.reasoning = level;
626
- await store.save(session);
661
+ if (blank !== session)
662
+ await store.save(session);
627
663
  }
628
664
  }
629
- activeId = session.id;
665
+ activeId = blank === session ? null : session.id;
630
666
  return json(res, 200, { session: session.id, sessions: await listSessions(), info: await info(session) });
631
667
  }
632
668
  if (path === '/api/complete' && req.method === 'GET') {
@@ -812,7 +848,8 @@ export async function startUiServer(options) {
812
848
  try {
813
849
  session.model = provider().model;
814
850
  session.provider = config.current;
815
- await store.save(session);
851
+ if (blank !== session)
852
+ await store.save(session);
816
853
  }
817
854
  catch {
818
855
  /* provider 暂时不可用,不影响设置已保存 */
@@ -925,6 +962,9 @@ export async function startUiServer(options) {
925
962
  }
926
963
  if (path === '/api/chat' && req.method === 'POST') {
927
964
  const body = await readJson(req);
965
+ if (typeof body.message !== 'string' || !body.message.trim()) {
966
+ return json(res, 400, { error: '消息不能为空' });
967
+ }
928
968
  if (turn)
929
969
  return json(res, 409, { error: '当前正在跑一轮对话' });
930
970
  // 前端会带上会话 id:以它为准,避免新建对话后又被解析回旧对话
@@ -934,6 +974,12 @@ export async function startUiServer(options) {
934
974
  if (found)
935
975
  target = found;
936
976
  }
977
+ // 空白草稿在第一次真正对话时才落盘。
978
+ if (target === blank) {
979
+ await store.save(target);
980
+ blank = null;
981
+ }
982
+ session = target;
937
983
  activeId = target.id;
938
984
  return chat(body, res, target);
939
985
  }
@@ -1086,11 +1132,18 @@ export async function startUiServer(options) {
1086
1132
  setSessionAndSave: async (value) => {
1087
1133
  next = value;
1088
1134
  await store.save(value);
1135
+ if (blank === value) {
1136
+ blank = null;
1137
+ activeId = value.id;
1138
+ }
1089
1139
  },
1090
1140
  setProvider: () => { },
1091
1141
  setConfig: (value) => Object.assign(config, value),
1092
1142
  setTools: () => { },
1093
1143
  saveSession: async () => {
1144
+ // 空白草稿不因为 /provider、/system 之类的命令偷偷落盘。
1145
+ if (blank === next)
1146
+ return;
1094
1147
  await store.save(next);
1095
1148
  },
1096
1149
  reloadProvider: () => { },
@@ -1449,8 +1502,15 @@ async function sendFile(res, name) {
1449
1502
  }
1450
1503
  async function readBody(req) {
1451
1504
  const chunks = [];
1452
- for await (const chunk of req)
1453
- chunks.push(Buffer.from(chunk));
1505
+ let size = 0;
1506
+ const max = 30 * 1024 * 1024;
1507
+ for await (const chunk of req) {
1508
+ const buffer = Buffer.from(chunk);
1509
+ size += buffer.byteLength;
1510
+ if (size > max)
1511
+ throw new Error('请求体过大');
1512
+ chunks.push(buffer);
1513
+ }
1454
1514
  return Buffer.concat(chunks).toString('utf8');
1455
1515
  }
1456
1516
  async function readJson(req) {
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
- renderHeader();
682
- renderSidebar();
683
- renderThread();
684
- setActiveTab(state.info?.session?.id ?? null);
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
  }
@@ -794,17 +813,20 @@ function sessionToMarkdown(messages, title) {
794
813
  }
795
814
 
796
815
  async function downloadSession(format, id) {
797
- let session = state.info?.session;
798
- if (!session) return;
799
- // 导出别的会话时只读取,不切换当前会话。
800
- if (id && id !== session.id) {
801
- try {
802
- const result = await post('session', { action: 'load', ref: id });
803
- if (result?.session) session = result.session;
804
- } catch (error) {
805
- toast('导出失败:' + (error?.message ?? error));
806
- return;
807
- }
816
+ // 始终从服务端读取完整会话:/api/info 为了性能裁掉了图片 base64 和附件全文。
817
+ const targetId = id || state.info?.session?.id;
818
+ if (!targetId) return;
819
+ let session;
820
+ try {
821
+ const result = await post('session', { action: 'load', ref: targetId });
822
+ session = result?.session;
823
+ } catch (error) {
824
+ toast('导出失败:' + (error?.message ?? error));
825
+ return;
826
+ }
827
+ if (!session) {
828
+ toast('导出失败:没找到这个对话');
829
+ return;
808
830
  }
809
831
  const blob =
810
832
  format === 'json'
@@ -1143,8 +1165,8 @@ async function refresh(path) {
1143
1165
  state.info = info;
1144
1166
  const { sessions } = await get('sessions');
1145
1167
  state.sessions = sessions;
1146
- // 即使标签条被清空,也要把服务端当前会话补回来,否则删掉当前会话后会变成无标签状态。
1147
- if (state.info?.session?.id) {
1168
+ // 空白草稿不是会话:不占标签,也不出现在侧栏;发出第一条消息后才补标签。
1169
+ if (state.info?.session?.id && !state.info.session.draft) {
1148
1170
  upsertTab(state.info.session.id, state.info.session.title);
1149
1171
  state.activeTab = state.info.session.id;
1150
1172
  } else {
@@ -1201,8 +1223,14 @@ let appDialog = null;
1201
1223
  * 返回值:有输入框时是字符串或 null;纯确认时是 true 或 null。
1202
1224
  */
1203
1225
  function openAppDialog({ title, body = '', value = null, placeholder = '', confirmLabel = '确定', danger = false }) {
1226
+ // 防止双击/连点开出两个对话框,留下一个永远不 resolve 的 Promise。
1227
+ if (appDialog) return Promise.resolve(null);
1204
1228
  return new Promise((resolve) => {
1205
- appDialog?.remove();
1229
+ // 任何弹层打开前先收掉选择工具条、会话菜单和模型/思考弹层,避免视觉层叠混乱。
1230
+ hideSelectionTools();
1231
+ document.querySelector('.popover')?.remove();
1232
+ closeModelPop?.();
1233
+ closeReasoningPop?.();
1206
1234
  const wrap = document.createElement('div');
1207
1235
  wrap.className = 'modal';
1208
1236
  wrap.id = 'appDialog';
@@ -1210,6 +1238,7 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
1210
1238
  card.className = 'modal-card dialog-card';
1211
1239
  card.setAttribute('role', 'dialog');
1212
1240
  card.setAttribute('aria-modal', 'true');
1241
+ card.setAttribute('aria-label', title);
1213
1242
  const heading = document.createElement('div');
1214
1243
  heading.className = 'modal-head';
1215
1244
  heading.textContent = title;
@@ -1252,9 +1281,29 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
1252
1281
  event.preventDefault();
1253
1282
  event.stopPropagation();
1254
1283
  finish(null);
1255
- } else if (event.key === 'Enter') {
1256
- event.preventDefault();
1257
- confirm();
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
+ }
1258
1307
  }
1259
1308
  };
1260
1309
  appDialog = wrap;
@@ -1268,6 +1317,9 @@ function openAppDialog({ title, body = '', value = null, placeholder = '', confi
1268
1317
  if (!input.hidden) {
1269
1318
  input.focus();
1270
1319
  input.select();
1320
+ } else if (danger) {
1321
+ // 删除/清空这类不可逆操作,默认焦点放在「取消」,避免顺手回车。
1322
+ cancel.focus();
1271
1323
  } else {
1272
1324
  ok.focus();
1273
1325
  }
@@ -2149,6 +2201,10 @@ async function send() {
2149
2201
  state.info = event.info;
2150
2202
  if (event.todos) state.info.session.todos = event.todos;
2151
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
+ }
2152
2208
  }
2153
2209
  const { sessions } = await get('sessions');
2154
2210
  state.sessions = sessions;
@@ -2407,7 +2463,13 @@ async function clearCurrentSession() {
2407
2463
  renderSidebar();
2408
2464
  renderThread();
2409
2465
  renderTodos();
2410
- setActiveTab(state.info?.session?.id ?? null);
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
+ }
2411
2473
  toast('已清空当前对话');
2412
2474
  } catch (error) {
2413
2475
  toast('清空失败:' + (error?.message ?? error));
@@ -2442,7 +2504,9 @@ async function renameCurrentSession(title) {
2442
2504
  if (result?.sessions) state.sessions = result.sessions;
2443
2505
  renderHeader();
2444
2506
  renderSidebar();
2445
- renderTabs();
2507
+ // 空白草稿被显式重命名后会落盘,补上标签。
2508
+ if (state.info?.session && !state.info.session.draft) setActiveTab(state.info.session.id);
2509
+ else renderTabs();
2446
2510
  toast('已重命名');
2447
2511
  } catch (error) {
2448
2512
  toast('重命名失败:' + (error?.message ?? error));
@@ -2709,6 +2773,10 @@ function toggleModelPop() {
2709
2773
  }
2710
2774
 
2711
2775
  function openSettings(category) {
2776
+ // 设置是整页层级,先收掉所有可能悬在上面的小弹层。
2777
+ closeModelPop();
2778
+ closeReasoningPop();
2779
+ document.querySelector('.popover')?.remove();
2712
2780
  if (category) state.settingsCategory = category;
2713
2781
  state.settingsScroll = 0;
2714
2782
  state.settingsReturn = document.activeElement;
@@ -4263,6 +4331,9 @@ function openCommandCenter() {
4263
4331
  return;
4264
4332
  }
4265
4333
  if (!$('settingsSheet').hidden) closeSettings();
4334
+ closeModelPop();
4335
+ closeReasoningPop();
4336
+ document.querySelector('.popover')?.remove();
4266
4337
  state.ccIndex = 0;
4267
4338
  state.ccFiles = [];
4268
4339
  $('ccInput').value = '';
@@ -4712,6 +4783,15 @@ function bind() {
4712
4783
  $('jumpLatest').hidden = true;
4713
4784
  scrollToEnd(true, true);
4714
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
+ }
4715
4795
  THREAD.addEventListener(
4716
4796
  'wheel',
4717
4797
  (event) => {
@@ -4813,6 +4893,8 @@ function bind() {
4813
4893
 
4814
4894
  $('ccInput').addEventListener('input', () => {
4815
4895
  state.ccIndex = 0;
4896
+ // 清空搜索时不要把上一次的文件结果留在列表里。
4897
+ if (!$('ccInput').value.trim()) state.ccFiles = [];
4816
4898
  renderCommandCenter($('ccInput').value);
4817
4899
  scheduleCommandFiles($('ccInput').value);
4818
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/bananacli",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "A multi-provider AI agent for your terminal: file tools, shell, web search, persistent sessions, diff preview and undo",
5
5
  "type": "module",
6
6
  "engines": {