Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): open the legacy models submenu leftward in the sidebar

Elian Doran0e6d471f906f
diff --git a/apps/client/src/widgets/sidebar/SidebarChat.tsx b/apps/client/src/widgets/sidebar/SidebarChat.tsx
index 61bfeea7d1..5a64ddc7bb 100644
--- a/apps/client/src/widgets/sidebar/SidebarChat.tsx
+++ b/apps/client/src/widgets/sidebar/SidebarChat.tsx
@@ -414,6 +414,7 @@ export default function SidebarChat() {
activeNoteId={activeNoteId ?? undefined}
activeNoteTitle={activeNote?.title}
onSubmit={handleSubmit}
+ inSidebar
/>
)}
</div>
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
index 57a5f61818..4b870e16d7 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
@@ -173,17 +173,19 @@
.llm-chat-model-selector .dropdown {
display: flex;
+}
- small {
- margin-left: 0.5em;
- color: var(--muted-text-color);
- }
+/* Scoped to the dropdown wrapper (not `.llm-chat-model-selector`) so these menu styles
+ survive `portalToBody`, which reparents the menu to <body> under this same class. */
+.llm-chat-model-dropdown small {
+ margin-left: 0.5em;
+ color: var(--muted-text-color);
+}
- /* Position legacy models submenu to open upward */
- .dropdown-submenu .dropdown-menu {
- bottom: 0;
- top: auto;
- }
+/* Position legacy models submenu to open upward */
+.llm-chat-model-dropdown .dropdown-submenu .dropdown-menu {
+ bottom: 0;
+ top: auto;
}
.llm-chat-model-select.select-button {
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
index 2e5364c622..3f678dae8d 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
@@ -71,6 +71,8 @@ interface ChatInputBarProps {
onExtendedThinkingChange?: () => void;
/** Callback when model changes */
onModelChange?: (model: string) => void;
+ /** Rendered inside the narrow right sidebar — opens the model submenu leftwards so it doesn't overflow. */
+ inSidebar?: boolean;
}
export default function ChatInputBar({
@@ -81,7 +83,8 @@ export default function ChatInputBar({
onWebSearchChange,
onNoteToolsChange,
onExtendedThinkingChange,
- onModelChange
+ onModelChange,
+ inSidebar
}: ChatInputBarProps) {
const [showAddProviderModal, setShowAddProviderModal] = useState(false);
const editorApiRef = useRef<CKEditorApi>();
@@ -345,6 +348,13 @@ export default function ChatInputBar({
text={<>{currentModel?.name}</>}
disabled={chat.isStreaming}
buttonClassName="llm-chat-model-select"
+ className="llm-chat-model-dropdown"
+ // In the sidebar the menu lives inside `.sidebar-chat-container`'s
+ // `overflow: hidden`, which clips the leftward-opening legacy submenu.
+ // Portal it to the body (with a fixed popper) so it can extend past the
+ // sidebar edge, matching the sidebar's other dropdowns.
+ portalToBody={inSidebar}
+ dropdownOptions={inSidebar ? { popperConfig: { strategy: "fixed" } } : undefined}
>
{currentModelGroups.map(group => (
<Fragment key={group.key}>
@@ -366,6 +376,7 @@ export default function ChatInputBar({
<FormDropdownSubmenu
icon="bx bx-history"
title={t("llm_chat.legacy_models")}
+ dropStart={inSidebar}
>
{legacyModelGroups.map(group => (
<Fragment key={group.key}>