mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
refactor: remove confirmed dead helpers
This commit is contained in:
@@ -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>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,6 @@ export function toNumber(value: string, fallback: number): number {
|
||||
return Number.isFinite(n) ? n : fallback;
|
||||
}
|
||||
|
||||
export function parseList(input: string): string[] {
|
||||
return input
|
||||
.split(/[,\n]/)
|
||||
.map((v) => v.trim())
|
||||
.filter((v) => v.length > 0);
|
||||
}
|
||||
|
||||
export function stripThinkingTags(value: string): string {
|
||||
return stripAssistantInternalScaffolding(value);
|
||||
}
|
||||
@@ -90,10 +83,3 @@ export function formatTokens(tokens: number | null | undefined, fallback = "0"):
|
||||
const m = tokens / 1_000_000;
|
||||
return m < 10 ? `${m.toFixed(1)}M` : `${Math.round(m)}M`;
|
||||
}
|
||||
|
||||
export function formatPercent(value: number | null | undefined, fallback = "—"): string {
|
||||
if (value == null || !Number.isFinite(value)) {
|
||||
return fallback;
|
||||
}
|
||||
return `${(value * 100).toFixed(1)}%`;
|
||||
}
|
||||
|
||||
@@ -152,8 +152,3 @@ export function resolveToolDisplay(params: {
|
||||
export function formatToolDetail(display: ToolDisplay): string | undefined {
|
||||
return formatToolDetailText(display.detail, { prefixWithWith: true });
|
||||
}
|
||||
|
||||
export function formatToolSummary(display: ToolDisplay): string {
|
||||
const detail = formatToolDetail(display);
|
||||
return detail ? `${display.label}: ${detail}` : display.label;
|
||||
}
|
||||
|
||||
@@ -139,10 +139,7 @@ const getSessionModels = (session: UsageSessionQueryTarget): string[] => {
|
||||
const getSessionTools = (session: UsageSessionQueryTarget): string[] =>
|
||||
(session.usage?.toolUsage?.tools ?? []).map((tool) => tool.name.toLowerCase());
|
||||
|
||||
export const matchesUsageQuery = (
|
||||
session: UsageSessionQueryTarget,
|
||||
term: UsageQueryTerm,
|
||||
): boolean => {
|
||||
const matchesUsageQuery = (session: UsageSessionQueryTarget, term: UsageQueryTerm): boolean => {
|
||||
const value = normalizeQueryText(term.value ?? "");
|
||||
if (!value) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user