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
Merge branch 'develop' into ai-llm-integration
perf3ctb00c20c357e9
diff --cc src/public/app/layouts/desktop_layout.tsindex 1467d3be24,8a6a8befdf..6a515d3724--- a/src/public/app/layouts/desktop_layout.ts+++ b/src/public/app/layouts/desktop_layout.ts@@@ -88,26 -87,23 +87,34 @@@ import utils from "../services/utils.jsimport GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";import CloseZenButton from "../widgets/close_zen_button.js";+import rightPaneTabManager from "../services/right_pane_tab_manager.js";+ import type { AppContext } from "./../components/app_context.js";+ import type { WidgetsByParent } from "../services/bundle.js";+ import SwitchSplitOrientationButton from "../widgets/floating_buttons/switch_layout_button.js";+ import ToggleReadOnlyButton from "../widgets/floating_buttons/toggle_read_only_button.js";+ import PngExportButton from "../widgets/floating_buttons/png_export_button.js";export default class DesktopLayout {- constructor(customWidgets) {++ private customWidgets: WidgetsByParent;++ constructor(customWidgets: WidgetsByParent) {this.customWidgets = customWidgets;}- getRootWidget(appContext) {+ getRootWidget(appContext: AppContext) {appContext.noteTreeWidget = new NoteTreeWidget();+ // Initialize the right pane tab manager after widget render+ setTimeout(() => {+ const $tabContainer = $("#right-pane-tab-container");+ const $contentContainer = $("#right-pane-content-container");++ if ($tabContainer.length && $contentContainer.length) {+ rightPaneTabManager.init($tabContainer, $contentContainer);+ }+ }, 500);+const launcherPaneIsHorizontal = options.get("layoutOrientation") === "horizontal";const launcherPane = this.#buildLauncherPane(launcherPaneIsHorizontal);const isElectron = utils.isElectron();diff --cc src/public/app/widgets/note_detail.tsindex aca9f9f180,b7db173373..2cd662efc3--- a/src/public/app/widgets/note_detail.ts+++ b/src/public/app/widgets/note_detail.ts@@@ -35,7 -35,7 +35,8 @@@ import GeoMapTypeWidget from "./type_wiimport utils from "../services/utils.js";import type { NoteType } from "../entities/fnote.js";import type TypeWidget from "./type_widgets/type_widget.js";+import LlmChatTypeWidget from "./type_widgets/llm_chat.js";+ import { MermaidTypeWidget } from "./type_widgets/mermaid.js";const TPL = `<div class="note-detail">@@@ -74,7 -74,9 +75,10 @@@ const typeWidgetClasses =attachmentList: AttachmentListTypeWidget,mindMap: MindMapWidget,geoMap: GeoMapTypeWidget,- llmChat: LlmChatTypeWidget++ llmChat: LlmChatTypeWidget,++ // Split type editors+ mermaid: MermaidTypeWidget};/**diff --cc src/public/stylesheets/style.cssindex 2aebf4c528,742757e598..ec247c2a22--- a/src/public/stylesheets/style.css+++ b/src/public/stylesheets/style.css@@@ -1722,202 -1728,20 +1728,196 @@@ footer.file-footer buttonmargin: 5px;}+/* AI Chat Widget Styles */+.chat-widget {+ display: flex;+ flex-direction: column;+ height: 100%;+ overflow: hidden;+}++.chat-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ padding: 10px 15px;+ border-bottom: 1px solid var(--main-border-color);+ background-color: var(--accented-background-color);+}++.chat-title {+ font-weight: bold;+ flex-grow: 1;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.chat-actions {+ display: flex;+ gap: 5px;+}++.chat-messages {+ flex-grow: 1;+ overflow-y: auto;+ padding: 15px;+ display: flex;+ flex-direction: column;+ gap: 15px;+}++.chat-message {+ display: flex;+ gap: 10px;+ max-width: 85%;+}++.chat-message-user {+ align-self: flex-end;+ flex-direction: row-reverse;+}++.chat-message-assistant {+ align-self: flex-start;+}++.chat-message-avatar {+ flex-shrink: 0;+ width: 30px;+ height: 30px;+ border-radius: 50%;+ background-color: var(--accented-background-color);+ display: flex;+ align-items: center;+ justify-content: center;+}++.chat-message-user .chat-message-avatar {+ background-color: var(--primary-color);+ color: white;+}++.chat-message-assistant .chat-message-avatar {+ background-color: var(--muted-text-color);+ color: white;+}++.chat-message-content {+ flex-grow: 1;+ padding: 10px 15px;+ border-radius: 12px;+ background-color: var(--accented-background-color);+ overflow-wrap: break-word;+ word-break: break-word;+}++.chat-message-user .chat-message-content {+ background-color: var(--primary-color);+ color: white;+}++.chat-message-content pre {+ background-color: var(--main-background-color);+ border-radius: 5px;+ padding: 10px;+ overflow-x: auto;+ margin: 10px 0;+}++.chat-message-user .chat-message-content pre {+ background-color: rgba(255, 255, 255, 0.2);+}++.chat-message-content code {+ font-family: monospace;+ background-color: var(--main-background-color);+ padding: 2px 4px;+ border-radius: 3px;+}++.chat-message-user .chat-message-content code {+ background-color: rgba(255, 255, 255, 0.2);+}++.chat-controls {+ display: flex;+ flex-direction: column;+ padding: 15px;+ gap: 10px;+ border-top: 1px solid var(--main-border-color);+}++.chat-input-container {+ position: relative;+}++.chat-input {+ width: 100%;+ resize: none;+ padding-right: 40px;+}++.chat-buttons {+ display: flex;+ justify-content: space-between;+}++.chat-loading {+ animation: chat-loading 1s infinite;+ letter-spacing: 3px;+}++@keyframes chat-loading {+ 0% { opacity: 0.3; }+ 50% { opacity: 1; }+ 100% { opacity: 0.3; }+}++/* Right Pane Tab Styles */+#right-pane-tab-container {+ display: flex;+ gap: 10px;+}++.right-pane-tab {+ padding: 5px 10px;+ cursor: pointer;+ border-radius: 5px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ transition: background-color 0.2s ease;+}++.right-pane-tab:hover {+ background-color: var(--hover-item-background-color);+}++.right-pane-tab.active {+ background-color: var(--primary-color);+ color: white;+}++.right-pane-tab .tab-title {+ display: flex;+ align-items: center;+ gap: 5px;+}++.right-pane-tab .tab-title .bx {+ font-size: 1.1em;+}+- .ck-content .admonition {+ .admonition {--accent-color: var(--card-border-color);border: 1px solid var(--accent-color);box-shadow: var(--card-box-shadow);background: var(--card-background-color);border-radius: 0.5em;padding: 1em;- margin: 1.25em 0;- position: relative;- padding-left: 2.5em;- overflow: hidden;}- margin: 1.25em 0;- position: relative;- padding-left: 2.5em;- overflow: hidden;- }--- .ck-content .admonition p:last-child {+ .admonition p:last-child {margin-bottom: 0;}@@@ -1929,64 -1753,50 +1929,105 @@@left: 1em;}- .ck-content .admonition.note { --accent-color: #69c7ff; }- .ck-content .admonition.tip { --accent-color: #40c025; }- .ck-content .admonition.important { --accent-color: #9839f7; }- .ck-content .admonition.caution { --accent-color: #ff2e2e; }- .ck-content .admonition.warning { --accent-color: #e2aa03; }+ .admonition.note { --accent-color: #69c7ff; }+ .admonition.tip { --accent-color: #40c025; }+ .admonition.important { --accent-color: #9839f7; }+ .admonition.caution { --accent-color: #ff2e2e; }+ .admonition.warning { --accent-color: #e2aa03; }+.ck-content .admonition.note::before { content: "\eb21"; }+.ck-content .admonition.tip::before { content: "\ea0d"; }+.ck-content .admonition.important::before { content: "\ea7c"; }+.ck-content .admonition.caution::before { content: "\eac7"; }+.ck-content .admonition.warning::before { content: "\eac5"; }++.chat-options-container {+ display: flex;+ margin: 5px 0;+ align-items: center;+ padding: 0 10px;+}++.chat-option {+ display: flex;+ align-items: center;+ font-size: 0.9em;+ margin-right: 15px;+ cursor: pointer;+}++.chat-option input[type="checkbox"] {+ margin-right: 5px;+}++/* Style for thinking process in chat responses */+.thinking-process {+ background-color: rgba(0, 0, 0, 0.05);+ border-left: 3px solid var(--main-text-color);+ padding: 10px;+ margin: 10px 0;+ border-radius: 4px;+}++.thinking-step {+ margin-bottom: 8px;+ padding-left: 10px;+}++.thinking-step.observation {+ border-left: 2px solid #69c7ff;+}++.thinking-step.hypothesis {+ border-left: 2px solid #9839f7;+}++.thinking-step.evidence {+ border-left: 2px solid #40c025;+}++.thinking-step.conclusion {+ border-left: 2px solid #e2aa03;+ font-weight: bold;+}+ .admonition.note::before { content: "\eb21"; }+ .admonition.tip::before { content: "\ea0d"; }+ .admonition.important::before { content: "\ea7c"; }+ .admonition.caution::before { content: "\eac7"; }+ .admonition.warning::before { content: "\eac5"; }++ /*+ * In-content floating buttons+ */++ .content-floating-buttons {+ position: absolute;+ z-index: 10; /* should be below dropdown (note actions) */+ }++ .content-floating-buttons.top-left {+ top: 10px;+ left: 10px;+ }++ .content-floating-buttons.bottom-left {+ bottom: 10px;+ left: 10px;+ }++ .content-floating-buttons.bottom-right {+ bottom: 10px;+ right: 10px;+ }++ .content-floating-buttons button.bx {+ font-size: 130%;+ padding: 1px 10px 1px 10px;+ }++ /* Customized icons */++ .bx-tn-toc::before {+ content: "\ec24";+ transform: rotate(180deg);-}++}diff --cc src/public/translations/en/translation.jsonindex 236a790d11,865d0dca0e..3a63ecc637--- a/src/public/translations/en/translation.json+++ b/src/public/translations/en/translation.json@@@ -1821,37 -1701,15 +1818,48 @@@"title": "Content languages","description": "Select one or more languages that should appear in the language selection in the Basic Properties section of a read-only or editable text note. This will allow features such as spell-checking or right-to-left support."},+ "ai": {+ "ai_settings": "AI Settings",+ "api_key": "API Key",+ "api_key_tooltip": "API key for accessing the service",+ "confirm_delete_embeddings": "Are you sure you want to delete all AI embeddings? This will remove all semantic search capabilities until notes are reindexed, which can take a significant amount of time.",+ "empty_key_warning": "Warning: Empty API key. You need to configure your API key in settings.",+ "enable_ai": "Enable AI Features",+ "enhanced_context_description": "Uses semantic search to find relevant information across your notes",+ "enter_message": "Enter your message...",+ "error_contacting_provider": "Error contacting AI provider. Please check your settings and internet connection.",+ "error_generating_response": "Error generating AI response",+ "index_all_notes": "Index All Notes",+ "index_status": "Index Status",+ "indexed_notes": "Indexed Notes",+ "indexing_stopped": "Indexing stopped",+ "indexing_in_progress": "Indexing in progress...",+ "last_indexed": "Last Indexed",+ "n_notes_queued": "{{ count }} note queued for indexing",+ "n_notes_queued_plural": "{{ count }} notes queued for indexing",+ "note_chat": "Note Chat",+ "notes_indexed": "{{ count }} note indexed",+ "notes_indexed_plural": "{{ count }} notes indexed",+ "reset_embeddings": "Reset Embeddings",+ "show_thinking": "Show Thinking",+ "show_thinking_description": "Reveals the reasoning process used to generate responses",+ "sources": "Sources",+ "start_indexing": "Start Indexing",+ "use_advanced_context": "Use Advanced Context",+ "use_enhanced_context": "Use Enhanced Note Context",+ "processing": {+ "common": "Processing..."+ }++ },+ "switch_layout_button": {+ "title_vertical": "Move editing pane to the bottom",+ "title_horizontal": "Move editing pane to the left"+ },+ "toggle_read_only_button": {+ "unlock-editing": "Unlock editing",+ "lock-editing": "Lock editing"+ },+ "png_export_button": {+ "button_title": "Export diagram as PNG"}}diff --cc src/routes/api/options.tsindex ce61f18f41,d4f480615c..ae57e38d41--- a/src/routes/api/options.ts+++ b/src/routes/api/options.ts@@@ -79,36 -79,7 +79,37 @@@ const ALLOWED_OPTIONS = new Set<OptionN"allowedHtmlTags","redirectBareDomain","showLoginInShareTheme",+ // AI/LLM integration options+ "aiEnabled",+ "openaiApiKey",+ "openaiDefaultModel",+ "openaiEmbeddingModel",+ "openaiBaseUrl",+ "anthropicApiKey",+ "anthropicDefaultModel",+ "voyageEmbeddingModel",+ "voyageApiKey",+ "anthropicBaseUrl",+ "ollamaEnabled",+ "ollamaBaseUrl",+ "ollamaDefaultModel",+ "ollamaEmbeddingModel",+ "aiProviderPrecedence",+ "aiTemperature",+ "aiSystemPrompt",+ // Embedding options+ "embeddingAutoUpdateEnabled",+ "embeddingBatchSize",+ "embeddingUpdateInterval",+ "embeddingDefaultDimension",+ "embeddingsDefaultProvider",+ "embeddingProviderPrecedence",+ "embeddingSimilarityThreshold",+ "maxNotesPerLlmQuery",+ "enableAutomaticIndexing",+ "embeddingGenerationLocation",- "embeddingDimensionStrategy"++ "embeddingDimensionStrategy",+ "splitEditorOrientation"]);function getOptions() {diff --cc src/services/options_interface.tsindex 80eeba0487,f7241956bd..5efd82555d--- a/src/services/options_interface.ts+++ b/src/services/options_interface.ts@@@ -45,41 -45,8 +45,42 @@@ export interface OptionDefinitions extepasswordVerificationSalt: string;passwordDerivedKeySalt: string;encryptedDataKey: string;+ hoistedNoteId: string;+ // AI/LLM integration options+ aiEnabled: boolean;+ aiProvider: string;+ aiSystemPrompt: string;+ aiTemperature: string;+ openaiApiKey: string;+ openaiDefaultModel: string;+ openaiEmbeddingModel: string;+ openaiBaseUrl: string;+ anthropicApiKey: string;+ anthropicDefaultModel: string;+ voyageEmbeddingModel: string;+ voyageApiKey: string;+ anthropicBaseUrl: string;+ ollamaEnabled: boolean;+ ollamaBaseUrl: string;+ ollamaDefaultModel: string;+ ollamaEmbeddingModel: string;+ codeOpenAiModel: string;+ aiProviderPrecedence: string;++ // Embedding-related options+ embeddingAutoUpdateEnabled: boolean;+ embeddingUpdateInterval: number;+ embeddingBatchSize: number;+ embeddingDefaultDimension: number;+ embeddingsDefaultProvider: string;+ embeddingProviderPrecedence: string;+ enableAutomaticIndexing: boolean;+ embeddingSimilarityThreshold: string;+ maxNotesPerLlmQuery: string;+ embeddingGenerationLocation: string;+ embeddingDimensionStrategy: string; // 'adapt' or 'regenerate'+lastSyncedPull: number;lastSyncedPush: number;revisionSnapshotTimeInterval: number;