fix: web search in chat setting shows while web search is off (#32972)

Settings > Interface showed "Web Search in Chat" when web search is off for the instance or the user may not use it, and the choice had no effect. It now shows under the same conditions as the web search button in the chat input, and the settings search skips it otherwise. A saved choice is kept and applies again once web search is available.

Refs #32830
This commit is contained in:
Classic298 2026-10-24 04:19:39 +02:00 • committed by GitHub
parent 646cd86f1d
commit 521da58ff3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 26 deletions

View file

@ -2,6 +2,7 @@
import {
canUseChannels,
canUseTemporaryChats,
canUseWebSearch,
isSettingsAdmin
} from '$lib/utils/settings-access';
import { config, settings, user } from '$lib/stores';
@ -1638,34 +1639,36 @@
</p>
</div>
<div>
<div class={settingRowClass}>
<label
id="web-search-in-chat-label"
class={settingLabelClass}
for="web-search-in-chat-label-control"
>
{$i18n.t('settings.personal.interface.webSearchInChat.label')}
</label>
<button
id="web-search-in-chat-label-control"
aria-labelledby="web-search-in-chat-label web-search-state"
class={actionButtonClass}
on:click={() => {
toggleWebSearch();
}}
type="button"
>
<span id="web-search-state"
>{webSearch === 'always' ? $i18n.t('Always') : $i18n.t('Default')}</span
{#if canUseWebSearch({ user: $user, config: $config })}
<div>
<div class={settingRowClass}>
<label
id="web-search-in-chat-label"
class={settingLabelClass}
for="web-search-in-chat-label-control"
>
</button>
{$i18n.t('settings.personal.interface.webSearchInChat.label')}
</label>
<button
id="web-search-in-chat-label-control"
aria-labelledby="web-search-in-chat-label web-search-state"
class={actionButtonClass}
on:click={() => {
toggleWebSearch();
}}
type="button"
>
<span id="web-search-state"
>{webSearch === 'always' ? $i18n.t('Always') : $i18n.t('Default')}</span
>
</button>
</div>
<p class={settingDescriptionClass}>
{$i18n.t('settings.personal.interface.webSearchInChat.description')}
</p>
</div>
<p class={settingDescriptionClass}>
{$i18n.t('settings.personal.interface.webSearchInChat.description')}
</p>
</div>
{/if}
<div class={sectionHeadingClass}>
{$i18n.t('settings.personal.interface.sections.input.title')}

View file

@ -21,6 +21,9 @@ export const canUseTemporaryChats = ({ user }: SettingsAccessContext) =>
export const canUseChannels = ({ user, config }: SettingsAccessContext) =>
config?.features?.enable_channels &&
(user?.role === 'admin' || (user?.permissions?.features?.channels ?? true));
export const canUseWebSearch = ({ user, config }: SettingsAccessContext) =>
config?.features?.enable_web_search &&
(user?.role === 'admin' || user?.permissions?.features?.web_search);
export const isSettingsAdmin = ({ user }: SettingsAccessContext) => user?.role === 'admin';
/** Only permission-gated text needs an explicit rule. Provider/disclosure state is irrelevant. */
@ -70,5 +73,6 @@ export function canSearchSetting(
return !!canUseTemporaryChats(context);
if (stem === 'settings.personal.interface.compressImagesInChannels')
return !!canUseChannels(context);
if (stem === 'settings.personal.interface.webSearchInChat') return !!canUseWebSearch(context);
return true;
}