Terminaalin koodivastaus tiivistetty yhdelle riville, klikkaus laajentaa

Tuloste näyttää ensimmäisen koodirivin + "(+N riviä)":
  ✓ Qwen2.5-Coder (75 tok)
  ▶ fn fibonacci(n: usize) -> usize { (+8 riviä)

Klikkaus laajentaa/sulkee koko koodin highlight.js-korostuksella
ja vasemman reunan indikaattoriviivalla.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaakko Vanhala
2026-04-05 18:29:18 +03:00
parent ac15336c9f
commit f17fcf0f9d

View File

@@ -1788,8 +1788,15 @@
const tokGen = data.tokens_generated || 0;
termLog(` <span style="color:#3fb950">✓</span> <span style="color:#58a6ff">${data.model || model}</span> <span style="color:#8b949e">(${tokGen} tok)</span>`);
if (!silent) {
const highlighted = highlightCode(response).replace(/\n/g, '\n ');
termLog(` <pre style="margin:0;font:inherit;white-space:pre-wrap">${highlighted}</pre>`);
// Kompakti yksirivinen esikatselu — klikkaa/hover laajentaa
const firstLine = response.split('\n').find(l => l.trim()) || response;
const lineCount = response.split('\n').filter(l => l.trim()).length;
const preview = esc(firstLine.trim());
const fullHighlighted = highlightCode(response).replace(/\n/g, '\n ');
const uid = 'code-' + Date.now();
termLog(` <span style="color:#3fb950;cursor:pointer" onclick="document.getElementById('${uid}').style.display=document.getElementById('${uid}').style.display==='none'?'block':'none'" title="Klikkaa nähdäksesi koko koodi">`
+ `<span style="color:#8b949e">▶</span> ${preview} <span style="color:#8b949e">${lineCount > 1 ? `(+${lineCount - 1} riviä)` : ''}</span></span>`
+ `<pre id="${uid}" style="display:none;margin:4px 0 0 16px;font:inherit;white-space:pre-wrap;border-left:2px solid #30363d;padding-left:10px">${fullHighlighted}</pre>`);
}
return response;
} catch (e) {