Skip to content

Commit 6b27069

Browse files
committed
v0.6.42
- Add the /copy-last command to copy the last Assistant response to the clipboard - Optimize some UI display effects - Enhance the compatibility of Usage information acquisition
1 parent 4c13132 commit 6b27069

8 files changed

Lines changed: 44 additions & 19 deletions

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ jobs:
5858
5959
### What's New
6060
61-
- Add streaming idle timeout retry
62-
- Add Anthropic adaptive thinking intensity scheme
61+
- Add the /copy-last command to copy the last Assistant response to the clipboard
62+
- Optimize some UI display effects
63+
- Enhance the compatibility of Usage information acquisition
6364
6465
### Installation
6566
```bash

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snow-ai",
3-
"version": "0.6.41",
3+
"version": "0.6.42",
44
"description": "Agentic coding in your terminal",
55
"license": "MIT",
66
"bin": {

source/api/anthropic.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,18 @@ function convertToAnthropicMessages(
222222
let systemContents: string[] | undefined;
223223
const anthropicMessages: AnthropicMessageParam[] = [];
224224

225+
const toolResults: any[] = [];
226+
225227
for (const msg of messages) {
228+
// Flush tool results when encountering non-tool messages
229+
if (msg.role !== 'tool' && toolResults.length > 0) {
230+
anthropicMessages.push({
231+
role: 'user',
232+
content: [...toolResults],
233+
});
234+
toolResults.length = 0;
235+
}
236+
226237
if (msg.role === 'system') {
227238
systemContents = [msg.content];
228239
continue;
@@ -271,15 +282,10 @@ function convertToAnthropicMessages(
271282
toolResultContent = msg.content;
272283
}
273284

274-
anthropicMessages.push({
275-
role: 'user',
276-
content: [
277-
{
278-
type: 'tool_result',
279-
tool_use_id: msg.tool_call_id,
280-
content: toolResultContent,
281-
},
282-
],
285+
toolResults.push({
286+
type: 'tool_result',
287+
tool_use_id: msg.tool_call_id,
288+
content: toolResultContent,
283289
});
284290
continue;
285291
}
@@ -389,6 +395,15 @@ function convertToAnthropicMessages(
389395
}
390396
}
391397

398+
// Flush any remaining tool results at the end of message processing
399+
if (toolResults.length > 0) {
400+
anthropicMessages.push({
401+
role: 'user',
402+
content: [...toolResults],
403+
});
404+
toolResults.length = 0;
405+
}
406+
392407
// 如果配置了自定义系统提示词(最高优先级,始终添加)
393408
if (customSystemPrompts && customSystemPrompts.length > 0) {
394409
systemContents = customSystemPrompts;

source/api/chat.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,14 @@ export async function* createStreamingChatCompletion(
584584
}
585585

586586
// Skip content processing if no choices (but usage is already captured above)
587-
const choice = chunk.choices[0];
587+
const choice = chunk.choices?.[0];
588588
if (!choice) {
589+
// If this chunk has usage but no choices, it's the final usage-only chunk
590+
// Some APIs send this as the last chunk after finish_reason
591+
if ((chunk as any).usage) {
592+
// Final chunk with usage, exit the loop
593+
break;
594+
}
589595
continue;
590596
}
591597

@@ -663,7 +669,10 @@ export async function* createStreamingChatCompletion(
663669
}
664670

665671
if (choice.finish_reason) {
666-
break;
672+
// Continue to wait for the final usage chunk.
673+
// Some APIs send finish_reason first, then usage-only chunk.
674+
// Don't break immediately as some APIs stream usage in each chunk.
675+
continue;
667676
}
668677
}
669678

source/i18n/lang/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const en: TranslationKeys = {
218218
manualInputHint: 'Press Enter to confirm, Esc to cancel',
219219
loadingError: '⚠ Failed to load models from API',
220220
requestMethodChat:
221-
'Chat Completions - Modern chat API (GPT-4, GPT-3.5-turbo)',
221+
'Chat Completions - Modern chat API (DeepSeek)',
222222
requestMethodResponses:
223223
'Responses - New responses API (2025, with built-in tools)',
224224
requestMethodGemini: 'Gemini - Google Gemini API',

source/i18n/lang/zh-TW.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export const zhTW: TranslationKeys = {
201201
manualInputSubtitle: '手動輸入模型名稱',
202202
manualInputHint: '按 Enter 確認,Esc 取消',
203203
loadingError: '⚠ 無法從 API 載入模型',
204-
requestMethodChat: 'Chat Completions - 現代聊天 API (GPT-4, GPT-3.5-turbo)',
204+
requestMethodChat: 'Chat Completions - 現代聊天 API (DeepSeek)',
205205
requestMethodResponses: 'Responses - 新 Responses API (2025, 內建工具)',
206206
requestMethodGemini: 'Gemini - Google Gemini API',
207207
requestMethodAnthropic: 'Anthropic - Claude API',

source/i18n/lang/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export const zh: TranslationKeys = {
200200
manualInputSubtitle: '手动输入模型名称',
201201
manualInputHint: '按 Enter 确认,Esc 取消',
202202
loadingError: '⚠ 无法从 API 加载模型',
203-
requestMethodChat: 'Chat Completions - 现代聊天 API (GPT-4, GPT-3.5-turbo)',
203+
requestMethodChat: 'Chat Completions - 现代聊天 API (DeepSeek)',
204204
requestMethodResponses: 'Responses - 新 Responses API (2025, 内置工具)',
205205
requestMethodGemini: 'Gemini - Google Gemini API',
206206
requestMethodAnthropic: 'Anthropic - Claude API',

0 commit comments

Comments
 (0)