mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-25 23:00:53 -05:00
Every toggle in personal Settings and the Save button in General reloaded the full model list after storing the setting, which calls every connected provider live. The "Settings saved" message waited for that, so a slow connection made each click lag. None of these settings change the model list any more since personal connections were removed from user settings, so a save now just stores the setting and applies it. <table> <tr><td>Mock provider, 500 ms model list, 15 saves</td><td>Before</td><td>After</td></tr> <tr><td>Interface toggle, click to save done</td><td>~580 ms</td><td>~45 ms</td></tr> <tr><td>General Save, click to "Settings saved"</td><td>~585 ms</td><td>~70 ms</td></tr> <tr><td>Provider model list calls per save</td><td>1</td><td>0</td></tr> </table> Fixes #34846
909 lines
30 KiB
Svelte
909 lines
30 KiB
Svelte
<script lang="ts">
|
|
import english from '$lib/i18n/locales/en-US/translation.json';
|
|
import {
|
|
buildSettingsSearchIndex,
|
|
searchSettingsTabs,
|
|
type SettingsTab
|
|
} from '$lib/utils/settings-search';
|
|
import { browser } from '$app/environment';
|
|
import { getContext, tick } from 'svelte';
|
|
import type { Writable } from 'svelte/store';
|
|
import { toast } from 'svelte-sonner';
|
|
import { config, mobile, settings, user, visibleControls } from '$lib/stores';
|
|
import type { SettingsModalRequest } from '$lib/stores';
|
|
import { getUserSettings, updateUserSettings } from '$lib/apis/users';
|
|
import { getBackendConfig, getModels as _getModels } from '$lib/apis';
|
|
|
|
import Modal from '../common/Modal.svelte';
|
|
import Account from './Settings/Account.svelte';
|
|
import About from './Settings/About.svelte';
|
|
import General from './Settings/General.svelte';
|
|
import Interface from './Settings/Interface.svelte';
|
|
import Notifications from './Settings/Notifications.svelte';
|
|
import Shortcuts from './Settings/Shortcuts.svelte';
|
|
import Audio from './Settings/Audio.svelte';
|
|
import DataControls from './Settings/DataControls.svelte';
|
|
import Usage from './Settings/Usage.svelte';
|
|
import ArchivedChats from './Settings/ArchivedChats.svelte';
|
|
import Personalization from './Settings/Personalization.svelte';
|
|
import Search from '../icons/Search.svelte';
|
|
import ChevronRight from '../icons/ChevronRight.svelte';
|
|
import DatabaseSettings from '../icons/DatabaseSettings.svelte';
|
|
import SettingsAlt from '../icons/SettingsAlt.svelte';
|
|
import UserCircle from '../icons/UserCircle.svelte';
|
|
import SoundHigh from '../icons/SoundHigh.svelte';
|
|
import InfoCircle from '../icons/InfoCircle.svelte';
|
|
import Face from '../icons/Face.svelte';
|
|
import AppNotification from '../icons/AppNotification.svelte';
|
|
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
|
import ArchiveBox from '../icons/ArchiveBox.svelte';
|
|
import ChevronLeft from '../icons/ChevronLeft.svelte';
|
|
import Keyboard from '../icons/Keyboard.svelte';
|
|
import UsageIcon from '../icons/UsageIcon.svelte';
|
|
import AdminTabIcon from '$lib/components/admin/Settings/AdminTabIcon.svelte';
|
|
import AdminGeneral from '$lib/components/admin/Settings/General.svelte';
|
|
import AdminAuthentication from '$lib/components/admin/Settings/Authentication.svelte';
|
|
import AdminConnections from '$lib/components/admin/Settings/Connections.svelte';
|
|
import AdminModels from '$lib/components/admin/Settings/Models.svelte';
|
|
import AdminSubagents from '$lib/components/admin/Settings/Subagents.svelte';
|
|
import AdminAnalytics from '$lib/components/admin/Analytics.svelte';
|
|
import AdminIntegrations from '$lib/components/admin/Settings/Integrations.svelte';
|
|
import AdminDocuments from '$lib/components/admin/Settings/Documents.svelte';
|
|
import AdminWebSearch from '$lib/components/admin/Settings/WebSearch.svelte';
|
|
import AdminCodeExecution from '$lib/components/admin/Settings/CodeExecution.svelte';
|
|
import AdminPipelines from '$lib/components/admin/Settings/Pipelines.svelte';
|
|
import AdminInterface from '$lib/components/admin/Settings/Interface.svelte';
|
|
import AdminAudio from '$lib/components/admin/Settings/Audio.svelte';
|
|
import AdminImages from '$lib/components/admin/Settings/Images.svelte';
|
|
import AdminDatabase from '$lib/components/admin/Settings/Database.svelte';
|
|
|
|
const i18n: Writable<any> = getContext('i18n');
|
|
|
|
export let show: boolean | string | SettingsModalRequest = false;
|
|
let modalShow = false;
|
|
let lastShow: boolean | string | SettingsModalRequest = false;
|
|
let tabState: Record<string, unknown> | null = null;
|
|
let personalUiSettings: Record<string, any> = {};
|
|
|
|
const mergeUiSettings = (defaults: Record<string, any>, userSettings: Record<string, any>) => {
|
|
const merged = { ...defaults };
|
|
for (const [key, value] of Object.entries(userSettings)) {
|
|
const defaultValue = merged[key];
|
|
merged[key] =
|
|
defaultValue &&
|
|
value &&
|
|
typeof defaultValue === 'object' &&
|
|
typeof value === 'object' &&
|
|
!Array.isArray(defaultValue) &&
|
|
!Array.isArray(value)
|
|
? mergeUiSettings(defaultValue, value)
|
|
: value;
|
|
}
|
|
return merged;
|
|
};
|
|
|
|
const loadPersonalUiSettings = async () => {
|
|
const userSettings = await getUserSettings(localStorage.token, true).catch((error) => {
|
|
console.error(error);
|
|
return null;
|
|
});
|
|
personalUiSettings =
|
|
userSettings?.ui && typeof userSettings.ui === 'object' && !Array.isArray(userSettings.ui)
|
|
? userSettings.ui
|
|
: {};
|
|
};
|
|
|
|
$: if (show !== lastShow) {
|
|
lastShow = show;
|
|
search = '';
|
|
showSearch = false;
|
|
if (show && typeof show === 'object') {
|
|
selectedTab = show.tab;
|
|
tabState = show.state ?? null;
|
|
show = true;
|
|
lastShow = true;
|
|
modalShow = true;
|
|
loadPersonalUiSettings();
|
|
} else if (typeof show === 'string') {
|
|
selectedTab = show;
|
|
show = true;
|
|
lastShow = true;
|
|
modalShow = true;
|
|
loadPersonalUiSettings();
|
|
} else {
|
|
modalShow = show;
|
|
if (show) {
|
|
loadPersonalUiSettings();
|
|
}
|
|
if (!show) {
|
|
selectedTab = 'general';
|
|
tabState = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
$: if (!modalShow && show !== false) {
|
|
show = false;
|
|
search = '';
|
|
showSearch = false;
|
|
lastShow = false;
|
|
selectedTab = 'general';
|
|
tabState = null;
|
|
}
|
|
|
|
const isAdminTab = (tabId: string) => tabId.startsWith('admin:');
|
|
const adminTabSegment = (tabId: string) => tabId.replace('admin:', '');
|
|
const adminTabPanelId = (tabId: string) => `tab-${tabId.replace(':', '-')}`;
|
|
let personalSettingGroups: Record<string, string> = {};
|
|
let adminSettingGroups: Record<string, string> = {};
|
|
|
|
$: personalSettingGroups = {
|
|
general: $i18n.t('Basics'),
|
|
interface: $i18n.t('Basics'),
|
|
notifications: $i18n.t('Basics'),
|
|
shortcuts: $i18n.t('Basics'),
|
|
connections: $i18n.t('Services'),
|
|
tools: $i18n.t('Services'),
|
|
personalization: $i18n.t('Preferences'),
|
|
audio: $i18n.t('Preferences'),
|
|
data_controls: $i18n.t('Data'),
|
|
usage: $i18n.t('Data'),
|
|
archived_chats: $i18n.t('Data'),
|
|
account: $i18n.t('Profile'),
|
|
about: $i18n.t('Profile')
|
|
};
|
|
// $i18n.t('Experience');
|
|
$: adminSettingGroups = {
|
|
'admin:general': $i18n.t('System'),
|
|
'admin:authentication': $i18n.t('System'),
|
|
'admin:interface': $i18n.t('System'),
|
|
'admin:connections': $i18n.t('AI'),
|
|
'admin:models': $i18n.t('AI'),
|
|
'admin:subagents': $i18n.t('AI'),
|
|
'admin:integrations': $i18n.t('Tools'),
|
|
'admin:documents': $i18n.t('Tools'),
|
|
'admin:audio': $i18n.t('Tools'),
|
|
'admin:images': $i18n.t('Tools'),
|
|
'admin:web': $i18n.t('Tools'),
|
|
'admin:code-execution': $i18n.t('Tools'),
|
|
'admin:pipelines': $i18n.t('Tools'),
|
|
'admin:analytics': $i18n.t('Quality'),
|
|
'admin:db': $i18n.t('Data')
|
|
};
|
|
const settingGroupTitle = (tabId: string) =>
|
|
(isAdminTab(tabId) ? adminSettingGroups[tabId] : personalSettingGroups[tabId]) ??
|
|
$i18n.t('General');
|
|
const shouldShowSettingGroup = (tabIds: string[], index: number) =>
|
|
index === 0 || settingGroupTitle(tabIds[index]) !== settingGroupTitle(tabIds[index - 1]);
|
|
// Code Execution and Pipelines are kept for existing setups, so they sit behind a closed
|
|
// "Legacy" row at the end of Tools. It opens on click, when one of them gets selected, or
|
|
// while searching.
|
|
const legacyAdminTabs = ['admin:code-execution', 'admin:pipelines'];
|
|
let showLegacyTabs = false;
|
|
// Open once when a legacy tab becomes selected, but leave it collapsible afterwards.
|
|
$: if (legacyAdminTabs.includes(selectedTab)) showLegacyTabs = true;
|
|
$: legacyTabsOpen = showLegacyTabs || search.trim() !== '';
|
|
const settingGroupHeadingClass = (first: boolean) =>
|
|
`hidden md:block shrink-0 text-[0.625rem] text-base-600 dark:text-base-500 px-2 ${
|
|
first ? 'mt-0.5' : 'mt-2'
|
|
} mb-0.5`;
|
|
|
|
let allSettings: SettingsTab[];
|
|
$: allSettings = [
|
|
{
|
|
id: 'general',
|
|
titleKey: 'settings.personal.general.title',
|
|
title: $i18n.t('settings.personal.general.title'),
|
|
searchPrefixes: ['settings.personal.general.']
|
|
},
|
|
{
|
|
id: 'interface',
|
|
titleKey: 'settings.personal.interface.title',
|
|
title: $i18n.t('settings.personal.interface.title'),
|
|
searchPrefixes: ['settings.personal.interface.']
|
|
},
|
|
{
|
|
id: 'notifications',
|
|
titleKey: 'settings.personal.notifications.title',
|
|
title: $i18n.t('settings.personal.notifications.title'),
|
|
searchPrefixes: ['settings.personal.notifications.']
|
|
},
|
|
{
|
|
id: 'shortcuts',
|
|
titleKey: 'settings.personal.shortcuts.title',
|
|
title: $i18n.t('settings.personal.shortcuts.title'),
|
|
searchPrefixes: ['settings.personal.shortcuts.']
|
|
},
|
|
{
|
|
id: 'personalization',
|
|
titleKey: 'settings.personal.personalization.title',
|
|
title: $i18n.t('settings.personal.personalization.title'),
|
|
searchPrefixes: ['settings.personal.personalization.']
|
|
},
|
|
{
|
|
id: 'audio',
|
|
titleKey: 'settings.personal.audio.title',
|
|
title: $i18n.t('settings.personal.audio.title'),
|
|
searchPrefixes: ['settings.personal.audio.']
|
|
},
|
|
{
|
|
id: 'data_controls',
|
|
titleKey: 'settings.personal.dataControls.title',
|
|
title: $i18n.t('settings.personal.dataControls.title'),
|
|
searchPrefixes: ['settings.personal.dataControls.']
|
|
},
|
|
{
|
|
id: 'usage',
|
|
titleKey: 'settings.personal.usage.title',
|
|
title: $i18n.t('settings.personal.usage.title'),
|
|
searchPrefixes: ['settings.personal.usage.']
|
|
},
|
|
{
|
|
id: 'archived_chats',
|
|
titleKey: 'settings.personal.archivedChats.title',
|
|
title: $i18n.t('settings.personal.archivedChats.title'),
|
|
searchPrefixes: ['settings.personal.archivedChats.']
|
|
},
|
|
{
|
|
id: 'account',
|
|
titleKey: 'settings.personal.account.title',
|
|
title: $i18n.t('settings.personal.account.title'),
|
|
searchPrefixes: ['settings.personal.account.']
|
|
},
|
|
{
|
|
id: 'about',
|
|
titleKey: 'settings.personal.about.title',
|
|
title: $i18n.t('settings.personal.about.title'),
|
|
searchPrefixes: ['settings.personal.about.']
|
|
}
|
|
];
|
|
let adminSettings: SettingsTab[];
|
|
$: adminSettings = [
|
|
{
|
|
id: 'admin:general',
|
|
titleKey: 'settings.admin.general.title',
|
|
title: $i18n.t('settings.admin.general.title'),
|
|
searchPrefixes: ['settings.admin.general.', 'settings.personal.interface.']
|
|
},
|
|
{
|
|
id: 'admin:authentication',
|
|
titleKey: 'settings.admin.authentication.title',
|
|
title: $i18n.t('settings.admin.authentication.title'),
|
|
searchPrefixes: ['settings.admin.authentication.']
|
|
},
|
|
{
|
|
id: 'admin:interface',
|
|
titleKey: 'settings.admin.interface.title',
|
|
title: $i18n.t('settings.admin.interface.title'),
|
|
searchPrefixes: ['settings.admin.interface.', 'settings.personal.general.parameters.']
|
|
},
|
|
{
|
|
id: 'admin:connections',
|
|
titleKey: 'settings.admin.connections.title',
|
|
title: $i18n.t('settings.admin.connections.title'),
|
|
searchPrefixes: ['settings.admin.connections.']
|
|
},
|
|
{
|
|
id: 'admin:models',
|
|
titleKey: 'settings.admin.models.title',
|
|
title: $i18n.t('settings.admin.models.title'),
|
|
searchPrefixes: ['settings.admin.models.', 'settings.personal.general.parameters.']
|
|
},
|
|
{
|
|
id: 'admin:subagents',
|
|
titleKey: 'settings.admin.subagents.title',
|
|
title: $i18n.t('settings.admin.subagents.title'),
|
|
searchPrefixes: ['settings.admin.subagents.']
|
|
},
|
|
{
|
|
id: 'admin:integrations',
|
|
titleKey: 'settings.admin.integrations.title',
|
|
title: $i18n.t('settings.admin.integrations.title'),
|
|
searchPrefixes: ['settings.admin.integrations.', 'settings.admin.general.apps.']
|
|
},
|
|
{
|
|
id: 'admin:documents',
|
|
titleKey: 'settings.admin.documents.title',
|
|
title: $i18n.t('settings.admin.documents.title'),
|
|
searchPrefixes: ['settings.admin.documents.']
|
|
},
|
|
{
|
|
id: 'admin:web',
|
|
titleKey: 'settings.admin.web.title',
|
|
title: $i18n.t('settings.admin.web.title'),
|
|
searchPrefixes: ['settings.admin.web.']
|
|
},
|
|
{
|
|
id: 'admin:audio',
|
|
titleKey: 'settings.admin.audio.title',
|
|
title: $i18n.t('settings.admin.audio.title'),
|
|
searchPrefixes: ['settings.admin.audio.']
|
|
},
|
|
{
|
|
id: 'admin:images',
|
|
titleKey: 'Images & Videos',
|
|
title: $i18n.t('Images & Videos'),
|
|
searchPrefixes: ['settings.admin.images.', 'settings.admin.videos.']
|
|
},
|
|
{
|
|
id: 'admin:code-execution',
|
|
titleKey: 'settings.admin.codeExecution.title',
|
|
title: $i18n.t('settings.admin.codeExecution.title'),
|
|
searchPrefixes: ['settings.admin.codeExecution.']
|
|
},
|
|
{
|
|
id: 'admin:pipelines',
|
|
titleKey: 'settings.admin.pipelines.title',
|
|
title: $i18n.t('settings.admin.pipelines.title'),
|
|
searchPrefixes: ['settings.admin.pipelines.']
|
|
},
|
|
{
|
|
id: 'admin:analytics',
|
|
titleKey: 'settings.admin.analytics.title',
|
|
title: $i18n.t('settings.admin.analytics.title'),
|
|
searchPrefixes: ['settings.admin.analytics.']
|
|
},
|
|
{
|
|
id: 'admin:db',
|
|
titleKey: 'settings.admin.db.title',
|
|
title: $i18n.t('settings.admin.db.title'),
|
|
searchPrefixes: ['settings.admin.db.']
|
|
}
|
|
];
|
|
let availableSettings: SettingsTab[] = [];
|
|
let filteredSettings: string[] = [];
|
|
let filteredPersonalSettings: string[] = [];
|
|
let filteredAdminSettings: string[] = [];
|
|
|
|
let search = '';
|
|
let showSearch = false;
|
|
let searchInput: HTMLInputElement;
|
|
let searchButton: HTMLButtonElement;
|
|
let englishRequested = false;
|
|
$: if (modalShow && !englishRequested) {
|
|
englishRequested = true;
|
|
$i18n.loadLanguages('en-US').catch((error: unknown) => {
|
|
console.error(error);
|
|
});
|
|
}
|
|
|
|
const getAvailableSettings = (personalTabs: SettingsTab[], administratorTabs: SettingsTab[]) => {
|
|
const personalSettings = personalTabs.filter((tab) => {
|
|
if (tab.id === 'interface') {
|
|
return $user?.role === 'admin' || ($user?.permissions?.settings?.interface ?? true);
|
|
}
|
|
|
|
if (tab.id === 'audio') {
|
|
return (
|
|
$user?.role === 'admin' ||
|
|
($user?.permissions?.chat?.stt ?? true) ||
|
|
($user?.permissions?.chat?.tts ?? true) ||
|
|
($user?.permissions?.chat?.call ?? true)
|
|
);
|
|
}
|
|
|
|
if (tab.id === 'usage') {
|
|
return $visibleControls['settings.usage'];
|
|
}
|
|
|
|
if (tab.id === 'personalization') {
|
|
return (
|
|
$config?.features?.enable_memories &&
|
|
($user?.role === 'admin' || ($user?.permissions?.features?.memories ?? true))
|
|
);
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
return (
|
|
$user?.role === 'admin' ? [...personalSettings, ...administratorTabs] : personalSettings
|
|
).filter(
|
|
(tab) => tab.id !== 'admin:analytics' || ($config?.features?.enable_admin_analytics ?? true)
|
|
);
|
|
};
|
|
|
|
$: searchIndex = buildSettingsSearchIndex(availableSettings, english, $i18n, {
|
|
user: $user,
|
|
config: $config
|
|
});
|
|
$: filteredSettings = searchSettingsTabs(searchIndex, search);
|
|
$: filteredPersonalSettings = filteredSettings.filter((id) => !isAdminTab(id));
|
|
$: filteredAdminSettings = filteredSettings.filter(isAdminTab);
|
|
|
|
const selectTab = (id: string) => {
|
|
if (!availableSettings.some((tab) => tab.id === id)) return;
|
|
selectedTab = id;
|
|
};
|
|
|
|
const toggleSearch = async () => {
|
|
showSearch = !(showSearch || search);
|
|
if (!showSearch) search = '';
|
|
await tick();
|
|
(showSearch ? searchInput : searchButton)?.focus();
|
|
};
|
|
|
|
const searchKeydown = (event: KeyboardEvent) => {
|
|
if (event.key === 'Escape' && (search || $mobile)) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
if (search) search = '';
|
|
else toggleSearch();
|
|
} else if (event.key === 'Enter') {
|
|
event.preventDefault();
|
|
if (filteredSettings.length) selectTab(filteredSettings[0]);
|
|
}
|
|
};
|
|
|
|
const saveSettings = async (updated: Record<string, any>) => {
|
|
const saved = await updateUserSettings(localStorage.token, {
|
|
ui: updated
|
|
}).catch((error) => {
|
|
toast.error(`${error}`);
|
|
throw error;
|
|
});
|
|
personalUiSettings =
|
|
saved?.ui && typeof saved.ui === 'object' && !Array.isArray(saved.ui) ? saved.ui : {};
|
|
await settings.set(
|
|
mergeUiSettings($config?.ui?.default_interface_settings ?? {}, personalUiSettings)
|
|
);
|
|
};
|
|
|
|
const getModels = async () => {
|
|
return await _getModels(localStorage.token);
|
|
};
|
|
|
|
const adminConfigSaveHandler = async () => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
await tick();
|
|
await config.set(await getBackendConfig());
|
|
};
|
|
|
|
const tabButtonClass = (active: boolean) =>
|
|
`flex items-center gap-1.5 h-7 px-2 md:w-full shrink-0 rounded-lg text-xs text-left transition-colors duration-75 ${
|
|
active
|
|
? 'font-medium text-base-900 dark:text-base-0 bg-base-50 dark:bg-base-0/[0.04]'
|
|
: 'text-base-600 hover:text-base-700 dark:text-base-400 dark:hover:text-base-300'
|
|
}`;
|
|
|
|
let selectedTab = 'general';
|
|
const scrollToSelectedTab = async () => {
|
|
if (!browser || !modalShow || !selectedTab) {
|
|
return;
|
|
}
|
|
|
|
await tick();
|
|
const tabElement = document.querySelector<HTMLElement>(
|
|
'#settings-tabs-container [role="tab"][aria-selected="true"]'
|
|
);
|
|
tabElement?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
|
|
};
|
|
|
|
$: if ($user?.role !== 'admin' && isAdminTab(selectedTab)) {
|
|
selectedTab = 'general';
|
|
}
|
|
|
|
$: if (
|
|
$config &&
|
|
$user &&
|
|
availableSettings.length &&
|
|
!availableSettings.some((tab) => tab.id === selectedTab)
|
|
) {
|
|
selectedTab = 'general';
|
|
}
|
|
|
|
$: if (modalShow && selectedTab) {
|
|
scrollToSelectedTab();
|
|
}
|
|
|
|
$: if ($config && $user) {
|
|
availableSettings = getAvailableSettings(allSettings, adminSettings);
|
|
}
|
|
</script>
|
|
|
|
<Modal
|
|
size="full"
|
|
containerClassName="p-3 sm:p-4 lg:p-6"
|
|
className="h-[calc(100dvh-1.5rem)] sm:h-[calc(100dvh-2rem)] lg:h-[calc(100dvh-3rem)] flex flex-col md:flex-row bg-base-0 dark:bg-base-900 rounded-4xl overflow-hidden"
|
|
ariaLabel={$i18n.t('Settings')}
|
|
bind:show={modalShow}
|
|
>
|
|
<nav
|
|
id="settings-tabs-container"
|
|
class="shrink-0 min-w-0 md:min-h-0 flex flex-col border-b md:border-b-0 md:border-r border-base-100/30 dark:border-base-0/[0.02] md:w-[15rem]"
|
|
>
|
|
<div class="flex items-center gap-1 m-1 md:mb-0 shrink-0">
|
|
<button
|
|
class="flex flex-1 items-center gap-1.5 h-7 px-2 rounded-lg text-xs text-base-600 dark:text-base-500 hover:text-base-700 dark:hover:text-base-300 transition-colors duration-75"
|
|
type="button"
|
|
on:click={() => {
|
|
show = false;
|
|
}}
|
|
>
|
|
<ChevronLeft className="size-3" strokeWidth="2" />
|
|
<span>{$i18n.t('Back')}</span>
|
|
</button>
|
|
<button
|
|
bind:this={searchButton}
|
|
type="button"
|
|
class="flex md:hidden size-7 shrink-0 items-center justify-center rounded-lg text-base-600 hover:bg-base-50 hover:text-base-700 dark:text-base-500 dark:hover:bg-base-0/[0.04] dark:hover:text-base-300"
|
|
aria-label={$i18n.t('Search')}
|
|
aria-expanded={showSearch || !!search}
|
|
aria-controls="search-input-settings-modal"
|
|
on:click={toggleSearch}
|
|
>
|
|
<Search className="size-3.5" strokeWidth="1.5" />
|
|
</button>
|
|
</div>
|
|
|
|
{#if !$mobile || showSearch || search}
|
|
<div
|
|
class="flex items-center gap-1.5 h-7 px-2 mx-1 md:mt-1 mb-0.5 shrink-0 rounded-lg text-xs bg-base-50/70 dark:bg-base-0/[0.03]"
|
|
>
|
|
<div class="self-center rounded-l-xl bg-transparent">
|
|
<Search className="size-3.5" strokeWidth="1.5" />
|
|
</div>
|
|
<label class="sr-only" for="search-input-settings-modal">{$i18n.t('Search')}</label>
|
|
<input
|
|
bind:this={searchInput}
|
|
data-settings-search
|
|
class="w-full text-xs bg-transparent py-1 outline-hidden placeholder:text-base-600 dark:text-base-300 dark:placeholder:text-base-500"
|
|
bind:value={search}
|
|
id="search-input-settings-modal"
|
|
on:keydown={searchKeydown}
|
|
placeholder={$i18n.t('Search')}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="sr-only" role="status" aria-live="polite">
|
|
{search
|
|
? filteredSettings.length
|
|
? $i18n.t('Matching tabs: {{count}}', { count: filteredSettings.length })
|
|
: $i18n.t('No matches')
|
|
: ''}
|
|
</div>
|
|
|
|
<div
|
|
class="tabs scrollbar-none max-h-32 md:max-h-none flex min-w-0 flex-1 min-h-0 overflow-x-auto md:overflow-x-hidden md:overflow-y-auto md:flex-col p-1 pl-0 md:pl-1 gap-px"
|
|
>
|
|
<span
|
|
class="hidden md:block text-[0.625rem] text-base-600 dark:text-base-500 px-2 mt-1.5 mb-0.5"
|
|
>
|
|
{$i18n.t('Personal')}
|
|
</span>
|
|
|
|
{#if filteredPersonalSettings.length > 0}
|
|
<div role="tablist" aria-label={$i18n.t('Personal')} class="contents">
|
|
{#each filteredPersonalSettings as tabId, index (tabId)}
|
|
{#if shouldShowSettingGroup(filteredPersonalSettings, index)}
|
|
<span class={settingGroupHeadingClass(index === 0)}>
|
|
{settingGroupTitle(tabId)}
|
|
</span>
|
|
{/if}
|
|
|
|
{#if tabId === 'general'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-general"
|
|
aria-selected={selectedTab === 'general'}
|
|
class={tabButtonClass(selectedTab === 'general')}
|
|
on:click={() => {
|
|
selectTab('general');
|
|
}}
|
|
>
|
|
<SettingsAlt className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.general.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'interface'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-interface"
|
|
aria-selected={selectedTab === 'interface'}
|
|
class={tabButtonClass(selectedTab === 'interface')}
|
|
on:click={() => {
|
|
selectTab('interface');
|
|
}}
|
|
>
|
|
<AdjustmentsHorizontal className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.interface.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'notifications'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-notifications"
|
|
aria-selected={selectedTab === 'notifications'}
|
|
class={tabButtonClass(selectedTab === 'notifications')}
|
|
on:click={() => {
|
|
selectTab('notifications');
|
|
}}
|
|
>
|
|
<AppNotification className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.notifications.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'shortcuts'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-shortcuts"
|
|
aria-selected={selectedTab === 'shortcuts'}
|
|
class={tabButtonClass(selectedTab === 'shortcuts')}
|
|
on:click={() => {
|
|
selectTab('shortcuts');
|
|
}}
|
|
>
|
|
<Keyboard className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.shortcuts.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'personalization'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-personalization"
|
|
aria-selected={selectedTab === 'personalization'}
|
|
class={tabButtonClass(selectedTab === 'personalization')}
|
|
on:click={() => {
|
|
selectTab('personalization');
|
|
}}
|
|
>
|
|
<Face className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.personalization.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'audio'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-audio"
|
|
aria-selected={selectedTab === 'audio'}
|
|
class={tabButtonClass(selectedTab === 'audio')}
|
|
on:click={() => {
|
|
selectTab('audio');
|
|
}}
|
|
>
|
|
<SoundHigh className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.audio.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'data_controls'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-data-controls"
|
|
aria-selected={selectedTab === 'data_controls'}
|
|
class={tabButtonClass(selectedTab === 'data_controls')}
|
|
on:click={() => {
|
|
selectTab('data_controls');
|
|
}}
|
|
>
|
|
<DatabaseSettings className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.dataControls.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'usage'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-usage"
|
|
aria-selected={selectedTab === 'usage'}
|
|
class={tabButtonClass(selectedTab === 'usage')}
|
|
on:click={() => {
|
|
selectTab('usage');
|
|
}}
|
|
>
|
|
<UsageIcon className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.usage.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'archived_chats'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-archived-chats"
|
|
aria-selected={selectedTab === 'archived_chats'}
|
|
class={tabButtonClass(selectedTab === 'archived_chats')}
|
|
on:click={() => {
|
|
selectTab('archived_chats');
|
|
}}
|
|
>
|
|
<ArchiveBox className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.archivedChats.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'account'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-account"
|
|
aria-selected={selectedTab === 'account'}
|
|
class={tabButtonClass(selectedTab === 'account')}
|
|
on:click={() => {
|
|
selectTab('account');
|
|
}}
|
|
>
|
|
<UserCircle className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.account.title')}</span>
|
|
</button>
|
|
{:else if tabId === 'about'}
|
|
<button
|
|
role="tab"
|
|
aria-controls="tab-about"
|
|
aria-selected={selectedTab === 'about'}
|
|
class={tabButtonClass(selectedTab === 'about')}
|
|
on:click={() => {
|
|
selectTab('about');
|
|
}}
|
|
>
|
|
<InfoCircle className="size-3.5" strokeWidth="2" />
|
|
<span>{$i18n.t('settings.personal.about.title')}</span>
|
|
</button>
|
|
{/if}
|
|
{/each}
|
|
</div>
|
|
{/if}
|
|
|
|
{#if $user?.role === 'admin' && filteredAdminSettings.length > 0}
|
|
<div
|
|
class="hidden md:block shrink-0 self-stretch h-px mx-1 my-2 bg-base-100/40 dark:bg-base-0/[0.025]"
|
|
></div>
|
|
<span class="hidden md:block text-[0.625rem] text-base-600 dark:text-base-500 px-2 mb-0.5">
|
|
{$i18n.t('Admin')}
|
|
</span>
|
|
|
|
<div role="tablist" aria-label={$i18n.t('Admin')} class="contents">
|
|
{#each filteredAdminSettings as tabId, index (tabId)}
|
|
{#if shouldShowSettingGroup(filteredAdminSettings, index)}
|
|
<span class={settingGroupHeadingClass(index === 0)}>
|
|
{settingGroupTitle(tabId)}
|
|
</span>
|
|
{/if}
|
|
|
|
{@const tab = adminSettings.find((setting) => setting.id === tabId)}
|
|
{@const legacy = legacyAdminTabs.includes(tabId)}
|
|
{#if legacy && tabId === filteredAdminSettings.find( (id) => legacyAdminTabs.includes(id) )}
|
|
<button
|
|
type="button"
|
|
aria-expanded={legacyTabsOpen}
|
|
class="flex items-center gap-1.5 h-7 px-2 md:w-full shrink-0 rounded-lg text-xs text-left text-base-500 hover:text-base-700 dark:text-base-500 dark:hover:text-base-300 transition-colors duration-75"
|
|
on:click={() => {
|
|
showLegacyTabs = !showLegacyTabs;
|
|
}}
|
|
>
|
|
<!-- Small chevron in an icon-sized slot, so the label lines up with the tabs. -->
|
|
<span class="flex size-3.5 shrink-0 items-center justify-center">
|
|
<ChevronRight
|
|
className="size-2.5 transition-transform duration-75 {legacyTabsOpen
|
|
? 'rotate-90'
|
|
: ''}"
|
|
strokeWidth="2.5"
|
|
/>
|
|
</span>
|
|
<span>{$i18n.t('Legacy')}</span>
|
|
</button>
|
|
{/if}
|
|
{#if tab && (!legacy || legacyTabsOpen)}
|
|
<button
|
|
role="tab"
|
|
aria-controls={adminTabPanelId(tab.id)}
|
|
aria-selected={selectedTab === tab.id}
|
|
class="{tabButtonClass(selectedTab === tab.id)} {legacy ? 'md:pl-4' : ''}"
|
|
on:click={() => {
|
|
selectTab(tab.id);
|
|
}}
|
|
>
|
|
<AdminTabIcon id={adminTabSegment(tab.id)} className="size-3.5" strokeWidth="2" />
|
|
<span>{tab.title}</span>
|
|
</button>
|
|
{/if}
|
|
{/each}
|
|
</div>
|
|
{/if}
|
|
|
|
{#if filteredSettings.length === 0}
|
|
<div class="px-2 py-1 text-xs text-base-600 dark:text-base-500">
|
|
{$i18n.t('No matches')}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="flex-1 min-w-0 min-h-0 p-4 md:px-5 flex flex-col">
|
|
<div
|
|
class="flex-1 min-h-0 overflow-hidden"
|
|
id={isAdminTab(selectedTab) ? adminTabPanelId(selectedTab) : undefined}
|
|
>
|
|
{#if selectedTab === 'general'}
|
|
<General
|
|
{getModels}
|
|
{saveSettings}
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'interface'}
|
|
<Interface
|
|
{saveSettings}
|
|
personalSettingsValue={personalUiSettings}
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'notifications'}
|
|
<Notifications {saveSettings} />
|
|
{:else if selectedTab === 'shortcuts'}
|
|
<Shortcuts {saveSettings} />
|
|
{:else if selectedTab === 'personalization'}
|
|
<Personalization
|
|
{saveSettings}
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'audio'}
|
|
<Audio
|
|
{saveSettings}
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'data_controls'}
|
|
<DataControls {saveSettings} />
|
|
{:else if selectedTab === 'usage'}
|
|
<Usage />
|
|
{:else if selectedTab === 'archived_chats'}
|
|
<ArchivedChats />
|
|
{:else if selectedTab === 'account'}
|
|
<Account
|
|
saveHandler={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'about'}
|
|
<About />
|
|
{:else if selectedTab === 'admin:general'}
|
|
<AdminGeneral saveHandler={adminConfigSaveHandler} />
|
|
{:else if selectedTab === 'admin:authentication'}
|
|
<AdminAuthentication />
|
|
{:else if selectedTab === 'admin:connections'}
|
|
<AdminConnections
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'admin:models'}
|
|
<AdminModels bind:tabState />
|
|
{:else if selectedTab === 'admin:subagents'}
|
|
<AdminSubagents />
|
|
{:else if selectedTab === 'admin:analytics'}
|
|
<AdminAnalytics />
|
|
{:else if selectedTab === 'admin:integrations'}
|
|
<AdminIntegrations {saveSettings} />
|
|
{:else if selectedTab === 'admin:documents'}
|
|
<AdminDocuments on:save={adminConfigSaveHandler} />
|
|
{:else if selectedTab === 'admin:web'}
|
|
<AdminWebSearch saveHandler={adminConfigSaveHandler} />
|
|
{:else if selectedTab === 'admin:code-execution'}
|
|
<AdminCodeExecution saveHandler={adminConfigSaveHandler} />
|
|
{:else if selectedTab === 'admin:pipelines'}
|
|
<AdminPipelines
|
|
saveHandler={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'admin:interface'}
|
|
<AdminInterface
|
|
saveHandler={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'admin:audio'}
|
|
<AdminAudio
|
|
saveHandler={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'admin:images'}
|
|
<AdminImages
|
|
on:save={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{:else if selectedTab === 'admin:db'}
|
|
<AdminDatabase
|
|
saveHandler={() => {
|
|
toast.success($i18n.t('Settings saved successfully!'));
|
|
}}
|
|
/>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
</Modal>
|