|
|
|
|
@ -16,8 +16,7 @@ import { loadSessions } from "./controllers/sessions.ts";
|
|
|
|
|
import { icons } from "./icons.ts";
|
|
|
|
|
import { iconForTab, pathForTab, titleForTab, type Tab } from "./navigation.ts";
|
|
|
|
|
import { parseAgentSessionKey } from "./session-key.ts";
|
|
|
|
|
import type { ThemeTransitionContext } from "./theme-transition.ts";
|
|
|
|
|
import type { ThemeMode, ThemeName } from "./theme.ts";
|
|
|
|
|
import type { ThemeMode } from "./theme.ts";
|
|
|
|
|
import {
|
|
|
|
|
listThinkingLevelLabels,
|
|
|
|
|
normalizeThinkLevel,
|
|
|
|
|
@ -1088,13 +1087,6 @@ function resolveSessionScopedOptionLabel(
|
|
|
|
|
return base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ThemeOption = { id: ThemeName; label: string; icon: string };
|
|
|
|
|
const THEME_OPTIONS: ThemeOption[] = [
|
|
|
|
|
{ id: "claw", label: "Claw", icon: "🦀" },
|
|
|
|
|
{ id: "knot", label: "Knot", icon: "🪢" },
|
|
|
|
|
{ id: "dash", label: "Dash", icon: "📊" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
type ThemeModeOption = { id: ThemeMode; label: string; short: string };
|
|
|
|
|
const THEME_MODE_OPTIONS: ThemeModeOption[] = [
|
|
|
|
|
{ id: "system", label: "System", short: "SYS" },
|
|
|
|
|
@ -1102,10 +1094,6 @@ const THEME_MODE_OPTIONS: ThemeModeOption[] = [
|
|
|
|
|
{ id: "dark", label: "Dark", short: "DARK" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function currentThemeIcon(theme: ThemeName): string {
|
|
|
|
|
return THEME_OPTIONS.find((o) => o.id === theme)?.icon ?? "🎨";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function renderTopbarThemeModeToggle(state: AppViewState) {
|
|
|
|
|
const modeIcon = (mode: ThemeMode) => {
|
|
|
|
|
if (mode === "system") {
|
|
|
|
|
@ -1162,78 +1150,3 @@ export function renderSidebarConnectionStatus(state: AppViewState) {
|
|
|
|
|
></span>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function renderThemeToggle(state: AppViewState) {
|
|
|
|
|
const setOpen = (orb: HTMLElement, nextOpen: boolean) => {
|
|
|
|
|
orb.classList.toggle("theme-orb--open", nextOpen);
|
|
|
|
|
const trigger = orb.querySelector<HTMLButtonElement>(".theme-orb__trigger");
|
|
|
|
|
const menu = orb.querySelector<HTMLElement>(".theme-orb__menu");
|
|
|
|
|
if (trigger) {
|
|
|
|
|
trigger.setAttribute("aria-expanded", nextOpen ? "true" : "false");
|
|
|
|
|
}
|
|
|
|
|
if (menu) {
|
|
|
|
|
menu.setAttribute("aria-hidden", nextOpen ? "false" : "true");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const toggleOpen = (e: Event) => {
|
|
|
|
|
const orb = (e.currentTarget as HTMLElement).closest<HTMLElement>(".theme-orb");
|
|
|
|
|
if (!orb) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const isOpen = orb.classList.contains("theme-orb--open");
|
|
|
|
|
if (isOpen) {
|
|
|
|
|
setOpen(orb, false);
|
|
|
|
|
} else {
|
|
|
|
|
setOpen(orb, true);
|
|
|
|
|
const close = (ev: MouseEvent) => {
|
|
|
|
|
if (!orb.contains(ev.target as Node)) {
|
|
|
|
|
setOpen(orb, false);
|
|
|
|
|
document.removeEventListener("click", close);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
requestAnimationFrame(() => document.addEventListener("click", close));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const pick = (opt: ThemeOption, e: Event) => {
|
|
|
|
|
const orb = (e.currentTarget as HTMLElement).closest<HTMLElement>(".theme-orb");
|
|
|
|
|
if (orb) {
|
|
|
|
|
setOpen(orb, false);
|
|
|
|
|
}
|
|
|
|
|
if (opt.id !== state.theme) {
|
|
|
|
|
const context: ThemeTransitionContext = { element: orb ?? undefined };
|
|
|
|
|
state.setTheme(opt.id, context);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div class="theme-orb" aria-label="Theme">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="theme-orb__trigger"
|
|
|
|
|
title="Theme"
|
|
|
|
|
aria-haspopup="menu"
|
|
|
|
|
aria-expanded="false"
|
|
|
|
|
@click=${toggleOpen}
|
|
|
|
|
>
|
|
|
|
|
${currentThemeIcon(state.theme)}
|
|
|
|
|
</button>
|
|
|
|
|
<div class="theme-orb__menu" role="menu" aria-hidden="true">
|
|
|
|
|
${THEME_OPTIONS.map(
|
|
|
|
|
(opt) => html` <button
|
|
|
|
|
type="button"
|
|
|
|
|
class="theme-orb__option ${opt.id === state.theme ? "theme-orb__option--active" : ""}"
|
|
|
|
|
title=${opt.label}
|
|
|
|
|
role="menuitemradio"
|
|
|
|
|
aria-checked=${opt.id === state.theme}
|
|
|
|
|
aria-label=${opt.label}
|
|
|
|
|
@click=${(e: Event) => pick(opt, e)}
|
|
|
|
|
>
|
|
|
|
|
${opt.icon}
|
|
|
|
|
</button>`,
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|