fix: chat menu Copy shows while chat export is not allowed (#32960)

* fix: chat menu Copy shows while chat export is not allowed

Users without the chat export permission get no Download entry in the chat menu, but Copy was still there and copied the whole chat as text, the same as the plain text download. Copy is now hidden as well while chat export is not allowed.

Refs #32830

* fix: chat menu opens empty once Copy is hidden

With Copy hidden for users without the chat export permission, a temporary chat with no artifacts that is not scrolled down had nothing left in its chat menu, so the button opened an empty dropdown. The button is now hidden in that case and shows again as soon as the menu has an entry.

Refs #32830
This commit is contained in:
Classic298 2026-10-23 03:58:00 +02:00 • committed by GitHub
parent 82d6f230b4
commit b17ee7d839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 19 deletions

View file

@ -4,6 +4,7 @@
import {
WEBUI_NAME,
artifactContents,
banners,
chatId,
config,
@ -127,7 +128,7 @@
{title || chat?.chat?.title || $i18n.t('New Chat')}
</h1>
{#if shareEnabled && chat && (chat.id || $temporaryChatEnabled)}
{#if shareEnabled && chat && (chat.id || $temporaryChatEnabled) && (scrollToTop || ($artifactContents ?? []).length > 0 || (!readOnly && !$temporaryChatEnabled) || $user?.role === 'admin' || ($user?.permissions?.chat?.export ?? true))}
<Menu
{chat}
{shareEnabled}

View file

@ -463,26 +463,26 @@
<div class="flex items-center line-clamp-1">{$i18n.t('PDF document (.pdf)')}</div>
</button>
</DropdownSub>
<button
draggable="false"
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] cursor-pointer select-none hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
id="chat-copy-button"
on:click={async () => {
const res = await copyToClipboard(await getChatAsText()).catch((e) => {
console.error(e);
});
if (res) {
toast.success($i18n.t('Copied to clipboard'));
}
}}
>
<Clipboard className="size-3.5" strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Copy')}</div>
</button>
{/if}
<button
draggable="false"
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] cursor-pointer select-none hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
id="chat-copy-button"
on:click={async () => {
const res = await copyToClipboard(await getChatAsText()).catch((e) => {
console.error(e);
});
if (res) {
toast.success($i18n.t('Copied to clipboard'));
}
}}
>
<Clipboard className="size-3.5" strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Copy')}</div>
</button>
{#if !readOnly && !$temporaryChatEnabled && chat?.id}
<hr class="border-gray-50/30 dark:border-gray-800/30 mx-1 my-0.5" />