@vincentbanana/bananacli 0.4.2 → 0.4.3

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/ui/app.js CHANGED
@@ -135,6 +135,33 @@ function closeSidebarIfOverlay() {
135
135
  if (window.matchMedia('(max-width: 900px)').matches) $('sidebar').classList.remove('open');
136
136
  }
137
137
 
138
+ let switching = false;
139
+ /**
140
+ * 切换会话。直接吃 POST 返回的 info/sessions,不再多跑一次 refresh:
141
+ * 少一次往返、也不会和其他请求抢着改 state(之前表现为「点了没反应」)。
142
+ */
143
+ async function switchSession(ref) {
144
+ if (switching) return;
145
+ switching = true;
146
+ document.body.classList.add('switching');
147
+ try {
148
+ const result = await post('session', { action: 'switch', ref });
149
+ if (result?.info) state.info = result.info;
150
+ if (result?.sessions) state.sessions = result.sessions;
151
+ renderHeader();
152
+ renderSidebar();
153
+ renderThread();
154
+ $('filesTitle').textContent = `项目文件 · ${state.info?.workspace ?? ''}`;
155
+ closeSidebarIfOverlay();
156
+ } catch (error) {
157
+ toast('切换会话失败:' + (error?.message ?? error));
158
+ await refresh(true);
159
+ } finally {
160
+ switching = false;
161
+ document.body.classList.remove('switching');
162
+ }
163
+ }
164
+
138
165
  function renderSidebar() {
139
166
  const list = $('sessionList');
140
167
  list.innerHTML = '';
@@ -152,10 +179,7 @@ function renderSidebar() {
152
179
 
153
180
  node.addEventListener('click', (event) => {
154
181
  if (event.target.closest('[data-del], [data-menu]')) return;
155
- post('session', { action: 'switch', ref: item.id }).then(() => {
156
- refresh(true);
157
- closeSidebarIfOverlay();
158
- });
182
+ switchSession(item.id);
159
183
  });
160
184
 
161
185
  node.querySelector('[data-del]').addEventListener('click', (event) => {
@@ -207,9 +231,7 @@ function openSessionMenu(item, anchor) {
207
231
  event.stopPropagation();
208
232
  close();
209
233
  if (action === 'switch') {
210
- await post('session', { action: 'switch', ref: item.id });
211
- await refresh(true);
212
- closeSidebarIfOverlay();
234
+ await switchSession(item.id);
213
235
  } else if (action === 'rename') {
214
236
  const title = prompt('新的标题', item.title || '');
215
237
  if (title && title.trim()) {
@@ -219,8 +241,7 @@ function openSessionMenu(item, anchor) {
219
241
  toast('已重命名');
220
242
  }
221
243
  } else {
222
- await post('session', { action: 'switch', ref: item.id });
223
- await refresh(true);
244
+ await switchSession(item.id);
224
245
  downloadSession(action === 'json' ? 'json' : 'md', item.id);
225
246
  }
226
247
  });
@@ -350,7 +371,8 @@ function renderThread() {
350
371
  if (node) THREAD.appendChild(node);
351
372
  }
352
373
  renderTurnMeta();
353
- scrollToEnd();
374
+ // 切换会话时瞬间定位到底部;平滑滚动只用于新消息
375
+ scrollToEnd(false);
354
376
  }
355
377
 
356
378
  function renderTurnMeta() {
package/dist/ui/style.css CHANGED
@@ -204,8 +204,7 @@ button, input, textarea, select { font: inherit; color: inherit; }
204
204
  height: 54px;
205
205
  padding: 0 16px;
206
206
  border-bottom: 1px solid var(--line);
207
- background: color-mix(in srgb, var(--bg) 82%, transparent);
208
- backdrop-filter: saturate(140%) blur(8px);
207
+ background: var(--bg);
209
208
  }
210
209
 
211
210
  .topbar-title {
@@ -257,9 +256,17 @@ button, input, textarea, select { font: inherit; color: inherit; }
257
256
  max-width: 780px;
258
257
  margin: 0 auto;
259
258
  padding: 0 24px;
260
- animation: rise 320ms var(--ease) both;
259
+ /* 历史消息不做入场动画:切换会话时整屏重绘,动画会让人以为界面在乱动,
260
+ 长对话里还会明显卡顿。新消息的即时感交给滚动和光标。 */
261
+ content-visibility: auto;
262
+ contain-intrinsic-size: auto 120px;
261
263
  }
262
264
 
265
+ /* 切换会话时给一点即时反馈,避免点了像没反应 */
266
+ .thread { transition: opacity 120ms var(--ease); }
267
+ body.switching .thread { opacity: 0.45; }
268
+ body.switching { cursor: progress; }
269
+
263
270
  @keyframes rise {
264
271
  from { opacity: 0; transform: translateY(8px); }
265
272
  to { opacity: 1; transform: none; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/bananacli",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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": {