Chain-Meta als Badges im Chat statt in Meta-Bar anzeigen
- Meta-Bar zeigt nur noch Status (Streaming.../Bereit) - Chain-Infos (Model, Tokens, Dauer etc.) als Badges im Chat - Badges bei Streaming, History-Load und Archiv-Ansicht - buildMetaString → buildMetaBadges, neue addChainMetaBubble Funktion
This commit is contained in:
1 parent
d434c3ff2a
commit
873e40b5d1
4 files changed
+58
-16
No files matched your search
+25
-11
@@ -1,13 +1,27 @@
|
||||
// ── Helpers ──
|
||||
|
||||
function buildMetaString(d) {
|
||||
let meta = `Model: ${d.model || '?'} | In: ${d.inputTokens || 0} | Out: ${d.outputTokens || 0}`;
|
||||
if (d.cacheCreationTokens > 0) meta += ` | Cache-Write: ${d.cacheCreationTokens}`;
|
||||
if (d.cacheReadTokens > 0) meta += ` | Cache-Read: ${d.cacheReadTokens}`;
|
||||
if ((d.iterations || 0) > 1) meta += ` | Iterations: ${d.iterations}`;
|
||||
if (d.durationMs) meta += ` | ${(d.durationMs / 1000).toFixed(1)}s`;
|
||||
if (d.stopReason && d.stopReason !== 'end_turn' && d.stopReason !== 'tool_use') meta += ` | Stop: ${d.stopReason}`;
|
||||
return meta;
|
||||
function buildMetaBadges(d) {
|
||||
const badges = [];
|
||||
badges.push(d.model || '?');
|
||||
badges.push('In: ' + (d.inputTokens || 0));
|
||||
badges.push('Out: ' + (d.outputTokens || 0));
|
||||
if (d.cacheCreationTokens > 0) badges.push('Cache-Write: ' + d.cacheCreationTokens);
|
||||
if (d.cacheReadTokens > 0) badges.push('Cache-Read: ' + d.cacheReadTokens);
|
||||
if ((d.iterations || 0) > 1) badges.push('Iterations: ' + d.iterations);
|
||||
if (d.durationMs) badges.push((d.durationMs / 1000).toFixed(1) + 's');
|
||||
if (d.stopReason && d.stopReason !== 'end_turn' && d.stopReason !== 'tool_use') badges.push('Stop: ' + d.stopReason);
|
||||
return badges;
|
||||
}
|
||||
|
||||
function addChainMetaBubble(d, streamed) {
|
||||
if (!d || !d.model) return;
|
||||
const badges = buildMetaBadges(d);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'chain-meta';
|
||||
if (streamed) div.classList.add('streamed');
|
||||
div.innerHTML = badges.map(b => '<span class="chain-meta-badge">' + esc(b) + '</span>').join('');
|
||||
chatEl().appendChild(div);
|
||||
scrollDown();
|
||||
}
|
||||
|
||||
// ── Chat State ──
|
||||
@@ -148,13 +162,13 @@ async function sendMessage() {
|
||||
addWarningBubble('⚠️ Antwort wurde abgeschnitten (max_tokens erreicht). Bitte frage nach dem Rest.', true);
|
||||
}
|
||||
if (data.model) {
|
||||
setMeta(buildMetaString(data));
|
||||
addChainMetaBubble(data, false);
|
||||
} else if (data.chainId) {
|
||||
// Leeres done (z.B. nach error/max_iterations) – Chain-Daten nachladen
|
||||
apiGetChain(data.chainId).then(chain => {
|
||||
if (chain) setMeta(buildMetaString(chain));
|
||||
if (chain) addChainMetaBubble(chain, false);
|
||||
}).catch(() => {});
|
||||
}
|
||||
setMeta('Bereit');
|
||||
break;
|
||||
}
|
||||
eventType = null;
|
||||
|
||||
Reference in new issue
Block a user