Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm): improve bubble layout
Elian Doran186b78400407
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 3d9942e4e4..a603b14317 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1660,9 +1660,7 @@"note_context_enabled": "Click to disable note context: {{title}}","note_context_disabled": "Click to include current note in context","no_provider_message": "No AI provider configured. Add one to start chatting.",- "add_provider": "Add AI Provider",- "role_user": "You",- "role_assistant": "Assistant"+ "add_provider": "Add AI Provider"},"sidebar_chat": {"title": "AI Chat",diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.cssindex 2329f80041..6e710e1ea3 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css@@ -12,6 +12,7 @@.llm-chat-message-wrapper-user {margin-left: auto;+ max-width: 70%;}.llm-chat-message-wrapper-assistant {@@ -70,7 +71,11 @@51%, 100% { opacity: 0; }}-/* Citations table (inside a tool-call-card) */+.expandable-card.llm-chat-citations-card {+ max-width: 100%;+}++/* Citations table (inside an expandable card) */.llm-chat-citations-list {width: 100%;border-collapse: collapse;diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsxindex bc729af405..d3d9b814f7 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx@@ -60,7 +60,7 @@ function CitationsSection({ citations }: { citations: LlmCitation[] }) {const summary = t("llm_chat.sources_summary", { count: citations.length, sites: siteCount });return (- <ExpandableCard>+ <ExpandableCard className="llm-chat-citations-card"><ExpandableSection icon="bx bx-link" label={summary}><table className="llm-chat-citations-list"><tbody>@@ -98,7 +98,6 @@ function CitationsSection({ citations }: { citations: LlmCitation[] }) {}export default function ChatMessage({ message, isStreaming }: Props) {- const roleLabel = message.role === "user" ? t("llm_chat.role_user") : t("llm_chat.role_assistant");const isError = message.type === "error";const isThinking = message.type === "thinking";const textContent = typeof message.content === "string" ? message.content : getMessageText(message.content);@@ -139,9 +138,7 @@ export default function ChatMessage({ message, isStreaming }: Props) {return (<div className={`llm-chat-message-wrapper llm-chat-message-wrapper-${message.role}`}><div className={messageClasses}>- <div className="llm-chat-message-role">- {isError ? "Error" : roleLabel}- </div>+ {isError && <div className="llm-chat-message-role">Error</div>}<div className="llm-chat-message-content">{message.role === "assistant" && !isError ? (hasBlockContent ? (diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.css b/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.cssindex 94343f5181..e237bd2244 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.css+++ b/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.css@@ -1,6 +1,7 @@/* Expandable card — bordered container for collapsible sections */.expandable-card {margin: 0.5rem 0;+ max-width: 80%;border: 1px solid var(--main-border-color);border-radius: 8px;font-size: 0.85rem;@@ -14,13 +15,23 @@.expandable-section-summary {display: flex;- flex-wrap: wrap;align-items: center;gap: 0.25rem;padding: 0.5rem 0.75rem;cursor: pointer;list-style: none;font-weight: 500;+ overflow: hidden;+}++.expandable-section-label {+ display: flex;+ align-items: center;+ gap: 0.25rem;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ min-width: 0;}.expandable-section-summary::-webkit-details-marker {diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.tsxindex 999ff3da19..2e12c08e64 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ExpandableCard.tsx@@ -15,7 +15,7 @@ export function ExpandableSection({ icon, label, className, children }: Expandab<details className={`expandable-section ${className ?? ""}`}><summary className="expandable-section-summary"><span className={icon} />- {label}+ <span className="expandable-section-label">{label}</span><span className="bx bx-chevron-down expandable-section-chevron" /></summary><div className="expandable-section-body">@@ -26,13 +26,14 @@ export function ExpandableSection({ icon, label, className, children }: Expandab}interface ExpandableCardProps {+ className?: string;children: ComponentChildren;}/** A bordered card that groups one or more ExpandableSections. */-export function ExpandableCard({ children }: ExpandableCardProps) {+export function ExpandableCard({ className, children }: ExpandableCardProps) {return (- <div className="expandable-card">+ <div className={`expandable-card ${className ?? ""}`}>{children}</div>);