kingkont 0.10.3 → 0.10.4
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/lib/providers.js +12 -1
- package/package.json +1 -1
- package/renderer/board.js +3 -1
package/lib/providers.js
CHANGED
|
@@ -485,7 +485,18 @@ async function generateText({ prompt, messages: msgsIn, model = 'anthropic/claud
|
|
|
485
485
|
messages.push({ role: 'user', content: prompt });
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
|
|
488
|
+
// promptLen для лога: либо длина prompt, либо суммарная длина всех текстов
|
|
489
|
+
// в messages — иначе `prompt.length` падает на messages-режиме (chat).
|
|
490
|
+
// content может быть string ИЛИ array of content-blocks {type:'text', text}.
|
|
491
|
+
function _msgLen(content) {
|
|
492
|
+
if (typeof content === 'string') return content.length;
|
|
493
|
+
if (Array.isArray(content)) return content.reduce((s, b) => s + (typeof b?.text === 'string' ? b.text.length : 0), 0);
|
|
494
|
+
return 0;
|
|
495
|
+
}
|
|
496
|
+
const promptLen = prompt
|
|
497
|
+
? prompt.length
|
|
498
|
+
: (msgsIn || []).reduce((s, m) => s + _msgLen(m?.content), 0);
|
|
499
|
+
logCall('POST', 'OpenRouter', 'https://openrouter.ai/api/v1/chat/completions', `model=${model} prompt=${promptLen}ch`);
|
|
489
500
|
const r = await fetch('https://openrouter.ai/api/v1/chat/completions', {
|
|
490
501
|
method: 'POST',
|
|
491
502
|
headers: {
|
package/package.json
CHANGED
package/renderer/board.js
CHANGED
|
@@ -951,8 +951,10 @@ async function closeProject() {
|
|
|
951
951
|
// Cmd+R после close = welcome, а не реоткрытие.
|
|
952
952
|
try { localStorage.setItem('welcomeOnNextStart', '1'); } catch {}
|
|
953
953
|
// Чат привязан к одному проекту — чистим историю при выходе чтобы
|
|
954
|
-
// не путал контекст следующего открытого проекта.
|
|
954
|
+
// не путал контекст следующего открытого проекта. И прячем панель —
|
|
955
|
+
// на welcome-экране чат не имеет смысла (нет state.currentBoard).
|
|
955
956
|
if (window.kingChat?.clear) window.kingChat.clear();
|
|
957
|
+
if (window.kingChat?.close) window.kingChat.close();
|
|
956
958
|
stopExternalWatcher();
|
|
957
959
|
// Сбрасываем UI таймлайна/превью — иначе при возврате через welcome
|
|
958
960
|
// в новый проект остаётся фрейм/дорожки прошлого.
|