fix(term): store text node ref for thinking_tokens, drop DOM dance
This commit is contained in:
parent
758f5ae5a8
commit
dc63bfcb23
1 changed files with 9 additions and 12 deletions
|
|
@ -1886,11 +1886,12 @@ window.marked = marked;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Coalescing target for the live `thinking_tokens` counter.
|
// Coalescing target for the live `thinking_tokens` counter.
|
||||||
// Holds the row currently showing the running estimate so consecutive
|
// Holds the row + its text node so consecutive ticks update in place
|
||||||
// ticks update in place instead of appending a note each. Reset
|
// instead of appending a note each. Reset implicitly: we only reuse
|
||||||
// implicitly: we only reuse it while it's still the last row rendered
|
// it while it's still the last row rendered (nextElementSibling ===
|
||||||
// (see the nextElementSibling check), so any other event starts fresh.
|
// null), so any other event starts fresh.
|
||||||
let thinkingTokensRow = null;
|
let thinkingTokensRow = null;
|
||||||
|
let thinkingTokensText = null;
|
||||||
function renderStream(v, api) {
|
function renderStream(v, api) {
|
||||||
// Drop claude's result line and rate-limit — noise. TurnEnd
|
// Drop claude's result line and rate-limit — noise. TurnEnd
|
||||||
// communicates pass/fail; rate-limit events are noisy status chatter.
|
// communicates pass/fail; rate-limit events are noisy status chatter.
|
||||||
|
|
@ -1930,15 +1931,11 @@ window.marked = marked;
|
||||||
+ (n != null ? '~' + Number(n).toLocaleString() + ' tokens' : '');
|
+ (n != null ? '~' + Number(n).toLocaleString() + ' tokens' : '');
|
||||||
if (thinkingTokensRow && thinkingTokensRow.isConnected
|
if (thinkingTokensRow && thinkingTokensRow.isConnected
|
||||||
&& thinkingTokensRow.nextElementSibling === null) {
|
&& thinkingTokensRow.nextElementSibling === null) {
|
||||||
// Update only the text portion after the icon glyph
|
thinkingTokensText.nodeValue = text;
|
||||||
// (textContent would clobber the .row-glyph span).
|
|
||||||
const glyph = thinkingTokensRow.querySelector('.row-glyph');
|
|
||||||
[...thinkingTokensRow.childNodes].forEach((node) => {
|
|
||||||
if (node !== glyph) thinkingTokensRow.removeChild(node);
|
|
||||||
});
|
|
||||||
thinkingTokensRow.appendChild(document.createTextNode(text));
|
|
||||||
} else {
|
} else {
|
||||||
thinkingTokensRow = api.row('note', text, '🧠');
|
thinkingTokensRow = api.row('note', '', '🧠');
|
||||||
|
thinkingTokensText = document.createTextNode(text);
|
||||||
|
thinkingTokensRow.appendChild(thinkingTokensText);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue