feat(webui): refine system navigation and appearance

This commit is contained in:
sam committed 2026-09-21 00:45:02 +10:00
1 parent 569d01c151
commit fffa6bc528
21 files changed
+433 -169

No files matched your search

+12 -2
View File
@@ -1,7 +1,13 @@
<script setup lang="ts">
import { ChevronDown } from "@lucide/vue";
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import type { NavEntry } from "@/lib/nav";
import NavItem from "./NavItem.vue";
import NavTrigger from "./NavTrigger.vue";
@@ -20,7 +26,11 @@ const holds = (path: string) => props.activePath === path;
</NavTrigger>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="w-52">
<NavItem v-for="item in items" :key="item.path" :entry="item" :current="holds(item.path)" />
<template v-for="item in items" :key="item.path">
<DropdownMenuSeparator v-if="item.dividerBefore" />
<DropdownMenuLabel v-if="item.dividerBefore">{{ item.dividerBefore }}</DropdownMenuLabel>
<NavItem :entry="item" :current="holds(item.path)" />
</template>
</DropdownMenuContent>
</DropdownMenu>
</template>
+3 -1
View File
@@ -1,12 +1,14 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import type { TooltipRootEmits, TooltipRootProps } from 'reka-ui'
import { TooltipRoot, useForwardPropsEmits } from 'reka-ui'
import { tooltipsEnabled } from '@/lib/preferences'
import { useAppearanceStore } from '@/stores/appearance'
const props = defineProps<TooltipRootProps>()
const emits = defineEmits<TooltipRootEmits>()
const forwarded = useForwardPropsEmits(props, emits)
const { tooltipsEnabled } = storeToRefs(useAppearanceStore())
</script>
<template>
+14 -2
View File
@@ -5,6 +5,7 @@ export interface NavEntry {
label: string;
description: string;
section?: string;
dividerBefore?: string;
soon?: boolean;
}
@@ -34,7 +35,13 @@ const table = routes as Array<{ path: string; meta?: RouteMeta }>;
// The group owns the context, so the items inside it are named for what they
// are rather than what they belong to. Order is the reading order of the menu.
const groups: Array<{ label: string; paths: string[] }> = [
interface GroupSpec {
label: string;
paths: string[];
dividerBefore?: { path: string; label: string };
}
const groups: GroupSpec[] = [
{ label: "Work", paths: ["/tasks", "/workflows"] },
{ label: "Agent", paths: ["/skills", "/curators"] },
{ label: "Events", paths: ["/captures", "/mappings", "/bindings"] },
@@ -50,6 +57,7 @@ const groups: Array<{ label: string; paths: string[] }> = [
"/channels",
"/system/advanced",
],
dividerBefore: { path: "/system/tasks", label: "Settings" },
},
];
@@ -75,7 +83,11 @@ export function navTree(hidden: string[] = []): NavNode[] {
const nodes: NavNode[] = [{ kind: "link", entry: entryFor("/") }];
for (const group of groups) {
const items = group.paths.map(entryFor).filter(visible);
if (items.length > 0) nodes.push({ kind: "group", label: group.label, items });
const divided = items.map((item) => ({
...item,
dividerBefore: item.path === group.dividerBefore?.path ? group.dividerBefore.label : undefined,
}));
if (divided.length > 0) nodes.push({ kind: "group", label: group.label, items: divided });
}
return nodes;
}
-26
View File
@@ -1,26 +0,0 @@
import { ref, type Ref } from "vue";
export const TOOLTIPS_KEY = "archie.tooltips";
export function storedTooltips(): boolean {
try {
return localStorage.getItem(TOOLTIPS_KEY) !== "off";
} catch {
// Private windows and blocked site data throw on access. On is the
// default, so this is not worth surfacing.
return true;
}
}
const current = ref<boolean>(storedTooltips());
/** The live preference, shared app-wide. Change it through `setTooltips`. */
export const tooltipsEnabled: Ref<boolean> = current;
export function setTooltips(enabled: boolean): void {
current.value = enabled;
try {
localStorage.setItem(TOOLTIPS_KEY, enabled ? "on" : "off");
} catch {
// Still applies for this page view; only persistence is lost.
}
}
-50
View File
@@ -1,50 +0,0 @@
import { ref, type Ref } from "vue";
/**
* The theme is an attribute on <html>, not a class, because index.html sets it
* from localStorage before the first paint. Everything downstream reads the CSS
* variables once that attribute is present, so nothing in the app branches on
* the theme itself.
*/
export const THEME_KEY = "archie.theme";
export type Theme = "dark" | "light";
export function isTheme(value: unknown): value is Theme {
return value === "dark" || value === "light";
}
/** Dark is the default: archied is a daemon you check at odd hours. */
export function storedTheme(): Theme {
try {
const stored = localStorage.getItem(THEME_KEY);
return isTheme(stored) ? stored : "dark";
} catch {
// Private windows and blocked site data throw on access. The default is
// correct there, so this is not worth surfacing.
return "dark";
}
}
export function applyTheme(theme: Theme): void {
document.documentElement.dataset.theme = theme;
try {
localStorage.setItem(THEME_KEY, theme);
} catch {
// The theme still applies for this page view; only persistence is lost.
}
}
const current = ref<Theme>(storedTheme());
/** The live theme, shared app-wide. Apply it through `setTheme` or `toggleTheme`. */
export const theme: Ref<Theme> = current;
export function setTheme(next: Theme): void {
current.value = next;
applyTheme(next);
}
export function toggleTheme(): void {
setTheme(current.value === "dark" ? "light" : "dark");
}
+8 -1
View File
@@ -1,12 +1,19 @@
import "./legacy-hash-redirect";
import { createPinia } from "pinia";
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import { useAppearanceStore } from "./stores/appearance";
// One stylesheet: the design tokens, and the element defaults that have no
// component to live in (the canvas, the focus floor, the motion preference).
// Everything else is Tailwind on the component that owns it.
import "./style.css";
createApp(App).use(router).mount("#app");
const app = createApp(App);
const pinia = createPinia();
app.use(pinia).use(router);
useAppearanceStore(pinia).initialize();
app.mount("#app");
+103 -10
View File
@@ -1,22 +1,115 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import ThemeCard from "./ThemeCard.vue";
import TooltipCard from "./TooltipCard.vue";
import { Switch } from "@/components/ui/switch";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import {
type Density,
type Motion,
type Theme,
useAppearanceStore,
} from "@/stores/appearance";
import ConfigCard from "./ConfigCard.vue";
const appearance = useAppearanceStore();
const { density, motion, theme, tooltipsEnabled } = storeToRefs(appearance);
const { setDensity, setMotion, setTheme, setTooltips } = appearance;
/**
* Appearance: how the dashboard looks, on this browser.
*
* The theme control moved here out of the topbar icon
* (docs/prds/dashboard-navigation-groups.md). These are all browser-local:
* there is no daemon-side appearance, so nothing on this page is submitted.
* The density and motion preferences the design names are still to come.
* These preferences are browser-local and apply immediately. They are grouped
* into one bounded surface so labels and controls can be read together instead
* of making the operator scan opposite edges of several full-width cards.
*/
function chooseTheme(value: unknown): void {
if (value === "system" || value === "light" || value === "dark") setTheme(value as Theme);
}
function chooseDensity(value: unknown): void {
if (value === "comfortable" || value === "compact") setDensity(value as Density);
}
function chooseMotion(value: unknown): void {
if (value === "system" || value === "reduced") setMotion(value as Motion);
}
</script>
<template>
<div>
<PageHeader title="Appearance" />
<ThemeCard />
<TooltipCard />
<div class="max-w-4xl">
<PageHeader title="Appearance" subtitle="How this dashboard looks and responds in this browser." />
<ConfigCard title="Dashboard preferences" description="Saved only in this browser and applied immediately.">
<div class="grid gap-8 min-[700px]:grid-cols-2">
<section class="flex min-w-0 flex-col items-start">
<div>
<h2 id="appearance-theme" class="text-sm font-medium">Theme</h2>
<p class="mt-1 text-sm text-muted-foreground">Follow your device, or keep Archie light or dark.</p>
</div>
<ToggleGroup
type="single"
variant="outline"
:model-value="theme"
class="mt-4"
aria-labelledby="appearance-theme"
@update:model-value="chooseTheme"
>
<ToggleGroupItem value="system">System</ToggleGroupItem>
<ToggleGroupItem value="light">Light</ToggleGroupItem>
<ToggleGroupItem value="dark">Dark</ToggleGroupItem>
</ToggleGroup>
</section>
<section class="flex min-w-0 flex-col items-start">
<div>
<h2 id="appearance-density" class="text-sm font-medium">Density</h2>
<p class="mt-1 text-sm text-muted-foreground">Use relaxed spacing, or fit more work on screen.</p>
</div>
<ToggleGroup
type="single"
variant="outline"
:model-value="density"
class="mt-4"
aria-labelledby="appearance-density"
@update:model-value="chooseDensity"
>
<ToggleGroupItem value="comfortable">Comfortable</ToggleGroupItem>
<ToggleGroupItem value="compact">Compact</ToggleGroupItem>
</ToggleGroup>
</section>
<section class="flex min-w-0 flex-col items-start">
<div>
<h2 id="appearance-motion" class="text-sm font-medium">Motion</h2>
<p class="mt-1 text-sm text-muted-foreground">Follow your device, or reduce interface animation here.</p>
</div>
<ToggleGroup
type="single"
variant="outline"
:model-value="motion"
class="mt-4"
aria-labelledby="appearance-motion"
@update:model-value="chooseMotion"
>
<ToggleGroupItem value="system">System</ToggleGroupItem>
<ToggleGroupItem value="reduced">Reduced</ToggleGroupItem>
</ToggleGroup>
</section>
<section class="flex min-w-0 flex-col items-start">
<div>
<h2 id="appearance-tooltips" class="text-sm font-medium">Tooltips</h2>
<p class="mt-1 text-sm text-muted-foreground">Show extra context when controls are hovered or focused.</p>
</div>
<Switch
:model-value="tooltipsEnabled"
class="mt-4"
aria-labelledby="appearance-tooltips"
@update:model-value="setTooltips"
/>
</section>
</div>
</ConfigCard>
</div>
</template>
-30
View File
@@ -1,30 +0,0 @@
<script setup lang="ts">
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import { setTheme, theme, type Theme } from "@/lib/theme";
import ConfigCard from "./ConfigCard.vue";
/**
* The theme control, moved off the topbar icon and onto a page of its own so
* the chrome carries no preference.
*
* It writes through lib/theme, which sets the attribute index.html reads before
* the first paint and stores the choice in this browser: there is no
* server-side appearance to save, and nothing here to submit. The density and
* motion preferences this page exists for are not built yet
* (docs/prds/dashboard-navigation-groups.md).
*/
function apply(value: unknown): void {
if (value === "light" || value === "dark") setTheme(value as Theme);
}
</script>
<template>
<ConfigCard title="Theme">
<div class="flex justify-end">
<ToggleGroup :model-value="theme" aria-label="Theme" @update:model-value="apply">
<ToggleGroupItem value="dark">Dark</ToggleGroupItem>
<ToggleGroupItem value="light">Light</ToggleGroupItem>
</ToggleGroup>
</div>
</ConfigCard>
</template>
-14
View File
@@ -1,14 +0,0 @@
<script setup lang="ts">
import { Switch } from "@/components/ui/switch";
import { setTooltips, tooltipsEnabled } from "@/lib/preferences";
import ConfigCard from "./ConfigCard.vue";
</script>
<template>
<ConfigCard title="Tooltips">
<div class="flex justify-end">
<Switch aria-label="Tooltips" :model-value="tooltipsEnabled" @update:model-value="setTooltips" />
</div>
</ConfigCard>
</template>
+101
View File
@@ -0,0 +1,101 @@
import { defineStore } from "pinia";
import { ref } from "vue";
export const THEME_KEY = "archie.theme";
export const DENSITY_KEY = "archie.density";
export const MOTION_KEY = "archie.motion";
export const TOOLTIPS_KEY = "archie.tooltips";
export type Theme = "system" | "dark" | "light";
export type Density = "comfortable" | "compact";
export type Motion = "system" | "reduced";
type ResolvedTheme = Exclude<Theme, "system">;
function storedChoice<T extends string>(key: string, choices: readonly T[], fallback: T): T {
try {
const value = localStorage.getItem(key);
return choices.includes(value as T) ? (value as T) : fallback;
} catch {
return fallback;
}
}
function persist(key: string, value: string): void {
try {
localStorage.setItem(key, value);
} catch {
// The preference still applies for this page view; only persistence is lost.
}
}
function resolveTheme(preference: Theme): ResolvedTheme {
if (preference !== "system") return preference;
try {
return matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
} catch {
return "dark";
}
}
export const useAppearanceStore = defineStore("appearance", () => {
const theme = ref<Theme>(storedChoice(THEME_KEY, ["system", "dark", "light"], "dark"));
const density = ref<Density>(storedChoice(DENSITY_KEY, ["comfortable", "compact"], "comfortable"));
const motion = ref<Motion>(storedChoice(MOTION_KEY, ["system", "reduced"], "system"));
const tooltipsEnabled = ref(storedChoice(TOOLTIPS_KEY, ["on", "off"], "on") === "on");
let initialized = false;
function applyTheme(): void {
document.documentElement.dataset.theme = resolveTheme(theme.value);
}
function setTheme(value: Theme): void {
theme.value = value;
applyTheme();
persist(THEME_KEY, value);
}
function setDensity(value: Density): void {
density.value = value;
document.documentElement.dataset.density = value;
persist(DENSITY_KEY, value);
}
function setMotion(value: Motion): void {
motion.value = value;
document.documentElement.dataset.motion = value;
persist(MOTION_KEY, value);
}
function setTooltips(enabled: boolean): void {
tooltipsEnabled.value = enabled;
persist(TOOLTIPS_KEY, enabled ? "on" : "off");
}
function initialize(): void {
if (initialized) return;
initialized = true;
applyTheme();
document.documentElement.dataset.density = density.value;
document.documentElement.dataset.motion = motion.value;
try {
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
if (theme.value === "system") applyTheme();
});
} catch {
// matchMedia is absent in older embedded views. The dark fallback stands.
}
}
return {
theme,
density,
motion,
tooltipsEnabled,
initialize,
setTheme,
setDensity,
setMotion,
setTooltips,
};
});
+14
View File
@@ -17,6 +17,13 @@
wrong palette. */
@custom-variant dark (&:is([data-theme="dark"] *));
/* Compact mode tightens the shared Tailwind spacing scale without shrinking
text or hit targets independently. Components keep their relative rhythm;
the whole workspace simply carries less air. */
[data-density="compact"] {
--spacing: 0.225rem;
}
/*
* Design tokens. Dark is the default because archied is a daemon you check at
* odd hours; light is a toggle, not an afterthought, so both themes define the
@@ -273,4 +280,11 @@
transition-duration: 0.01ms !important;
}
}
[data-motion="reduced"] *,
[data-motion="reduced"] *::before,
[data-motion="reduced"] *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}