mirror of
https://github.com/open-webui/computer.git
synced 2026-12-02 17:57:59 -05:00
refac
This commit is contained in:
1 parent
83d7085760
commit
577836a086
33 files changed
+1077
-359
No files matched your search
+174
-1
@@ -25,6 +25,15 @@
|
||||
|
||||
:root {
|
||||
--app-text-scale: 1;
|
||||
--app-bg: #ffffff;
|
||||
--app-fg: #525252;
|
||||
--app-fg-muted: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
--app-fg-subtle: color-mix(in oklab, var(--app-fg) 48%, var(--app-bg));
|
||||
--app-border: color-mix(in oklab, var(--app-fg) 10%, transparent);
|
||||
--app-divider: color-mix(in oklab, var(--app-fg) 8%, transparent);
|
||||
--app-hover: color-mix(in oklab, var(--app-fg) 6%, transparent);
|
||||
--app-active: color-mix(in oklab, var(--app-fg) 7%, transparent);
|
||||
--app-ui-font: var(--font-sans);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
@@ -33,7 +42,7 @@
|
||||
::before,
|
||||
::backdrop,
|
||||
::file-selector-button {
|
||||
border-color: var(--color-gray-200, currentColor);
|
||||
border-color: var(--app-border, var(--color-gray-200, currentColor));
|
||||
}
|
||||
|
||||
html,
|
||||
@@ -44,6 +53,9 @@
|
||||
overscroll-behavior: none;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
font-family: var(--app-ui-font);
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar,
|
||||
@@ -104,6 +116,167 @@
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.app-theme {
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.app-surface {
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.app-subtle-surface {
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.app-divider {
|
||||
background: var(--app-divider);
|
||||
}
|
||||
|
||||
.app-muted {
|
||||
color: var(--app-fg-muted);
|
||||
}
|
||||
|
||||
.app-icon-muted {
|
||||
color: var(--app-fg-subtle);
|
||||
}
|
||||
|
||||
.app-interactive:hover {
|
||||
background: var(--app-hover);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.app-interactive-active {
|
||||
background: var(--app-active);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.app-theme:where([class*='border-gray-'], [class*='border-black/'], [class*='border-white/']),
|
||||
.app-theme :where([class*='border-gray-'], [class*='border-black/'], [class*='border-white/']) {
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.dark .app-theme:where([class*='dark:border-gray-'], [class*='dark:border-white/']),
|
||||
.dark .app-theme :where([class*='dark:border-gray-'], [class*='dark:border-white/']) {
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.app-theme
|
||||
:where(
|
||||
[class*='divide-gray-'] > :not(:last-child),
|
||||
[class*='divide-black/'] > :not(:last-child),
|
||||
[class*='divide-white/'] > :not(:last-child)
|
||||
) {
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.dark .app-theme :where([class*='dark:divide-gray-'] > :not(:last-child)),
|
||||
.dark .app-theme :where([class*='dark:divide-white/'] > :not(:last-child)) {
|
||||
border-color: var(--app-border);
|
||||
}
|
||||
|
||||
.app-theme :where([class~='h-px'][class*='bg-gray-'], [class~='h-px'][class*='bg-black/']) {
|
||||
background: var(--app-divider);
|
||||
}
|
||||
|
||||
.dark .app-theme :where([class~='h-px'][class*='dark:bg-white/']) {
|
||||
background: var(--app-divider);
|
||||
}
|
||||
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='bg-gray-50'],
|
||||
[class~='bg-gray-50/50'],
|
||||
[class~='bg-gray-100'],
|
||||
[class~='bg-gray-200/50']
|
||||
) {
|
||||
background: var(--app-hover);
|
||||
}
|
||||
|
||||
.dark
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='dark:bg-white/3'],
|
||||
[class~='dark:bg-white/4'],
|
||||
[class~='dark:bg-white/5'],
|
||||
[class~='dark:bg-white/6'],
|
||||
[class~='dark:bg-white/8'],
|
||||
[class~='dark:bg-white/10']
|
||||
) {
|
||||
background: var(--app-hover);
|
||||
}
|
||||
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='hover:bg-gray-50']:hover,
|
||||
[class~='hover:bg-gray-100']:hover,
|
||||
[class~='hover:bg-gray-200']:hover,
|
||||
[class~='hover:bg-gray-200/60']:hover,
|
||||
[class~='hover:bg-gray-200/70']:hover
|
||||
) {
|
||||
background: var(--app-active);
|
||||
}
|
||||
|
||||
.dark
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='dark:hover:bg-white/3']:hover,
|
||||
[class~='dark:hover:bg-white/4']:hover,
|
||||
[class~='dark:hover:bg-white/5']:hover,
|
||||
[class~='dark:hover:bg-white/6']:hover,
|
||||
[class~='dark:hover:bg-white/8']:hover,
|
||||
[class~='dark:hover:bg-white/10']:hover,
|
||||
[class~='dark:hover:bg-white/12']:hover
|
||||
) {
|
||||
background: var(--app-active);
|
||||
}
|
||||
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='text-gray-950'],
|
||||
[class~='text-gray-900'],
|
||||
[class~='text-gray-800'],
|
||||
[class~='text-gray-700']
|
||||
) {
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.dark
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='dark:text-white'],
|
||||
[class~='dark:text-gray-100'],
|
||||
[class~='dark:text-gray-200'],
|
||||
[class~='dark:text-gray-300']
|
||||
) {
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='text-gray-600'],
|
||||
[class~='text-gray-500'],
|
||||
[class~='text-gray-400'],
|
||||
[class~='text-gray-300']
|
||||
) {
|
||||
color: var(--app-fg-muted);
|
||||
}
|
||||
|
||||
.dark
|
||||
.app-theme
|
||||
:where(
|
||||
[class~='dark:text-gray-400'],
|
||||
[class~='dark:text-gray-500'],
|
||||
[class~='dark:text-gray-600'],
|
||||
[class~='dark:text-gray-700']
|
||||
) {
|
||||
color: var(--app-fg-muted);
|
||||
}
|
||||
|
||||
/* CodeMirror - match Open WebUI */
|
||||
.cm-editor {
|
||||
height: 100%;
|
||||
|
||||
@@ -337,7 +337,7 @@
|
||||
bind:this={menuEl}
|
||||
class="{inlineAbove
|
||||
? `absolute bottom-full mb-1 ${align === 'end' ? 'right-0' : 'left-0'}`
|
||||
: 'fixed'} z-[1001] min-w-36 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5 flex flex-col overflow-hidden {className}"
|
||||
: 'fixed'} app-theme app-surface z-[1001] min-w-36 rounded-xl border shadow-xl p-0.5 flex flex-col overflow-hidden {className}"
|
||||
style="{inlineAbove
|
||||
? ''
|
||||
: `left: ${pos.x}px; ${pos.bottom != null ? `bottom: ${pos.bottom}px;` : `top: ${pos.top ?? -9999}px;`} ${
|
||||
@@ -352,7 +352,7 @@
|
||||
<div class="flex-none">
|
||||
{@render header()}
|
||||
{#if headerDivider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -365,13 +365,12 @@
|
||||
{:else}
|
||||
{#each items as item}
|
||||
{#if item.divider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
{:else}
|
||||
<div
|
||||
class="group flex items-center gap-1 w-full h-6 rounded-xl text-xs transition-colors duration-75
|
||||
{item.active
|
||||
? 'text-gray-900 dark:text-white bg-gray-50 dark:bg-white/5'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
class="group menu-row flex items-center gap-1 w-full h-6 rounded-xl text-xs transition-colors duration-75 {item.active
|
||||
? 'app-interactive-active'
|
||||
: ''}"
|
||||
>
|
||||
<button
|
||||
class="flex items-center gap-2 min-w-0 flex-1 h-full px-2 text-inherit"
|
||||
@@ -391,7 +390,7 @@
|
||||
{/if}
|
||||
{#if item.check && item.active}
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
class="app-icon-muted w-3 h-3 shrink-0"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
@@ -405,7 +404,7 @@
|
||||
</button>
|
||||
{#if item.actionIcon && item.actionOnclick}
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 mr-0.5 rounded-lg shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-white/10 transition-all duration-75"
|
||||
class="app-icon-muted app-interactive flex items-center justify-center w-5 h-5 mr-0.5 rounded-lg shrink-0 transition-all duration-75"
|
||||
aria-label={item.actionLabel}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -424,9 +423,20 @@
|
||||
{#if footer}
|
||||
<div class="flex-none">
|
||||
{#if footerDivider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
{/if}
|
||||
{@render footer()}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.menu-row {
|
||||
color: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
}
|
||||
|
||||
.menu-row:hover {
|
||||
background: color-mix(in oklab, var(--app-fg) 6%, transparent);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
</style>
|
||||
@@ -26,7 +26,8 @@
|
||||
<div class="fixed inset-0 z-[100] flex {overlayClass}" onmousedown={onclose} onkeydown={() => {}}>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="bg-white dark:bg-[#0a0a0a] dark:border dark:border-white/8 rounded-3xl overflow-visible shadow-2xl {className}"
|
||||
class="app-theme app-surface border rounded-3xl overflow-visible shadow-2xl {className}"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
onmousedown={(e) => e.stopPropagation()}
|
||||
onkeydown={() => {}}
|
||||
>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<div
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
class="notification-toast group relative flex gap-2.5 text-left w-full bg-white dark:bg-[#1a1a1a] text-gray-700 dark:text-gray-300 border border-black/[0.08] dark:border-white/[0.06] shadow-lg dark:shadow-none rounded-2xl py-3 px-4 cursor-pointer select-none"
|
||||
class="notification-toast app-theme app-surface group relative flex gap-2.5 text-left w-full border shadow-lg dark:shadow-none rounded-2xl py-3 px-4 cursor-pointer select-none"
|
||||
onpointerdown={onPointerDown}
|
||||
onpointermove={onPointerMove}
|
||||
onpointerup={onPointerUp}
|
||||
@@ -69,7 +69,7 @@
|
||||
<!-- Close button -->
|
||||
<button
|
||||
bind:this={closeButtonEl}
|
||||
class="absolute -top-0.5 -left-0.5 p-0.5 rounded-full opacity-0 group-hover:opacity-100 bg-gray-200 dark:bg-[#222] text-gray-500 dark:text-gray-400 hover:bg-gray-300 dark:hover:bg-[#333] hover:text-gray-700 dark:hover:text-gray-300 border-none cursor-pointer transition-opacity duration-150 z-10"
|
||||
class="app-subtle-surface app-muted app-interactive absolute -top-0.5 -left-0.5 p-0.5 rounded-full opacity-0 group-hover:opacity-100 border-none cursor-pointer transition-opacity duration-150 z-10"
|
||||
aria-label={$t('a11y.dismissNotification')}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -92,13 +92,13 @@
|
||||
<div class="min-w-0">
|
||||
{#if title}
|
||||
<div
|
||||
class="text-[0.8125rem] font-medium mb-0.5 overflow-hidden text-ellipsis whitespace-nowrap text-gray-900 dark:text-white"
|
||||
class="text-[0.8125rem] font-medium mb-0.5 overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
{/if}
|
||||
{#if content}
|
||||
<div class="text-xs text-gray-500 dark:text-[#aaa] font-normal line-clamp-2">{content}</div>
|
||||
<div class="app-muted text-xs font-normal line-clamp-2">{content}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -61,15 +61,13 @@
|
||||
<div class="fixed bottom-8 right-3 z-[200] flex flex-col gap-1.5 pointer-events-none">
|
||||
{#each relevantPorts as port (port.port)}
|
||||
<div
|
||||
class="flex items-center gap-2 px-3 py-2 rounded-lg bg-white dark:bg-neutral-900 border border-gray-200 dark:border-white/10 shadow-lg pointer-events-auto animate-in"
|
||||
class="app-theme app-surface flex items-center gap-2 px-3 py-2 rounded-lg border shadow-lg pointer-events-auto animate-in"
|
||||
>
|
||||
<span class="text-xs text-gray-400 shrink-0">🌐</span>
|
||||
<span class="text-xs font-medium font-mono text-gray-700 dark:text-gray-200"
|
||||
>:{port.port}</span
|
||||
>
|
||||
<span class="text-[0.6875rem] text-gray-400">({port.process})</span>
|
||||
<span class="app-icon-muted text-xs shrink-0">🌐</span>
|
||||
<span class="text-xs font-medium font-mono">:{port.port}</span>
|
||||
<span class="app-muted text-[0.6875rem]">({port.process})</span>
|
||||
{#if terminalLabel(port.session_id)}
|
||||
<span class="text-[0.625rem] text-gray-400 italic"
|
||||
<span class="app-muted text-[0.625rem] italic"
|
||||
>{$t('port.via', { name: terminalLabel(port.session_id) })}</span
|
||||
>
|
||||
{/if}
|
||||
@@ -78,7 +76,7 @@
|
||||
onclick={() => preview(port)}>{$t('port.preview')}</button
|
||||
>
|
||||
<button
|
||||
class="flex items-center justify-center w-4 h-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100 shrink-0"
|
||||
class="app-icon-muted app-interactive flex items-center justify-center w-4 h-4 rounded transition-colors duration-100 shrink-0"
|
||||
onclick={() => dismiss(port)}
|
||||
>
|
||||
<Icon name="xmark" size={9} />
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="w-full max-w-[32.5rem] mx-4 bg-white dark:bg-[#111] dark:border dark:border-white/8 rounded-3xl overflow-hidden shadow-2xl max-h-[26.25rem] flex flex-col"
|
||||
class="app-theme app-surface w-full max-w-[32.5rem] mx-4 border rounded-3xl overflow-hidden shadow-2xl max-h-[26.25rem] flex flex-col"
|
||||
onmousedown={(e) => e.stopPropagation()}
|
||||
onkeydown={() => {}}
|
||||
>
|
||||
@@ -194,10 +194,8 @@
|
||||
{#each filteredDirs as dir, i (dir.name)}
|
||||
<button
|
||||
data-index={i}
|
||||
class="flex items-center gap-2 w-full h-7 px-2 rounded-lg text-left transition-colors duration-75
|
||||
{i === selectedIndex
|
||||
? 'bg-gray-200/50 text-gray-900 dark:bg-white/6 dark:text-white'
|
||||
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/4'}"
|
||||
class="directory-row flex items-center gap-2 w-full h-7 px-2 rounded-lg text-left transition-colors duration-75
|
||||
{i === selectedIndex ? 'app-interactive-active' : ''}"
|
||||
onclick={() => navigateTo(dir.name)}
|
||||
onmouseenter={() => {
|
||||
selectedIndex = i;
|
||||
@@ -239,3 +237,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.directory-row {
|
||||
color: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
}
|
||||
|
||||
.directory-row:hover {
|
||||
background: color-mix(in oklab, var(--app-fg) 7%, transparent);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,381 @@
|
||||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import Icon from '../Icon.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
import { textScale, theme, themeConfig } from '$lib/stores';
|
||||
import type { Theme, ThemeConfig } from '$lib/stores';
|
||||
import {
|
||||
normalizeHexColor,
|
||||
resolveThemeMode,
|
||||
resolveThemeConfig,
|
||||
sanitizeThemeConfig
|
||||
} from '$lib/utils/appearance';
|
||||
|
||||
const minTextScale = 1;
|
||||
const maxTextScale = 1.5;
|
||||
|
||||
let fileInput: HTMLInputElement;
|
||||
let scaleEnabled = $state(false);
|
||||
let scaleDraft = $state(1);
|
||||
let colorDrafts = $state({ background: '', foreground: '' });
|
||||
|
||||
const resolvedTheme = $derived(resolveThemeMode($theme));
|
||||
const resolvedConfig = $derived(resolveThemeConfig($theme, $themeConfig));
|
||||
const hasCustomAppearance = $derived(Boolean($themeConfig || $textScale !== null));
|
||||
|
||||
$effect(() => {
|
||||
colorDrafts = {
|
||||
background: resolvedConfig.background,
|
||||
foreground: resolvedConfig.foreground
|
||||
};
|
||||
if ($textScale !== null) {
|
||||
scaleEnabled = true;
|
||||
scaleDraft = $textScale;
|
||||
} else if (!scaleEnabled) {
|
||||
scaleDraft = 1;
|
||||
}
|
||||
});
|
||||
|
||||
function setTheme(v: Theme) {
|
||||
theme.set(v);
|
||||
}
|
||||
|
||||
function updateThemeColors(next: { background?: string; foreground?: string }) {
|
||||
const current = $themeConfig ?? {};
|
||||
themeConfig.set(
|
||||
sanitizeThemeConfig({
|
||||
...current,
|
||||
[resolvedTheme]: { ...(current[resolvedTheme] ?? {}), ...next }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function updateThemeConfig(next: ThemeConfig) {
|
||||
themeConfig.set(sanitizeThemeConfig({ ...($themeConfig ?? {}), ...next }));
|
||||
}
|
||||
|
||||
function updateColor(key: 'background' | 'foreground', value: string) {
|
||||
colorDrafts = { ...colorDrafts, [key]: value };
|
||||
const color = normalizeHexColor(value);
|
||||
if (color) updateThemeColors({ [key]: color });
|
||||
}
|
||||
|
||||
function updateFont(value: string) {
|
||||
updateThemeConfig({ uiFont: value });
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function resetAppearance() {
|
||||
themeConfig.set(null);
|
||||
scaleEnabled = false;
|
||||
scaleDraft = 1;
|
||||
textScale.set(null);
|
||||
}
|
||||
|
||||
function exportTheme() {
|
||||
const payload = {
|
||||
theme: $theme,
|
||||
themeConfig: sanitizeThemeConfig($themeConfig),
|
||||
textScale: $textScale
|
||||
};
|
||||
|
||||
try {
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = 'computer-theme.json';
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
toast.success($t('appearance.exported'));
|
||||
} catch {
|
||||
toast.error($t('appearance.exportFailed'));
|
||||
}
|
||||
}
|
||||
|
||||
function validateImportedColors(source: Record<string, unknown>) {
|
||||
for (const bucket of [source, source.light, source.dark]) {
|
||||
if (!bucket || typeof bucket !== 'object') continue;
|
||||
for (const key of ['background', 'foreground']) {
|
||||
if (key in bucket && !normalizeHexColor((bucket as Record<string, unknown>)[key])) {
|
||||
throw new Error('invalid color');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function importTheme(event: Event) {
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = '';
|
||||
if (!file) return;
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(await file.text());
|
||||
const source = parsed?.themeConfig ?? parsed;
|
||||
if (!source || typeof source !== 'object') throw new Error('invalid theme');
|
||||
validateImportedColors(source);
|
||||
const importedConfig = sanitizeThemeConfig(source);
|
||||
const importedTheme = ['system', 'light', 'dark'].includes(parsed?.theme)
|
||||
? (parsed.theme as Theme)
|
||||
: null;
|
||||
const importedScale =
|
||||
typeof parsed?.textScale === 'number' && Number.isFinite(parsed.textScale)
|
||||
? normalizeTextScale(parsed.textScale)
|
||||
: undefined;
|
||||
|
||||
if (!importedConfig && !importedTheme && importedScale === undefined) {
|
||||
throw new Error('empty theme');
|
||||
}
|
||||
if (importedTheme) theme.set(importedTheme);
|
||||
if (importedConfig) themeConfig.set(importedConfig);
|
||||
if (importedScale !== undefined) textScale.set(importedScale === 1 ? null : importedScale);
|
||||
toast.success($t('appearance.imported'));
|
||||
} catch {
|
||||
toast.error($t('appearance.importFailed'));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col h-full">
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-none pr-1.5 -mr-1.5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">{$t('appearance.title')}</h2>
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
bind:this={fileInput}
|
||||
type="file"
|
||||
accept="application/json,.json"
|
||||
class="hidden"
|
||||
onchange={importTheme}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[0.625rem] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100"
|
||||
onclick={() => fileInput?.click()}
|
||||
>
|
||||
{$t('appearance.import')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[0.625rem] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100"
|
||||
onclick={exportTheme}
|
||||
>
|
||||
{$t('appearance.exportTheme')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[0.625rem] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100 disabled:opacity-30 disabled:pointer-events-none"
|
||||
disabled={!hasCustomAppearance}
|
||||
onclick={resetAppearance}
|
||||
>
|
||||
{$t('appearance.reset')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('general.theme')}</h3>
|
||||
<div class="flex gap-1">
|
||||
{#each [{ value: 'light' as Theme, label: $t('general.light'), icon: 'sun-light' }, { value: 'dark' as Theme, label: $t('general.dark'), icon: 'half-moon' }, { value: 'system' as Theme, label: $t('general.system'), icon: 'monitor' }] as opt}
|
||||
<button
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg text-xs transition-colors duration-100
|
||||
{$theme === opt.value
|
||||
? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white font-medium'
|
||||
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
|
||||
onclick={() => setTheme(opt.value)}
|
||||
>
|
||||
<Icon name={opt.icon} size={13} />
|
||||
{opt.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
|
||||
{$t('appearance.colors')}
|
||||
</h3>
|
||||
<div class="flex flex-col gap-2.5">
|
||||
{#each [{ key: 'background' as const, label: $t('appearance.background'), value: resolvedConfig.background }, { key: 'foreground' as const, label: $t('appearance.foreground'), value: resolvedConfig.foreground }] as opt}
|
||||
<label class="flex items-center justify-between gap-3">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{opt.label}</span>
|
||||
<div class="flex items-center gap-2 min-w-0">
|
||||
<input
|
||||
type="color"
|
||||
value={opt.value}
|
||||
class="appearance-swatch"
|
||||
aria-label={opt.label}
|
||||
oninput={(e) => updateColor(opt.key, e.currentTarget.value)}
|
||||
/>
|
||||
<input
|
||||
value={colorDrafts[opt.key]}
|
||||
class="w-24 bg-transparent text-right text-[0.8125rem] text-gray-700 dark:text-gray-300 outline-none"
|
||||
aria-label={opt.label}
|
||||
oninput={(e) => updateColor(opt.key, e.currentTarget.value)}
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
|
||||
{$t('appearance.interface')}
|
||||
</h3>
|
||||
<label class="flex items-center justify-between gap-3">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('appearance.uiFont')}</span>
|
||||
<input
|
||||
value={$themeConfig?.uiFont ?? ''}
|
||||
placeholder={resolvedConfig.uiFont}
|
||||
class="w-full max-w-[15rem] bg-transparent text-right text-[0.8125rem] text-gray-700 dark:text-gray-300 outline-none"
|
||||
aria-label={$t('appearance.uiFont')}
|
||||
onchange={(e) => updateFont(e.currentTarget.value)}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.appearance-swatch {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
border: 1px solid rgb(156 163 175 / 0.35);
|
||||
border-radius: 624.9375rem;
|
||||
background: transparent;
|
||||
padding: 0.125rem;
|
||||
}
|
||||
|
||||
.ui-scale-range {
|
||||
appearance: none;
|
||||
height: 1rem;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-scale-range::-webkit-slider-runnable-track {
|
||||
height: 0.125rem;
|
||||
border-radius: 624.9375rem;
|
||||
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: 624.9375rem;
|
||||
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: 624.9375rem;
|
||||
background: rgb(209 213 219 / 0.7);
|
||||
}
|
||||
|
||||
.ui-scale-range::-moz-range-thumb {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
border-radius: 624.9375rem;
|
||||
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>
|
||||
@@ -1,8 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import Icon from '../Icon.svelte';
|
||||
import { theme, streamingBehavior, showUpdateToastPref, textScale } from '$lib/stores';
|
||||
import type { Theme, StreamingBehavior } from '$lib/stores';
|
||||
import { streamingBehavior, showUpdateToastPref } from '$lib/stores';
|
||||
import type { StreamingBehavior } from '$lib/stores';
|
||||
import { t, locale, changeLocale, supportedLocales } from '$lib/i18n';
|
||||
import { notificationsEnabled, notificationSound } from '$lib/stores/chat';
|
||||
import { fetchJSON } from '$lib/apis';
|
||||
@@ -11,28 +10,13 @@
|
||||
import ToggleSwitch from '../common/ToggleSwitch.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
function setTheme(v: Theme) {
|
||||
theme.set(v);
|
||||
}
|
||||
|
||||
// ── Webhook URL ─────────────────────────────────────────────
|
||||
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> }>(
|
||||
@@ -71,62 +55,13 @@
|
||||
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">
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5 -mr-1.5">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$t('general.title')}</h2>
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('general.theme')}</h3>
|
||||
<div class="flex gap-1">
|
||||
{#each [{ value: 'light' as Theme, label: $t('general.light'), icon: 'sun-light' }, { value: 'dark' as Theme, label: $t('general.dark'), icon: 'half-moon' }, { value: 'system' as Theme, label: $t('general.system'), icon: 'monitor' }] as opt}
|
||||
<button
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg text-xs transition-colors duration-100
|
||||
{$theme === opt.value
|
||||
? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white font-medium'
|
||||
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
|
||||
onclick={() => setTheme(opt.value)}
|
||||
>
|
||||
<Icon name={opt.icon} size={13} />
|
||||
{opt.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.language')}</h3>
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('general.language')}</h3>
|
||||
<select
|
||||
class="w-full max-w-[12.5rem] bg-transparent text-[0.8125rem] text-gray-700 dark:text-gray-300 outline-none py-1 cursor-pointer"
|
||||
value={$locale}
|
||||
@@ -137,61 +72,6 @@
|
||||
{/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')}
|
||||
@@ -278,53 +158,3 @@
|
||||
</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: 624.9375rem;
|
||||
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: 624.9375rem;
|
||||
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: 624.9375rem;
|
||||
background: rgb(209 213 219 / 0.7);
|
||||
}
|
||||
|
||||
.ui-scale-range::-moz-range-thumb {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
border-radius: 624.9375rem;
|
||||
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>
|
||||
@@ -3,6 +3,7 @@
|
||||
import Icon from './Icon.svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import General from './Settings/General.svelte';
|
||||
import Appearance from './Settings/Appearance.svelte';
|
||||
import Memory from './Settings/Memory.svelte';
|
||||
import PWA from './Settings/PWA.svelte';
|
||||
import Account from './Settings/Account.svelte';
|
||||
@@ -24,6 +25,7 @@
|
||||
|
||||
type Tab =
|
||||
| 'general'
|
||||
| 'appearance'
|
||||
| 'memory'
|
||||
| 'pwa'
|
||||
| 'keyboard'
|
||||
@@ -73,6 +75,7 @@
|
||||
const personalTabs: SettingsTab[] = $derived.by(() => {
|
||||
const tabs: SettingsTab[] = [
|
||||
{ id: 'general', label: $t('settings.general'), icon: 'settings' },
|
||||
{ id: 'appearance', label: $t('settings.appearance'), icon: 'sun-light' },
|
||||
{ id: 'keyboard', label: $t('settings.keyboard'), icon: 'terminal' },
|
||||
{ id: 'account', label: $t('settings.account'), icon: 'user' }
|
||||
];
|
||||
@@ -172,9 +175,11 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="flex-1 overflow-y-auto min-h-0 p-4 md:px-5">
|
||||
<div class="flex-1 overflow-y-auto scrollbar-none min-h-0 p-4 md:px-5">
|
||||
{#if activeTab === 'general'}
|
||||
<General />
|
||||
{:else if activeTab === 'appearance'}
|
||||
<Appearance />
|
||||
{:else if activeTab === 'memory'}
|
||||
<Memory />
|
||||
{:else if activeTab === 'pwa' && showPwaSettings}
|
||||
|
||||
@@ -281,6 +281,7 @@
|
||||
<!-- Logo header with collapse button -->
|
||||
<div
|
||||
class="flex items-center justify-between h-9 pl-3.5 pr-1.5 shrink-0 border-b border-gray-200 dark:border-white/6"
|
||||
style="border-color: var(--app-border);"
|
||||
>
|
||||
<a
|
||||
href="/"
|
||||
@@ -566,14 +567,14 @@
|
||||
z-index: 50;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: white;
|
||||
border-right: 1px solid var(--color-gray-200);
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
border-right: 1px solid var(--app-border);
|
||||
padding-top: env(safe-area-inset-top, 0);
|
||||
}
|
||||
|
||||
:global(.dark) .sidebar {
|
||||
background: #000;
|
||||
border-right-color: rgba(255, 255, 255, 0.06);
|
||||
border-right-color: var(--app-border);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
</script>
|
||||
|
||||
<div class="fixed bottom-4 right-4 z-50" in:fade={{ duration: 100 }} out:fade={{ duration: 75 }}>
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-lg border border-gray-200 dark:border-white/6 bg-white dark:bg-[#1a1a1a] px-3 py-2"
|
||||
>
|
||||
<span class="text-[0.6875rem] text-gray-500 dark:text-gray-400">
|
||||
<div class="app-theme app-surface flex items-center gap-2 rounded-lg border px-3 py-2">
|
||||
<span class="app-muted text-[0.6875rem]">
|
||||
{$t('update.available', { version: $latestVersion })}
|
||||
</span>
|
||||
|
||||
@@ -19,14 +17,14 @@
|
||||
href="https://github.com/open-webui/computer/releases"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-[0.6875rem] text-gray-900 dark:text-white hover:underline font-medium"
|
||||
class="text-[0.6875rem] hover:underline font-medium"
|
||||
>
|
||||
{$t('update.viewRelease')}
|
||||
</a>
|
||||
|
||||
<button
|
||||
onclick={onclose}
|
||||
class="ml-0.5 flex items-center justify-center w-5 h-5 rounded text-gray-300 hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-400 transition-colors duration-75"
|
||||
class="app-icon-muted app-interactive ml-0.5 flex items-center justify-center w-5 h-5 rounded transition-colors duration-75"
|
||||
aria-label="Dismiss"
|
||||
>
|
||||
<Icon name="xmark" size={12} />
|
||||
|
||||
@@ -365,9 +365,7 @@
|
||||
{#if edit}
|
||||
<!-- Edit mode -->
|
||||
<div class="w-full">
|
||||
<div
|
||||
class="bg-gray-50 dark:bg-white/4 rounded-xl border border-gray-200 dark:border-white/8 px-3.5 py-2.5"
|
||||
>
|
||||
<div class="app-subtle-surface rounded-xl border px-3.5 py-2.5">
|
||||
{#if editedOutput}
|
||||
<OutputEditView
|
||||
output={editedOutput}
|
||||
|
||||
@@ -973,7 +973,7 @@
|
||||
<!-- Queued messages (above input, matching open-webui layout) -->
|
||||
{#if queuedMessages.length > 0}
|
||||
<div
|
||||
class="mb-1 mx-2 py-0.5 px-1.5 rounded-2xl border border-gray-100 dark:border-white/5 overflow-x-hidden overflow-y-auto max-h-[25vh]"
|
||||
class="app-subtle-surface mb-1 mx-2 py-0.5 px-1.5 rounded-2xl border overflow-x-hidden overflow-y-auto max-h-[25vh]"
|
||||
>
|
||||
{#each queuedMessages as qm (qm.id)}
|
||||
<QueuedMessageItem
|
||||
@@ -989,20 +989,16 @@
|
||||
|
||||
{#if showSlashCommands}
|
||||
<div
|
||||
class="absolute left-2 bottom-full mb-1 z-50 w-60 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
|
||||
class="app-theme app-surface absolute left-2 bottom-full mb-1 z-50 w-60 max-h-40 overflow-y-auto rounded-xl border shadow-xl p-0.5"
|
||||
>
|
||||
<div
|
||||
class="mb-0.5 px-2 pt-1 pb-0.5 text-[0.625rem] leading-none text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
Commands
|
||||
</div>
|
||||
<div class="app-muted mb-0.5 px-2 pt-1 pb-0.5 text-[0.625rem] leading-none">Commands</div>
|
||||
{#if slashCommandIds.includes('compact')}
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{slashCommandIds[selectedSlashCommandIndex] === 'compact'
|
||||
? 'bg-gray-50 dark:bg-white/5 text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'} disabled:opacity-50"
|
||||
? 'app-interactive-active'
|
||||
: ''} disabled:opacity-50"
|
||||
disabled={sending || streaming}
|
||||
onmousedown={(e) => e.preventDefault()}
|
||||
onclick={() => {
|
||||
@@ -1010,9 +1006,7 @@
|
||||
}}
|
||||
onmouseenter={() => (selectedSlashCommandIndex = slashCommandIds.indexOf('compact'))}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-4 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
>
|
||||
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
|
||||
<svg class="size-3.5 -rotate-90" viewBox="0 0 20 20" aria-hidden="true">
|
||||
<circle
|
||||
cx="10"
|
||||
@@ -1038,7 +1032,7 @@
|
||||
</span>
|
||||
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
|
||||
<span class="truncate">{$t('chat.commandCompact')}</span>
|
||||
<span class="text-[0.625rem] text-gray-400 dark:text-gray-600 truncate shrink-0">
|
||||
<span class="app-muted text-[0.625rem] truncate shrink-0">
|
||||
{$t('chat.commandCompactPercent', { percent: contextPercent })}
|
||||
</span>
|
||||
</span>
|
||||
@@ -1047,19 +1041,15 @@
|
||||
{#if slashCommandIds.includes('plan')}
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{slashCommandIds[selectedSlashCommandIndex] === 'plan'
|
||||
? 'bg-gray-50 dark:bg-white/5 text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{slashCommandIds[selectedSlashCommandIndex] === 'plan' ? 'app-interactive-active' : ''}"
|
||||
onmousedown={(e) => e.preventDefault()}
|
||||
onclick={() => {
|
||||
runSlashCommand('plan');
|
||||
}}
|
||||
onmouseenter={() => (selectedSlashCommandIndex = slashCommandIds.indexOf('plan'))}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-4 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
>
|
||||
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
|
||||
<svg
|
||||
class="size-3.5"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -1078,7 +1068,7 @@
|
||||
</span>
|
||||
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
|
||||
<span class="truncate">{$t('chat.commandPlan')}</span>
|
||||
<span class="text-[0.625rem] text-gray-400 dark:text-gray-600 truncate shrink-0">
|
||||
<span class="app-muted text-[0.625rem] truncate shrink-0">
|
||||
{$planMode ? $t('chat.commandPlanOn') : $t('chat.commandPlanOff')}
|
||||
</span>
|
||||
</span>
|
||||
@@ -1087,19 +1077,15 @@
|
||||
{#if slashCommandIds.includes('status')}
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{slashCommandIds[selectedSlashCommandIndex] === 'status'
|
||||
? 'bg-gray-50 dark:bg-white/5 text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{slashCommandIds[selectedSlashCommandIndex] === 'status' ? 'app-interactive-active' : ''}"
|
||||
onmousedown={(e) => e.preventDefault()}
|
||||
onclick={() => {
|
||||
runSlashCommand('status');
|
||||
}}
|
||||
onmouseenter={() => (selectedSlashCommandIndex = slashCommandIds.indexOf('status'))}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-4 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
>
|
||||
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
|
||||
<svg
|
||||
class="size-3.5"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -1116,7 +1102,7 @@
|
||||
</span>
|
||||
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
|
||||
<span class="truncate">{$t('chat.commandStatus')}</span>
|
||||
<span class="text-[0.625rem] text-gray-400 dark:text-gray-600 truncate shrink-0">
|
||||
<span class="app-muted text-[0.625rem] truncate shrink-0">
|
||||
{$t('chat.commandStatusDesc')}
|
||||
</span>
|
||||
</span>
|
||||
@@ -1125,9 +1111,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
class="rounded-3xl shadow-lg border border-gray-100/40 dark:border-white/4 focus-within:border-gray-200/50 focus-within:dark:border-white/8 transition px-1 bg-white dark:bg-gray-500/5"
|
||||
>
|
||||
<div class="app-surface rounded-3xl shadow-lg border transition px-1">
|
||||
<!-- Uploaded Files Preview -->
|
||||
{#if attachedUploads.length > 0}
|
||||
<div class="mx-2 pt-2 flex flex-wrap gap-2">
|
||||
@@ -1135,7 +1119,7 @@
|
||||
<div class="relative group flex-shrink-0">
|
||||
{#if upload.loading}
|
||||
<div
|
||||
class="flex items-center justify-center size-8 bg-gray-50 dark:bg-white/5 rounded-xl border border-gray-200 dark:border-white/10 shadow-sm"
|
||||
class="app-subtle-surface flex items-center justify-center size-8 rounded-xl border shadow-sm"
|
||||
>
|
||||
<Spinner size={16} />
|
||||
</div>
|
||||
@@ -1143,21 +1127,19 @@
|
||||
<img
|
||||
src={upload.url}
|
||||
alt={upload.name}
|
||||
class="size-8 object-cover rounded-xl border border-gray-200 dark:border-white/10 shadow-sm"
|
||||
class="app-surface size-8 object-cover rounded-xl border shadow-sm"
|
||||
/>
|
||||
{:else}
|
||||
<div
|
||||
class="relative group px-2 w-48 h-8 flex items-center gap-1.5 bg-white dark:bg-[#1a1a1a] border border-gray-100 dark:border-white/5 rounded-xl text-left flex-shrink-0 shadow-sm"
|
||||
class="app-surface relative group px-2 w-48 h-8 flex items-center gap-1.5 border rounded-xl text-left flex-shrink-0 shadow-sm"
|
||||
>
|
||||
<div class="shrink-0">
|
||||
<Icon name="page-text" size={14} class="text-gray-500 dark:text-gray-400" />
|
||||
<Icon name="page-text" size={14} class="app-icon-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col justify-center w-full overflow-hidden">
|
||||
<div
|
||||
class="dark:text-gray-100 text-xs flex justify-between items-center w-full gap-2"
|
||||
>
|
||||
<div class="text-xs flex justify-between items-center w-full gap-2">
|
||||
<div class="font-medium truncate flex-1">{upload.name}</div>
|
||||
<div class="text-[0.625rem] text-gray-500 capitalize shrink-0">
|
||||
<div class="app-muted text-[0.625rem] capitalize shrink-0">
|
||||
{upload.type === 'file' ? 'File' : upload.type}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1167,7 +1149,7 @@
|
||||
|
||||
<div class="absolute -top-1.5 -right-1.5 z-10">
|
||||
<button
|
||||
class="bg-white text-black border border-white rounded-full group-hover:visible invisible transition outline-none shadow-sm flex items-center justify-center"
|
||||
class="app-surface border rounded-full group-hover:visible invisible transition outline-none shadow-sm flex items-center justify-center"
|
||||
type="button"
|
||||
onclick={() => removeUpload(upload.id)}
|
||||
aria-label={$t('chat.removeUpload')}
|
||||
@@ -1192,9 +1174,7 @@
|
||||
<!-- Editor area -->
|
||||
<div class="px-2.5">
|
||||
{#if $voiceModeEnabled}
|
||||
<div
|
||||
class="pt-2 flex items-center gap-2 text-[0.6875rem] font-medium text-gray-600 dark:text-gray-300"
|
||||
>
|
||||
<div class="app-muted pt-2 flex items-center gap-2 text-[0.6875rem] font-medium">
|
||||
<span class="relative flex size-2">
|
||||
<span
|
||||
class="absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-70 {voiceListening
|
||||
@@ -1232,8 +1212,9 @@
|
||||
{#if $planMode}
|
||||
<button
|
||||
type="button"
|
||||
class="group p-[0.3125rem] flex gap-1 items-center text-xs rounded-full transition-colors duration-150
|
||||
text-gray-600 dark:text-gray-300 bg-gray-50 hover:bg-gray-100 dark:bg-white/8 dark:hover:bg-white/12 border border-gray-200 dark:border-white/8"
|
||||
aria-label={$t('chat.commandPlanOff')}
|
||||
title={$t('chat.commandPlanOff')}
|
||||
class="app-surface app-interactive group p-[0.3125rem] flex gap-1 items-center text-xs rounded-full transition-colors duration-150 border"
|
||||
onclick={() => planMode.set(false)}
|
||||
>
|
||||
<svg
|
||||
@@ -1291,14 +1272,16 @@
|
||||
/* ── ProseMirror editor ───────────────────────── */
|
||||
|
||||
.chat-editor-mount :global(.chat-prosemirror) {
|
||||
@apply pt-2.5 pb-2 px-1 min-h-6 max-h-96 overflow-y-auto text-[0.8125rem] leading-relaxed text-gray-900 dark:text-gray-100 outline-none break-words;
|
||||
@apply pt-2.5 pb-2 px-1 min-h-6 max-h-96 overflow-y-auto text-[0.8125rem] leading-relaxed outline-none break-words;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
/* Placeholder */
|
||||
.chat-editor-mount :global(.chat-prosemirror p.is-editor-empty:first-child::before) {
|
||||
content: attr(data-placeholder);
|
||||
@apply float-left text-gray-400 dark:text-gray-600 pointer-events-none h-0;
|
||||
@apply float-left pointer-events-none h-0;
|
||||
color: color-mix(in oklab, var(--app-fg) 48%, var(--app-bg));
|
||||
}
|
||||
|
||||
/* Paragraphs */
|
||||
@@ -1323,12 +1306,14 @@
|
||||
|
||||
/* Inline code */
|
||||
.chat-editor-mount :global(.chat-prosemirror code) {
|
||||
@apply bg-gray-100 dark:bg-white/8 rounded-sm px-1 py-px text-xs font-mono;
|
||||
@apply rounded-sm px-1 py-px text-xs font-mono;
|
||||
background: color-mix(in oklab, var(--app-fg) 7%, transparent);
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
.chat-editor-mount :global(.chat-prosemirror pre) {
|
||||
@apply bg-gray-100 dark:bg-white/4 rounded-md px-3 py-2 overflow-x-auto my-1 text-xs font-mono;
|
||||
@apply rounded-md px-3 py-2 overflow-x-auto my-1 text-xs font-mono;
|
||||
background: color-mix(in oklab, var(--app-fg) 5%, transparent);
|
||||
}
|
||||
.chat-editor-mount :global(.chat-prosemirror pre code) {
|
||||
@apply bg-transparent p-0 rounded-none text-inherit;
|
||||
@@ -1336,7 +1321,9 @@
|
||||
|
||||
/* Blockquote */
|
||||
.chat-editor-mount :global(.chat-prosemirror blockquote) {
|
||||
@apply my-1 py-0.5 pl-3 border-l-2 border-gray-300 dark:border-white/12 text-gray-500 dark:text-gray-400;
|
||||
@apply my-1 py-0.5 pl-3 border-l-2;
|
||||
border-color: color-mix(in oklab, var(--app-fg) 18%, transparent);
|
||||
color: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
}
|
||||
|
||||
/* Strong */
|
||||
@@ -1358,7 +1345,8 @@
|
||||
|
||||
/* HR */
|
||||
.chat-editor-mount :global(.chat-prosemirror hr) {
|
||||
@apply border-none border-t border-gray-200 dark:border-white/8 my-2;
|
||||
@apply border-none border-t my-2;
|
||||
border-color: color-mix(in oklab, var(--app-fg) 10%, transparent);
|
||||
}
|
||||
|
||||
/* Syntax highlighting */
|
||||
|
||||
@@ -1414,10 +1414,14 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="relative flex h-full flex-col bg-white dark:bg-black">
|
||||
<div
|
||||
class="app-theme relative flex h-full flex-col"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
>
|
||||
{#if !isLanding}
|
||||
<div
|
||||
class="flex h-7 shrink-0 items-center gap-2 border-b border-gray-100 px-3 dark:border-white/6"
|
||||
style="border-color: color-mix(in oklab, var(--app-fg) 8%, transparent);"
|
||||
>
|
||||
<div
|
||||
class="min-w-0 flex-1 truncate text-[0.6875rem] font-medium text-gray-600 dark:text-gray-400"
|
||||
@@ -1487,7 +1491,12 @@
|
||||
<Spinner size={24} />
|
||||
</div>
|
||||
{:else}
|
||||
<div bind:this={messagesEl} class="flex-1 overflow-y-auto" onscroll={handleMessagesScroll}>
|
||||
<div
|
||||
bind:this={messagesEl}
|
||||
class="flex-1 overflow-y-auto"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
onscroll={handleMessagesScroll}
|
||||
>
|
||||
<div class="max-w-2xl mx-auto px-4 pt-4 pb-16 flex flex-col gap-4">
|
||||
{#if hasHiddenMessages}
|
||||
<div bind:this={loadSentinelEl} class="h-1 w-full" aria-hidden="true"></div>
|
||||
@@ -1526,14 +1535,14 @@
|
||||
{/if}
|
||||
|
||||
<!-- Input area -->
|
||||
<div class="px-4 py-3">
|
||||
<div class="px-4 py-3" style="background: var(--app-bg);">
|
||||
<div class="max-w-2xl mx-auto relative">
|
||||
{#if !autoScroll && activePath.length > 0}
|
||||
<div
|
||||
class="absolute -top-10 left-0 right-0 pr-2 flex justify-end z-30 pointer-events-none"
|
||||
>
|
||||
<button
|
||||
class="bg-white dark:bg-white/20 border border-gray-200 dark:border-gray-700 p-1 rounded-full pointer-events-auto shadow-sm hover:bg-gray-50 dark:hover:bg-white/30 transition-colors"
|
||||
class="app-surface app-interactive border p-1 rounded-full pointer-events-auto shadow-sm transition-colors"
|
||||
onclick={() => {
|
||||
autoScroll = true;
|
||||
scrollToBottom();
|
||||
|
||||
@@ -34,43 +34,31 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="fixed z-50 w-60 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
|
||||
class="app-theme app-surface fixed z-50 w-60 max-h-40 overflow-y-auto rounded-xl border shadow-xl p-0.5"
|
||||
>
|
||||
{#if items.length === 0}
|
||||
<div class="flex items-center h-6 px-2 text-xs text-gray-400 dark:text-gray-600">
|
||||
No files found
|
||||
</div>
|
||||
<div class="app-muted flex items-center h-6 px-2 text-xs">No files found</div>
|
||||
{:else}
|
||||
<div
|
||||
class="mb-0.5 px-2 pt-1 pb-0.5 text-[0.625rem] leading-none text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
Files
|
||||
</div>
|
||||
<div class="app-muted mb-0.5 px-2 pt-1 pb-0.5 text-[0.625rem] leading-none">Files</div>
|
||||
<div bind:this={listEl}>
|
||||
{#each items as item, i (item.id)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{i === selectedIndex
|
||||
? 'bg-gray-50 dark:bg-white/5 text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
class="suggestion-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{i === selectedIndex ? 'app-interactive-active' : ''}"
|
||||
onmousedown={(e) => {
|
||||
e.preventDefault();
|
||||
onselect(i);
|
||||
}}
|
||||
onmouseenter={() => (selectedIndex = i)}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-4 shrink-0 {item.type === 'directory'
|
||||
? 'text-gray-500 dark:text-gray-400'
|
||||
: 'text-gray-400 dark:text-gray-500'}"
|
||||
>
|
||||
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
|
||||
<Icon name={fileIconName(item.label, item.type)} size={14} />
|
||||
</span>
|
||||
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
|
||||
<span class="truncate">{item.label}</span>
|
||||
{#if relativePath(item.id)}
|
||||
<span class="text-[0.625rem] text-gray-400 dark:text-gray-600 truncate shrink-0"
|
||||
<span class="app-muted text-[0.625rem] truncate shrink-0"
|
||||
>{relativePath(item.id)}</span
|
||||
>
|
||||
{/if}
|
||||
@@ -80,3 +68,14 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.suggestion-row {
|
||||
color: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
}
|
||||
|
||||
.suggestion-row:hover {
|
||||
background: color-mix(in oklab, var(--app-fg) 6%, transparent);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
</style>
|
||||
@@ -227,7 +227,7 @@
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
bind:this={menuEl}
|
||||
class="fixed z-[101] w-56 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5 overflow-hidden"
|
||||
class="app-theme app-surface fixed z-[101] w-56 rounded-xl border shadow-xl p-0.5 overflow-hidden"
|
||||
style="left: {pos.x}px; bottom: {pos.bottom}px; opacity: {ready ? 1 : 0}; pointer-events: {ready
|
||||
? 'auto'
|
||||
: 'none'};"
|
||||
@@ -277,7 +277,7 @@
|
||||
<span class="flex-1 text-left truncate">{$t('plusMenu.capture')}</span>
|
||||
</button>
|
||||
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
|
||||
<!-- Plan mode toggle -->
|
||||
<button
|
||||
@@ -302,7 +302,7 @@
|
||||
<ToggleSwitch value={$planMode} onchange={(v) => planMode.set(v)} />
|
||||
</button>
|
||||
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
|
||||
@@ -316,7 +316,7 @@
|
||||
<Icon name="chevron-right" size={12} class="shrink-0 text-gray-400 dark:text-gray-500" />
|
||||
</button>
|
||||
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
|
||||
@@ -354,7 +354,7 @@
|
||||
<span class="flex-1 text-left font-medium">{$t('plusMenu.toolPermissions')}</span>
|
||||
</button>
|
||||
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
|
||||
{#each modes as mode}
|
||||
<button
|
||||
@@ -393,7 +393,7 @@
|
||||
<span class="flex-1 text-left font-medium">{$t('plusMenu.parameters')}</span>
|
||||
</button>
|
||||
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="app-divider h-px mx-1 my-0.5"></div>
|
||||
|
||||
{#if paramRows.length === 0}
|
||||
<p
|
||||
|
||||
@@ -25,24 +25,18 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="fixed z-50 w-60 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
|
||||
class="app-theme app-surface fixed z-50 w-60 max-h-40 overflow-y-auto rounded-xl border shadow-xl p-0.5"
|
||||
>
|
||||
{#if items.length === 0}
|
||||
<div class="flex items-center h-6 px-2 text-xs text-gray-400 dark:text-gray-600">
|
||||
No skills found
|
||||
</div>
|
||||
<div class="app-muted flex items-center h-6 px-2 text-xs">No skills found</div>
|
||||
{:else}
|
||||
<div class="px-2 pt-1 pb-0.5 text-[0.625rem] leading-none text-gray-400 dark:text-gray-600">
|
||||
Skills
|
||||
</div>
|
||||
<div class="app-muted px-2 pt-1 pb-0.5 text-[0.625rem] leading-none">Skills</div>
|
||||
<div bind:this={listEl}>
|
||||
{#each items as item, i (item.id)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{i === selectedIndex
|
||||
? 'bg-gray-50 dark:bg-white/5 text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
class="suggestion-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
|
||||
{i === selectedIndex ? 'app-interactive-active' : ''}"
|
||||
onmousedown={(e) => {
|
||||
e.preventDefault();
|
||||
onselect(i);
|
||||
@@ -50,9 +44,7 @@
|
||||
onmouseenter={() => (selectedIndex = i)}
|
||||
title={item.description}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-4 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
>
|
||||
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
|
||||
<svg viewBox="0 0 16 16" fill="currentColor" class="size-3.5">
|
||||
<path
|
||||
d="M8.75 1a.75.75 0 0 0-1.5 0v1.249c-1.373.158-2.476.682-3.33 1.536C3.066 4.639 2.5 5.77 2.5 7.25c0 1.296-.266 2.193-.613 2.852-.35.663-.83 1.132-1.268 1.507a.75.75 0 0 0 .494 1.315h3.137a3.75 3.75 0 0 0 7.5 0h3.137a.75.75 0 0 0 .494-1.315c-.438-.375-.919-.844-1.268-1.507-.347-.659-.613-1.556-.613-2.852 0-1.48-.566-2.611-1.42-3.465-.854-.854-1.957-1.378-3.33-1.536V1ZM6.5 12.924a2.25 2.25 0 0 0 3 0h-3Z"
|
||||
@@ -62,9 +54,7 @@
|
||||
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
|
||||
<span class="truncate">{item.label}</span>
|
||||
{#if item.source && item.source !== 'workspace'}
|
||||
<span class="text-[0.625rem] text-gray-400 dark:text-gray-600 truncate shrink-0"
|
||||
>{item.source}</span
|
||||
>
|
||||
<span class="app-muted text-[0.625rem] truncate shrink-0">{item.source}</span>
|
||||
{/if}
|
||||
</span>
|
||||
</button>
|
||||
@@ -72,3 +62,14 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.suggestion-row {
|
||||
color: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
|
||||
}
|
||||
|
||||
.suggestion-row:hover {
|
||||
background: color-mix(in oklab, var(--app-fg) 6%, transparent);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
</style>
|
||||
@@ -143,7 +143,7 @@
|
||||
{terminatingSelectedSession ? 'Terminating' : 'Terminate'}
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 bg-white dark:bg-black">
|
||||
<div class="min-h-0 flex-1" style="background: var(--app-bg); color: var(--app-fg);">
|
||||
<Terminal
|
||||
wsPath={`/api/terminal/sessions/${selectedSession.command_session_id}/ws`}
|
||||
initialOutput={selectedSession.output ?? ''}
|
||||
|
||||
@@ -155,9 +155,7 @@
|
||||
{:else if edit}
|
||||
<!-- Edit mode: full width -->
|
||||
<div class="w-full">
|
||||
<div
|
||||
class="bg-gray-50 dark:bg-white/4 rounded-xl border border-gray-200 dark:border-white/8 px-3.5 py-2.5"
|
||||
>
|
||||
<div class="app-subtle-surface rounded-xl border px-3.5 py-2.5">
|
||||
<textarea
|
||||
bind:this={textareaEl}
|
||||
bind:value={editedContent}
|
||||
@@ -194,17 +192,15 @@
|
||||
<img src={upload.url} alt={upload.name || 'image'} class="max-h-96 rounded-lg" />
|
||||
{:else}
|
||||
<div
|
||||
class="relative group py-1.5 px-2 w-48 flex items-center gap-1.5 bg-white dark:bg-[#1a1a1a] border border-gray-100 dark:border-white/5 rounded-xl text-left flex-shrink-0 shadow-sm"
|
||||
class="app-surface relative group py-1.5 px-2 w-48 flex items-center gap-1.5 border rounded-xl text-left flex-shrink-0 shadow-sm"
|
||||
>
|
||||
<div class="shrink-0">
|
||||
<Icon name="page-text" size={14} class="text-gray-500 dark:text-gray-400" />
|
||||
<Icon name="page-text" size={14} class="app-icon-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col justify-center w-full overflow-hidden">
|
||||
<div
|
||||
class="dark:text-gray-100 text-xs flex justify-between items-center w-full gap-2"
|
||||
>
|
||||
<div class="text-xs flex justify-between items-center w-full gap-2">
|
||||
<div class="font-medium truncate flex-1">{upload.name || 'File'}</div>
|
||||
<div class="text-[0.625rem] text-gray-500 capitalize shrink-0">
|
||||
<div class="app-muted text-[0.625rem] capitalize shrink-0">
|
||||
{upload.type === 'file' ? 'File' : upload.type || 'File'}
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +212,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex justify-end">
|
||||
<div class="max-w-[90%] px-4 py-2 rounded-3xl bg-gray-50 dark:bg-white/[0.06]">
|
||||
<div class="max-w-[90%] px-4 py-2 rounded-3xl app-interactive-active">
|
||||
<div
|
||||
class="text-[0.8125rem] leading-relaxed text-gray-900 dark:text-gray-200 whitespace-pre-wrap break-words"
|
||||
>
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "Keine letzten Chats",
|
||||
"settings.back": "Zurück",
|
||||
"settings.general": "Allgemein",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Speicher",
|
||||
"pwa.settingsTitle": "Progressive Web App",
|
||||
"intent.chooseWorkspace": "Arbeitsbereich",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "No recent chats",
|
||||
"settings.back": "Back",
|
||||
"settings.general": "General",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Memory",
|
||||
"pwa.settingsTitle": "Progressive Web App",
|
||||
"intent.chooseWorkspace": "Workspace",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "Sin chats recientes",
|
||||
"settings.back": "Atrás",
|
||||
"settings.general": "General",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Memoria",
|
||||
"pwa.settingsTitle": "Aplicación web progresiva",
|
||||
"intent.chooseWorkspace": "Espacio de trabajo",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "Aucune conversation récente",
|
||||
"settings.back": "Retour",
|
||||
"settings.general": "Général",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Mémoire",
|
||||
"pwa.settingsTitle": "Application web progressive",
|
||||
"intent.chooseWorkspace": "Espace de travail",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "最近のチャットはありません",
|
||||
"settings.back": "戻る",
|
||||
"settings.general": "一般",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "メモリ",
|
||||
"pwa.settingsTitle": "プログレッシブ Web アプリ",
|
||||
"intent.chooseWorkspace": "ワークスペース",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "최근 채팅 없음",
|
||||
"settings.back": "뒤로",
|
||||
"settings.general": "일반",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "메모리",
|
||||
"pwa.settingsTitle": "프로그레시브 웹 앱",
|
||||
"intent.chooseWorkspace": "작업공간",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "Sem conversas recentes",
|
||||
"settings.back": "Voltar",
|
||||
"settings.general": "Geral",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Memória",
|
||||
"pwa.settingsTitle": "Aplicativo Web Progressivo",
|
||||
"intent.chooseWorkspace": "Workspace",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "Нет недавних чатов",
|
||||
"settings.back": "Назад",
|
||||
"settings.general": "Основные",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "Память",
|
||||
"pwa.settingsTitle": "Прогрессивное веб-приложение",
|
||||
"intent.chooseWorkspace": "Рабочая область",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "没有最近对话",
|
||||
"settings.back": "返回",
|
||||
"settings.general": "通用",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "记忆",
|
||||
"pwa.settingsTitle": "渐进式 Web 应用",
|
||||
"intent.chooseWorkspace": "工作区",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
"search.noRecentChats": "沒有最近對話",
|
||||
"settings.back": "返回",
|
||||
"settings.general": "一般",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.memory": "記憶",
|
||||
"pwa.settingsTitle": "漸進式 Web 應用程式",
|
||||
"intent.chooseWorkspace": "工作區",
|
||||
@@ -863,5 +864,18 @@
|
||||
"general.uiScale": "UI Scale",
|
||||
"general.default": "Default",
|
||||
"general.decreaseUiScale": "Decrease UI Scale",
|
||||
"general.increaseUiScale": "Increase UI Scale"
|
||||
"general.increaseUiScale": "Increase UI Scale",
|
||||
"appearance.title": "Appearance",
|
||||
"appearance.colors": "Colors",
|
||||
"appearance.interface": "Interface",
|
||||
"appearance.import": "Import",
|
||||
"appearance.exportTheme": "Export",
|
||||
"appearance.reset": "Reset",
|
||||
"appearance.background": "Background",
|
||||
"appearance.foreground": "Foreground",
|
||||
"appearance.uiFont": "UI font",
|
||||
"appearance.exported": "Theme exported",
|
||||
"appearance.exportFailed": "Failed to export theme",
|
||||
"appearance.imported": "Theme imported",
|
||||
"appearance.importFailed": "Failed to import theme"
|
||||
}
|
||||
@@ -30,7 +30,15 @@ import { streamingChatTabs } from '$lib/stores/chat';
|
||||
import { keybindings, loadKeybindings } from '$lib/stores/keybindings';
|
||||
import { defaultPwaPreferences, type PwaPreferences } from '$lib/intents/types';
|
||||
import { getPathDisplayName, isSupportedWorkspacePath } from '$lib/utils/paths';
|
||||
import { setTextScale } from '$lib/utils/text-scale';
|
||||
import {
|
||||
applyAppearance,
|
||||
sanitizeThemeConfig,
|
||||
type AppearancePreferences,
|
||||
type Theme,
|
||||
type ThemeConfig
|
||||
} from '$lib/utils/appearance';
|
||||
|
||||
export type { AppearancePreferences, Theme, ThemeConfig };
|
||||
|
||||
// ── Types ───────────────────────────────────────────────────────
|
||||
|
||||
@@ -70,7 +78,8 @@ export interface WorkspaceState {
|
||||
export type ToolApprovalMode = 'ask' | 'auto' | 'full';
|
||||
|
||||
export interface UserPreferences {
|
||||
theme: Theme;
|
||||
theme?: Theme;
|
||||
appearance?: AppearancePreferences;
|
||||
sidebarOpen: boolean;
|
||||
sidebarWidth: number;
|
||||
toolApprovalMode: ToolApprovalMode;
|
||||
@@ -86,8 +95,6 @@ export interface UserPreferences {
|
||||
textScale?: number | null;
|
||||
}
|
||||
|
||||
export type Theme = 'dark' | 'light' | 'system';
|
||||
|
||||
// ── ID generation ───────────────────────────────────────────────
|
||||
|
||||
let _idCounter = Date.now();
|
||||
@@ -174,6 +181,7 @@ export type StreamingBehavior = 'queue' | 'interrupt';
|
||||
export const streamingBehavior = writable<StreamingBehavior>('queue');
|
||||
export const selectedModelId = writable<string>('');
|
||||
export const pwaPreferences = writable<PwaPreferences>(defaultPwaPreferences);
|
||||
export const themeConfig = writable<ThemeConfig | null>(null);
|
||||
export const textScale = writable<number | null>(null);
|
||||
|
||||
/** Saved workspace path order for sidebar drag-reorder. */
|
||||
@@ -300,6 +308,11 @@ function persistPreferences(): void {
|
||||
_savePrefTimer = setTimeout(() => {
|
||||
const prefs: UserPreferences = {
|
||||
theme: get(theme),
|
||||
appearance: {
|
||||
theme: get(theme),
|
||||
themeConfig: sanitizeThemeConfig(get(themeConfig)),
|
||||
textScale: get(textScale) ?? undefined
|
||||
},
|
||||
sidebarOpen: get(sidebarOpen),
|
||||
sidebarWidth: get(sidebarWidth),
|
||||
toolApprovalMode: get(toolApprovalMode),
|
||||
@@ -328,6 +341,9 @@ function subscribeForPersistence() {
|
||||
theme.subscribe(() => {
|
||||
if (get(stateLoaded)) persistPreferences();
|
||||
});
|
||||
themeConfig.subscribe(() => {
|
||||
if (get(stateLoaded)) persistPreferences();
|
||||
});
|
||||
sidebarOpen.subscribe(() => {
|
||||
if (get(stateLoaded)) persistPreferences();
|
||||
});
|
||||
@@ -374,7 +390,11 @@ function subscribeForPersistence() {
|
||||
export async function loadPreferences(): Promise<void> {
|
||||
try {
|
||||
const prefs = await getPreferences();
|
||||
if (prefs.theme) theme.set(prefs.theme as Theme);
|
||||
const appearance = (
|
||||
prefs.appearance && typeof prefs.appearance === 'object' ? prefs.appearance : {}
|
||||
) as AppearancePreferences;
|
||||
if (appearance.theme || prefs.theme) theme.set((appearance.theme ?? prefs.theme) as Theme);
|
||||
themeConfig.set(sanitizeThemeConfig(appearance.themeConfig));
|
||||
if (prefs.sidebarOpen !== undefined) sidebarOpen.set(prefs.sidebarOpen as boolean);
|
||||
if (prefs.sidebarWidth !== undefined) sidebarWidth.set(prefs.sidebarWidth as number);
|
||||
// Support new toolApprovalMode and legacy boolean autoApproveTools
|
||||
@@ -393,7 +413,13 @@ export async function loadPreferences(): Promise<void> {
|
||||
if (prefs.requestParams) requestParams.set(prefs.requestParams as Record<string, unknown>);
|
||||
if (prefs.showUpdateToast !== undefined)
|
||||
showUpdateToastPref.set(prefs.showUpdateToast as boolean);
|
||||
textScale.set(typeof prefs.textScale === 'number' ? (prefs.textScale as number) : null);
|
||||
textScale.set(
|
||||
typeof appearance.textScale === 'number'
|
||||
? appearance.textScale
|
||||
: typeof prefs.textScale === 'number'
|
||||
? (prefs.textScale as number)
|
||||
: null
|
||||
);
|
||||
const pwaPrefs = prefs.pwa;
|
||||
if (pwaPrefs)
|
||||
pwaPreferences.set({
|
||||
@@ -496,26 +522,19 @@ export async function initState(): Promise<void> {
|
||||
/** @deprecated Use initState */
|
||||
export const loadStateFromServer = initState;
|
||||
|
||||
// ── Theme application ───────────────────────────────────────────
|
||||
// ── Appearance application ──────────────────────────────────────
|
||||
|
||||
function applyTheme(t: Theme) {
|
||||
if (typeof window === 'undefined') return;
|
||||
let resolved = t;
|
||||
if (t === 'system') {
|
||||
resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
document.documentElement.classList.toggle('dark', resolved === 'dark');
|
||||
document.documentElement.style.colorScheme = resolved;
|
||||
const meta = document.querySelector('meta[name="theme-color"]');
|
||||
if (meta) meta.setAttribute('content', resolved === 'dark' ? '#0d0d0d' : '#ffffff');
|
||||
function applyCurrentAppearance() {
|
||||
applyAppearance(get(theme), get(themeConfig), get(textScale));
|
||||
}
|
||||
|
||||
theme.subscribe(applyTheme);
|
||||
textScale.subscribe((scale) => setTextScale(scale ?? 1));
|
||||
theme.subscribe(applyCurrentAppearance);
|
||||
themeConfig.subscribe(applyCurrentAppearance);
|
||||
textScale.subscribe(applyCurrentAppearance);
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||
if (get(theme) === 'system') applyTheme('system');
|
||||
if (get(theme) === 'system') applyCurrentAppearance();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -534,6 +553,10 @@ if (typeof BroadcastChannel !== 'undefined') {
|
||||
try {
|
||||
if (type === 'theme' && value) {
|
||||
theme.set(value);
|
||||
} else if (type === 'appearance' && value) {
|
||||
if (value.theme) theme.set(value.theme);
|
||||
themeConfig.set(sanitizeThemeConfig(value.themeConfig));
|
||||
textScale.set(typeof value.textScale === 'number' ? value.textScale : null);
|
||||
} else if (type === 'locale' && value) {
|
||||
changeLocale(value);
|
||||
}
|
||||
@@ -545,6 +568,28 @@ if (typeof BroadcastChannel !== 'undefined') {
|
||||
theme.subscribe((t) => {
|
||||
if (!_syncingFromBroadcast) {
|
||||
channel.postMessage({ type: 'theme', value: t });
|
||||
channel.postMessage({
|
||||
type: 'appearance',
|
||||
value: { theme: t, themeConfig: get(themeConfig), textScale: get(textScale) }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
themeConfig.subscribe((config) => {
|
||||
if (!_syncingFromBroadcast) {
|
||||
channel.postMessage({
|
||||
type: 'appearance',
|
||||
value: { theme: get(theme), themeConfig: config, textScale: get(textScale) }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
textScale.subscribe((scale) => {
|
||||
if (!_syncingFromBroadcast) {
|
||||
channel.postMessage({
|
||||
type: 'appearance',
|
||||
value: { theme: get(theme), themeConfig: get(themeConfig), textScale: scale }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import { setTextScale } from '$lib/utils/text-scale';
|
||||
|
||||
export type Theme = 'dark' | 'light' | 'system';
|
||||
|
||||
export type ThemeColors = {
|
||||
background?: string;
|
||||
foreground?: string;
|
||||
};
|
||||
|
||||
export type ThemeConfig = {
|
||||
light?: ThemeColors;
|
||||
dark?: ThemeColors;
|
||||
uiFont?: string;
|
||||
};
|
||||
|
||||
export type AppearancePreferences = {
|
||||
theme?: Theme;
|
||||
themeConfig?: ThemeConfig | null;
|
||||
textScale?: number | null;
|
||||
};
|
||||
|
||||
type ResolvedTheme = 'dark' | 'light';
|
||||
|
||||
const DEFAULT_UI_FONT =
|
||||
"'Inter', -apple-system, BlinkMacSystemFont, ui-sans-serif, system-ui, sans-serif";
|
||||
|
||||
export function resolveThemeMode(theme: Theme): ResolvedTheme {
|
||||
if (theme === 'system' && typeof window !== 'undefined') {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
return theme === 'light' ? 'light' : 'dark';
|
||||
}
|
||||
|
||||
export function normalizeHexColor(value: unknown): string | undefined {
|
||||
if (typeof value !== 'string') return undefined;
|
||||
const color = value.trim();
|
||||
const short = /^#([0-9a-f]{3})$/i.exec(color);
|
||||
if (short) {
|
||||
return `#${short[1]
|
||||
.split('')
|
||||
.map((char) => char + char)
|
||||
.join('')}`.toLowerCase();
|
||||
}
|
||||
if (/^#[0-9a-f]{6}$/i.test(color)) return color.toLowerCase();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function sanitizeThemeColors(value: unknown): ThemeColors | null {
|
||||
if (!value || typeof value !== 'object') return null;
|
||||
const raw = value as Record<string, unknown>;
|
||||
const next: ThemeColors = {};
|
||||
const background = normalizeHexColor(raw.background);
|
||||
const foreground = normalizeHexColor(raw.foreground);
|
||||
if (background) next.background = background;
|
||||
if (foreground) next.foreground = foreground;
|
||||
return Object.keys(next).length ? next : null;
|
||||
}
|
||||
|
||||
export function sanitizeThemeConfig(value: unknown): ThemeConfig | null {
|
||||
if (!value || typeof value !== 'object') return null;
|
||||
const raw = value as Record<string, unknown>;
|
||||
const next: ThemeConfig = {};
|
||||
const light = sanitizeThemeColors(raw.light);
|
||||
const dark = sanitizeThemeColors(raw.dark);
|
||||
const legacy = sanitizeThemeColors(raw);
|
||||
if (light) next.light = light;
|
||||
if (dark) next.dark = dark;
|
||||
if (legacy && !light && !dark) {
|
||||
next.light = legacy;
|
||||
next.dark = legacy;
|
||||
}
|
||||
if (typeof raw.uiFont === 'string' && raw.uiFont.trim()) {
|
||||
next.uiFont = raw.uiFont.trim().slice(0, 240);
|
||||
}
|
||||
return Object.keys(next).length ? next : null;
|
||||
}
|
||||
|
||||
export function defaultThemeConfig(theme: Theme): Required<ThemeColors> & { uiFont: string } {
|
||||
const resolved = resolveThemeMode(theme);
|
||||
return {
|
||||
background: resolved === 'dark' ? '#000000' : '#ffffff',
|
||||
foreground: resolved === 'dark' ? '#d4d4d4' : '#525252',
|
||||
uiFont: DEFAULT_UI_FONT
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveThemeConfig(
|
||||
theme: Theme,
|
||||
config: ThemeConfig | null
|
||||
): Required<ThemeColors> & { uiFont: string } {
|
||||
const resolved = resolveThemeMode(theme);
|
||||
return {
|
||||
...defaultThemeConfig(theme),
|
||||
...(config?.[resolved] ?? {}),
|
||||
uiFont: config?.uiFont ?? DEFAULT_UI_FONT
|
||||
};
|
||||
}
|
||||
|
||||
function setVar(name: string, value: string) {
|
||||
document.documentElement.style.setProperty(name, value);
|
||||
}
|
||||
|
||||
export function applyAppearance(
|
||||
theme: Theme,
|
||||
config: ThemeConfig | null,
|
||||
textScale: number | null
|
||||
) {
|
||||
if (typeof document === 'undefined') return;
|
||||
|
||||
const resolved = resolveThemeMode(theme);
|
||||
const merged = resolveThemeConfig(theme, config);
|
||||
|
||||
document.documentElement.classList.toggle('dark', resolved === 'dark');
|
||||
document.documentElement.style.colorScheme = resolved;
|
||||
|
||||
setVar('--app-bg', merged.background);
|
||||
setVar('--app-fg', merged.foreground);
|
||||
setVar('--app-ui-font', merged.uiFont);
|
||||
setVar('--font-sans', merged.uiFont);
|
||||
|
||||
setTextScale(textScale ?? 1);
|
||||
|
||||
const meta = document.querySelector('meta[name="theme-color"]');
|
||||
if (meta) meta.setAttribute('content', merged.background);
|
||||
}
|
||||
@@ -421,7 +421,10 @@
|
||||
|
||||
{#if authState === 'checking'}
|
||||
<!-- Loading spinner while checking auth -->
|
||||
<div class="flex items-center justify-center h-dvh bg-white dark:bg-black">
|
||||
<div
|
||||
class="app-theme flex items-center justify-center h-dvh bg-white dark:bg-black"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
>
|
||||
<Spinner size={20} />
|
||||
</div>
|
||||
{:else if authState === 'needs_setup' || authState === 'needs_login'}
|
||||
@@ -441,7 +444,8 @@
|
||||
/>
|
||||
{:else if $stateLoaded}
|
||||
<div
|
||||
class="h-screen max-h-[100dvh] flex overflow-hidden font-sans antialiased text-gray-900 bg-white dark:text-gray-100 dark:bg-black"
|
||||
class="app-theme h-screen max-h-[100dvh] flex overflow-hidden font-sans antialiased text-gray-900 bg-white dark:text-gray-100 dark:bg-black"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
>
|
||||
<Sidebar />
|
||||
|
||||
@@ -483,7 +487,10 @@
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="flex items-center justify-center h-dvh bg-white dark:bg-black">
|
||||
<div
|
||||
class="app-theme flex items-center justify-center h-dvh bg-white dark:bg-black"
|
||||
style="background: var(--app-bg); color: var(--app-fg);"
|
||||
>
|
||||
<Spinner size={20} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -982,6 +982,8 @@
|
||||
height: 100%;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.split-horizontal {
|
||||
@@ -1014,6 +1016,8 @@
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background: var(--app-bg);
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
/* ── Divider ─────────────────────────────────────────────── */
|
||||
|
||||
Reference in new issue
Block a user