Chat: User-Nachrichten [Datei:]-Tags als klickbare Chips rendern, System-Prompt mit Workspace-Pfad und Leerzeilen-Hinweis erweitern

This commit is contained in:
Meleki committed 2026-02-28 11:53:50 +01:00
1 parent bba82aad7e
commit 3cb468f4e8
5 files changed
+75 -4

No files matched your search

+36 -1
View File
@@ -30,11 +30,46 @@ function truncate(s, max) {
// ── Message Bubbles ──
function renderUserContent(container, text) {
const raw = (text || '').trim();
// [Datei: path] oder [Datei: path:1-10] erkennen
const pattern = /\[Datei: ([^\]]+)\]/g;
let last = 0;
let match;
const frag = document.createDocumentFragment();
while ((match = pattern.exec(raw)) !== null) {
// Text vor dem Tag
if (match.index > last) {
frag.appendChild(document.createTextNode(raw.slice(last, match.index)));
}
const ref = match[1]; // z.B. "src/foo.cs:10-25"
const chip = document.createElement('span');
chip.className = 'file-ref-chip';
chip.textContent = match[0];
chip.title = ref;
chip.style.cursor = 'pointer';
chip.addEventListener('click', () => {
openFileExplorer({ sessionId: getCurrentSessionId() });
});
frag.appendChild(chip);
last = match.index + match[0].length;
}
// Resttext
if (last < raw.length) {
frag.appendChild(document.createTextNode(raw.slice(last)));
}
container.appendChild(frag);
}
function addUserBubble(text, streamed = false) {
const div = document.createElement('div');
div.className = 'msg user';
if (streamed) div.classList.add('streamed');
div.textContent = (text || '').trim();
renderUserContent(div, text);
chatEl().appendChild(div);
scrollDown();
}