ui: fix review follow-ups for dashboard tabs

This commit is contained in:
Val Alexander
2026-03-09 20:04:17 -05:00
parent 37a914bb88
commit 20100a0982
5 changed files with 24 additions and 13 deletions

View File

@@ -36,7 +36,7 @@ import {
} from "./navigation.ts";
import { saveSettings, type UiSettings } from "./storage.ts";
import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition.ts";
import { resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
import { colorSchemeForTheme, resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
import type { AgentsListResult } from "./types.ts";
type SettingsHost = {
@@ -273,7 +273,7 @@ export function applyResolvedTheme(host: SettingsHost, resolved: ResolvedTheme)
}
const root = document.documentElement;
root.dataset.theme = resolved;
root.style.colorScheme = resolved;
root.style.colorScheme = colorSchemeForTheme(resolved);
}
export function attachThemeListener(host: SettingsHost) {

View File

@@ -0,0 +1,9 @@
import { describe, expect, it } from "vitest";
import { TAB_GROUPS } from "./navigation.ts";
describe("TAB_GROUPS", () => {
it("does not expose unfinished settings slices in the sidebar", () => {
const settings = TAB_GROUPS.find((group) => group.label === "settings");
expect(settings?.tabs).toEqual(["config", "debug", "logs"]);
});
});

View File

@@ -10,16 +10,7 @@ export const TAB_GROUPS = [
{ label: "agent", tabs: ["agents", "skills", "nodes"] },
{
label: "settings",
tabs: [
"config",
"communications",
"appearance",
"automation",
"infrastructure",
"aiAgents",
"debug",
"logs",
],
tabs: ["config", "debug", "logs"],
},
] as const;

View File

@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { parseThemeSelection, resolveTheme } from "./theme.ts";
import { colorSchemeForTheme, parseThemeSelection, resolveTheme } from "./theme.ts";
describe("resolveTheme", () => {
it("keeps the legacy mode-only signature working for existing callers", () => {
@@ -17,6 +17,11 @@ describe("resolveTheme", () => {
expect(resolveTheme("knot")).toBe("openknot-light");
vi.unstubAllGlobals();
});
it("maps resolved theme families back to valid CSS color-scheme values", () => {
expect(colorSchemeForTheme("openknot")).toBe("dark");
expect(colorSchemeForTheme("dash-light")).toBe("light");
});
});
describe("parseThemeSelection", () => {

View File

@@ -91,3 +91,9 @@ export function resolveTheme(themeOrMode: ThemeName | ThemeMode, mode?: ThemeMod
}
return resolvedMode === "light" ? "dash-light" : "dash";
}
export function colorSchemeForTheme(theme: ResolvedTheme): "light" | "dark" {
return theme === "light" || theme === "openknot-light" || theme === "dash-light"
? "light"
: "dark";
}