feat: detect artifacts toggle

This commit is contained in:
Timothy Jaeryang Baek 2025-04-10 10:36:57 -07:00
parent d4297a3e3e
commit d8780e4de2
2 changed files with 32 additions and 1 deletions

View File

@ -4,7 +4,7 @@
const dispatch = createEventDispatcher();
import Markdown from './Markdown.svelte';
import { chatId, mobile, showArtifacts, showControls, showOverview } from '$lib/stores';
import { chatId, mobile, settings, showArtifacts, showControls, showOverview } from '$lib/stores';
import FloatingButtons from '../ContentRenderer/FloatingButtons.svelte';
import { createMessagesList } from '$lib/utils';
@ -161,6 +161,7 @@
const { lang, code } = e.detail;
if (
($settings?.detectArtifacts ?? true) &&
(['html', 'svg'].includes(lang) || (lang === 'xml' && code.includes('svg'))) &&
!$mobile &&
$chatId

View File

@ -32,6 +32,8 @@
let showUsername = false;
let notificationSound = true;
let detectArtifacts = true;
let richTextInput = true;
let promptAutocomplete = false;
@ -176,6 +178,11 @@
saveSettings({ autoTags });
};
const toggleDetectArtifacts = async () => {
detectArtifacts = !detectArtifacts;
saveSettings({ detectArtifacts });
};
const toggleRichTextInput = async () => {
richTextInput = !richTextInput;
saveSettings({ richTextInput });
@ -242,6 +249,7 @@
titleAutoGenerate = $settings?.title?.auto ?? true;
autoTags = $settings.autoTags ?? true;
detectArtifacts = $settings.detectArtifacts ?? true;
responseAutoCopy = $settings.responseAutoCopy ?? false;
showUsername = $settings.showUsername ?? false;
@ -537,6 +545,28 @@
</div>
</div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs">
{$i18n.t('Detect Artifacts Automatically')}
</div>
<button
class="p-1 px-3 text-xs flex rounded-sm transition"
on:click={() => {
toggleDetectArtifacts();
}}
type="button"
>
{#if detectArtifacts === true}
<span class="ml-2 self-center">{$i18n.t('On')}</span>
{:else}
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
{/if}
</button>
</div>
</div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs">