Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: add theme switcher with 5 dark themes
Adam Eivyc5cc917efed3
diff --git a/.changelog/v0.21.x.md b/.changelog/v0.21.x.mdnew file mode 100644index 0000000000..2309ccb467--- /dev/null+++ b/.changelog/v0.21.x.md@@ -0,0 +1,16 @@+# Release v0.21.x - Changelog++Released: YYYY-MM-DD++## Overview++Theme support with 5 dark themes.++## Features++### Theme switcher+- **5 dark themes** — Midnight (default, current look), Phosphor (terminal green), Ember (warm orange), Arctic (ice blue), Synthwave (neon purple)+- Palette icon in sidebar footer and mobile header opens a theme popover+- Selection persists across sessions via localStorage+- All existing `port-*` Tailwind classes respond automatically via CSS custom properties — zero component changes needed+- Shell terminal, toast notifications, scrollbars, and focus rings all adapt to the active themediff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex 1b7f3d9188..089fe1cfec 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -42,6 +42,7 @@ import { useErrorNotifications } from '../hooks/useErrorNotifications';import { useNotifications } from '../hooks/useNotifications';import { useAgentFeedbackToast } from '../hooks/useAgentFeedbackToast';import NotificationDropdown from './NotificationDropdown';+import ThemeSwitcher from './ThemeSwitcher';const navItems = [{ to: '/', label: 'Dashboard', icon: Home, single: true },@@ -415,7 +416,8 @@ export default function Layout() {<span className={`text-sm text-gray-500 ${collapsed ? 'lg:hidden' : ''}`}>v{packageJson.version}</span>- <div className={collapsed ? '' : ''}>+ <div className="flex items-center gap-1">+ <ThemeSwitcher /><NotificationDropdownnotifications={notifications}unreadCount={unreadCount}@@ -445,15 +447,18 @@ export default function Layout() {<Logo size={18} className="text-port-accent" /><span className="font-bold text-sm text-port-accent">PortOS</span></div>- <NotificationDropdown- notifications={notifications}- unreadCount={unreadCount}- onMarkAsRead={markAsRead}- onMarkAllAsRead={markAllAsRead}- onRemove={removeNotification}- onClearAll={clearAll}- position="top"- />+ <div className="flex items-center gap-1">+ <ThemeSwitcher position="below" />+ <NotificationDropdown+ notifications={notifications}+ unreadCount={unreadCount}+ onMarkAsRead={markAsRead}+ onMarkAllAsRead={markAllAsRead}+ onRemove={removeNotification}+ onClearAll={clearAll}+ position="top"+ />+ </div></header>{/* Main content */}diff --git a/client/src/components/ThemeContext.jsx b/client/src/components/ThemeContext.jsxnew file mode 100644index 0000000000..21ded29dd4--- /dev/null+++ b/client/src/components/ThemeContext.jsx@@ -0,0 +1,20 @@+import { createContext, useContext } from 'react';+import useTheme from '../hooks/useTheme';++const ThemeContext = createContext(null);++export function ThemeProvider({ children }) {+ const value = useTheme();++ return (+ <ThemeContext.Provider value={value}>+ {children}+ </ThemeContext.Provider>+ );+}++export function useThemeContext() {+ const ctx = useContext(ThemeContext);+ if (!ctx) return { themeId: 'midnight', theme: null, themes: {}, setTheme: () => {} };+ return ctx;+}diff --git a/client/src/components/ThemeSwitcher.jsx b/client/src/components/ThemeSwitcher.jsxnew file mode 100644index 0000000000..27e4953dd3--- /dev/null+++ b/client/src/components/ThemeSwitcher.jsx@@ -0,0 +1,70 @@+import { useState, useRef, useEffect } from 'react';+import { Palette } from 'lucide-react';+import { useThemeContext } from './ThemeContext';++export default function ThemeSwitcher({ position = 'above' }) {+ const { themeId, themes, setTheme } = useThemeContext();+ const [open, setOpen] = useState(false);+ const containerRef = useRef(null);++ // Close on click outside+ useEffect(() => {+ if (!open) return;+ const handle = (e) => {+ if (containerRef.current && !containerRef.current.contains(e.target)) {+ setOpen(false);+ }+ };+ document.addEventListener('mousedown', handle);+ return () => document.removeEventListener('mousedown', handle);+ }, [open]);++ // Close on Escape+ useEffect(() => {+ if (!open) return;+ const handle = (e) => e.key === 'Escape' && setOpen(false);+ document.addEventListener('keydown', handle);+ return () => document.removeEventListener('keydown', handle);+ }, [open]);++ return (+ <div ref={containerRef} className="relative">+ <button+ onClick={() => setOpen(!open)}+ className="p-1.5 text-gray-500 hover:text-port-accent transition-colors"+ title="Switch theme"+ aria-label="Switch theme"+ aria-expanded={open}+ >+ <Palette size={18} />+ </button>++ {open && (+ <div+ className={`absolute ${+ position === 'above' ? 'bottom-full mb-2' : 'top-full mt-2'+ } right-0 w-44 bg-port-card border border-port-border rounded-lg shadow-xl z-50 py-1`}+ >+ {Object.entries(themes).map(([id, theme]) => (+ <button+ key={id}+ onClick={() => { setTheme(id); setOpen(false); }}+ className={`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors ${+ themeId === id+ ? 'bg-port-accent/10 text-port-accent'+ : 'text-gray-400 hover:text-white hover:bg-port-border/50'+ }`}+ >+ <span+ className="w-3 h-3 rounded-full flex-shrink-0 border border-white/20"+ style={{ backgroundColor: theme.accent }}+ />+ {theme.label}+ {themeId === id && <span className="ml-auto text-xs opacity-60">Active</span>}+ </button>+ ))}+ </div>+ )}+ </div>+ );+}diff --git a/client/src/hooks/useAgentFeedbackToast.jsx b/client/src/hooks/useAgentFeedbackToast.jsxindex e6bf5ca5ef..fa44db9582 100644--- a/client/src/hooks/useAgentFeedbackToast.jsx+++ b/client/src/hooks/useAgentFeedbackToast.jsx@@ -104,8 +104,8 @@ export function useAgentFeedbackToast() {id: toastId,duration: 15000, // 15 seconds - enough time to react but not annoyingstyle: {- background: '#1a1a1a',- border: '1px solid #2a2a2a',+ background: 'rgb(var(--port-card))',+ border: '1px solid rgb(var(--port-border))',padding: '12px 16px',borderRadius: '8px'}diff --git a/client/src/hooks/useTheme.js b/client/src/hooks/useTheme.jsnew file mode 100644index 0000000000..fb032b683a--- /dev/null+++ b/client/src/hooks/useTheme.js@@ -0,0 +1,119 @@+import { useState, useCallback } from 'react';++const STORAGE_KEY = 'portos-theme';++// RGB channel values (space-separated) for Tailwind opacity modifier compatibility+const THEMES = {+ midnight: {+ label: 'Midnight',+ accent: '#3b82f6',+ colors: {+ '--port-bg': '15 15 15',+ '--port-card': '26 26 26',+ '--port-border': '42 42 42',+ '--port-accent': '59 130 246',+ '--port-success': '34 197 94',+ '--port-warning': '245 158 11',+ '--port-error': '239 68 68',+ '--port-text': '229 229 229',+ '--port-text-muted': '163 163 163',+ '--port-focus-ring': '59 130 246',+ },+ },+ phosphor: {+ label: 'Phosphor',+ accent: '#22c55e',+ colors: {+ '--port-bg': '10 15 10',+ '--port-card': '18 28 18',+ '--port-border': '30 50 30',+ '--port-accent': '34 197 94',+ '--port-success': '74 222 128',+ '--port-warning': '250 204 21',+ '--port-error': '248 113 113',+ '--port-text': '200 230 200',+ '--port-text-muted': '130 170 130',+ '--port-focus-ring': '34 197 94',+ },+ },+ ember: {+ label: 'Ember',+ accent: '#f97316',+ colors: {+ '--port-bg': '18 12 10',+ '--port-card': '30 22 18',+ '--port-border': '55 38 28',+ '--port-accent': '249 115 22',+ '--port-success': '34 197 94',+ '--port-warning': '251 191 36',+ '--port-error': '239 68 68',+ '--port-text': '235 220 210',+ '--port-text-muted': '180 150 130',+ '--port-focus-ring': '249 115 22',+ },+ },+ arctic: {+ label: 'Arctic',+ accent: '#38bdf8',+ colors: {+ '--port-bg': '12 15 20',+ '--port-card': '20 26 35',+ '--port-border': '35 45 60',+ '--port-accent': '56 189 248',+ '--port-success': '34 197 94',+ '--port-warning': '245 158 11',+ '--port-error': '248 113 113',+ '--port-text': '210 225 240',+ '--port-text-muted': '140 160 185',+ '--port-focus-ring': '56 189 248',+ },+ },+ synthwave: {+ label: 'Synthwave',+ accent: '#c084fc',+ colors: {+ '--port-bg': '16 10 20',+ '--port-card': '28 18 35',+ '--port-border': '50 32 60',+ '--port-accent': '192 132 252',+ '--port-success': '74 222 128',+ '--port-warning': '251 191 36',+ '--port-error': '251 113 133',+ '--port-text': '230 215 240',+ '--port-text-muted': '170 140 190',+ '--port-focus-ring': '192 132 252',+ },+ },+};++const applyTheme = (id) => {+ const theme = THEMES[id] ?? THEMES.midnight;+ const style = document.documentElement.style;+ for (const [prop, value] of Object.entries(theme.colors)) {+ style.setProperty(prop, value);+ }+};++const loadTheme = () => {+ const saved = localStorage.getItem(STORAGE_KEY);+ return saved && THEMES[saved] ? saved : 'midnight';+};++export { THEMES, applyTheme };++export default function useTheme() {+ const [themeId, setThemeId] = useState(() => {+ const id = loadTheme();+ applyTheme(id);+ return id;+ });++ const setTheme = useCallback((id) => {+ if (!THEMES[id]) return;+ localStorage.setItem(STORAGE_KEY, id);+ applyTheme(id);+ setThemeId(id);+ }, []);++ return { themeId, theme: THEMES[themeId], themes: THEMES, setTheme };+}diff --git a/client/src/index.css b/client/src/index.cssindex 854a470cca..13a7c3fb38 100644--- a/client/src/index.css+++ b/client/src/index.css@@ -2,6 +2,20 @@@tailwind components;@tailwind utilities;+/* Default theme CSS vars (Midnight) — overridden by JS on load */+:root {+ --port-bg: 15 15 15;+ --port-card: 26 26 26;+ --port-border: 42 42 42;+ --port-accent: 59 130 246;+ --port-success: 34 197 94;+ --port-warning: 245 158 11;+ --port-error: 239 68 68;+ --port-text: 229 229 229;+ --port-text-muted: 163 163 163;+ --port-focus-ring: 59 130 246;+}+/* Geist Pixel font for CyberCity */@font-face {font-family: 'GeistPixelSquare';@@ -34,8 +48,8 @@ html, body, #root {}body {- background-color: #0f0f0f;- color: #e5e5e5;+ background-color: rgb(var(--port-bg));+ color: rgb(var(--port-text));font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;}@@ -46,7 +60,7 @@ body {/* Accessibility: Global focus styles for keyboard navigation */*:focus-visible {- outline: 2px solid #3b82f6;+ outline: 2px solid rgb(var(--port-focus-ring));outline-offset: 2px;}@@ -60,9 +74,9 @@ button:focus-visible,a:focus-visible,[role="button"]:focus-visible,[tabindex="0"]:focus-visible {- outline: 2px solid #3b82f6;+ outline: 2px solid rgb(var(--port-focus-ring));outline-offset: 2px;- box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);+ box-shadow: 0 0 0 4px rgb(var(--port-focus-ring) / 0.2);}/* Accessibility: Ensure disabled elements are perceivable but not interactive */@@ -90,7 +104,7 @@ a:focus-visible,}::-webkit-scrollbar-track {- background: #1a1a1a;+ background: rgb(var(--port-card));}::-webkit-scrollbar-thumb {diff --git a/client/src/main.jsx b/client/src/main.jsxindex 6fc1901dd5..6da4c5401e 100644--- a/client/src/main.jsx+++ b/client/src/main.jsx@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client';import { BrowserRouter } from 'react-router-dom';import { Toaster } from 'react-hot-toast';import ErrorBoundary from './components/ErrorBoundary';+import { ThemeProvider } from './components/ThemeContext';import App from './App';import './index.css';@@ -20,19 +21,21 @@ window.addEventListener('error', (event) => {ReactDOM.createRoot(document.getElementById('root')).render(<React.StrictMode><ErrorBoundary>- <BrowserRouter>- <App />- <Toaster- position="bottom-right"- toastOptions={{- style: {- background: '#1e1e2e',- color: '#fff',- border: '1px solid #313244'- }- }}- />- </BrowserRouter>+ <ThemeProvider>+ <BrowserRouter>+ <App />+ <Toaster+ position="bottom-right"+ toastOptions={{+ style: {+ background: 'rgb(var(--port-card))',+ color: 'rgb(var(--port-text))',+ border: '1px solid rgb(var(--port-border))'+ }+ }}+ />+ </BrowserRouter>+ </ThemeProvider></ErrorBoundary></React.StrictMode>);diff --git a/client/src/pages/Shell.jsx b/client/src/pages/Shell.jsxindex fff4fb1501..e958e3460f 100644--- a/client/src/pages/Shell.jsx+++ b/client/src/pages/Shell.jsx@@ -6,6 +6,15 @@ import '@xterm/xterm/css/xterm.css';import { useSocket } from '../hooks/useSocket';import { RefreshCw, Power, PowerOff } from 'lucide-react';+// Read a CSS custom property as hex (e.g., '--port-bg' → '#0f0f0f')+const getThemeHex = (varName) => {+ const raw = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();+ if (!raw) return '#000000';+ const parts = raw.split(' ').map(Number);+ if (parts.length !== 3) return '#000000';+ return '#' + parts.map(n => n.toString(16).padStart(2, '0')).join('');+};+export default function Shell() {const terminalRef = useRef(null);const termInstanceRef = useRef(null);@@ -18,25 +27,33 @@ export default function Shell() {useEffect(() => {if (!terminalRef.current || termInstanceRef.current) return;+ const bg = getThemeHex('--port-bg');+ const fg = getThemeHex('--port-text');+ const accent = getThemeHex('--port-accent');+ const card = getThemeHex('--port-card');+ const error = getThemeHex('--port-error');+ const success = getThemeHex('--port-success');+ const warning = getThemeHex('--port-warning');+const term = new Terminal({cursorBlink: true,cursorStyle: 'block',fontSize: 14,fontFamily: '"Roboto Mono for Powerline", "MesloLGS NF", "MesloLGS Nerd Font", "Hack Nerd Font", "FiraCode Nerd Font", "JetBrainsMono Nerd Font", Menlo, Monaco, "Courier New", monospace',theme: {- background: '#0f0f0f',- foreground: '#e5e5e5',- cursor: '#3b82f6',- cursorAccent: '#0f0f0f',- selectionBackground: '#3b82f640',- black: '#1a1a1a',- red: '#ef4444',- green: '#22c55e',- yellow: '#f59e0b',- blue: '#3b82f6',+ background: bg,+ foreground: fg,+ cursor: accent,+ cursorAccent: bg,+ selectionBackground: accent + '40',+ black: card,+ red: error,+ green: success,+ yellow: warning,+ blue: accent,magenta: '#a855f7',cyan: '#06b6d4',- white: '#e5e5e5',+ white: fg,brightBlack: '#404040',brightRed: '#f87171',brightGreen: '#4ade80',diff --git a/client/tailwind.config.js b/client/tailwind.config.jsindex 8a444976f9..abc7cb6052 100644--- a/client/tailwind.config.js+++ b/client/tailwind.config.js@@ -7,13 +7,13 @@ export default {theme: {extend: {colors: {- 'port-bg': '#0f0f0f',- 'port-card': '#1a1a1a',- 'port-border': '#2a2a2a',- 'port-accent': '#3b82f6',- 'port-success': '#22c55e',- 'port-warning': '#f59e0b',- 'port-error': '#ef4444'+ 'port-bg': 'rgb(var(--port-bg) / <alpha-value>)',+ 'port-card': 'rgb(var(--port-card) / <alpha-value>)',+ 'port-border': 'rgb(var(--port-border) / <alpha-value>)',+ 'port-accent': 'rgb(var(--port-accent) / <alpha-value>)',+ 'port-success': 'rgb(var(--port-success) / <alpha-value>)',+ 'port-warning': 'rgb(var(--port-warning) / <alpha-value>)',+ 'port-error': 'rgb(var(--port-error) / <alpha-value>)',},keyframes: {scanline: {diff --git a/package-lock.json b/package-lock.jsonindex c5ed85de36..68fcd269ee 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,16 @@{"name": "portos",- "version": "0.20.5",+ "version": "0.21.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "portos",+<<<<<<< HEAD"version": "0.20.5",+=======+ "version": "0.21.0",+>>>>>>> bebf89b (feat: add theme switcher with 5 dark themes)"license": "MIT","workspaces": ["packages/*",diff --git a/package.json b/package.jsonindex cc8b6ff808..67fddb2b0b 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "portos",- "version": "0.20.5",+ "version": "0.21.0","private": true,"description": "Local dev machine App OS portal","author": "Adam Eivy (@antic|@atomantic)",