Skip to content

Commit 2133a9b

Browse files
committed
v0.7.18
- Optimize rendering performance of all panels - Add input box real terminal cursor - Optimize think field return for chat requests
1 parent ecaad55 commit 2133a9b

4 files changed

Lines changed: 76 additions & 52 deletions

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ jobs:
5656
5757
### What's New
5858
59-
- Pure TS implementation of the Yoga engine to avoid infinite linear memory growth.
60-
- Optimized Diffviewer rendering algorithm to reduce large number of Yoga nodes allocated.
61-
- widestLine cache to reduce stringWidth recalculation.
62-
- Add clearYogaNodeReferences to prevent dangling WASM pointers.
63-
- Output instance reuse to reduce GC pressure
64-
- Set limited cache to prevent infinite growth
59+
- Optimize rendering performance of all panels
60+
- Add input box real terminal cursor
61+
- Optimize think field return for chat requests
6562
6663
### Installation
6764
```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.7.17",
3+
"version": "0.7.18",
44
"description": "Agentic coding in your terminal",
55
"license": "MIT",
66
"bin": {

source/api/chat.ts

Lines changed: 70 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function convertToOpenAIMessages(
110110
vulnerabilityHuntingMode: boolean = false,
111111
toolSearchDisabled: boolean = false,
112112
teamMode: boolean = false,
113+
thinkingEnabled: boolean = false,
113114
): ChatCompletionMessageParam[] {
114115
const customSystemPrompts = customSystemPromptOverride;
115116

@@ -156,9 +157,11 @@ function convertToOpenAIMessages(
156157
...baseMessage,
157158
tool_calls: msg.tool_calls,
158159
};
159-
// Include reasoning_content for DeepSeek R1 models
160-
if ((msg as any).reasoning_content) {
161-
result.reasoning_content = (msg as any).reasoning_content;
160+
const rc = (msg as any).reasoning_content;
161+
if (rc !== undefined && rc !== null) {
162+
result.reasoning_content = rc;
163+
} else if (thinkingEnabled) {
164+
result.reasoning_content = '';
162165
}
163166
return result as ChatCompletionMessageParam;
164167
}
@@ -208,12 +211,20 @@ function convertToOpenAIMessages(
208211
} as ChatCompletionMessageParam;
209212
}
210213

211-
// Include reasoning_content for assistant messages (DeepSeek R1)
212-
if (msg.role === 'assistant' && (msg as any).reasoning_content) {
213-
return {
214-
...baseMessage,
215-
reasoning_content: (msg as any).reasoning_content,
216-
} as any;
214+
if (msg.role === 'assistant') {
215+
const rc = (msg as any).reasoning_content;
216+
if (rc !== undefined && rc !== null) {
217+
return {
218+
...baseMessage,
219+
reasoning_content: rc,
220+
} as any;
221+
}
222+
if (thinkingEnabled) {
223+
return {
224+
...baseMessage,
225+
reasoning_content: '',
226+
} as any;
227+
}
217228
}
218229

219230
return baseMessage as ChatCompletionMessageParam;
@@ -236,35 +247,45 @@ function convertToOpenAIMessages(
236247
text,
237248
})),
238249
} as ChatCompletionMessageParam,
239-
{
240-
role: 'user',
241-
content: getSystemPromptForMode(planMode, vulnerabilityHuntingMode, toolSearchDisabled, teamMode),
242-
} as ChatCompletionMessageParam,
243-
...result,
244-
];
245-
} else {
246-
// 只添加自定义系统提示词
250+
{
251+
role: 'user',
252+
content: getSystemPromptForMode(
253+
planMode,
254+
vulnerabilityHuntingMode,
255+
toolSearchDisabled,
256+
teamMode,
257+
),
258+
} as ChatCompletionMessageParam,
259+
...result,
260+
];
261+
} else {
262+
// 只添加自定义系统提示词
263+
result = [
264+
{
265+
role: 'system',
266+
content: customSystemPrompts.map(text => ({
267+
type: 'text' as const,
268+
text,
269+
})),
270+
} as ChatCompletionMessageParam,
271+
...result,
272+
];
273+
}
274+
} else if (includeBuiltinSystemPrompt) {
275+
// 没有自定义系统提示词,但需要添加默认系统提示词
247276
result = [
248277
{
249278
role: 'system',
250-
content: customSystemPrompts.map(text => ({
251-
type: 'text' as const,
252-
text,
253-
})),
279+
content: getSystemPromptForMode(
280+
planMode,
281+
vulnerabilityHuntingMode,
282+
toolSearchDisabled,
283+
teamMode,
284+
),
254285
} as ChatCompletionMessageParam,
255286
...result,
256287
];
257288
}
258-
} else if (includeBuiltinSystemPrompt) {
259-
// 没有自定义系统提示词,但需要添加默认系统提示词
260-
result = [
261-
{
262-
role: 'system',
263-
content: getSystemPromptForMode(planMode, vulnerabilityHuntingMode, toolSearchDisabled, teamMode),
264-
} as ChatCompletionMessageParam,
265-
...result,
266-
];
267-
}
268289

269290
return result;
270291
}
@@ -494,19 +515,24 @@ export async function* createStreamingChatCompletion(
494515
customSystemPromptContent ||= getCustomSystemPromptForConfig(config);
495516

496517
// 使用重试包装生成器
518+
const thinkingEnabled = !!(
519+
config.chatThinking?.enabled && !options.disableThinking
520+
);
521+
497522
yield* withRetryGenerator(
498523
async function* () {
499524
const requestBody: Record<string, any> = {
500525
model: options.model || config.advancedModel,
501-
messages: convertToOpenAIMessages(
502-
options.messages,
503-
options.includeBuiltinSystemPrompt !== false, // 默认为 true
504-
customSystemPromptContent,
505-
options.planMode || false,
506-
options.vulnerabilityHuntingMode || false,
507-
options.toolSearchDisabled || false,
508-
options.teamMode || false,
509-
),
526+
messages: convertToOpenAIMessages(
527+
options.messages,
528+
options.includeBuiltinSystemPrompt !== false, // 默认为 true
529+
customSystemPromptContent,
530+
options.planMode || false,
531+
options.vulnerabilityHuntingMode || false,
532+
options.toolSearchDisabled || false,
533+
options.teamMode || false,
534+
thinkingEnabled,
535+
),
510536
stream: true,
511537
stream_options: {include_usage: true},
512538
temperature: options.temperature || 0.7,
@@ -515,10 +541,11 @@ export async function* createStreamingChatCompletion(
515541
tool_choice: options.tool_choice,
516542
};
517543

518-
if (config.chatThinking?.enabled && !options.disableThinking) {
544+
if (thinkingEnabled) {
519545
requestBody['thinking'] = {type: 'enabled'};
520-
if (config.chatThinking.reasoning_effort) {
521-
requestBody['reasoning_effort'] = config.chatThinking.reasoning_effort;
546+
if (config.chatThinking?.reasoning_effort) {
547+
requestBody['reasoning_effort'] =
548+
config.chatThinking.reasoning_effort;
522549
}
523550
}
524551

0 commit comments

Comments
 (0)