// ── Reply / Quote ── let pendingReply = null; // { index, role, text } - Zitierte Nachricht function _formatReplyTimestamp(ts) { if (!ts) return 'Jetzt'; try { const d = new Date(ts); const now = new Date(); const hh = d.getHours().toString().padStart(2, '0'); const mm = d.getMinutes().toString().padStart(2, '0'); // Gleiches Datum → nur Uhrzeit, sonst Datum + Uhrzeit if (d.toDateString() === now.toDateString()) { return hh + ':' + mm; } const dd = d.getDate().toString().padStart(2, '0'); const mo = (d.getMonth() + 1).toString().padStart(2, '0'); return dd + '.' + mo + '. ' + hh + ':' + mm; } catch { return 'Jetzt'; } } function setReply(reply) { pendingReply = reply; renderReplyPreview(); document.getElementById('input')?.focus(); } function clearReply() { pendingReply = null; renderReplyPreview(); } function renderReplyPreview() { const container = $('#replyPreview'); if (!container) return; if (!pendingReply) { container.innerHTML = ''; container.hidden = true; return; } const roleLabel = pendingReply.role === 'user' ? 'User' : 'Assistant'; const timeLabel = _formatReplyTimestamp(pendingReply.timestamp); const preview = truncate(pendingReply.text, 150); container.innerHTML = `
`; container.hidden = false; }