@vincentbanana/bananacli 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -876,6 +876,7 @@ export async function startUiServer(options) {
876
876
  todos: session.todos,
877
877
  };
878
878
  const started = Date.now();
879
+ const toolStartedAt = new Map();
879
880
  let result;
880
881
  try {
881
882
  result = await runTurn({
@@ -892,15 +893,24 @@ export async function startUiServer(options) {
892
893
  recordChange: (path, beforeContent) => recorder.record(path, beforeContent),
893
894
  onText: (chunk) => send('text', { chunk }),
894
895
  onReasoning: (chunk) => send('reasoning', { chunk }),
895
- onToolStart: (name, input) => send('tool_start', { name, detail: summarizeInput(input) }),
896
- onToolEnd: (name, toolResult) => send('tool_end', {
897
- name,
898
- ok: toolResult.ok,
899
- display: toolResult.display ?? '',
900
- error: toolResult.ok ? '' : toolResult.content.slice(0, 400),
901
- // 详情面板用:命令输出 / 搜索结果等,最多 8KB
902
- detail: toolResult.content.slice(0, 8000),
903
- }),
896
+ onStep: (step) => send('step', { step }),
897
+ onToolStart: (name, input) => {
898
+ toolStartedAt.set(name, Date.now());
899
+ send('tool_start', { name, detail: summarizeInput(input) });
900
+ },
901
+ onToolEnd: (name, toolResult) => {
902
+ const began = toolStartedAt.get(name);
903
+ toolStartedAt.delete(name);
904
+ send('tool_end', {
905
+ name,
906
+ ok: toolResult.ok,
907
+ ms: began ? Date.now() - began : undefined,
908
+ display: toolResult.display ?? '',
909
+ error: toolResult.ok ? '' : toolResult.content.slice(0, 400),
910
+ // 详情面板用:命令输出 / 搜索结果等,最多 8KB
911
+ detail: toolResult.content.slice(0, 8000),
912
+ });
913
+ },
904
914
  onNotice: (message) => send('status', { message }),
905
915
  onCompact: () => send('status', { message: '已压缩历史对话' }),
906
916
  onRetry: (info) => send('status', { message: `网络重试 ${info.attempt}:${info.reason}` }),
package/dist/ui/app.js CHANGED
@@ -180,6 +180,7 @@ const state = {
180
180
  activeTab: null,
181
181
  review: { open: false, mode: 'changes', width: 520 },
182
182
  sidebar: { open: true, width: 344 },
183
+ sessionQuery: '',
183
184
  dock: { open: false, height: 280 },
184
185
  changes: null,
185
186
  changesFile: null,
@@ -391,7 +392,11 @@ function renderSidebar() {
391
392
  if (value >= start - 86_400_000) return '昨天';
392
393
  return '更早';
393
394
  };
394
- state.sessions.forEach((item, index) => {
395
+ const sessions = state.sessions.filter((item) => {
396
+ const q = state.sessionQuery.trim().toLowerCase();
397
+ return !q || String(item.title ?? '').toLowerCase().includes(q);
398
+ });
399
+ sessions.forEach((item, index) => {
395
400
  const label = dayOf(item.updatedAt);
396
401
  if (label !== group) {
397
402
  group = label;
@@ -551,6 +556,32 @@ function toolGroup(calls, results) {
551
556
  return wrap;
552
557
  }
553
558
 
559
+ function reasoningDetails(text) {
560
+ const details = document.createElement('details');
561
+ details.className = 'think';
562
+ const summary = document.createElement('summary');
563
+ summary.innerHTML = '<span class="think-title">思考</span>';
564
+ const body = document.createElement('div');
565
+ body.className = 'think-body';
566
+ body.textContent = text;
567
+ details.append(summary, body);
568
+ return details;
569
+ }
570
+
571
+ function messageActions(node, text, role) {
572
+ const actions = document.createElement('div');
573
+ actions.className = `msg-actions ${role === 'user' ? 'is-user' : 'is-assistant'}`;
574
+ const button = document.createElement('button');
575
+ button.type = 'button';
576
+ button.className = 'msg-action';
577
+ button.title = '复制';
578
+ button.setAttribute('aria-label', '复制');
579
+ button.innerHTML = svg('copy');
580
+ button.addEventListener('click', () => copyText(text ?? '', '已复制'));
581
+ actions.appendChild(button);
582
+ node.appendChild(actions);
583
+ }
584
+
554
585
  function renderMessage(message) {
555
586
  if (message.role === 'tool') return null;
556
587
  const node = document.createElement('article');
@@ -564,6 +595,9 @@ function renderMessage(message) {
564
595
  body.textContent = message.content;
565
596
  } else {
566
597
  body.innerHTML = markdown(message.content || '');
598
+ if (message.reasoning && state.info?.showReasoning !== false) {
599
+ body.insertBefore(reasoningDetails(message.reasoning), body.firstChild);
600
+ }
567
601
  if (message.toolCalls?.length) {
568
602
  const results = new Map(
569
603
  (state.info?.session?.messages ?? []).filter((m) => m.role === 'tool').map((m) => [m.toolCallId, m]),
@@ -572,6 +606,7 @@ function renderMessage(message) {
572
606
  }
573
607
  }
574
608
  node.append(role, body);
609
+ if (message.content?.trim()) messageActions(node, message.content, message.role);
575
610
  return node;
576
611
  }
577
612
 
@@ -922,6 +957,7 @@ async function send() {
922
957
  const workBody = document.createElement('div');
923
958
  workBody.className = 'tool-group-body';
924
959
  work.append(workSummary, workBody);
960
+ work.classList.add('is-running');
925
961
 
926
962
  // 思考过程:流式展开,回答开始后自动折叠
927
963
  const reasoning = document.createElement('details');
@@ -938,7 +974,10 @@ async function send() {
938
974
  body.className = 'msg-body caret';
939
975
  const meta = document.createElement('div');
940
976
  meta.className = 'turn-meta';
941
- botMsg.append(work, reasoning, body, meta);
977
+ const working = document.createElement('div');
978
+ working.className = 'working-row';
979
+ working.innerHTML = '<span class="wg-dot"></span><span class="shimmer">Banana 正在运行</span>';
980
+ botMsg.append(working, work, reasoning, body, meta);
942
981
  THREAD.appendChild(botMsg);
943
982
 
944
983
  let reasoningStarted = 0;
@@ -955,6 +994,7 @@ async function send() {
955
994
  const finishWork = () => {
956
995
  if (work.hidden || work.dataset.done === '1') return;
957
996
  work.dataset.done = '1';
997
+ work.classList.remove('is-running');
958
998
  const seconds = toolStarted ? ((Date.now() - toolStarted) / 1000).toFixed(1) : '0';
959
999
  workSummary.querySelector('.wg-title').textContent = `运行了 ${toolCount} 个工具`;
960
1000
  workSummary.querySelector('.wg-state').textContent = `${seconds}s${toolErrors ? ' · 有失败' : ''}`;
@@ -1012,6 +1052,7 @@ async function send() {
1012
1052
  const event = JSON.parse(line.slice(6));
1013
1053
  if (event.type === 'text') {
1014
1054
  finishReasoning();
1055
+ working.hidden = true;
1015
1056
  buffer += event.chunk;
1016
1057
  schedule();
1017
1058
  } else if (event.type === 'reasoning') {
@@ -1029,6 +1070,8 @@ async function send() {
1029
1070
  work.open = true;
1030
1071
  workSummary.querySelector('.wg-title').textContent = `正在运行 ${toolCount} 个工具`;
1031
1072
  workSummary.querySelector('.wg-state').textContent = '';
1073
+ work.classList.add('is-updating');
1074
+ setTimeout(() => work.classList.remove('is-updating'), 220);
1032
1075
  const row = document.createElement('div');
1033
1076
  row.className = 'tool-row';
1034
1077
  row.innerHTML =
@@ -1045,12 +1088,20 @@ async function send() {
1045
1088
  row.querySelector('.t-state').innerHTML = event.ok ? svg('check') : svg('x');
1046
1089
  row.classList.toggle('is-error', !event.ok);
1047
1090
  if (!event.ok) toolErrors = true;
1091
+ if (event.ms) {
1092
+ const time = document.createElement('span');
1093
+ time.className = 't-time';
1094
+ time.textContent = `${(event.ms / 1000).toFixed(1)}s`;
1095
+ row.querySelector('.t-state').after(time);
1096
+ }
1048
1097
  if (event.detail) {
1049
1098
  row.classList.add('is-clickable');
1050
1099
  row.title = '点击展开输出';
1051
1100
  row.addEventListener('click', () => toggleToolOutput(row, event.detail, !event.ok));
1052
1101
  }
1053
1102
  }
1103
+ } else if (event.type === 'step') {
1104
+ $('composerHint').textContent = `第 ${event.step} 步 · 处理中`;
1054
1105
  } else if (event.type === 'status') {
1055
1106
  if (event.message) {
1056
1107
  $('composerHint').textContent = event.message;
@@ -1076,6 +1127,7 @@ async function send() {
1076
1127
  if (event.error) body.innerHTML = markdown(`**请求失败** ${escapeHtml(event.error)}`);
1077
1128
  else if (!buffer.trim()) body.innerHTML = markdown('这一轮没有返回内容。');
1078
1129
  else body.innerHTML = markdown(buffer);
1130
+ if (buffer.trim()) messageActions(botMsg, buffer, 'assistant');
1079
1131
  metaLine('步数', event.steps);
1080
1132
  metaLine('用时', (event.ms / 1000).toFixed(1) + 's');
1081
1133
  if (event.cost && event.cost !== '≈$0') metaLine('花费', event.cost);
@@ -1084,6 +1136,7 @@ async function send() {
1084
1136
  state.info.session.messages[state.info.session.messages.length - 1] = {
1085
1137
  role: 'assistant',
1086
1138
  content: buffer,
1139
+ reasoning: reasonBody.textContent || undefined,
1087
1140
  };
1088
1141
  const { sessions } = await get('sessions');
1089
1142
  state.sessions = sessions;
@@ -1112,6 +1165,8 @@ async function send() {
1112
1165
  } finally {
1113
1166
  finishReasoning();
1114
1167
  finishWork();
1168
+ working.hidden = true;
1169
+ controller = null;
1115
1170
  setBusy(false);
1116
1171
  scrollToEnd();
1117
1172
  renderHeader();
@@ -3169,6 +3224,10 @@ function bind() {
3169
3224
  if (event.target === $('settingsSheet')) closeSettings();
3170
3225
  });
3171
3226
  $('toggleSidebar').addEventListener('click', toggleSidebar);
3227
+ $('sessionSearch').addEventListener('input', () => {
3228
+ state.sessionQuery = $('sessionSearch').value;
3229
+ renderSidebar();
3230
+ });
3172
3231
  $('filesBtn').addEventListener('click', toggleFiles);
3173
3232
  $('reviewBtn').addEventListener('click', () => {
3174
3233
  if (state.review.open && state.review.mode === 'changes') closeReview();
@@ -44,6 +44,10 @@
44
44
  </div>
45
45
  <button class="icon-btn" id="newChat" title="新建对话" aria-label="新建对话"></button>
46
46
  </div>
47
+ <label class="sb-search">
48
+ <span class="sb-search-ico" data-icon="search"></span>
49
+ <input id="sessionSearch" autocomplete="off" spellcheck="false" placeholder="搜索会话" />
50
+ </label>
47
51
  <div class="session-list" id="sessionList"></div>
48
52
  <div class="sidebar-foot">
49
53
  <button class="ghost-btn" id="openSettingsFoot">
package/dist/ui/style.css CHANGED
@@ -3380,3 +3380,155 @@ html[data-reduce-motion='1'] *::after {
3380
3380
  .chat-card.home-mode .composer-wrap { top: calc(22% + 120px); }
3381
3381
  .home-tips { top: calc(22% + 232px); }
3382
3382
  }
3383
+
3384
+ /* ============================================================
3385
+ 细节层:滚动条、焦点、会话搜索、消息操作、Review 侧栏
3386
+ ============================================================ */
3387
+ ::selection { background: color-mix(in srgb, var(--accent) 70%, transparent); color: var(--text); }
3388
+ :focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; border-radius: 4px; }
3389
+ input:focus-visible, textarea:focus-visible { outline: none; }
3390
+
3391
+ /* 细滚动条 */
3392
+ .thread, .session-list, .changes-list, .changes-detail, .files-tree, .files-code,
3393
+ .viewer-body, .settings-content, .cc-results, .think-body {
3394
+ scrollbar-width: thin;
3395
+ scrollbar-color: var(--line-strong) transparent;
3396
+ }
3397
+ .thread::-webkit-scrollbar, .session-list::-webkit-scrollbar, .changes-list::-webkit-scrollbar,
3398
+ .changes-detail::-webkit-scrollbar, .files-tree::-webkit-scrollbar, .files-code::-webkit-scrollbar,
3399
+ .viewer-body::-webkit-scrollbar, .settings-content::-webkit-scrollbar, .cc-results::-webkit-scrollbar {
3400
+ width: 8px;
3401
+ height: 8px;
3402
+ }
3403
+ .thread::-webkit-scrollbar-thumb, .session-list::-webkit-scrollbar-thumb, .changes-list::-webkit-scrollbar-thumb,
3404
+ .changes-detail::-webkit-scrollbar-thumb, .files-tree::-webkit-scrollbar-thumb, .files-code::-webkit-scrollbar-thumb,
3405
+ .viewer-body::-webkit-scrollbar-thumb, .settings-content::-webkit-scrollbar-thumb, .cc-results::-webkit-scrollbar-thumb {
3406
+ background: var(--line-strong);
3407
+ border-radius: 999px;
3408
+ border: 2px solid transparent;
3409
+ background-clip: padding-box;
3410
+ }
3411
+ .thread::-webkit-scrollbar-track, .session-list::-webkit-scrollbar-track,
3412
+ .changes-list::-webkit-scrollbar-track, .changes-detail::-webkit-scrollbar-track,
3413
+ .files-tree::-webkit-scrollbar-track, .files-code::-webkit-scrollbar-track,
3414
+ .viewer-body::-webkit-scrollbar-track, .settings-content::-webkit-scrollbar-track,
3415
+ .cc-results::-webkit-scrollbar-track { background: transparent; }
3416
+
3417
+ /* 会话搜索 */
3418
+ .sb-search {
3419
+ flex: none;
3420
+ height: 36px;
3421
+ margin: 2px 0 8px;
3422
+ padding: 0 8px;
3423
+ display: flex;
3424
+ align-items: center;
3425
+ gap: 7px;
3426
+ border-radius: 6px;
3427
+ background: var(--panel);
3428
+ color: var(--text-3);
3429
+ transition: background 140ms var(--ease), box-shadow 140ms var(--ease);
3430
+ }
3431
+ .sb-search:hover { background: var(--panel-2); }
3432
+ .sb-search:focus-within { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
3433
+ .sb-search-ico { display: inline-grid; place-items: center; width: 14px; height: 14px; }
3434
+ .sb-search-ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
3435
+ .sb-search input {
3436
+ flex: 1;
3437
+ min-width: 0;
3438
+ border: 0;
3439
+ outline: none;
3440
+ background: transparent;
3441
+ color: var(--text);
3442
+ font-family: var(--sans);
3443
+ font-size: 13px;
3444
+ font-weight: 440;
3445
+ }
3446
+ .sb-search input::placeholder { color: var(--text-3); }
3447
+
3448
+ /* 会话行对齐 opencode:40px 高、13px/530 */
3449
+ .session-item {
3450
+ min-height: 40px;
3451
+ display: flex;
3452
+ flex-direction: column;
3453
+ justify-content: center;
3454
+ padding: 0 8px;
3455
+ border-radius: 6px;
3456
+ }
3457
+ .session-item .s-title { font-size: 13px; font-weight: 530; line-height: 16px; }
3458
+ .session-item .s-meta { font-size: 11px; line-height: 14px; margin-top: 0; }
3459
+ .sb-group { height: 28px; display: flex; align-items: center; padding: 0 6px; margin-top: 6px; font-size: 13px; font-weight: 440; letter-spacing: 0; text-transform: none; color: var(--text-3); }
3460
+
3461
+ /* 消息操作 */
3462
+ .msg-actions {
3463
+ display: flex;
3464
+ gap: 4px;
3465
+ margin-top: 4px;
3466
+ min-height: 24px;
3467
+ opacity: 0;
3468
+ pointer-events: none;
3469
+ transition: opacity 140ms var(--ease);
3470
+ }
3471
+ .msg.user .msg-actions { justify-content: flex-end; }
3472
+ .msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; pointer-events: auto; }
3473
+ .msg-action {
3474
+ width: 24px; height: 24px; display: grid; place-items: center;
3475
+ border: 0; border-radius: 5px; background: transparent; color: var(--text-3); cursor: pointer;
3476
+ transition: background 130ms var(--ease), color 130ms var(--ease);
3477
+ }
3478
+ .msg-action:hover { background: var(--panel); color: var(--text); }
3479
+ .msg-action svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
3480
+
3481
+ /* 运行中 */
3482
+ .msg .working-row { max-width: none; padding: 0; margin: 0 0 8px; font-size: 13px; color: var(--text-3); }
3483
+ .msg .working-row .wg-dot { background: var(--accent-ink); }
3484
+
3485
+ /* Review:左侧文件栏 + 右侧 Diff */
3486
+ #changesPanel { flex-direction: row; }
3487
+ #changesPanel .changes-list {
3488
+ width: 208px;
3489
+ flex: 0 0 208px;
3490
+ max-height: none;
3491
+ min-height: 0;
3492
+ border-bottom: 0;
3493
+ border-right: 1px solid var(--line);
3494
+ padding: 4px;
3495
+ }
3496
+ #changesPanel .changes-detail { flex: 1; min-width: 0; }
3497
+ #changesPanel .change-file { height: 30px; }
3498
+ #changesPanel .changes-turn { padding: 8px 6px 4px; }
3499
+ #changesPanel .changes-empty { padding: 14px 10px; }
3500
+ @media (max-width: 1280px) {
3501
+ #changesPanel .changes-list { width: 176px; flex-basis: 176px; }
3502
+ }
3503
+ @media (max-width: 760px) {
3504
+ #changesPanel { flex-direction: column; }
3505
+ #changesPanel .changes-list { width: auto; flex: 0 1 40%; max-height: 40%; border-right: 0; border-bottom: 1px solid var(--line); }
3506
+ }
3507
+
3508
+ /* Composer 细节 */
3509
+ .composer textarea::placeholder { color: #b3b3b3; }
3510
+ :root[data-theme='dark'] .composer textarea::placeholder { color: #6f6f6f; }
3511
+ .composer-hint { opacity: 0; transition: opacity 160ms var(--ease); }
3512
+ .composer:hover .composer-hint, .composer:focus-within .composer-hint { opacity: 1; }
3513
+ .composer-toolbar { border-top: 1px solid transparent; transition: border-color 160ms var(--ease); }
3514
+ .composer:focus-within .composer-toolbar { border-top-color: var(--line); }
3515
+
3516
+ /* 工具汇总的弹性 */
3517
+ .work-group > summary .wg-title, .work-group > summary .wg-state { transition: opacity 180ms var(--ease), filter 240ms var(--ease), transform 480ms var(--cubic, cubic-bezier(0.22,1,0.36,1)); }
3518
+ .work-group.is-updating > summary .wg-title { filter: blur(1.5px); opacity: .55; transform: translateY(1px) scale(.99); }
3519
+ .work-group .wg-dot { transition: transform 480ms cubic-bezier(0.34, 1.3, 0.64, 1), background 180ms var(--ease); }
3520
+ .work-group.is-running .wg-dot { animation: bananaPulse 1.1s ease-in-out infinite; }
3521
+ @keyframes bananaPulse { 0%,100% { transform: scale(.8); opacity:.45 } 50% { transform: scale(1.35); opacity:1 } }
3522
+
3523
+ /* wordmark 再收一点 */
3524
+ .home-wordmark { opacity: .13; }
3525
+ .home-wordmark .wm-text { font-size: clamp(68px, 10vw, 120px); letter-spacing: -0.075em; }
3526
+
3527
+ /* 按钮统一 */
3528
+ .btn { border-radius: 6px; font-size: 13px; }
3529
+ .btn.primary { background: var(--inverse); color: var(--bg); border-color: var(--inverse); }
3530
+ .btn.tiny { height: 26px; padding: 0 8px; font-size: 11.5px; }
3531
+ .icon-btn { width: 28px; height: 28px; border-radius: 6px; }
3532
+ .chip-btn { border-radius: 6px; }
3533
+
3534
+ .tool-row .t-time { margin-left: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/bananacli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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": {