Avoid duplicate thinking line on cancel

This commit is contained in:
JOJO 2026-02-28 20:19:51 +08:00
parent e649731f6b
commit 1f456a732a

View File

@ -539,7 +539,11 @@ function promptWithStatus(force = false) {
}
function buildApiMessages() {
const system = buildSystemPrompt(systemPrompt, { workspace: WORKSPACE, allowMode: state.allowMode });
const system = buildSystemPrompt(systemPrompt, {
workspace: WORKSPACE,
allowMode: state.allowMode,
modelId: state.modelId || state.modelKey,
});
const messages = [{ role: 'system', content: system }];
for (const msg of state.messages) {
const m = { role: msg.role };
@ -668,7 +672,7 @@ async function runAssistantLoop() {
if (!gotAnswer) {
clearTimeout(thinkingDelay);
if (state.thinkingMode) {
spinner.stop(thinkingActive ? '○ 思考完成' : '○');
spinner.stop(thinkingActive ? '∙ 思考完成' : '∙');
} else {
spinner.stopSilent();
}
@ -695,7 +699,7 @@ async function runAssistantLoop() {
} else {
clearTimeout(thinkingDelay);
if (state.thinkingMode) {
spinner.stop('');
spinner.stop('');
} else {
spinner.stopSilent();
}
@ -708,14 +712,18 @@ async function runAssistantLoop() {
clearTimeout(thinkingDelay);
if (cancelled) {
stopSpinnerForCancel(spinner, thinkingActive, showThinkingLabel, state.thinkingMode);
if (gotAnswer) {
spinner.stopSilent();
} else {
stopSpinnerForCancel(spinner, thinkingActive, showThinkingLabel, state.thinkingMode);
}
showCursor();
printCancelLine();
return;
}
if (!gotAnswer) {
if (state.thinkingMode) {
spinner.stop(thinkingActive ? '○ 思考完成' : '○');
spinner.stop(thinkingActive ? '∙ 思考完成' : '∙');
} else {
spinner.stopSilent();
}