Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
name="description"
content="Corbits Workbench: deploy, run, and supervise agents from one interface."
/>
<script>
// Paint in the saved theme before React mounts; theme-store.ts writes the key.
try {
var t = localStorage.getItem("corbits-theme:last");
var r = document.documentElement;
if (t === "dark" || t === "canvas") r.setAttribute("data-theme", t);
if (t === "dark") r.classList.add("dark");
r.style.colorScheme = t === "dark" ? "dark" : "light";
} catch (e) {}
</script>
<title>Corbits Workbench</title>
<link rel="icon" type="image/svg+xml" href="/corbits-favicon.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/theme-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function isTheme(value: unknown): value is Theme {
}

const DEFAULT_KEY = "corbits-theme";
// Unscoped copy of the last-set theme; the boot script in index.html reads it.
const LAST_KEY = "corbits-theme:last";

let storageKey = DEFAULT_KEY;
let current: Theme = "light";
Expand All @@ -33,6 +35,7 @@ function apply(theme: Theme) {
else root.setAttribute("data-theme", theme);
// react-ui's `dark:` variant keys off the class.
root.classList.toggle("dark", theme === "dark");
root.style.colorScheme = theme === "dark" ? "dark" : "light";
}

function commit(theme: Theme) {
Expand All @@ -53,6 +56,7 @@ export function setTheme(theme: Theme) {
commit(theme);
try {
window.localStorage.setItem(storageKey, theme);
window.localStorage.setItem(LAST_KEY, theme);
} catch (error) {
reportError(error, { operation: "theme_persist" });
}
Expand Down
Loading