7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
feat: theme follows the dashboard, dashboard window vibrancy, green chart
Tashfeenab3d2ee226a8
diff --git a/renderer/popover.html b/renderer/popover.htmlindex 02819584..1a6a2164 100644--- a/renderer/popover.html+++ b/renderer/popover.html@@ -3,19 +3,46 @@<head><meta charset="UTF-8" /><style>+ /* Theme variables: dark by default (deep black glass), body.light flips+ them. The theme is driven by the dashboard's toggle via main.ts. */:root {--fg: rgba(255, 255, 255, 0.92);--fg-dim: rgba(255, 255, 255, 0.55);--fg-faint: rgba(255, 255, 255, 0.32);--hairline: rgba(255, 255, 255, 0.10);+ --card: rgba(255, 255, 255, 0.055);+ --card-edge: rgba(255, 255, 255, 0.10);+ --ghost: rgba(255, 255, 255, 0.08);+ --ghost-hover: rgba(255, 255, 255, 0.13);+ --switch-off: rgba(255, 255, 255, 0.16);+ --sheen: rgba(255, 255, 255, 0.12);+ --zero-bar: rgba(255, 255, 255, 0.10);--accent: #6aa6ff;--accent-2: #8e7bff;--ok: #34c759;+ --panel-tint: linear-gradient(180deg, rgba(12,12,15,0.62), rgba(0,0,2,0.72));+ --panel-solid: linear-gradient(180deg, #19191d, #0a0a0d);+ }+ body.light {+ --fg: rgba(20, 20, 24, 0.92);+ --fg-dim: rgba(20, 20, 24, 0.56);+ --fg-faint: rgba(20, 20, 24, 0.34);+ --hairline: rgba(0, 0, 0, 0.10);+ --card: rgba(0, 0, 0, 0.05);+ --card-edge: rgba(255, 255, 255, 0.45);+ --ghost: rgba(0, 0, 0, 0.06);+ --ghost-hover: rgba(0, 0, 0, 0.10);+ --switch-off: rgba(0, 0, 0, 0.14);+ --sheen: rgba(255, 255, 255, 0.55);+ --zero-bar: rgba(0, 0, 0, 0.10);+ --ok: #1ea83f;+ --panel-tint: linear-gradient(180deg, rgba(255,255,255,0.38), rgba(244,244,247,0.46));+ --panel-solid: linear-gradient(180deg, #f4f4f6, #e9e9ee);}* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }/* The window itself is the panel: native rounded corners + vibrancy showthrough everywhere the page stays (near-)transparent. CSS adds only a- whisper of tint and the gloss sheen. */+ tint and the gloss sheen. */html, body { background: transparent; height: 100%; }body {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;@@ -25,19 +52,17 @@.panel {position: relative;height: 100%;- /* Dark glass: deep tint over the hud material — blur stays visible,- but the panel always reads black for the light text. */- background: linear-gradient(180deg, rgba(22,22,26,0.50), rgba(8,8,12,0.58));- box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);+ background: var(--panel-tint);+ box-shadow: inset 0 1px 0 var(--card-edge);overflow: hidden;padding: 14px 14px 12px;}- body.no-vibrancy .panel { background: linear-gradient(180deg, #2c2c31, #1d1d21); }+ body.no-vibrancy .panel { background: var(--panel-solid); }/* gloss sheen */.panel::before {content: "";position: absolute; inset: 0 0 auto 0; height: 110px;- background: radial-gradient(120% 100% at 50% -20%, rgba(255,255,255,0.12), rgba(255,255,255,0) 70%);+ background: radial-gradient(120% 100% at 50% -20%, var(--sheen), rgba(255,255,255,0) 70%);pointer-events: none;}@@ -63,8 +88,8 @@.stat {flex: 1; padding: 9px 11px 8px;border-radius: 12px;- background: rgba(255,255,255,0.055);- box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.10);+ background: var(--card);+ box-shadow: inset 0 0.5px 0 var(--card-edge);}.stat .v { font-size: 19px; font-weight: 650; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }.stat .l { font-size: 10px; color: var(--fg-dim); margin-top: 1px; text-transform: uppercase; letter-spacing: 0.5px; }@@ -99,17 +124,17 @@.primary:hover { filter: brightness(1.07); }.ghost {flex: 1; padding: 8px 4px;- background: rgba(255,255,255,0.08);- box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.12);+ background: var(--ghost);+ box-shadow: inset 0 0.5px 0 var(--card-edge);color: var(--fg);}- .ghost:hover { background: rgba(255,255,255,0.13); }+ .ghost:hover { background: var(--ghost-hover); }.ghost.copied { color: var(--ok); }.foot { display: flex; align-items: center; font-size: 11.5px; color: var(--fg-dim); }.switch {position: relative; width: 30px; height: 18px; border-radius: 9px;- background: rgba(255,255,255,0.16); margin-right: 7px; flex: none;+ background: var(--switch-off); margin-right: 7px; flex: none;transition: background 0.18s ease; cursor: pointer;box-shadow: inset 0 1px 2px rgba(0,0,0,0.25);}@@ -192,13 +217,14 @@const bw = (cssW - gap * (n - 1)) / n;const max = Math.max(...hourly, 1);const grad = ctx.createLinearGradient(0, 0, 0, cssH);- grad.addColorStop(0, 'rgba(142,123,255,0.95)');- grad.addColorStop(1, 'rgba(106,166,255,0.55)');+ grad.addColorStop(0, 'rgba(48,209,88,0.95)');+ grad.addColorStop(1, 'rgba(52,199,89,0.45)');+ const zeroBar = getComputedStyle(document.body).getPropertyValue('--zero-bar').trim();for (let i = 0; i < n; i++) {const v = hourly[i];const h = v === 0 ? 2 : Math.max(3, (v / max) * (cssH - 6));const x = i * (bw + gap), y = cssH - h;- ctx.fillStyle = v === 0 ? 'rgba(255,255,255,0.10)' : grad;+ ctx.fillStyle = v === 0 ? zeroBar : grad;ctx.beginPath();ctx.roundRect(x, y, bw, h, Math.min(3, bw / 2));ctx.fill();@@ -209,6 +235,7 @@let loginOn = false;async function refresh() {const s = await window.freeapi.snapshot();+ document.body.classList.toggle('light', s.theme === 'light');$('addr').textContent = '127.0.0.1:' + s.port;$('reqs').textContent = fmt(s.requests);$('tokens').textContent = fmt(s.tokens);diff --git a/src/config.ts b/src/config.tsindex a47f9027..3b236bce 100644--- a/src/config.ts+++ b/src/config.ts@@ -4,6 +4,7 @@ import { app } from 'electron';export interface DesktopConfig {port?: number;+ theme?: 'dark' | 'light';}function configPath(): string {diff --git a/src/main.ts b/src/main.tsindex db9a88b2..832d9b09 100644--- a/src/main.ts+++ b/src/main.ts@@ -1,6 +1,6 @@import path from 'node:path';import { fileURLToPath } from 'node:url';-import { app, dialog, ipcMain, clipboard } from 'electron';+import { app, dialog, ipcMain, clipboard, nativeTheme } from 'electron';import { startServer, ensureSessionToken, getUnifiedApiKey } from './server.mjs';import { loadConfig, saveConfig } from './config.js';import { buildTray } from './tray.js';@@ -20,6 +20,15 @@ if (!app.requestSingleInstanceLock()) {} else {let resolvedPort = DEFAULT_PORT;let sessionToken = '';+ // The dashboard owns the theme (its navbar toggle); the popover and the+ // window vibrancy follow. Last choice persists in config; before the+ // dashboard has ever reported, fall back to the system appearance —+ // matching the dashboard's own prefers-color-scheme default.+ let theme: 'dark' | 'light' =+ (process.env.FREEAPI_THEME as 'dark' | 'light' | undefined) // dev-only screenshot override+ ?? loadConfig().theme+ ?? (nativeTheme.shouldUseDarkColors ? 'dark' : 'light');+ nativeTheme.themeSource = theme;app.on('second-instance', () => {if (sessionToken) openDashboard(resolvedPort, sessionToken);@@ -39,8 +48,19 @@ if (!app.requestSingleInstanceLock()) {successRate: successRateToday(),hourly: hourlyRequests(),loginItem: app.getLoginItemSettings().openAtLogin,+ theme,};});+ ipcMain.on('freeapi:theme-changed', async (_e, next: 'dark' | 'light') => {+ if (next !== 'dark' && next !== 'light') return;+ if (next === theme) return;+ theme = next;+ saveConfig({ ...loadConfig(), theme });+ // Flips the vibrancy materials (popover glass + dashboard backdrop).+ nativeTheme.themeSource = theme;+ const { getPopoverWindow } = await import('./popover.js');+ getPopoverWindow()?.webContents.send('freeapi:refresh');+ });ipcMain.handle('freeapi:open-dashboard', () => openDashboard(resolvedPort, sessionToken));ipcMain.handle('freeapi:copy-base-url', () => clipboard.writeText(`http://127.0.0.1:${resolvedPort}/v1`));ipcMain.handle('freeapi:copy-api-key', () => clipboard.writeText(getUnifiedApiKey()));@@ -88,6 +108,19 @@ if (!app.requestSingleInstanceLock()) {const pop = getPopoverWindow();pop?.removeAllListeners('blur'); // stay open unfocusedif (pop) fs.writeFileSync('/tmp/freeapi-popover-bounds.json', JSON.stringify(pop.getBounds()));+ // FREEAPI_THEME forces a theme for captures — skip the dashboard+ // then, or its theme report would immediately override the override.+ if (!process.env.FREEAPI_THEME) {+ openDashboard(port, sessionToken);+ await sleep(2500);+ const dashWin = getDashboardWindow();+ if (dashWin) {+ dashWin.show();+ dashWin.focus();+ dashWin.moveTop();+ fs.writeFileSync('/tmp/freeapi-dashboard-bounds.json', JSON.stringify(dashWin.getBounds()));+ }+ }return;}await sleep(1500);diff --git a/src/popover.ts b/src/popover.tsindex b3bc48b9..56352829 100644--- a/src/popover.ts+++ b/src/popover.ts@@ -31,10 +31,11 @@ function createPopover(): BrowserWindow {alwaysOnTop: true,...(process.platform === 'darwin'? {- // 'hud' renders the DARK glass variant regardless of the system- // light/dark appearance — 'popover' follows the system theme and- // turns white under light mode, fighting the panel's light text.- vibrancy: 'hud' as const,+ // 'popover' follows the app appearance, which main.ts pins via+ // nativeTheme.themeSource to the DASHBOARD's theme choice — so the+ // glass flips dark/light together with the dashboard. The dark+ // variant is deepened toward black by the panel's CSS tint.+ vibrancy: 'popover' as const,visualEffectState: 'active' as const,backgroundColor: '#00000000',}diff --git a/src/preload.ts b/src/preload.tsindex 1d858b4f..2d302a2e 100644--- a/src/preload.ts+++ b/src/preload.ts@@ -3,7 +3,7 @@// token into localStorage so AuthGate's very first /api/auth/status call is// authenticated. The token arrives via additionalArguments (process.argv),// which avoids templating strings into executeJavaScript.-import { contextBridge } from 'electron';+import { contextBridge, ipcRenderer } from 'electron';const TOKEN_KEY = 'freellmapi_dashboard_token';const arg = process.argv.find((a) => a.startsWith('--freeapi-token='));@@ -18,3 +18,27 @@ if (arg) {// Lets the client adapt its chrome (drag region, traffic-light padding,// no Sign out) when running inside the desktop shell.contextBridge.exposeInMainWorld('__FREEAPI_DESKTOP__', true);++// `desktop` class before page styles paint → the client's translucent+// desktop backdrop applies from the first frame (window vibrancy shows+// through, no opaque flash).+document.documentElement.classList.add('desktop');++// Mirror the dashboard's theme to the main process so the tray popover+// matches. The dashboard expresses its theme as the `dark` class on+// documentElement (set by the early script in index.html and toggled by+// the navbar) — observe that class rather than reaching across worlds+// into localStorage.+function reportTheme() {+ ipcRenderer.send(+ 'freeapi:theme-changed',+ document.documentElement.classList.contains('dark') ? 'dark' : 'light',+ );+}+window.addEventListener('DOMContentLoaded', () => {+ reportTheme();+ new MutationObserver(reportTheme).observe(document.documentElement, {+ attributes: true,+ attributeFilter: ['class'],+ });+});diff --git a/src/window.ts b/src/window.tsindex b63b41bc..b7a75f58 100644--- a/src/window.ts+++ b/src/window.ts@@ -28,11 +28,19 @@ export function openDashboard(port: number, token: string): void {minHeight: 480,title: 'FreeLLMAPI',// Native feel: traffic lights float over the app's own header (the client- // adds a drag region + left padding when it detects the desktop shell).+ // adds a drag region + left padding when it detects the desktop shell),+ // and the window carries an under-window vibrancy so the client's+ // slightly-translucent desktop backdrop (html.desktop in index.css)+ // picks up a hint of the same glass as the tray popover. The material+ // follows nativeTheme.themeSource, i.e. the dashboard's own theme....(process.platform === 'darwin'- ? { titleBarStyle: 'hiddenInset' as const }- : {}),- backgroundColor: '#09090b',+ ? {+ titleBarStyle: 'hiddenInset' as const,+ vibrancy: 'under-window' as const,+ visualEffectState: 'followWindow' as const,+ backgroundColor: '#00000000',+ }+ : { backgroundColor: '#09090b' }),webPreferences: {preload: path.join(__dirname, 'preload.cjs'),contextIsolation: true,