kingkont 0.10.3 → 0.10.5
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 +11 -3
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
|
@@ -213,10 +213,16 @@ async function renderWelcomeIdentity() {
|
|
|
213
213
|
let status = null;
|
|
214
214
|
try { status = await window.appChatium?.status?.(); } catch {}
|
|
215
215
|
if (status?.connected) {
|
|
216
|
-
// Приоритет имени: displayName (
|
|
216
|
+
// Приоритет имени: displayName (UI Chatium) → confirmedEmail →
|
|
217
217
|
// email → login → fullName → name → userId.
|
|
218
|
-
const name = status.displayName || status.
|
|
218
|
+
const name = status.displayName || status.confirmedEmail || status.email
|
|
219
|
+
|| status.login || status.fullName || status.name
|
|
220
|
+
|| status.userId || 'KingKont';
|
|
219
221
|
const sub = status.userId && status.userId !== name ? `· ${status.userId.slice(0, 8)}` : '';
|
|
222
|
+
// Диагностика: если ничего кроме userId не пришло — лог в консоль.
|
|
223
|
+
if (!status.displayName && !status.confirmedEmail && !status.email) {
|
|
224
|
+
console.log('[chat-identity] available fields:', status, 'allKeys:', status._allKeys);
|
|
225
|
+
}
|
|
220
226
|
wrap.innerHTML = `
|
|
221
227
|
<span style="color:#5c5; font-size:13px; line-height:1;">●</span>
|
|
222
228
|
<span class="who">${escapeHtml(name)}</span>
|
|
@@ -951,8 +957,10 @@ async function closeProject() {
|
|
|
951
957
|
// Cmd+R после close = welcome, а не реоткрытие.
|
|
952
958
|
try { localStorage.setItem('welcomeOnNextStart', '1'); } catch {}
|
|
953
959
|
// Чат привязан к одному проекту — чистим историю при выходе чтобы
|
|
954
|
-
// не путал контекст следующего открытого проекта.
|
|
960
|
+
// не путал контекст следующего открытого проекта. И прячем панель —
|
|
961
|
+
// на welcome-экране чат не имеет смысла (нет state.currentBoard).
|
|
955
962
|
if (window.kingChat?.clear) window.kingChat.clear();
|
|
963
|
+
if (window.kingChat?.close) window.kingChat.close();
|
|
956
964
|
stopExternalWatcher();
|
|
957
965
|
// Сбрасываем UI таймлайна/превью — иначе при возврате через welcome
|
|
958
966
|
// в новый проект остаётся фрейм/дорожки прошлого.
|