This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-02 13:39:52 -05:00
1 parent cee39914bc
commit 6a359036c5
6 files changed
+227 -68

No files matched your search

@@ -941,7 +941,7 @@
EditorView.theme({
'&': {
height: '100%',
fontSize: '13px',
fontSize: '0.8125rem',
backgroundColor: dark ? '#000' : '#ffffff'
},
'.cm-scroller': { fontFamily: '"JetBrains Mono", "Fira Code", ui-monospace, monospace' },
@@ -1,7 +1,7 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import Icon from '../Icon.svelte';
import { theme, streamingBehavior, showUpdateToastPref } from '$lib/stores';
import { theme, streamingBehavior, showUpdateToastPref, textScale } from '$lib/stores';
import type { Theme, StreamingBehavior } from '$lib/stores';
import { t, locale, changeLocale, supportedLocales } from '$lib/i18n';
import { notificationsEnabled, notificationSound } from '$lib/stores/chat';
@@ -19,12 +19,25 @@
let webhookUrl = $state('');
let webhookUrlOriginal = $state('');
let saving = $state(false);
let scaleEnabled = $state(false);
let scaleDraft = $state(1);
const minTextScale = 1;
const maxTextScale = 1.5;
let dirty = $derived(webhookUrl.trim() !== webhookUrlOriginal);
$effect(() => {
if ($textScale !== null) {
scaleEnabled = true;
scaleDraft = $textScale;
}
});
onMount(async () => {
try {
const data = await fetchJSON<{ config: Record<string, any> }>('/api/admin/config/notifications');
const data = await fetchJSON<{ config: Record<string, any> }>(
'/api/admin/config/notifications'
);
const url = data.config?.['notifications.webhook_url'] || '';
webhookUrl = url;
webhookUrlOriginal = url;
@@ -58,6 +71,39 @@
notificationsEnabled.set(false);
}
}
function toggleTextScale() {
if (scaleEnabled) {
scaleEnabled = false;
scaleDraft = 1;
textScale.set(null);
} else {
scaleEnabled = true;
scaleDraft = $textScale ?? 1;
}
}
function normalizeTextScale(scale: number | string) {
const value = Number(scale);
if (!Number.isFinite(value)) return minTextScale;
return Math.max(minTextScale, Math.min(maxTextScale, Number(value.toFixed(2))));
}
function scaleLabel(scale: number) {
return `${scale.toFixed(scale % 1 === 0 ? 0 : 2)}x`;
}
function setTextScalePreference(scale: number | string) {
const next = normalizeTextScale(scale);
scaleDraft = next;
if (next === minTextScale) {
scaleEnabled = false;
textScale.set(null);
} else {
scaleEnabled = true;
textScale.set(next);
}
}
</script>
<div class="flex flex-col h-full">
@@ -91,13 +137,72 @@
{/each}
</select>
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.uiScale')}</h3>
<div class="w-full">
<div class="flex items-center gap-2">
<span id="ui-scale-label" class="text-xs text-gray-600 dark:text-gray-400">
{$t('general.uiScale')}
</span>
<button
type="button"
class="ml-auto h-6 px-2 rounded-lg text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors"
aria-live="polite"
onclick={toggleTextScale}
>
{scaleEnabled ? scaleLabel(scaleDraft) : $t('general.default')}
</button>
</div>
{#if scaleEnabled}
<div class="flex items-center gap-1.5 pt-1.5">
<button
type="button"
class="flex items-center justify-center w-6 h-6 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors"
aria-labelledby="ui-scale-label"
aria-label={$t('general.decreaseUiScale')}
onclick={() => setTextScalePreference(scaleDraft - 0.1)}
>
<Icon name="minus" size={12} />
</button>
<input
id="ui-scale-slider"
class="ui-scale-range flex-1 min-w-0"
type="range"
min={minTextScale}
max={maxTextScale}
step="0.01"
bind:value={scaleDraft}
aria-labelledby="ui-scale-label"
aria-valuemin={minTextScale}
aria-valuemax={maxTextScale}
aria-valuenow={scaleDraft}
aria-valuetext={scaleLabel(scaleDraft)}
oninput={() => setTextScalePreference(scaleDraft)}
/>
<button
type="button"
class="flex items-center justify-center w-6 h-6 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors"
aria-labelledby="ui-scale-label"
aria-label={$t('general.increaseUiScale')}
onclick={() => setTextScalePreference(scaleDraft + 0.1)}
>
<Icon name="plus" size={12} />
</button>
</div>
{/if}
</div>
<!-- Notifications -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.notifications')}</h3>
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
{$t('general.notifications')}
</h3>
<div class="flex flex-col gap-2.5">
<!-- Browser notifications toggle -->
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.browserNotifications')}</span>
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('general.browserNotifications')}</span
>
<ToggleSwitch value={$notificationsEnabled} onchange={() => toggleNotifications()} />
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
@@ -106,7 +211,9 @@
<!-- Sound toggle -->
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.notificationSound')}</span>
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('general.notificationSound')}</span
>
<ToggleSwitch value={$notificationSound} onchange={(v) => notificationSound.set(v)} />
</label>
@@ -131,7 +238,9 @@
{#if $session?.role === 'admin'}
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.updates')}</h3>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.updateNotifications')}</span>
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('general.updateNotifications')}</span
>
<ToggleSwitch value={$showUpdateToastPref} onchange={(v) => showUpdateToastPref.set(v)} />
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
@@ -154,9 +263,7 @@
{/each}
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
{$streamingBehavior === 'queue'
? $t('general.queueDesc')
: $t('general.interruptDesc')}
{$streamingBehavior === 'queue' ? $t('general.queueDesc') : $t('general.interruptDesc')}
</p>
</div>
@@ -171,3 +278,53 @@
</button>
</div>
</div>
<style>
.ui-scale-range {
appearance: none;
height: 1rem;
background: transparent;
cursor: pointer;
}
.ui-scale-range::-webkit-slider-runnable-track {
height: 0.125rem;
border-radius: 9999px;
background: rgb(209 213 219 / 0.7);
}
.ui-scale-range::-webkit-slider-thumb {
appearance: none;
width: 0.75rem;
height: 0.75rem;
margin-top: -0.3125rem;
border-radius: 9999px;
border: 1px solid rgb(156 163 175 / 0.45);
background: rgb(255 255 255);
}
.ui-scale-range::-moz-range-track {
height: 0.125rem;
border-radius: 9999px;
background: rgb(209 213 219 / 0.7);
}
.ui-scale-range::-moz-range-thumb {
width: 0.75rem;
height: 0.75rem;
border-radius: 9999px;
border: 1px solid rgb(156 163 175 / 0.45);
background: rgb(255 255 255);
}
:global(.dark) .ui-scale-range::-webkit-slider-runnable-track,
:global(.dark) .ui-scale-range::-moz-range-track {
background: rgb(255 255 255 / 0.12);
}
:global(.dark) .ui-scale-range::-webkit-slider-thumb,
:global(.dark) .ui-scale-range::-moz-range-thumb {
border-color: rgb(255 255 255 / 0.18);
background: rgb(229 231 235);
}
</style>
@@ -124,7 +124,7 @@
class="w-full max-w-3xl mx-4 md:mx-0 flex flex-col md:flex-row max-h-[85vh] md:h-[560px]"
>
<nav
class="shrink-0 min-w-0 overflow-x-auto md:overflow-x-visible scrollbar-hidden border-b md:border-b-0 md:border-r border-gray-200 dark:border-white/6 md:w-[180px]"
class="shrink-0 min-w-0 md:min-h-0 overflow-x-auto md:overflow-x-hidden md:overflow-y-auto scrollbar-none border-b md:border-b-0 md:border-r border-gray-200 dark:border-white/6 md:w-[180px]"
>
<div class="flex w-max min-w-full md:w-auto md:min-w-0 md:flex-col p-1 gap-px">
<button
@@ -1292,6 +1292,7 @@
.chat-editor-mount :global(.chat-prosemirror) {
@apply pt-2.5 pb-2 px-1 min-h-6 max-h-96 overflow-y-auto text-[13px] leading-relaxed text-gray-900 dark:text-gray-100 outline-none break-words;
font-size: 0.8125rem;
}
/* Placeholder */
@@ -1352,6 +1353,7 @@
}
.chat-editor-mount :global(.chat-prosemirror h3) {
@apply text-[13px] font-semibold my-1;
font-size: 0.8125rem;
}
/* HR */
@@ -219,8 +219,8 @@
.editor-toolbar {
display: flex;
align-items: center;
height: 36px;
padding: 0 8px;
height: 2.25rem;
padding: 0 0.5rem;
border-bottom: 1px solid var(--color-gray-200);
background: white;
flex-shrink: 0;
@@ -235,7 +235,7 @@
.toolbar-scroll {
display: flex;
align-items: center;
gap: 1px;
gap: 0.0625rem;
overflow-x: auto;
overflow-y: hidden;
scrollbar-width: none;
@@ -251,14 +251,14 @@
display: flex;
align-items: center;
justify-content: center;
min-width: 28px;
height: 28px;
padding: 0 6px;
min-width: 1.75rem;
height: 1.75rem;
padding: 0 0.375rem;
border: none;
border-radius: 5px;
border-radius: 0.3125rem;
background: transparent;
color: var(--color-gray-500);
font-size: 12px;
font-size: 0.75rem;
font-weight: 500;
cursor: pointer;
transition: all 0.1s;
@@ -296,16 +296,16 @@
}
.heading-btn {
font-size: 11px;
font-size: 0.6875rem;
font-weight: 700;
font-family: inherit;
}
.tb-divider {
width: 1px;
height: 16px;
height: 1rem;
background: var(--color-gray-200);
margin: 0 4px;
margin: 0 0.25rem;
flex-shrink: 0;
}
@@ -315,10 +315,10 @@
.highlight-icon {
background: rgba(255, 213, 79, 0.4);
border-radius: 2px;
padding: 0 3px;
border-radius: 0.125rem;
padding: 0 0.1875rem;
font-weight: 700;
font-size: 11px;
font-size: 0.6875rem;
}
/* ── Mobile: pin to bottom above keyboard ────── */
@@ -329,8 +329,8 @@
left: 0;
right: 0;
z-index: 60;
height: 44px;
padding: 0 12px;
height: 2.75rem;
padding: 0 0.75rem;
border-bottom: none;
border-top: 1px solid var(--color-gray-200);
padding-bottom: env(safe-area-inset-bottom, 0);
@@ -342,9 +342,9 @@
}
.tb-btn {
min-width: 36px;
height: 36px;
font-size: 13px;
min-width: 2.25rem;
height: 2.25rem;
font-size: 0.8125rem;
}
}
</style>
@@ -216,9 +216,9 @@
/* ── ProseMirror core ──────────────────────────── */
.rte-container :global(.rte-prosemirror) {
padding: 24px 32px;
padding: 1.5rem 2rem;
min-height: 100%;
font-size: 14px;
font-size: 0.875rem;
line-height: 1.7;
color: var(--color-gray-800);
outline: none;
@@ -248,75 +248,75 @@
/* ── Headings (match MarkdownRenderer sizes) ──── */
.rte-container :global(.rte-prosemirror h1) {
font-size: 24px;
font-size: 1.5rem;
font-weight: 600;
margin: 0 0 8px;
margin: 0 0 0.5rem;
letter-spacing: -0.02em;
}
.rte-container :global(.rte-prosemirror h2) {
font-size: 20px;
font-size: 1.25rem;
font-weight: 600;
margin: 24px 0 8px;
margin: 1.5rem 0 0.5rem;
letter-spacing: -0.01em;
}
.rte-container :global(.rte-prosemirror h3) {
font-size: 16px;
font-size: 1rem;
font-weight: 600;
margin: 20px 0 6px;
margin: 1.25rem 0 0.375rem;
}
.rte-container :global(.rte-prosemirror h4) {
font-size: 14px;
font-size: 0.875rem;
font-weight: 600;
margin: 16px 0 4px;
margin: 1rem 0 0.25rem;
}
.rte-container :global(.rte-prosemirror h5),
.rte-container :global(.rte-prosemirror h6) {
font-size: 13px;
font-size: 0.8125rem;
font-weight: 600;
margin: 16px 0 4px;
margin: 1rem 0 0.25rem;
}
/* ── Paragraph ─────────────────────────────────── */
.rte-container :global(.rte-prosemirror p) {
margin: 0 0 12px;
margin: 0 0 0.75rem;
}
/* ── Lists ─────────────────────────────────────── */
.rte-container :global(.rte-prosemirror ul),
.rte-container :global(.rte-prosemirror ol) {
margin: 0 0 12px;
padding-left: 20px;
margin: 0 0 0.75rem;
padding-left: 1.25rem;
}
.rte-container :global(.rte-prosemirror li) {
margin: 4px 0;
margin: 0.25rem 0;
}
.rte-container :global(.rte-prosemirror li > p) {
margin-bottom: 4px;
margin-bottom: 0.25rem;
}
/* ── Task lists ────────────────────────────────── */
.rte-container :global(.rte-prosemirror ul[data-type='taskList']) {
list-style: none;
padding-left: 4px;
padding-left: 0.25rem;
}
.rte-container :global(.rte-prosemirror ul[data-type='taskList'] li) {
display: flex;
align-items: flex-start;
gap: 6px;
gap: 0.375rem;
}
.rte-container :global(.rte-prosemirror ul[data-type='taskList'] li label) {
margin-top: 3px;
margin-top: 0.1875rem;
}
.rte-container :global(.rte-prosemirror ul[data-type='taskList'] li > div) {
@@ -326,9 +326,9 @@
/* ── Blockquote ────────────────────────────────── */
.rte-container :global(.rte-prosemirror blockquote) {
margin: 0 0 12px;
padding: 4px 16px;
border-left: 3px solid var(--color-gray-300);
margin: 0 0 0.75rem;
padding: 0.25rem 1rem;
border-left: 0.1875rem solid var(--color-gray-300);
color: var(--color-gray-600);
}
@@ -342,7 +342,7 @@
.rte-container :global(.rte-prosemirror hr) {
border: none;
border-top: 1px solid var(--color-gray-200);
margin: 20px 0;
margin: 1.25rem 0;
}
.rte-container.dark-mode :global(.rte-prosemirror hr) {
@@ -353,9 +353,9 @@
.rte-container :global(.rte-prosemirror code) {
background: var(--color-gray-100);
border-radius: 3px;
padding: 1px 5px;
font-size: 12.5px;
border-radius: 0.1875rem;
padding: 0.0625rem 0.3125rem;
font-size: 0.78125rem;
font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
@@ -367,11 +367,11 @@
.rte-container :global(.rte-prosemirror pre) {
background: var(--color-gray-100);
border-radius: 6px;
padding: 12px 16px;
border-radius: 0.375rem;
padding: 0.75rem 1rem;
overflow-x: auto;
margin: 0 0 12px;
font-size: 13px;
margin: 0 0 0.75rem;
font-size: 0.8125rem;
font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
@@ -391,14 +391,14 @@
.rte-container :global(.rte-prosemirror table) {
border-collapse: collapse;
width: 100%;
margin: 0 0 16px;
font-size: 13px;
margin: 0 0 1rem;
font-size: 0.8125rem;
}
.rte-container :global(.rte-prosemirror th),
.rte-container :global(.rte-prosemirror td) {
border: 1px solid var(--color-gray-200);
padding: 6px 10px;
padding: 0.375rem 0.625rem;
text-align: left;
}
@@ -432,8 +432,8 @@
.rte-container :global(.rte-prosemirror img) {
max-width: 100%;
border-radius: 6px;
margin: 8px 0;
border-radius: 0.375rem;
margin: 0.5rem 0;
}
/* ── Strong / emphasis ─────────────────────────── */
@@ -446,8 +446,8 @@
.rte-container :global(.rte-prosemirror mark) {
background: rgba(255, 213, 79, 0.4);
border-radius: 2px;
padding: 0 2px;
border-radius: 0.125rem;
padding: 0 0.125rem;
}
.rte-container.dark-mode :global(.rte-prosemirror mark) {