An open-source, faster Devin alternative
TypeScript
web: dark mode for the dashboard (#833)
devin-ai-integration[bot]8aa9691c8160
diff --git a/web/index.html b/web/index.htmlindex fb62e57a..9c71d01b 100644--- a/web/index.html+++ b/web/index.html@@ -4,8 +4,27 @@<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="icon" type="image/svg+xml" href="/favicon.svg" />- <meta name="theme-color" content="#161513" />+ <meta name="color-scheme" content="dark light" />+ <meta+ name="theme-color"+ media="(prefers-color-scheme: light)"+ content="#f8f6f1"+ />+ <meta+ name="theme-color"+ media="(prefers-color-scheme: dark)"+ content="#161513"+ /><title>OpenComputer</title>+ <script>+ // Apply the saved theme before first paint; falls back to the OS+ // preference when the user has never toggled.+ var stored = localStorage.getItem('oc.theme')+ var dark = stored+ ? stored === 'dark'+ : matchMedia('(prefers-color-scheme: dark)').matches+ document.documentElement.classList.toggle('dark', dark)+ </script></head><body><div id="root"></div>diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsxindex 79bded4e..6beee894 100644--- a/web/src/components/app-shell.tsx+++ b/web/src/components/app-shell.tsx@@ -48,6 +48,7 @@ import {DropdownMenuTrigger,} from '@/components/ui/dropdown-menu'import { ErrorBoundary } from '@/components/error-boundary'+import { ThemeToggle } from '@/components/theme-toggle'import { AgentSecurityAlertBanner } from '@/components/agent-security-alert'import { cn } from '@/lib/utils'import { managedAgentsExperimentEnabled } from '@/managed-agents/feature'@@ -666,6 +667,9 @@ export default function AppShell() {/></div>) : null}+ <div className="ml-auto flex items-center px-4">+ <ThemeToggle />+ </div></header>{/* Desktop sidebar (below the top bar) */}@@ -700,6 +704,9 @@ export default function AppShell() {onChange={changeProjectEnvironment}/>) : null}+ <div className="ml-auto">+ <ThemeToggle />+ </div></header>{/* Main content */}diff --git a/web/src/components/theme-toggle.tsx b/web/src/components/theme-toggle.tsxnew file mode 100644index 00000000..9f877811--- /dev/null+++ b/web/src/components/theme-toggle.tsx@@ -0,0 +1,24 @@+import { Moon, Sun } from 'lucide-react'+import { Button } from '@/components/ui/button'+import { useTheme } from '@/hooks/useTheme'++export function ThemeToggle() {+ const { dark, setDark } = useTheme()+ const label = dark ? 'Switch to light theme' : 'Switch to dark theme'+ return (+ <Button+ variant="ghost"+ size="icon"+ onClick={() => setDark(!dark)}+ aria-label={label}+ title={label}+ className="text-muted-foreground hover:text-foreground"+ >+ {dark ? (+ <Sun className="size-4" strokeWidth={1.5} aria-hidden />+ ) : (+ <Moon className="size-4" strokeWidth={1.5} aria-hidden />+ )}+ </Button>+ )+}diff --git a/web/src/components/ui/sonner.tsx b/web/src/components/ui/sonner.tsxindex 670f5a1b..2dc68aa5 100644--- a/web/src/components/ui/sonner.tsx+++ b/web/src/components/ui/sonner.tsx@@ -6,13 +6,13 @@ import {OctagonXIcon,Loader2Icon,} from 'lucide-react'+import { useTheme } from '@/hooks/useTheme'-// The dashboard is light-only (no theme provider), so the toaster defaults to-// the light theme; callers can still override via the `theme` prop.-const Toaster = ({ theme = 'light', ...props }: ToasterProps) => {+const Toaster = ({ theme, ...props }: ToasterProps) => {+ const { dark } = useTheme()return (<Sonner- theme={theme}+ theme={theme ?? (dark ? 'dark' : 'light')}className="toaster group"icons={{success: <CircleCheckIcon className="size-4" />,diff --git a/web/src/hooks/useTheme.ts b/web/src/hooks/useTheme.tsnew file mode 100644index 00000000..52775001--- /dev/null+++ b/web/src/hooks/useTheme.ts@@ -0,0 +1,26 @@+import { useSyncExternalStore } from 'react'++// Theme is a DOM-level fact (the `.dark` class on <html>, applied before React+// boots by the inline script in index.html) so it can't live in component+// state — the toaster and every toggle must observe the same value.+const STORAGE_KEY = 'oc.theme'+const listeners = new Set<() => void>()++function isDark(): boolean {+ return document.documentElement.classList.contains('dark')+}++function subscribe(callback: () => void) {+ listeners.add(callback)+ return () => listeners.delete(callback)+}++export function useTheme() {+ const dark = useSyncExternalStore(subscribe, isDark, () => false)+ const setDark = (next: boolean) => {+ document.documentElement.classList.toggle('dark', next)+ localStorage.setItem(STORAGE_KEY, next ? 'dark' : 'light')+ listeners.forEach((listener) => listener())+ }+ return { dark, setDark }+}diff --git a/web/src/index.css b/web/src/index.cssindex a5deb0b6..ef2e3792 100644--- a/web/src/index.css+++ b/web/src/index.css@@ -1,5 +1,5 @@/* ============================================================- OpenComputer dashboard — design tokens (light, ink-on-paper)+ OpenComputer dashboard — design tokens (light + warm dark)Brand source: opencomputer-site-v1/src/index.css + Mintlify docs.The legacy "Void Glass" theme.css is gone; Tailwind Preflight is on (the@@ -114,7 +114,11 @@--radius-md: var(--radius);--radius-lg: calc(var(--radius) + 2px);--radius-xl: calc(var(--radius) + 4px);+}+/* Non-inline so the overlay shadow resolves through var(--shadow-overlay) at+ runtime and .dark can deepen it below. */+@theme {/* Soft, diffuse elevation for overlays (dialogs, menus, sheets) — largeblur + negative spread + low opacity, warm-ink tinted, so it reads as agentle lift rather than a crude default drop shadow. */@@ -129,6 +133,8 @@the pairs the dashboard actually uses (body >=4.5:1, large/UI >=3:1).------------------------------------------------------------------ */:root {+ color-scheme: light;+/* Brand base (verbatim from opencomputer-site-v1) */--background: hsl(40 33% 97%); /* paper #f8f6f1 */--foreground: hsl(45 8% 8%); /* ink */@@ -214,35 +220,84 @@Use Tailwind z-* utilities per this scale; do not invent z-9999. */}-/* Dark mode is deferred for this effort but kept wired (darkMode: class).- Placeholder neutral-dark values so the mechanism is testable later. */+/* Dark theme — the warm-light palette inverted, not a generic cool-dark.+ Hues stay at 36–40 (paper/ink warmth) and the ramp is lifted off pure+ black (bg ~12%) so the shell reads as the same product at night rather+ than a void; surfaces go background → panel → inset as *lighter*+ steps (light mode's inset-darker relationship mirrors to raised-darker).+ Status solids brighten for AA text on their now-dark tints; code and+ terminal surfaces keep their existing warm-dark values since they're+ already the app's own dark. */.dark {- --background: hsl(240 10% 8%);- --foreground: hsl(40 10% 92%);- --card: hsl(240 10% 11%);- --card-foreground: hsl(40 10% 92%);- --popover: hsl(240 10% 11%);- --popover-foreground: hsl(40 10% 92%);- --panel: hsl(240 10% 11%);- --panel-2: hsl(240 8% 14%);- --primary: hsl(40 10% 92%);- --primary-foreground: hsl(240 10% 8%);- --secondary: hsl(240 8% 16%);- --secondary-foreground: hsl(40 10% 92%);- --muted: hsl(240 8% 16%);- --muted-foreground: hsl(40 6% 64%);- --accent: hsl(240 8% 16%);- --accent-foreground: hsl(40 10% 92%);- --border: hsl(240 8% 18%);- --input: hsl(240 8% 22%);- --ring: hsl(40 10% 70%);- --row-hover: hsl(240 8% 13%);- --row-selected: hsl(240 8% 17%);- --sidebar: hsl(240 10% 10%);- --sidebar-foreground: hsl(40 10% 92%);- --sidebar-border: hsl(240 8% 18%);- --sidebar-accent: hsl(240 8% 16%);- --sidebar-accent-foreground: hsl(40 10% 92%);+ color-scheme: dark;++ --background: hsl(36 8% 12%);+ --foreground: hsl(40 12% 90%);++ --card: hsl(36 7% 15%);+ --card-foreground: hsl(40 12% 90%);+ --popover: hsl(36 7% 15%);+ --popover-foreground: hsl(40 12% 90%);+ --panel: hsl(36 7% 15%);+ --panel-2: hsl(36 6% 18%);++ --secondary: hsl(36 6% 19%);+ --secondary-foreground: hsl(40 12% 90%);+ --muted: hsl(36 6% 19%);+ --accent: hsl(36 6% 19%);+ --accent-foreground: hsl(40 12% 90%);++ --muted-foreground: hsl(40 6% 62%); /* ~6:1 on background */++ --border: hsl(36 6% 22%);+ --input: hsl(36 6% 28%);+ --ring: hsl(40 8% 60%);++ --row-hover: hsl(36 6% 17%);+ --row-selected: hsl(36 7% 21%);++ --primary: hsl(40 12% 90%);+ --primary-foreground: hsl(36 8% 12%);++ --destructive: hsl(0 62% 50%);+ --destructive-foreground: hsl(0 0% 100%);++ --status-running: hsl(142 55% 50%);+ --status-running-bg: hsl(142 30% 16%);+ --status-stopped: hsl(40 6% 65%);+ --status-stopped-bg: hsl(40 8% 19%);+ --status-hibernated: hsl(222 65% 70%);+ --status-hibernated-bg: hsl(222 30% 19%);+ --status-error: hsl(0 70% 65%);+ --status-error-bg: hsl(0 35% 19%);+ --status-pending: hsl(38 85% 60%);+ --status-pending-bg: hsl(38 40% 18%);++ /* Code blocks sit a step above the shell bg so they still read as a+ distinct surface; the terminal stays near-black (recessed). */+ --code: hsl(36 8% 15%);+ --code-foreground: hsl(40 12% 88%);+ --code-muted: hsl(40 6% 54%);+ --code-border: hsl(36 7% 22%);+ --terminal: hsl(36 13% 8%);++ /* Charts — neutral paper ramp (dark → light), inverted from light mode */+ --chart-1: hsl(40 12% 85%);+ --chart-2: hsl(40 10% 65%);+ --chart-3: hsl(40 7% 50%);+ --chart-4: hsl(36 6% 36%);+ --chart-5: hsl(36 6% 26%);++ --sidebar: hsl(36 8% 10%);+ --sidebar-foreground: hsl(40 12% 90%);+ --sidebar-border: hsl(36 6% 22%);+ --sidebar-accent: hsl(36 6% 18%);+ --sidebar-accent-foreground: hsl(40 12% 90%);++ /* Overlays need real elevation on dark — the light-tinted shadow is+ invisible against a dark shell. */+ --shadow-overlay:+ 0 10px 30px -12px rgb(0 0 0 / 0.5), 0 1px 3px -1px rgb(0 0 0 / 0.35);}@layer base {diff --git a/web/src/main.tsx b/web/src/main.tsxindex d2977b6d..f6b21d27 100644--- a/web/src/main.tsx+++ b/web/src/main.tsx@@ -76,7 +76,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(><App /></ErrorBoundary>- <Toaster theme="light" richColors closeButton />+ <Toaster richColors closeButton /></BrowserRouter></QueryClientProvider></PostHogProvider>