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

+18
View File
@@ -328,6 +328,24 @@
opacity: 1;
}
/* File Ref Chips in User-Bubbles */
.file-ref-chip {
display: inline-block;
padding: var(--badge-padding);
background: var(--f2-bg);
border: var(--border-width) solid var(--f2-border);
border-radius: var(--border-radius);
font-family: var(--mono);
font-size: .85em;
white-space: nowrap;
}
.file-ref-chip:hover {
border-color: var(--f3-border);
background: var(--f3-bg);
}
/* Attachments in History */
.attachment-indicator {
+1 -1
View File
@@ -112,7 +112,7 @@ async function loadLatestArchive() {
case 'text':
if (msg.role === 'user') {
div.className = 'msg user archived';
div.textContent = (msg.content || '').trim();
renderUserContent(div, msg.content);
} else {
div.className = 'msg assistant markdown archived';
div.innerHTML = renderMarkdown(msg.content);
+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();
}