// ── History Loading ── async function loadHistory() { try { const data = await apiHistory('null'); data.reverse(); // DESC → chronologisch for (const entry of data) { for (const msg of entry.messages) { switch (msg.type) { case 'text': if (msg.role === 'user') { addUserBubble(msg.content); messages.push({ role: 'user', content: msg.content }); } else if (msg.role === 'assistant') { addAssistantBubble(msg.content); messages.push({ role: 'assistant', content: msg.content }); } break; case 'tool_use': addToolBoxStatic(msg.toolName, msg.content, null, false); break; case 'tool_result': addToolBoxStatic(null, null, msg.content, msg.isError); break; case 'error': addErrorBubble(msg.content); break; } } } scrollDown(); } catch (e) { console.error('History laden fehlgeschlagen:', e); } }