From 159a29ed06c4e689c465c105c74cf0d9ff4904b9 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:05:31 +0200 Subject: [PATCH] fix: temporary chat and delete chat shortcuts show while not allowed (#32978) * fix: temporary chat and delete chat shortcuts show while not allowed The keyboard shortcuts list showed "New Temporary Chat" and "Delete Chat" to users who may not use temporary chats or delete chats, and pressing those shortcuts neither opened a temporary chat nor deleted anything for them. Both entries now only show to users with the matching permission, and the settings search skips them otherwise. Refs #32830 * fix: new temporary chat shortcut does nothing without the permission Users without the temporary chat permission were sent to a new chat by the New Temporary Chat shortcut; it now does nothing for them. --- src/lib/components/chat/Settings/Shortcuts.svelte | 14 ++++++++++++-- src/lib/utils/settings-access.ts | 3 +++ src/routes/(app)/+layout.svelte | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/Settings/Shortcuts.svelte b/src/lib/components/chat/Settings/Shortcuts.svelte index 7e57240f0e..5e8f1932e8 100644 --- a/src/lib/components/chat/Settings/Shortcuts.svelte +++ b/src/lib/components/chat/Settings/Shortcuts.svelte @@ -14,7 +14,8 @@ shortcuts } from '$lib/shortcuts'; import type { KeybindingsMap, ShortcutDefinition } from '$lib/shortcuts'; - import { settings } from '$lib/stores'; + import { settings, user } from '$lib/stores'; + import { canManageChats, canUseTemporaryChats } from '$lib/utils/settings-access'; import Switch from '$lib/components/common/Switch.svelte'; import ShortcutItem from '../ShortcutItem.svelte'; @@ -44,7 +45,16 @@ }); $: { - const allShortcuts = Object.entries(shortcuts).filter(([, shortcut]) => { + const allShortcuts = Object.entries(shortcuts).filter(([id, shortcut]) => { + if ( + id === Shortcut.NEW_TEMPORARY_CHAT && + !canUseTemporaryChats({ user: $user, config: null }) + ) { + return false; + } + if (id === Shortcut.DELETE_CHAT && !canManageChats({ user: $user, config: null }, 'delete')) { + return false; + } if (!shortcut.setting) { return true; } diff --git a/src/lib/utils/settings-access.ts b/src/lib/utils/settings-access.ts index b50081875a..076480585b 100644 --- a/src/lib/utils/settings-access.ts +++ b/src/lib/utils/settings-access.ts @@ -81,5 +81,8 @@ export function canSearchSetting( ) return canUseCalls(context); if (stem === 'settings.personal.interface.webSearchInChat') return !!canUseWebSearch(context); + if (stem === 'settings.personal.shortcuts.newTemporaryChat') + return !!canUseTemporaryChats(context); + if (stem === 'settings.personal.shortcuts.deleteChat') return canManageChats(context, 'delete'); return true; } diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 75fc0edc8a..c535951b68 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -51,6 +51,7 @@ import UpdateInfoToast from '$lib/components/layout/UpdateInfoToast.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import { loadKeybindings, matchKeybinding, Shortcut } from '$lib/shortcuts'; + import { canUseTemporaryChats } from '$lib/utils/settings-access'; const i18n = getContext('i18n'); @@ -350,6 +351,9 @@ } else if (shortcut === Shortcut.NEW_TEMPORARY_CHAT) { console.log('Shortcut triggered: NEW_TEMPORARY_CHAT'); event.preventDefault(); + if (!canUseTemporaryChats({ user: $user, config: null })) { + return; + } if ($user?.role !== 'admin' && $user?.permissions?.chat?.temporary_enforced) { temporaryChatEnabled.set(true); } else {