Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(ui): move toast accent tint to CSS class to satisfy CSP

Akarshan Biswasca7a8a335b81
diff --git a/web-app/src/components/ui/sonner.tsx b/web-app/src/components/ui/sonner.tsx
index 6f7ebc2ff..8abd6b1c4 100644
--- a/web-app/src/components/ui/sonner.tsx
+++ b/web-app/src/components/ui/sonner.tsx
@@ -4,21 +4,12 @@ import { useTheme } from '@/hooks/useTheme'
const Toaster = ({ ...props }: ToasterProps) => {
const isDark = useTheme((s) => s.isDark)
+ // CSS-var tinting lives in index.css (.toaster); an inline style prop here
+ // violates WebView2's hashed style-src CSP and gets dropped.
return (
<Sonner
theme={isDark ? 'dark' : 'light'}
className="toaster group"
- style={
- {
- // Neutral toasts pick up the accent tint (Appearance > Accent color,
- // exposed as --primary). richColors typed toasts keep their semantics.
- '--normal-bg':
- 'color-mix(in oklch, var(--popover) 92%, var(--primary))',
- '--normal-text': 'var(--popover-foreground)',
- '--normal-border':
- 'color-mix(in oklch, var(--border) 55%, var(--primary))',
- } as React.CSSProperties
- }
{...props}
/>
)
diff --git a/web-app/src/index.css b/web-app/src/index.css
index 512df0523..9dadaced7 100644
--- a/web-app/src/index.css
+++ b/web-app/src/index.css
@@ -4,6 +4,15 @@
/* Linked from 'self' so CSP keeps it: WebView2 drops sonner's runtime <style>
once index.html's inline <style> makes Tauri hash style-src (voids unsafe-inline). */
@import 'sonner/dist/styles.css';
+
+/* Accent tint for neutral toasts (Appearance > Accent color, --primary).
+ Set via class, not an inline style prop, so WebView2's hashed style-src
+ CSP doesn't drop it. richColors typed toasts keep their semantics. */
+.toaster {
+ --normal-bg: color-mix(in oklch, var(--popover) 92%, var(--primary));
+ --normal-text: var(--popover-foreground);
+ --normal-border: color-mix(in oklch, var(--border) 55%, var(--primary));
+}
@import '@/styles/font.css';
@import '@/styles/markdown.css';
@source '../node_modules/streamdown/dist/**/*.js';