mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-17 01:20:28 +00:00
refactor(dashboard): F4 — remove the legacy shell, Material font and Icon fallback (KEA-7886) (#17896)
refactor(dashboard): F4 — remove the legacy shell, Material font and Icon fallback (KEA-7886)
This commit is contained in:
@@ -132,7 +132,6 @@
|
||||
"lucide-react",
|
||||
"marked",
|
||||
"marked-terminal",
|
||||
"material-symbols",
|
||||
"mermaid",
|
||||
"monaco-editor",
|
||||
"next",
|
||||
|
||||
@@ -28,14 +28,16 @@ lastUpdated: 2026-10-20
|
||||
`globals.css`) and the legacy Tailwind `dark:` utilities key on the `.dark` class. There are no
|
||||
accent color presets: the accent always comes from the kit.
|
||||
- **Components.** `src/shared/components/*` keep the OmniRoute component API. `Button variant="primary"`
|
||||
paints with the bridged accent (`--grad-brand` → `--ci-color-accent`) and the kit's accent ink
|
||||
(`text-accent-foreground`); the `.ci-button--warning` and `.ci-badge[data-tone]` rules at the end of
|
||||
is the kit `default` button (`--ci-button-primary-*`: the inverse surface in light, the accent with
|
||||
its `--ci-color-accent-foreground` ink in dark); the `.ci-button--warning` and `.ci-badge[data-tone]` rules at the end of
|
||||
`globals.css` (`@layer components`) are OmniRoute extensions on top of the kit classes.
|
||||
- **Icons.** `<Icon name="material_name">` (`src/shared/components/Icon.tsx`) resolves the Material
|
||||
Symbols name through `ICON_MAP` (`src/shared/constants/iconMap.ts`) to a Lucide glyph; a name mapped to
|
||||
`null` falls back to the Material ligature (with a dev-only console warning). `npm run gen:icon-map`
|
||||
prints the names in use that are missing from the map (`tests/unit/icon-map-coverage.test.ts` fails on
|
||||
any missing entry); `scripts/dev/codemod-material-icons.mjs <dir|file>... [--write]` rewrites literal
|
||||
- **Icons.** `<Icon name="material_name">` (`src/shared/components/Icon.tsx`) resolves the name (the
|
||||
Material Symbols vocabulary the screens use) through `ICON_MAP` (`src/shared/constants/iconMap.ts`) to a
|
||||
Lucide glyph. The Material Symbols font and package are gone: a name missing from the map renders a
|
||||
neutral placeholder glyph (`data-icon-missing="true"`) and logs a console warning outside production.
|
||||
`npm run gen:icon-map` prints the names in use that are missing from the map
|
||||
(`tests/unit/icon-map-coverage.test.ts` fails on any name without a Lucide icon);
|
||||
`scripts/dev/codemod-material-icons.mjs <dir|file>... [--write]` rewrites literal
|
||||
`<span className="material-symbols-outlined">` spans to `<Icon>`.
|
||||
- **Brand.** `src/shared/components/OmniRouteLogo.tsx` wraps the kit: the default export `OmniRouteLogo`
|
||||
renders `ProductIcon product="omniroute" variant="glyph"` (inline SVG, `basePath`-safe) and
|
||||
|
||||
@@ -46,7 +46,7 @@ A boolean flag is considered **enabled** when its effective value is `"true"`,
|
||||
|
||||
## Flag Catalog
|
||||
|
||||
112 flags across 6 categories. **Default** is the definition default — the value
|
||||
111 flags across 6 categories. **Default** is the definition default — the value
|
||||
used when neither a DB override nor an environment variable is present.
|
||||
|
||||
### Security (10)
|
||||
@@ -111,13 +111,12 @@ used when neither a DB override nor an environment variable is present.
|
||||
| `RADAR_ENABLED` | boolean | `false` | Enable the OmniRoute Radar module (catalog feed screens and sync). Off by default; enabling only unlocks the UI — data sync remains a separate opt-in. |
|
||||
| `MODEL_ENDPOINT_CAPABILITY_GATE_ENABLED` | boolean | `false` | Enforce trusted model endpoint tags (provider-declared, inferred from a specialty model id, or operator-set): reject a request sent to an endpoint the model does not serve with HTTP 400 before dispatch on `/v1/chat/completions`, `/v1/embeddings`, `/v1/rerank`, `/v1/images/generations`, `/v1/videos/generations`, `/v1/music/generations` and `/v1/audio/*`; hide models whose tagged endpoints have no OmniRoute adapter from `/v1/models`; answer the dashboard model test with 422 for them (#16929). Off by default: endpoint tags stay informational and dispatch is unchanged. |
|
||||
|
||||
### Runtime (54)
|
||||
### Runtime (53)
|
||||
|
||||
| Key | Type | Default | Restart | Description |
|
||||
| ---------------------------------------------- | ------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `UNIVERSAL_CONTEXT_HANDOFF_ENABLED` | boolean | `true` | | Generate and inject conversation summaries when combo routing switches models. Disable to treat model switches independently and prevent background handoff requests for all existing and future combos. |
|
||||
| `REASONING_REPLAY_ENABLED` | boolean | `true` | | Cache and replay model reasoning across multi-turn conversations. Disable to stop storing and re-injecting reasoning. |
|
||||
| `UI_KIT_SHELL` | boolean | `true` | | Render the dashboard shell (sidebar, header, command palette) with the Keak CI UI Kit. Disable to fall back to the legacy shell during the cutover. |
|
||||
| `RESPONSES_PASSTHROUGH_DROP_COMMENTARY` | boolean | `true` | | Drop internal commentary-phase output items from Responses API passthrough streams before forwarding to clients. Disable to receive raw upstream commentary. |
|
||||
| `OMNIROUTE_MCP_ENFORCE_SCOPES` | boolean | `false` | | Enforce scope restrictions on MCP tool access. |
|
||||
| `OMNIROUTE_MCP_COMPRESS_DESCRIPTIONS` | boolean | `false` | | Compress MCP tool descriptions to reduce token usage. |
|
||||
|
||||
@@ -240,7 +240,6 @@ const nextConfig = {
|
||||
"date-fns",
|
||||
"lodash",
|
||||
"lodash-es",
|
||||
"material-symbols",
|
||||
"next-intl",
|
||||
],
|
||||
},
|
||||
|
||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -68,7 +68,6 @@
|
||||
"lucide-react": "^1.33.0",
|
||||
"marked": "^18.0.11",
|
||||
"marked-terminal": "^7.3.0",
|
||||
"material-symbols": "^0.47.0",
|
||||
"mermaid": "^11.17.2",
|
||||
"monaco-editor": "^0.56.0",
|
||||
"next": "16.3.8",
|
||||
@@ -28418,12 +28417,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/material-symbols": {
|
||||
"version": "0.47.0",
|
||||
"resolved": "https://registry.npmjs.org/material-symbols/-/material-symbols-0.47.0.tgz",
|
||||
"integrity": "sha512-/Wt7QSv5Hih8EFj9ySHnnF+NAGajTMRLkfajj0j4MNCY3FB2QhGRg5xtnBs5bUE63mzVo7J5XbbIDr0HeITpHg==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
|
||||
@@ -379,7 +379,6 @@
|
||||
"lucide-react": "^1.33.0",
|
||||
"marked": "^18.0.11",
|
||||
"marked-terminal": "^7.3.0",
|
||||
"material-symbols": "^0.47.0",
|
||||
"mermaid": "^11.17.2",
|
||||
"monaco-editor": "^0.56.0",
|
||||
"next": "16.3.8",
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
// Lista os nomes Material Symbols em uso (ligaduras, props icon=/iconRight=/emptyIcon= e
|
||||
// `icon: "..."` em constantes) e imprime um esqueleto de ICON_MAP para preencher à mão.
|
||||
// Só nomes do vocabulário real (node_modules/material-symbols/index.d.ts) são emitidos — strings
|
||||
// de aparência parecida (`true`, `asc`, `amber`, `anthropic`…) nunca entram no mapa.
|
||||
// Lista os nomes de ícone em uso (props icon=/iconRight=/emptyIcon=/leadingIcon=, `<Icon name>` e
|
||||
// `icon: "..."` em constantes) e imprime um esqueleto de ICON_MAP para os que ainda faltam.
|
||||
// O vocabulário é o dos nomes Material Symbols que as telas já usam, mas a fonte e o pacote
|
||||
// `material-symbols` saíram no F4 (KEA-7886): todo nome capturado precisa mapear para um ícone
|
||||
// Lucide em src/shared/constants/iconMap.ts, exceto as strings de NOT_ICON_NAMES abaixo.
|
||||
// node scripts/dev/gen-icon-map.mjs # esqueleto TS com os nomes que faltam no mapa atual
|
||||
// node scripts/dev/gen-icon-map.mjs --names # só os nomes, um por linha (usado pelo teste de cobertura)
|
||||
import fs from "node:fs";
|
||||
@@ -11,65 +12,37 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
const DIRS = ["src/app", "src/shared"];
|
||||
// `(?<![-\w])` keeps `data-provider-icon="generic"` and similar attributes out of the icon slots.
|
||||
const PATTERNS = [
|
||||
/material-symbols-outlined[^>]*>\s*([a-z][a-z0-9_]+)\s*</g, // <span className="material-symbols-outlined">name</span>
|
||||
/\b(?:icon|iconRight|emptyIcon|leadingIcon)=\"([a-z][a-z0-9_]+)\"/g, // prop icon="name"
|
||||
/(?<![-\w])(?:icon|iconRight|emptyIcon|leadingIcon)=\"([a-z][a-z0-9_]+)\"/g, // prop icon="name"
|
||||
/\bicon:\s*\"([a-z][a-z0-9_]+)\"/g, // { icon: "name" } (sidebar sections, tabs)
|
||||
/<Icon\b[^>]*\bname=\"([a-z][a-z0-9_]+)\"/g, // <Icon name="name" /> (already converted by the codemod)
|
||||
/<Icon\b[^>]*\bname=\"([a-z][a-z0-9_]+)\"/g, // <Icon name="name" />
|
||||
];
|
||||
// Ternários (`cond ? "a" : "b"`) só contam quando estão num slot de ícone: o conteúdo de um span
|
||||
// material-symbols-outlined ou a expressão de uma prop icon=/iconRight=/emptyIcon=/leadingIcon={…}.
|
||||
// Ternários (`cond ? "a" : "b"`) só contam quando estão num slot de ícone: a expressão de uma prop
|
||||
// icon=/iconRight=/emptyIcon=/leadingIcon={…} ou de <Icon name={…} />.
|
||||
const SLOT_PATTERNS = [
|
||||
/material-symbols-outlined[^>]*>([^<]*)</g, // <span className="material-symbols-outlined">{cond ? "a" : "b"}</span>
|
||||
/\b(?:icon|iconRight|emptyIcon|leadingIcon)=\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g, // icon={cond ? "a" : "b"}
|
||||
/(?<![-\w])(?:icon|iconRight|emptyIcon|leadingIcon)=\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g, // icon={cond ? "a" : "b"}
|
||||
/<Icon\b[^>]*\bname=\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g, // <Icon name={cond ? "a" : "b"} />
|
||||
];
|
||||
const TERNARY_RE = /\?\s*\"([a-z][a-z0-9_]+)\"\s*:\s*\"([a-z][a-z0-9_]+)\"/g;
|
||||
const VOCABULARY_FILE = "node_modules/material-symbols/index.d.ts";
|
||||
// Pre-Symbols ("Material Icons") names that index.d.ts does not declare but the bundled
|
||||
// material-symbols-outlined.woff2 still ligates (checked in its GSUB ligature table,
|
||||
// material-symbols@0.47.0, 2026-10-19). Only the ones in use are listed; add a name here only
|
||||
// after confirming the font renders it — new code should prefer the canonical Symbols name
|
||||
// (expand_more → keyboard_arrow_down, push_pin → keep, emoji_events → trophy, …).
|
||||
export const LEGACY_LIGATURES = [
|
||||
"auto_awesome",
|
||||
"auto_fix_high",
|
||||
"auto_fix_normal",
|
||||
"business",
|
||||
"cloud_queue",
|
||||
"do_not_disturb",
|
||||
"emoji_events",
|
||||
"error_outline",
|
||||
"expand_less",
|
||||
"expand_more",
|
||||
"file_download",
|
||||
"file_upload",
|
||||
"generating_tokens",
|
||||
"insert_drive_file",
|
||||
"push_pin",
|
||||
"restore",
|
||||
"tips_and_updates",
|
||||
];
|
||||
|
||||
/** The names the installed `material-symbols` package declares (`type MaterialSymbols = ["123", …]`). */
|
||||
export function loadDtsNames(root = ROOT) {
|
||||
const file = path.join(root, VOCABULARY_FILE);
|
||||
if (!fs.existsSync(file)) {
|
||||
throw new Error(`${VOCABULARY_FILE} not found under ${root} — run npm install first`);
|
||||
}
|
||||
const text = fs.readFileSync(file, "utf8");
|
||||
const start = text.indexOf("type MaterialSymbols = [");
|
||||
const end = text.indexOf("];", start);
|
||||
if (start < 0 || end < 0) throw new Error(`${VOCABULARY_FILE}: MaterialSymbols tuple not found`);
|
||||
return new Set([...text.slice(start, end).matchAll(/"([^"]+)"/g)].map((m) => m[1]));
|
||||
}
|
||||
|
||||
/** The vocabulary the scanner accepts: loadDtsNames() plus LEGACY_LIGATURES. */
|
||||
export function loadMaterialNames(root = ROOT) {
|
||||
const names = loadDtsNames(root);
|
||||
for (const n of LEGACY_LIGATURES) names.add(n);
|
||||
return names;
|
||||
}
|
||||
/**
|
||||
* Strings the scanner sees in an `icon:` slot that never reach <Icon>. Each one was checked by
|
||||
* hand (2026-10-21): provider-catalog `icon` fields are logo keys (no `<Icon name={provider.icon}>`
|
||||
* exists), RoutingTab's tile `icon` field is never read, and Button's `icon: "icon"` is a size key.
|
||||
* Add a name here only with the same proof; a real icon name belongs in ICON_MAP instead.
|
||||
*/
|
||||
export const NOT_ICON_NAMES = new Set([
|
||||
"anthropic", // RoutingTab PROVIDER_TILE_DISPLAY.icon (field unused)
|
||||
"dahl", // provider catalog logo keys (src/shared/constants/providers/**) ↓
|
||||
"opencode",
|
||||
"openference",
|
||||
"proxy",
|
||||
"server",
|
||||
"unorouter",
|
||||
"vector_polygon",
|
||||
"icon", // Button ICON_SIZE / size map key `icon: "icon"`
|
||||
]);
|
||||
|
||||
function walk(dir, out = []) {
|
||||
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
@@ -81,13 +54,13 @@ function walk(dir, out = []) {
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Material names used in one source text (sorted, vocabulary-filtered). */
|
||||
export function collectNamesFromSource(text, vocabulary) {
|
||||
/** Icon names used in one source text (sorted, NOT_ICON_NAMES removed). */
|
||||
export function collectNamesFromSource(text) {
|
||||
const names = new Set();
|
||||
const add = (g) => {
|
||||
if (g && vocabulary.has(g)) names.add(g);
|
||||
if (g && !NOT_ICON_NAMES.has(g)) names.add(g);
|
||||
};
|
||||
if (/material-symbols-outlined|icon[:=]|<Icon\b/.test(text)) {
|
||||
if (/icon[:=]|<Icon\b/.test(text)) {
|
||||
for (const re of PATTERNS)
|
||||
for (const m of text.matchAll(re)) for (const g of m.slice(1)) add(g);
|
||||
for (const re of SLOT_PATTERNS)
|
||||
@@ -98,12 +71,10 @@ export function collectNamesFromSource(text, vocabulary) {
|
||||
}
|
||||
|
||||
export function collectNames(root = ROOT) {
|
||||
const vocabulary = loadMaterialNames(root);
|
||||
const names = new Set();
|
||||
for (const dir of DIRS)
|
||||
for (const file of walk(path.join(root, dir)))
|
||||
for (const n of collectNamesFromSource(fs.readFileSync(file, "utf8"), vocabulary))
|
||||
names.add(n);
|
||||
for (const n of collectNamesFromSource(fs.readFileSync(file, "utf8"))) names.add(n);
|
||||
return [...names].sort();
|
||||
}
|
||||
|
||||
@@ -124,7 +95,10 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
const have = existingMap();
|
||||
const missing = names.filter((n) => !have.has(n));
|
||||
console.log(
|
||||
`// ${names.length} Material names in use; ${missing.length} missing from ICON_MAP. Paste into iconMap.ts and replace null with a Lucide import.`
|
||||
`// ${names.length} icon names in use; ${missing.length} missing from ICON_MAP. Map each real icon to a Lucide import in iconMap.ts;`
|
||||
);
|
||||
for (const n of missing) console.log(` ${n}: null,`);
|
||||
console.log(
|
||||
"// not an icon (logo key, size key… that never reaches <Icon>)? add it to NOT_ICON_NAMES above, with the proof."
|
||||
);
|
||||
for (const n of missing) console.log(` ${n}: /* Lucide */,`);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import routeNamespaces from "@/i18n/routeNamespaces.generated.json";
|
||||
import { normalizeComplianceEventTypes } from "@/i18n/request";
|
||||
import { pickMessages } from "@/i18n/pickMessages";
|
||||
import { DashboardLayout } from "@/shared/components";
|
||||
import { isUiKitShellEnabled } from "@/shared/utils/featureFlags";
|
||||
|
||||
/**
|
||||
* Dashboard chrome i18n provider — serves only the namespaces the shared
|
||||
@@ -14,22 +13,17 @@ import { isUiKitShellEnabled } from "@/shared/utils/featureFlags";
|
||||
* re-scopes the catalog again with its own SectionI18nProvider layout
|
||||
* (generated — see scripts/i18n/generate-route-namespaces.mjs).
|
||||
*
|
||||
* The shell renderer is picked here, on the server: the Keak UI Kit shell when
|
||||
* UI_KIT_SHELL is on (default), the legacy shell when it is off (cutover kill
|
||||
* switch). The kit sidebar's collapsed state comes from its `ci_sidebar_state`
|
||||
* cookie so the first paint already matches the persisted state.
|
||||
* The kit sidebar's collapsed state comes from its `ci_sidebar_state` cookie,
|
||||
* read here on the server, so the first paint already matches the persisted state.
|
||||
*/
|
||||
export default async function DashboardRootLayout({ children }: { children: React.ReactNode }) {
|
||||
const messages = normalizeComplianceEventTypes(
|
||||
pickMessages((await getMessages()) as Record<string, unknown>, routeNamespaces.chrome)
|
||||
);
|
||||
const shell = isUiKitShellEnabled() ? "kit" : "legacy";
|
||||
const sidebarDefaultOpen = (await cookies()).get("ci_sidebar_state")?.value !== "0";
|
||||
return (
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<DashboardLayout shell={shell} sidebarDefaultOpen={sidebarDefaultOpen}>
|
||||
{children}
|
||||
</DashboardLayout>
|
||||
<DashboardLayout sidebarDefaultOpen={sidebarDefaultOpen}>{children}</DashboardLayout>
|
||||
</NextIntlClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@import "tailwindcss" source(none);
|
||||
@import "fumadocs-ui/css/neutral.css";
|
||||
@import "fumadocs-ui/css/preset.css";
|
||||
/* Keak type ramp — self-hosted (same reasoning as Material Symbols, #3695: no CDN). Inter is the
|
||||
/* Keak type ramp — self-hosted (no CDN: Google Fonts is unreachable in some regions, #3695). Inter is the
|
||||
UI family (tracking 0), Instrument Serif only for sparse large headings, IBM Plex Mono for code.
|
||||
Static weights on purpose: the variable Inter package registers the family "Inter Variable",
|
||||
which the kit's `--ci-font-ui: "Inter", …` never matches (spike finding). Mirrors the kit's
|
||||
@@ -21,9 +21,6 @@
|
||||
legacy screens keep winning over kit components, and the kit's `@layer base` (.ci-theme)
|
||||
wins over the preflight because of selector specificity. */
|
||||
@import "../../packages/ui-kit/src/ci-ui.css";
|
||||
/* Self-hosted Material Symbols icon font (#3695) — kept until the final wave removes the
|
||||
last `material-symbols-outlined` usage (see <Icon> fallback in src/shared/components/Icon.tsx). */
|
||||
@import "material-symbols/outlined.css" layer(base);
|
||||
/* react18-json-view (request/response JSON tree in RequestLoggerDetail) — imported here
|
||||
instead of in the component so node:test / esbuild never see a .css import. */
|
||||
@import "react18-json-view/src/style.css";
|
||||
@@ -63,10 +60,8 @@
|
||||
to the lime below. */
|
||||
--color-primary-ink: var(--ci-lime-800);
|
||||
--color-accent: var(--ci-color-accent);
|
||||
--color-accent-hover: var(--ci-color-accent-hover);
|
||||
--color-accent-light: var(--ci-color-accent-surface-strong);
|
||||
--color-accent-foreground: var(--ci-color-accent-foreground);
|
||||
--grad-brand: var(--ci-color-accent);
|
||||
|
||||
/* Semantic */
|
||||
--color-error: var(--ci-color-danger);
|
||||
@@ -85,11 +80,6 @@
|
||||
--orch-status-muted: var(--ci-color-text-muted);
|
||||
--orch-status-approval: var(--ci-chart-3);
|
||||
|
||||
/* Traffic lights (terminal chrome only) */
|
||||
--color-traffic-red: var(--ci-color-danger);
|
||||
--color-traffic-yellow: var(--ci-color-warning);
|
||||
--color-traffic-green: var(--ci-color-success);
|
||||
|
||||
/* Surfaces & text */
|
||||
--color-bg: var(--ci-color-background);
|
||||
--color-bg-alt: var(--ci-color-surface-subtle);
|
||||
@@ -144,10 +134,6 @@
|
||||
|
||||
/* Data-table surfaces */
|
||||
--table-header-bg: var(--ci-color-surface-muted);
|
||||
--table-row-zebra: var(--ci-color-neutral-tint);
|
||||
--table-row-hover: var(--ci-color-neutral-tint);
|
||||
--table-cell-border: var(--ci-color-border-subtle);
|
||||
--table-row-selected: var(--ci-color-accent-surface-subtle);
|
||||
}
|
||||
|
||||
/* Dark: lime reads on the dark background (≈ 17:1), so the primary ink is the accent itself.
|
||||
@@ -177,7 +163,6 @@
|
||||
|
||||
/* Accent */
|
||||
--color-accent: var(--color-accent);
|
||||
--color-accent-hover: var(--color-accent-hover);
|
||||
--color-accent-light: var(--color-accent-light);
|
||||
|
||||
/* Semantic */
|
||||
@@ -340,32 +325,6 @@ body.electron-macos {
|
||||
);
|
||||
}
|
||||
|
||||
/* Material Symbols */
|
||||
@layer base {
|
||||
:where(.material-symbols-outlined) {
|
||||
font-family: "Material Symbols Outlined", sans-serif !important;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
word-wrap: normal;
|
||||
direction: ltr;
|
||||
font-feature-settings: "liga";
|
||||
-webkit-font-feature-settings: "liga";
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-variation-settings:
|
||||
"FILL" 0,
|
||||
"wght" 400,
|
||||
"GRAD" 0,
|
||||
"opsz" 24;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Phones: any wrapping row of 3+ buttons, and any row made only of 3+ buttons (tabs,
|
||||
filters, toolbars), stretches its buttons to fill each line instead of leaving a ragged
|
||||
gap on the right. Same behaviour as the shared ActionBar / FilterPills; a component
|
||||
@@ -408,20 +367,6 @@ body.electron-macos {
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure icon clicks always bubble to the parent button */
|
||||
button .material-symbols-outlined,
|
||||
[role="button"] .material-symbols-outlined {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.material-symbols-outlined.fill-1 {
|
||||
font-variation-settings:
|
||||
"FILL" 1,
|
||||
"wght" 400,
|
||||
"GRAD" 0,
|
||||
"opsz" 24;
|
||||
}
|
||||
|
||||
/* react18-json-view fold control: the SVG chevron itself is ~14px, too small
|
||||
a touch target on mobile. Padding + a matching negative margin grows the
|
||||
hit area without shifting sibling layout -- unlike the row-level icon this
|
||||
@@ -495,30 +440,6 @@ button .material-symbols-outlined,
|
||||
background: rgba(16, 20, 30, 0.72);
|
||||
}
|
||||
|
||||
/* macOS Traffic Lights */
|
||||
.traffic-lights {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.traffic-light {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.traffic-light.red {
|
||||
background: var(--color-traffic-red);
|
||||
}
|
||||
|
||||
.traffic-light.yellow {
|
||||
background: var(--color-traffic-yellow);
|
||||
}
|
||||
|
||||
.traffic-light.green {
|
||||
background: var(--color-traffic-green);
|
||||
}
|
||||
|
||||
/* ── Mobile Layout Fixes (Issue #659) ── */
|
||||
@media (max-width: 768px) {
|
||||
.ant-table-wrapper {
|
||||
@@ -549,58 +470,6 @@ select option {
|
||||
--xy-controls-button-border-color: var(--color-border);
|
||||
}
|
||||
|
||||
/* Desktop sidebar visibility must not depend on Tailwind's hidden/lg:flex cascade
|
||||
(ordering/specificity can collapse it). Explicit class + 1024px media query. */
|
||||
.dashboard-sidebar-desktop {
|
||||
display: none;
|
||||
min-height: 0;
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.dashboard-sidebar-desktop {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.dashboard-sidebar-mobile {
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
.dashboard-sidebar-mobile.-translate-x-full {
|
||||
translate: -100% 0 !important;
|
||||
transform: translateX(-100%) !important;
|
||||
}
|
||||
.dashboard-sidebar-mobile.translate-x-0 {
|
||||
translate: 0 0 !important;
|
||||
transform: translateX(0) !important;
|
||||
}
|
||||
|
||||
html[dir="rtl"] .dashboard-sidebar-mobile,
|
||||
[dir="rtl"] .dashboard-sidebar-mobile {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
inset-inline-start: 0 !important;
|
||||
inset-inline-end: auto !important;
|
||||
}
|
||||
html[dir="rtl"] .dashboard-sidebar-mobile.-translate-x-full,
|
||||
html[dir="rtl"] .dashboard-sidebar-mobile.rtl\:translate-x-full,
|
||||
[dir="rtl"] .dashboard-sidebar-mobile.-translate-x-full,
|
||||
[dir="rtl"] .dashboard-sidebar-mobile.rtl\:translate-x-full {
|
||||
translate: 100% 0 !important;
|
||||
transform: translateX(100%) !important;
|
||||
}
|
||||
html[dir="rtl"] .dashboard-sidebar-mobile.translate-x-0,
|
||||
[dir="rtl"] .dashboard-sidebar-mobile.translate-x-0 {
|
||||
translate: 0 0 !important;
|
||||
transform: translateX(0) !important;
|
||||
}
|
||||
html[dir="rtl"] .dashboard-sidebar-mobile aside,
|
||||
[dir="rtl"] .dashboard-sidebar-mobile aside {
|
||||
border-right-width: 0 !important;
|
||||
border-left-width: 1px !important;
|
||||
border-inline-end-width: 0 !important;
|
||||
border-inline-start-width: 1px !important;
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════════
|
||||
RTL (Right-to-Left) Compatibility — fixes #7680
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
@@ -901,7 +770,7 @@ html[dir="rtl"] :where(code, pre, kbd, samp, input[type="email"], input[type="ur
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
}
|
||||
html[dir="rtl"] :where(.material-symbols-outlined, .traffic-lights, .react-flow) {
|
||||
html[dir="rtl"] :where(.react-flow) {
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,6 @@ export default async function RootLayout({ children }) {
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
{/* Material Symbols icon font is self-hosted via globals.css
|
||||
(@import "material-symbols/outlined.css") so icons render even when
|
||||
the Google Fonts CDN is unreachable (#3695). */}
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
|
||||
@@ -1011,7 +1011,6 @@
|
||||
"featureFlagArenaEloSyncEnabledDescription": "Enable periodic Arena AI leaderboard ELO sync for model intelligence rankings.",
|
||||
"featureFlagUniversalContextHandoffEnabledDescription": "Generate and inject conversation summaries when combo routing switches models. Disable to treat model switches independently and prevent background handoff requests for all existing and future combos.",
|
||||
"featureFlagReasoningReplayEnabledDescription": "Cache and replay model reasoning across multi-turn conversations. Disable to stop storing and re-injecting reasoning.",
|
||||
"featureFlagUiKitShellDescription": "Render the dashboard shell (sidebar, header, command palette) with the Keak UI Kit. Disable to fall back to the legacy shell during the cutover.",
|
||||
"featureFlagExposeCcDiscoveryAliasesDescription": "Advertise claude/<provider>/<model> mirror ids on /v1/models so Claude Code gateway model discovery lists non-Claude models. Warning: doubles catalog entries for all clients when enabled globally.",
|
||||
"featureFlagNoThinkingAliasEnabledDescription": "Master switch for the no-think/<provider>/<model> gateway aliases. On (default): /v1/models advertises a no-thinking variant for every eligible thinking-capable Claude model, and a no-think/ id sent on a request resolves back to the real model with reasoning suppressed. Off: no variants are advertised and a no-think/ id is treated like any other unknown model id. The per-model ModelSpec.noThinkingAlias opt-in/opt-out still applies while this is on.",
|
||||
"featureFlagChatVirtualLanesEnabledDescription": "Enable per-tenant adaptive virtual admission lanes for provider dispatch (#9654): one tenant's burst no longer 503s another. The OMNIROUTE_CHAT_VIRTUAL_LANES env var wins over this dashboard override; changes take effect at server restart.",
|
||||
|
||||
@@ -1011,7 +1011,6 @@
|
||||
"featureFlagArenaEloSyncEnabledDescription": "Ativar a sincronização periódica do ELO do leaderboard da Arena AI para classificações de inteligência do modelo.",
|
||||
"featureFlagUniversalContextHandoffEnabledDescription": "Gera e injeta resumos da conversa quando o roteamento de combo troca de modelo. Desative para tratar trocas de modelo de forma independente e evitar requisições de handoff em segundo plano para todos os combos existentes e futuros.",
|
||||
"featureFlagReasoningReplayEnabledDescription": "Armazena e reproduz o raciocínio do modelo em conversas de vários turnos. Desative para interromper o armazenamento e a reinjeção do raciocínio.",
|
||||
"featureFlagUiKitShellDescription": "Renderiza o shell do dashboard (sidebar, cabeçalho, paleta de comandos) com o UI Kit da Keak. Desative para voltar ao shell legado durante a migração.",
|
||||
"featureFlagExposeCcDiscoveryAliasesDescription": "Divulgar ids espelho claude/<provider>/<model> em /v1/models para que a descoberta de modelos do gateway Claude Code liste modelos não-Claude. Atenção: duplica as entradas do catálogo para todos os clientes quando ativado globalmente.",
|
||||
"featureFlagNoThinkingAliasEnabledDescription": "Controle principal dos aliases de gateway no-think/<provider>/<model>. Ativado (padrão): /v1/models anuncia uma variante sem raciocínio para cada modelo Claude qualificado com capacidade de raciocínio, e um ID no-think/ enviado em uma solicitação é resolvido para o modelo real com o raciocínio suprimido. Desativado: nenhuma variante é anunciada, e um ID no-think/ é tratado como qualquer outro ID de modelo desconhecido. A configuração de ativação/desativação ModelSpec.noThinkingAlias por modelo continua válida enquanto esta opção estiver ativada.",
|
||||
"featureFlagChatVirtualLanesEnabledDescription": "Ative faixas de admissão virtuais adaptativas por tenant para o despacho de provedores (#9654): o pico de um tenant não gera mais 503 para outro. A variável de ambiente OMNIROUTE_CHAT_VIRTUAL_LANES tem precedência sobre esta configuração do painel; as alterações entram em vigor ao reiniciar o servidor.",
|
||||
|
||||
@@ -1011,7 +1011,6 @@
|
||||
"featureFlagArenaEloSyncEnabledDescription": "Bật đồng bộ ELO định kỳ từ bảng xếp hạng Arena AI để xếp hạng năng lực của mô hình.",
|
||||
"featureFlagUniversalContextHandoffEnabledDescription": "Tạo và chèn bản tóm tắt hội thoại khi định tuyến combo chuyển đổi mô hình. Tắt để xử lý các lần chuyển mô hình một cách độc lập và ngăn các yêu cầu bàn giao chạy nền cho mọi combo hiện có và trong tương lai.",
|
||||
"featureFlagReasoningReplayEnabledDescription": "Lưu vào bộ nhớ đệm và phát lại phần suy luận của mô hình trong các cuộc hội thoại nhiều lượt. Tắt để ngừng lưu trữ và chèn lại phần suy luận.",
|
||||
"featureFlagUiKitShellDescription": "Hiển thị khung bảng điều khiển (thanh bên, tiêu đề, bảng lệnh) bằng Keak UI Kit. Tắt để quay về khung cũ trong thời gian chuyển đổi.",
|
||||
"featureFlagExposeCcDiscoveryAliasesDescription": "Quảng bá các id phản chiếu claude/<provider>/<model> trên /v1/models để tính năng khám phá mô hình qua gateway của Claude Code liệt kê được các mô hình không phải Claude. Cảnh báo: khi bật ở phạm vi toàn cục, số mục trong danh mục tăng gấp đôi với mọi client.",
|
||||
"featureFlagNoThinkingAliasEnabledDescription": "Công tắc chính cho các bí danh gateway no-think/<provider>/<model>. Bật (mặc định): /v1/models quảng bá biến thể không suy nghĩ cho mọi mô hình Claude có khả năng suy nghĩ đủ điều kiện, và id no-think/ được gửi trên một yêu cầu sẽ giải quyết lại về mô hình thực với phần lý luận bị triệt tiêu. Tắt: không có biến thể nào được quảng bá và id no-think/ được xử lý như bất kỳ id mô hình không xác định nào khác. Tùy chọn tham gia/từ chối ModelSpec.noThinkingAlias theo từng mô hình vẫn áp dụng khi tính năng này bật.",
|
||||
"featureFlagChatVirtualLanesEnabledDescription": "Bật làn tiếp nhận ảo thích ứng cho từng đối tượng thuê (tenant) để phân phối nhà cung cấp (#9654): một đợt bùng phát của tenant này không còn trả 503 cho tenant khác. Biến môi trường OMNIROUTE_CHAT_VIRTUAL_LANES được ưu tiên hơn cài đặt bảng điều khiển này; các thay đổi có hiệu lực khi khởi động lại máy chủ.",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { createElement } from "react";
|
||||
import type { LucideProps } from "lucide-react";
|
||||
import { SquareDashedBottom, type LucideIcon, type LucideProps } from "lucide-react";
|
||||
import { cn } from "@/shared/utils/cn";
|
||||
import { resolveIcon } from "@/shared/constants/iconMap";
|
||||
|
||||
export interface IconProps {
|
||||
/** Material Symbols name (the legacy vocabulary). Mapped names render Lucide; others fall back. */
|
||||
/** Icon name from ICON_MAP (the Material Symbols vocabulary the screens already use). */
|
||||
name?: string | null;
|
||||
/** Pixel size (width = height). 18 matches the legacy `text-[18px]` icon spans. */
|
||||
size?: number;
|
||||
@@ -20,6 +20,19 @@ export interface IconProps {
|
||||
|
||||
const warned = new Set<string>();
|
||||
|
||||
/**
|
||||
* Glyph drawn for a name missing from ICON_MAP. It must not be any ICON_MAP value, so a gap never
|
||||
* reads as a real icon or status (CircleDashed, for instance, is `pending`) — pinned by
|
||||
* tests/unit/ui/adapters/icon.test.tsx.
|
||||
*/
|
||||
export const MISSING_ICON_GLYPH: LucideIcon = SquareDashedBottom;
|
||||
|
||||
/**
|
||||
* Every icon renders Lucide (KEA-7886): the Material Symbols font is gone. A name missing from
|
||||
* ICON_MAP draws a neutral placeholder glyph (MISSING_ICON_GLYPH) (never ligature text, never a crash) and, outside
|
||||
* production, warns once so the gap is visible — tests/unit/icon-map-coverage.test.ts keeps the
|
||||
* names used in src/ mapped.
|
||||
*/
|
||||
export default function Icon({
|
||||
name,
|
||||
size = 18,
|
||||
@@ -29,38 +42,28 @@ export default function Icon({
|
||||
fill = false,
|
||||
}: IconProps) {
|
||||
if (!name) return null;
|
||||
const Lucide = resolveIcon(name);
|
||||
const mapped = resolveIcon(name);
|
||||
if (!mapped && process.env.NODE_ENV !== "production" && !warned.has(name)) {
|
||||
warned.add(name);
|
||||
console.warn(
|
||||
`[Icon] "${name}" is not in ICON_MAP — rendering a placeholder glyph (map it in src/shared/constants/iconMap.ts)`
|
||||
);
|
||||
}
|
||||
const Lucide: LucideIcon = mapped ?? MISSING_ICON_GLYPH;
|
||||
const a11y = ariaLabel
|
||||
? { role: "img" as const, "aria-label": ariaLabel }
|
||||
: { "aria-hidden": true as const };
|
||||
if (Lucide) {
|
||||
// ICON_MAP values are module-level Lucide components (stable identity), but the
|
||||
// react-hooks/static-components rule cannot see through resolveIcon(); createElement
|
||||
// renders the same element without the JSX-tag heuristic.
|
||||
const props: LucideProps & { "data-icon": string } = {
|
||||
...a11y,
|
||||
width: size,
|
||||
height: size,
|
||||
strokeWidth: strokeWidth ?? (fill ? 2.5 : 2),
|
||||
className: cn("oi-icon shrink-0 pointer-events-none", className),
|
||||
"data-icon": name,
|
||||
};
|
||||
return createElement(Lucide, props);
|
||||
}
|
||||
if (process.env.NODE_ENV !== "production" && !warned.has(name)) {
|
||||
warned.add(name);
|
||||
console.warn(
|
||||
`[Icon] "${name}" has no Lucide mapping yet — rendering the Material ligature (add it to src/shared/constants/iconMap.ts)`
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span
|
||||
{...a11y}
|
||||
className={cn("material-symbols-outlined shrink-0 pointer-events-none", className)}
|
||||
style={{ fontSize: size, ...(fill ? { fontVariationSettings: "'FILL' 1" } : null) }}
|
||||
data-icon={name}
|
||||
>
|
||||
{name}
|
||||
</span>
|
||||
);
|
||||
// ICON_MAP values are module-level Lucide components (stable identity), but the
|
||||
// react-hooks/static-components rule cannot see through resolveIcon(); createElement
|
||||
// renders the same element without the JSX-tag heuristic.
|
||||
const props: LucideProps & { "data-icon": string; "data-icon-missing"?: "true" } = {
|
||||
...a11y,
|
||||
width: size,
|
||||
height: size,
|
||||
strokeWidth: strokeWidth ?? (fill ? 2.5 : 2),
|
||||
className: cn("oi-icon shrink-0 pointer-events-none", className),
|
||||
"data-icon": name,
|
||||
...(mapped ? null : { "data-icon-missing": "true" as const }),
|
||||
};
|
||||
return createElement(Lucide, props);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import DashboardShell from "./DashboardShell";
|
||||
import DashboardLayoutLegacy from "./legacy/DashboardLayoutLegacy";
|
||||
|
||||
export type DashboardShellMode = "kit" | "legacy";
|
||||
|
||||
/** Shell selector: `shell` comes from the server layout (UI_KIT_SHELL flag). */
|
||||
/** Dashboard chrome: the Keak CI UI Kit shell (KEA-7886). `sidebarDefaultOpen` comes from the
|
||||
* server layout (`ci_sidebar_state` cookie) so the first paint matches the persisted state. */
|
||||
export default function DashboardLayout({
|
||||
children,
|
||||
shell = "kit",
|
||||
sidebarDefaultOpen = true,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
shell?: DashboardShellMode;
|
||||
sidebarDefaultOpen?: boolean;
|
||||
}) {
|
||||
if (shell === "legacy") return <DashboardLayoutLegacy>{children}</DashboardLayoutLegacy>;
|
||||
return <DashboardShell sidebarDefaultOpen={sidebarDefaultOpen}>{children}</DashboardShell>;
|
||||
}
|
||||
|
||||
@@ -1,409 +0,0 @@
|
||||
"use client";
|
||||
// LEGACY SHELL — rendered only when UI_KIT_SHELL=false (cutover kill switch). Removed in the final wave.
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import {
|
||||
SIDEBAR_SECTIONS,
|
||||
HIDDEN_SIDEBAR_ITEMS_SETTING_KEY,
|
||||
SIDEBAR_PRESET_KEY,
|
||||
ESSENTIALS_ADVANCED_TOOL_IDS,
|
||||
normalizeHiddenSidebarItems,
|
||||
resolveRuntimeSidebarSections,
|
||||
type HideableSidebarItemId,
|
||||
type SidebarItemDefinition,
|
||||
type SidebarSectionChild,
|
||||
} from "@/shared/constants/sidebarVisibility";
|
||||
|
||||
function isSidebarGroup(
|
||||
child: SidebarSectionChild
|
||||
): child is Extract<SidebarSectionChild, { type: "group" }> {
|
||||
return "type" in child && child.type === "group";
|
||||
}
|
||||
|
||||
interface CommandPaletteProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function CommandPalette({ isOpen, onClose }: CommandPaletteProps) {
|
||||
if (!isOpen) return null;
|
||||
return <CommandPaletteDialog onClose={onClose} />;
|
||||
}
|
||||
|
||||
interface PaletteItem {
|
||||
id: string;
|
||||
href: string;
|
||||
icon: string;
|
||||
label: string;
|
||||
subtitle?: string;
|
||||
external: boolean;
|
||||
sectionId: string;
|
||||
sectionLabel: string;
|
||||
subgroupId?: string;
|
||||
subgroupLabel?: string;
|
||||
}
|
||||
|
||||
interface PaletteSubgroup {
|
||||
subgroupId: string | null;
|
||||
subgroupLabel: string | null;
|
||||
items: { item: PaletteItem; flatIndex: number }[];
|
||||
}
|
||||
|
||||
interface PaletteGroup {
|
||||
sectionId: string;
|
||||
sectionLabel: string;
|
||||
subgroups: PaletteSubgroup[];
|
||||
}
|
||||
|
||||
function CommandPaletteDialog({ onClose }: { onClose: () => void }) {
|
||||
const router = useRouter();
|
||||
const t = useTranslations("sidebar");
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const listRef = useRef<HTMLUListElement>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [hiddenItems, setHiddenItems] = useState<Set<string>>(new Set());
|
||||
const [activePreset, setActivePreset] = useState<string | null>(null);
|
||||
const [radarAdminUrl, setRadarAdminUrl] = useState<unknown>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const ctrl = new AbortController();
|
||||
fetch("/api/settings", { signal: ctrl.signal })
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
setHiddenItems(
|
||||
new Set(normalizeHiddenSidebarItems(data?.[HIDDEN_SIDEBAR_ITEMS_SETTING_KEY]))
|
||||
);
|
||||
setActivePreset(
|
||||
typeof data?.[SIDEBAR_PRESET_KEY] === "string" ? data[SIDEBAR_PRESET_KEY] : null
|
||||
);
|
||||
setRadarAdminUrl(data?.radarAdminUrl ?? null);
|
||||
})
|
||||
.catch(() => {
|
||||
// ignore aborts and fetch failures; palette still works with empty hidden set
|
||||
});
|
||||
return () => ctrl.abort();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const id = setTimeout(() => inputRef.current?.focus(), 30);
|
||||
return () => clearTimeout(id);
|
||||
}, []);
|
||||
|
||||
const safeTranslate = useCallback(
|
||||
(key: string, fallback: string) => {
|
||||
try {
|
||||
if (typeof t.has === "function" && !t.has(key)) return fallback;
|
||||
return t(key);
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
const allItems = useMemo<PaletteItem[]>(
|
||||
() =>
|
||||
resolveRuntimeSidebarSections(SIDEBAR_SECTIONS, { radarAdminUrl }).flatMap((section) => {
|
||||
const sectionLabel = safeTranslate(section.titleKey, section.titleFallback);
|
||||
return section.children.flatMap<PaletteItem>((child) => {
|
||||
if (isSidebarGroup(child)) {
|
||||
const subgroupLabel = safeTranslate(child.titleKey, child.titleFallback);
|
||||
return child.items
|
||||
.filter((item) => {
|
||||
if (!hiddenItems.has(item.id)) return true;
|
||||
return (
|
||||
activePreset === "essentials" &&
|
||||
ESSENTIALS_ADVANCED_TOOL_IDS.has(item.id as HideableSidebarItemId)
|
||||
);
|
||||
})
|
||||
.map<PaletteItem>((item) => ({
|
||||
id: item.id,
|
||||
href: item.href,
|
||||
icon: item.icon,
|
||||
label: safeTranslate(item.i18nKey, item.labelFallback ?? item.id),
|
||||
subtitle: item.subtitleKey
|
||||
? safeTranslate(item.subtitleKey, item.subtitleFallback ?? "")
|
||||
: item.subtitleFallback,
|
||||
external: item.external ?? false,
|
||||
sectionId: section.id,
|
||||
sectionLabel,
|
||||
subgroupId: child.id,
|
||||
subgroupLabel,
|
||||
}));
|
||||
}
|
||||
const item = child as SidebarItemDefinition;
|
||||
if (hiddenItems.has(item.id)) {
|
||||
const keepForEssentials =
|
||||
activePreset === "essentials" &&
|
||||
ESSENTIALS_ADVANCED_TOOL_IDS.has(item.id as HideableSidebarItemId);
|
||||
if (!keepForEssentials) return [];
|
||||
}
|
||||
return [
|
||||
{
|
||||
id: item.id,
|
||||
href: item.href,
|
||||
icon: item.icon,
|
||||
label: safeTranslate(item.i18nKey, item.labelFallback ?? item.id),
|
||||
subtitle: item.subtitleKey
|
||||
? safeTranslate(item.subtitleKey, item.subtitleFallback ?? "")
|
||||
: item.subtitleFallback,
|
||||
external: item.external ?? false,
|
||||
sectionId: section.id,
|
||||
sectionLabel,
|
||||
},
|
||||
];
|
||||
});
|
||||
}),
|
||||
[hiddenItems, radarAdminUrl, safeTranslate, activePreset]
|
||||
);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const q = query.trim().toLowerCase();
|
||||
if (!q) return allItems;
|
||||
return allItems.filter(
|
||||
(item) =>
|
||||
item.label.toLowerCase().includes(q) ||
|
||||
item.subtitle?.toLowerCase().includes(q) ||
|
||||
item.sectionLabel.toLowerCase().includes(q) ||
|
||||
item.subgroupLabel?.toLowerCase().includes(q)
|
||||
);
|
||||
}, [allItems, query]);
|
||||
|
||||
const grouped = useMemo<PaletteGroup[]>(() => {
|
||||
const groups: PaletteGroup[] = [];
|
||||
const sectionById = new Map<string, PaletteGroup>();
|
||||
filtered.forEach((item, flatIndex) => {
|
||||
// Look up the section/subgroup by id across the whole list, not just the
|
||||
// previous item — a section's children can interleave root items and
|
||||
// groups (e.g. "omni-proxy" has a trailing root item after its groups),
|
||||
// which would otherwise produce two separate "_root" subgroups sharing
|
||||
// the same React key.
|
||||
let section = sectionById.get(item.sectionId);
|
||||
if (!section) {
|
||||
section = {
|
||||
sectionId: item.sectionId,
|
||||
sectionLabel: item.sectionLabel,
|
||||
subgroups: [],
|
||||
};
|
||||
sectionById.set(item.sectionId, section);
|
||||
groups.push(section);
|
||||
}
|
||||
const itemSubgroupId = item.subgroupId ?? null;
|
||||
let subgroup = section.subgroups.find((sg) => sg.subgroupId === itemSubgroupId);
|
||||
if (!subgroup) {
|
||||
subgroup = {
|
||||
subgroupId: itemSubgroupId,
|
||||
subgroupLabel: item.subgroupLabel ?? null,
|
||||
items: [],
|
||||
};
|
||||
section.subgroups.push(subgroup);
|
||||
}
|
||||
subgroup.items.push({ item, flatIndex });
|
||||
});
|
||||
return groups;
|
||||
}, [filtered]);
|
||||
|
||||
const handleNavigate = useCallback(
|
||||
(href: string, external: boolean) => {
|
||||
onClose();
|
||||
if (external) {
|
||||
window.open(href, "_blank", "noopener,noreferrer");
|
||||
} else {
|
||||
router.push(href);
|
||||
}
|
||||
},
|
||||
[onClose, router]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") {
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
setSelectedIndex((prev) => (prev + 1) % Math.max(1, filtered.length));
|
||||
} else if (e.key === "ArrowUp") {
|
||||
e.preventDefault();
|
||||
setSelectedIndex(
|
||||
(prev) => (prev - 1 + Math.max(1, filtered.length)) % Math.max(1, filtered.length)
|
||||
);
|
||||
} else if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const item = filtered[selectedIndex];
|
||||
if (item) {
|
||||
handleNavigate(item.href, item.external);
|
||||
}
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
return () => document.removeEventListener("keydown", handleKeyDown);
|
||||
}, [filtered, selectedIndex, onClose, handleNavigate]);
|
||||
|
||||
useEffect(() => {
|
||||
const list = listRef.current;
|
||||
if (!list) return;
|
||||
const el = list.querySelector<HTMLElement>(`[data-flat-index="${selectedIndex}"]`);
|
||||
el?.scrollIntoView({ block: "nearest" });
|
||||
}, [selectedIndex]);
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-[60] flex items-start justify-center pt-[10vh] px-4">
|
||||
<div
|
||||
className="absolute inset-0 bg-black/40 backdrop-blur-sm"
|
||||
onClick={onClose}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div
|
||||
className="relative w-full max-w-3xl bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={t("commandPalette.title")}
|
||||
>
|
||||
<div className="flex items-center gap-3 px-6 py-4 border-b border-black/5 dark:border-white/5">
|
||||
<span className="material-symbols-outlined text-[20px] text-text-muted shrink-0">
|
||||
search
|
||||
</span>
|
||||
<input
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
className="flex-1 bg-transparent text-text placeholder:text-text-muted outline-none text-base"
|
||||
placeholder={t("commandPalette.searchPlaceholder")}
|
||||
value={query}
|
||||
onChange={(e) => {
|
||||
setQuery(e.target.value);
|
||||
setSelectedIndex(0);
|
||||
}}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
{query && (
|
||||
<button
|
||||
className="text-text-muted hover:text-text transition-colors"
|
||||
onClick={() => {
|
||||
setQuery("");
|
||||
setSelectedIndex(0);
|
||||
}}
|
||||
tabIndex={-1}
|
||||
aria-label={t("commandPalette.clearSearch")}
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px]">close</span>
|
||||
</button>
|
||||
)}
|
||||
<kbd className="hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-mono bg-black/5 dark:bg-white/5 text-text-muted border border-black/10 dark:border-white/10 shrink-0">
|
||||
Esc
|
||||
</kbd>
|
||||
</div>
|
||||
|
||||
{grouped.length > 0 ? (
|
||||
<ul
|
||||
ref={listRef}
|
||||
className="py-2 max-h-[60vh] overflow-y-auto custom-scrollbar"
|
||||
role="listbox"
|
||||
>
|
||||
{grouped.map((group) => (
|
||||
<li key={group.sectionId} role="presentation">
|
||||
<div className="sticky top-0 z-10 bg-surface/95 backdrop-blur-sm px-6 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-text-muted border-b border-black/5 dark:border-white/5">
|
||||
{group.sectionLabel}
|
||||
</div>
|
||||
<ul role="group" aria-label={group.sectionLabel}>
|
||||
{group.subgroups.map((subgroup) => (
|
||||
<li
|
||||
key={`${group.sectionId}::${subgroup.subgroupId ?? "_root"}`}
|
||||
role="presentation"
|
||||
>
|
||||
{subgroup.subgroupLabel && (
|
||||
<div className="px-6 pt-2 pb-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/70">
|
||||
{subgroup.subgroupLabel}
|
||||
</div>
|
||||
)}
|
||||
<ul
|
||||
role={subgroup.subgroupLabel ? "group" : "presentation"}
|
||||
aria-label={subgroup.subgroupLabel ?? undefined}
|
||||
>
|
||||
{subgroup.items.map(({ item, flatIndex }) => (
|
||||
<li
|
||||
key={item.id}
|
||||
role="option"
|
||||
aria-selected={flatIndex === selectedIndex}
|
||||
data-flat-index={flatIndex}
|
||||
>
|
||||
<button
|
||||
className={`w-full flex items-center gap-3 ${
|
||||
subgroup.subgroupLabel ? "pl-10 pr-6" : "px-6"
|
||||
} py-2.5 text-left transition-colors ${
|
||||
flatIndex === selectedIndex
|
||||
? "bg-accent/10 text-accent ring-1 ring-inset ring-accent/20"
|
||||
: "text-text hover:bg-black/5 dark:hover:bg-white/5"
|
||||
}`}
|
||||
onClick={() => handleNavigate(item.href, item.external)}
|
||||
onMouseEnter={() => setSelectedIndex(flatIndex)}
|
||||
>
|
||||
<span
|
||||
className={`material-symbols-outlined text-[18px] shrink-0 ${
|
||||
flatIndex === selectedIndex ? "text-accent" : "text-text-muted"
|
||||
}`}
|
||||
>
|
||||
{item.icon}
|
||||
</span>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium truncate">{item.label}</p>
|
||||
{item.subtitle && (
|
||||
<p
|
||||
className={`text-xs truncate ${
|
||||
flatIndex === selectedIndex
|
||||
? "text-accent/70"
|
||||
: "text-text-muted"
|
||||
}`}
|
||||
>
|
||||
{item.subtitle}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{item.external && (
|
||||
<span className="material-symbols-outlined text-[14px] text-text-muted shrink-0">
|
||||
open_in_new
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<div className="py-10 text-center text-text-muted text-sm">{t("noResults")}</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-4 px-4 py-2 border-t border-black/5 dark:border-white/5 text-[11px] text-text-muted">
|
||||
<span className="flex items-center gap-1">
|
||||
<kbd className="px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono">
|
||||
↑↓
|
||||
</kbd>
|
||||
{t("commandPalette.navigate")}
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<kbd className="px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono">
|
||||
↵
|
||||
</kbd>
|
||||
{t("commandPalette.open")}
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<kbd className="px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono">
|
||||
Esc
|
||||
</kbd>
|
||||
{t("commandPalette.close")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
"use client";
|
||||
// LEGACY SHELL — rendered only when UI_KIT_SHELL=false (cutover kill switch). Removed in the final wave.
|
||||
|
||||
import { Suspense, useEffect, useInsertionEffect, useState } from "react";
|
||||
import Sidebar from "./SidebarLegacy";
|
||||
import Header from "./HeaderLegacy";
|
||||
import NotificationToast from "@/shared/components/NotificationToast";
|
||||
import Breadcrumbs from "@/shared/components/Breadcrumbs";
|
||||
import MaintenanceBanner from "@/shared/components/MaintenanceBanner";
|
||||
import CommandPalette from "./CommandPaletteLegacy";
|
||||
import NavigationProgress from "@/shared/components/NavigationProgress";
|
||||
import { useIsElectron } from "@/shared/hooks/useElectron";
|
||||
import {
|
||||
installDashboardCsrfFetch,
|
||||
prefetchDashboardCsrfToken,
|
||||
} from "@/shared/utils/dashboardCsrf";
|
||||
import { installBasePathFetch } from "@/shared/utils/basePathFetch";
|
||||
|
||||
const SIDEBAR_COLLAPSED_KEY = "sidebar-collapsed";
|
||||
const isE2EMode = process.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE === "1";
|
||||
|
||||
export default function DashboardLayoutLegacy({ children }) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
const [commandPaletteOpen, setCommandPaletteOpen] = useState(false);
|
||||
const isElectron = useIsElectron();
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
if (localStorage.getItem(SIDEBAR_COLLAPSED_KEY) === "true") {
|
||||
setTimeout(() => setCollapsed(true), 0);
|
||||
}
|
||||
} catch {}
|
||||
}, []);
|
||||
|
||||
const isMacElectron =
|
||||
isElectron &&
|
||||
typeof globalThis.window !== "undefined" &&
|
||||
globalThis.electronAPI?.platform === "darwin";
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document === "undefined") return;
|
||||
|
||||
document.body.classList.toggle("electron-macos", isMacElectron);
|
||||
|
||||
return () => {
|
||||
document.body.classList.remove("electron-macos");
|
||||
};
|
||||
}, [isMacElectron]);
|
||||
|
||||
useInsertionEffect(() => {
|
||||
// basePath rewrite must wrap native fetch first so CSRF's originalFetch
|
||||
// chain (and bare `fetch("/api/...")` call sites) hit the subpath.
|
||||
const uninstallBasePathFetch = installBasePathFetch();
|
||||
const uninstallDashboardCsrfFetch = installDashboardCsrfFetch();
|
||||
void prefetchDashboardCsrfToken();
|
||||
return () => {
|
||||
uninstallDashboardCsrfFetch();
|
||||
uninstallBasePathFetch();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
||||
e.preventDefault();
|
||||
setCommandPaletteOpen((prev) => !prev);
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
return () => document.removeEventListener("keydown", handleKeyDown);
|
||||
}, []);
|
||||
|
||||
const handleToggleCollapse = () => {
|
||||
const next = !collapsed;
|
||||
setCollapsed(next);
|
||||
localStorage.setItem(SIDEBAR_COLLAPSED_KEY, String(next));
|
||||
};
|
||||
|
||||
return (
|
||||
// No bg-bg here: the body grid wallpaper (globals.css body::before) shows through
|
||||
// this transparent wrapper into the content area. body's --color-bg is the base fill.
|
||||
<div className="flex h-dvh min-h-0 w-full overflow-hidden">
|
||||
<Suspense fallback={null}>
|
||||
<NavigationProgress />
|
||||
</Suspense>
|
||||
{/* Mobile sidebar overlay */}
|
||||
{sidebarOpen && (
|
||||
<div
|
||||
className="fixed inset-0 z-40 bg-black/20 lg:hidden"
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Sidebar - Desktop: keep visibility independent from Tailwind hidden/lg:flex ordering. */}
|
||||
<div className="dashboard-sidebar-desktop">
|
||||
<Sidebar
|
||||
collapsed={collapsed}
|
||||
onToggleCollapse={handleToggleCollapse}
|
||||
isMacElectron={isMacElectron}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sidebar - Mobile: RTL-safe slide (anchored to right in RTL, left in LTR). */}
|
||||
<div
|
||||
className={`dashboard-sidebar-mobile fixed inset-y-0 start-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out h-dvh overflow-y-auto ${
|
||||
sidebarOpen ? "translate-x-0" : "-translate-x-full rtl:translate-x-full"
|
||||
}`}
|
||||
style={{
|
||||
top: "var(--ios-safe-top, 0px)",
|
||||
bottom: "var(--ios-safe-bottom, 0px)",
|
||||
}}
|
||||
>
|
||||
<Sidebar onClose={() => setSidebarOpen(false)} isMacElectron={isMacElectron} />
|
||||
</div>
|
||||
|
||||
{/* Main content */}
|
||||
<main
|
||||
id="main-content"
|
||||
className="relative flex min-h-0 flex-1 min-w-0 flex-col transition-colors duration-300"
|
||||
>
|
||||
<Header
|
||||
onMenuClick={() => setSidebarOpen(true)}
|
||||
onOpenCommandPalette={() => setCommandPaletteOpen(true)}
|
||||
/>
|
||||
{!isE2EMode && <MaintenanceBanner />}
|
||||
<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar p-4 sm:p-6 lg:p-10">
|
||||
{/* Fluid up to a 4K cap (3840px): content follows the viewport on large
|
||||
monitors and only centers (side gutters) beyond ~4K, instead of the prior
|
||||
1280px cap that left big empty margins on wide screens. */}
|
||||
<div className="max-w-[3840px] mx-auto w-full h-full min-h-0 flex flex-col">
|
||||
<Breadcrumbs />
|
||||
<div className="flex-1 min-h-0">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{/* Global notification toast system */}
|
||||
<NotificationToast />
|
||||
|
||||
<CommandPalette isOpen={commandPaletteOpen} onClose={() => setCommandPaletteOpen(false)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
"use client";
|
||||
// LEGACY SHELL — rendered only when UI_KIT_SHELL=false (cutover kill switch). Removed in the final wave.
|
||||
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
|
||||
const subscribePlatform = () => () => {};
|
||||
const getPlatformIsMac = () => {
|
||||
if (typeof navigator === "undefined") return false;
|
||||
const platform = navigator.platform || navigator.userAgent;
|
||||
return /Mac|iPhone|iPad|iPod/.test(platform);
|
||||
};
|
||||
const getPlatformIsMacServer = () => false;
|
||||
import ThemeToggle from "@/shared/components/ThemeToggle";
|
||||
import TokenHealthBadge from "@/shared/components/TokenHealthBadge";
|
||||
import DegradationBadge from "@/shared/components/DegradationBadge";
|
||||
import LanguageSelector from "@/shared/components/LanguageSelector";
|
||||
import ProviderIcon from "@/shared/components/ProviderIcon";
|
||||
import { useTranslations } from "next-intl";
|
||||
import {
|
||||
OAUTH_PROVIDERS,
|
||||
APIKEY_PROVIDERS,
|
||||
NOAUTH_PROVIDERS,
|
||||
CLAUDE_CODE_COMPATIBLE_PREFIX,
|
||||
OPENAI_COMPATIBLE_PREFIX,
|
||||
ANTHROPIC_COMPATIBLE_PREFIX,
|
||||
} from "@/shared/constants/providers";
|
||||
import {
|
||||
SIDEBAR_SECTIONS,
|
||||
getSectionItems,
|
||||
type SidebarItemDefinition,
|
||||
type HideableSidebarItemId,
|
||||
} from "@/shared/constants/sidebarVisibility";
|
||||
import { useIsElectron } from "@/shared/hooks/useElectron";
|
||||
|
||||
const isE2EMode = process.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE === "1";
|
||||
|
||||
// Map sidebar item id → header description i18n key
|
||||
// "omni-skills" is an extended key for the /dashboard/omni-skills route (graceful fallback during deploy)
|
||||
// `proxy` is a live (non-hideable) item id with its own description, so the key type names it;
|
||||
// the dead `settings` key (no item has that id) was dropped.
|
||||
const HEADER_DESCRIPTIONS: Partial<
|
||||
Record<HideableSidebarItemId | "omni-skills" | "proxy", string>
|
||||
> = {
|
||||
home: "homeDescription",
|
||||
endpoints: "endpointDescription",
|
||||
"api-manager": "apiManagerDescription",
|
||||
providers: "providerDescription",
|
||||
combos: "comboDescription",
|
||||
batch: "batchDescription",
|
||||
costs: "costsDescription",
|
||||
analytics: "analyticsDescription",
|
||||
cache: "cacheDescription",
|
||||
quota: "limitsDescription",
|
||||
runtime: "runtimeDescription",
|
||||
media: "mediaDescription",
|
||||
"cli-code": "cliToolsDescription",
|
||||
"cli-agents": "agentsDescription",
|
||||
"acp-agents": "agentsDescription",
|
||||
"cloud-agents": "cloudAgentsDescription",
|
||||
memory: "memoryDescription",
|
||||
skills: "skillsDescription",
|
||||
"agent-skills": "agentSkillsDescription",
|
||||
"omni-skills": "omniSkillsDescription",
|
||||
"context-caveman": "contextCavemanDescription",
|
||||
"context-rtk": "contextRtkDescription",
|
||||
"context-combos": "contextCombosDescription",
|
||||
translator: "translatorDescription",
|
||||
playground: "playgroundDescription",
|
||||
"search-tools": "searchToolsDescription",
|
||||
logs: "logsDescription",
|
||||
audit: "auditDescription",
|
||||
webhooks: "webhooksDescription",
|
||||
health: "healthDescription",
|
||||
proxy: "proxyDescription",
|
||||
changelog: "changelogDescription",
|
||||
// Protocols
|
||||
mcp: "mcpDescription",
|
||||
a2a: "a2aDescription",
|
||||
"api-endpoints": "apiEndpointsDescription",
|
||||
// Agents & AI sub-pages
|
||||
"batch-files": "batchFilesDescription",
|
||||
// Analytics sub-pages
|
||||
"analytics-evals": "analyticsEvalsDescription",
|
||||
"analytics-search": "analyticsSearchDescription",
|
||||
"analytics-utilization": "analyticsUtilizationDescription",
|
||||
"analytics-combo-health": "analyticsComboHealthDescription",
|
||||
"analytics-compression": "analyticsCompressionDescription",
|
||||
// Costs sub-pages
|
||||
"costs-budget": "costsBudgetDescription",
|
||||
"costs-pricing": "costsPricingDescription",
|
||||
// Logs sub-pages
|
||||
"logs-proxy": "logsProxyDescription",
|
||||
"logs-console": "logsConsoleDescription",
|
||||
"logs-activity": "logsActivityDescription",
|
||||
// Audit sub-pages
|
||||
"audit-mcp": "auditMcpDescription",
|
||||
// Settings sub-pages
|
||||
"settings-general": "settingsGeneralDescription",
|
||||
"settings-appearance": "settingsAppearanceDescription",
|
||||
"settings-ai": "settingsAiDescription",
|
||||
"settings-security": "settingsSecurityDescription",
|
||||
"settings-routing": "settingsRoutingDescription",
|
||||
"settings-resilience": "settingsResilienceDescription",
|
||||
"settings-cache": "settingsCacheDescription",
|
||||
"settings-advanced": "settingsAdvancedDescription",
|
||||
// Proxy sub-pages
|
||||
"mitm-proxy": "mitmProxyDescription",
|
||||
"1proxy": "oneProxyDescription",
|
||||
};
|
||||
|
||||
// Build href → sidebar item lookup (non-external items only)
|
||||
const sidebarByHref = new Map<string, SidebarItemDefinition>();
|
||||
for (const section of SIDEBAR_SECTIONS) {
|
||||
for (const item of getSectionItems(section)) {
|
||||
if (!item.external) sidebarByHref.set(item.href, item);
|
||||
}
|
||||
}
|
||||
|
||||
function getSidebarItem(pathname: string): SidebarItemDefinition | undefined {
|
||||
const exact = sidebarByHref.get(pathname);
|
||||
if (exact) return exact;
|
||||
// Longest prefix match
|
||||
let best: SidebarItemDefinition | undefined;
|
||||
let bestLen = 0;
|
||||
for (const [href, item] of sidebarByHref) {
|
||||
if (pathname.startsWith(href) && href.length > bestLen) {
|
||||
best = item;
|
||||
bestLen = href.length;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
type HeaderProps = {
|
||||
onMenuClick?: () => void;
|
||||
onOpenCommandPalette?: () => void;
|
||||
showMenuButton?: boolean;
|
||||
};
|
||||
|
||||
type PageInfo = {
|
||||
title: string;
|
||||
description: string;
|
||||
icon?: string;
|
||||
providerId?: string;
|
||||
};
|
||||
|
||||
function usePageInfo(pathname: string | null): PageInfo {
|
||||
const ts = useTranslations("sidebar");
|
||||
const th = useTranslations("header");
|
||||
|
||||
if (!pathname) return { title: "", description: "" };
|
||||
|
||||
// Special: provider detail page /dashboard/providers/[id]
|
||||
const providerMatch = pathname.match(/\/providers\/([^/]+)$/);
|
||||
if (providerMatch) {
|
||||
const pid = providerMatch[1];
|
||||
const info = OAUTH_PROVIDERS[pid] || NOAUTH_PROVIDERS[pid] || APIKEY_PROVIDERS[pid];
|
||||
if (info) return { title: info.name, description: "", providerId: info.id };
|
||||
if (pid.startsWith(CLAUDE_CODE_COMPATIBLE_PREFIX))
|
||||
return { title: "CC Compatible", description: "", providerId: "claude" };
|
||||
if (pid.startsWith(OPENAI_COMPATIBLE_PREFIX))
|
||||
return { title: th("openaiCompatible"), description: "", providerId: "oai-cc" };
|
||||
if (pid.startsWith(ANTHROPIC_COMPATIBLE_PREFIX))
|
||||
return { title: th("anthropicCompatible"), description: "", providerId: "anthropic-m" };
|
||||
}
|
||||
|
||||
// Derive from sidebar
|
||||
const item = getSidebarItem(pathname);
|
||||
if (item) {
|
||||
const descKey = HEADER_DESCRIPTIONS[item.id];
|
||||
return {
|
||||
title: ts(item.i18nKey),
|
||||
description: descKey ? th(descKey) : "",
|
||||
icon: item.icon,
|
||||
};
|
||||
}
|
||||
|
||||
return { title: "", description: "" };
|
||||
}
|
||||
|
||||
export default function Header({
|
||||
onMenuClick,
|
||||
onOpenCommandPalette,
|
||||
showMenuButton = true,
|
||||
}: HeaderProps) {
|
||||
const isMac = useSyncExternalStore(subscribePlatform, getPlatformIsMac, getPlatformIsMacServer);
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const isElectron = useIsElectron();
|
||||
const t = useTranslations("header");
|
||||
const { title, description, icon, providerId } = usePageInfo(pathname);
|
||||
const isMacElectron =
|
||||
isElectron &&
|
||||
typeof window !== "undefined" &&
|
||||
(window as any).electronAPI?.platform === "darwin";
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/auth/logout", { method: "POST" });
|
||||
if (res.ok) {
|
||||
router.push("/login");
|
||||
router.refresh();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to logout:", err);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<header
|
||||
className="sticky top-0 z-10 flex items-center justify-between border-b border-black/5 bg-bg px-8 py-4 dark:border-white/5"
|
||||
style={{
|
||||
paddingTop: isMacElectron
|
||||
? "calc(1rem + var(--desktop-safe-top))"
|
||||
: "calc(1rem + var(--ios-safe-top, 0px))",
|
||||
}}
|
||||
>
|
||||
{/* Mobile menu button */}
|
||||
<div className="flex items-center gap-3 lg:hidden">
|
||||
{showMenuButton && (
|
||||
<button
|
||||
onClick={onMenuClick}
|
||||
className="text-text-main hover:text-primary transition-colors"
|
||||
>
|
||||
<span className="material-symbols-outlined">menu</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Page title with icon - desktop */}
|
||||
<div className="hidden lg:flex items-center gap-3">
|
||||
{(icon || providerId) && (
|
||||
<div className="flex items-center justify-center size-9 rounded-lg bg-primary/10 shrink-0">
|
||||
{icon ? (
|
||||
<span className="material-symbols-outlined text-primary text-[20px]">{icon}</span>
|
||||
) : (
|
||||
providerId && <ProviderIcon providerId={providerId} size={22} type="color" />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{title && (
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-text-main tracking-tight">{title}</h1>
|
||||
{description && <p className="text-xs text-text-muted mt-0.5">{description}</p>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right actions */}
|
||||
<div className="flex items-center gap-3 ml-auto">
|
||||
{onOpenCommandPalette && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenCommandPalette}
|
||||
className="hidden md:inline-flex items-center gap-2 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 bg-bg-subtle text-text-muted hover:text-text-main hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors"
|
||||
title={t("quickNavigationTitle")}
|
||||
aria-label={t("openQuickNavigation")}
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px]">search</span>
|
||||
<span className="text-xs">{t("quickNavigation")}</span>
|
||||
<kbd className="hidden lg:inline-flex font-mono text-[10px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10">
|
||||
{isMac ? "⌘K" : "Ctrl+K"}
|
||||
</kbd>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenCommandPalette}
|
||||
className="md:hidden p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-colors"
|
||||
aria-label={t("openQuickNavigation")}
|
||||
>
|
||||
<span className="material-symbols-outlined">search</span>
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<LanguageSelector />
|
||||
<ThemeToggle />
|
||||
{!isE2EMode && <DegradationBadge />}
|
||||
{!isE2EMode && <TokenHealthBadge />}
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className="flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all"
|
||||
title={t("logout")}
|
||||
aria-label={t("logout")}
|
||||
>
|
||||
<span className="material-symbols-outlined">logout</span>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -589,18 +589,6 @@ export const FEATURE_FLAG_DEFINITIONS: FeatureFlagDefinition[] = [
|
||||
requiresRestart: false,
|
||||
warningLevel: "info",
|
||||
},
|
||||
{
|
||||
key: "UI_KIT_SHELL",
|
||||
label: "Keak UI Kit Shell",
|
||||
description:
|
||||
"Render the dashboard shell (sidebar, header, command palette) with the Keak CI UI Kit. Disable to fall back to the legacy shell during the cutover.",
|
||||
descriptionI18nKey: "featureFlagUiKitShellDescription",
|
||||
category: "runtime",
|
||||
defaultValue: "true",
|
||||
type: "boolean",
|
||||
requiresRestart: false,
|
||||
warningLevel: "info",
|
||||
},
|
||||
{
|
||||
key: "RESPONSES_PASSTHROUGH_DROP_COMMENTARY",
|
||||
label: "Drop Responses Commentary",
|
||||
|
||||
@@ -314,12 +314,10 @@ import {
|
||||
// Droplet and Mail are imported by the blocks above.
|
||||
import {
|
||||
Aperture,
|
||||
ArrowBigUp,
|
||||
AudioWaveform,
|
||||
BellRing,
|
||||
Bird,
|
||||
Box,
|
||||
Boxes,
|
||||
BrainCog,
|
||||
BriefcaseBusiness,
|
||||
Brush,
|
||||
@@ -334,7 +332,6 @@ import {
|
||||
Leaf,
|
||||
MicVocal,
|
||||
PackageCheck,
|
||||
PackageOpen,
|
||||
PawPrint,
|
||||
Plane,
|
||||
Router,
|
||||
@@ -348,14 +345,17 @@ import {
|
||||
Wind,
|
||||
} from "lucide-react";
|
||||
|
||||
// F4 (Task 41) — picks that the F4 sweep block above does not import (KEA-7886).
|
||||
import { ArrowBigUpDash, Blend } from "lucide-react";
|
||||
|
||||
/**
|
||||
* Material Symbols name → Lucide icon. `null` = still rendered with the Material ligature by
|
||||
* <Icon> (fallback); no entry is null since the F4 sweep, and names in use must stay mapped
|
||||
* (tests/unit/icon-map-object-values.test.ts). Every name in use MUST have an
|
||||
* entry (tests/unit/icon-map-coverage.test.ts); `npm run gen:icon-map` prints the missing ones.
|
||||
* Icon name (the Material Symbols vocabulary the screens use) → Lucide icon. Every name in use
|
||||
* MUST map to a Lucide glyph (tests/unit/icon-map-coverage.test.ts for literal names,
|
||||
* tests/unit/icon-map-object-values.test.ts for object-map values); `npm run gen:icon-map`
|
||||
* prints the missing ones. An unmapped name renders <Icon>'s neutral placeholder glyph.
|
||||
* Navigation uses one ink (no per-item accent) — SIDEBAR_ICON_ACCENTS was retired (spec §3.5).
|
||||
*/
|
||||
export const ICON_MAP: Record<string, LucideIcon | null> = {
|
||||
export const ICON_MAP: Record<string, LucideIcon> = {
|
||||
// ── shell + primitives ──
|
||||
home: House,
|
||||
settings: Settings,
|
||||
@@ -610,7 +610,7 @@ export const ICON_MAP: Record<string, LucideIcon | null> = {
|
||||
gpp_maybe: ShieldAlert,
|
||||
graphic_eq: AudioLines,
|
||||
grid_view: LayoutGrid,
|
||||
group_work: Boxes,
|
||||
group_work: Blend,
|
||||
handshake: Handshake,
|
||||
handyman: Hammer,
|
||||
hearing: Ear,
|
||||
@@ -621,13 +621,13 @@ export const ICON_MAP: Record<string, LucideIcon | null> = {
|
||||
input: ArrowRightToLine,
|
||||
insert_drive_file: File,
|
||||
install_desktop: MonitorDown,
|
||||
inventory_2: PackageOpen,
|
||||
inventory_2: Archive,
|
||||
// Lucide has no key-off glyph; KeyRound is the closest key icon (the "no key" meaning comes from the label).
|
||||
key_off: KeyRound,
|
||||
key_vertical: KeyRound,
|
||||
keyboard_arrow_down: ChevronDown,
|
||||
keyboard_arrow_up: ChevronUp,
|
||||
keyboard_capslock: ArrowBigUp,
|
||||
keyboard_capslock: ArrowBigUpDash,
|
||||
label: Tag,
|
||||
library_books: LibraryBig,
|
||||
linear_scale: GitCommitHorizontal,
|
||||
@@ -767,6 +767,7 @@ export const ICON_MAP: Record<string, LucideIcon | null> = {
|
||||
};
|
||||
|
||||
export function resolveIcon(name: string | null | undefined): LucideIcon | null {
|
||||
if (!name) return null;
|
||||
return ICON_MAP[name] ?? null;
|
||||
// Own keys only: `constructor`/`toString` must not resolve to Object.prototype members.
|
||||
if (!name || !Object.hasOwn(ICON_MAP, name)) return null;
|
||||
return ICON_MAP[name];
|
||||
}
|
||||
|
||||
@@ -207,27 +207,6 @@ export function isArenaEloSyncEnabled(): boolean {
|
||||
return isFeatureFlagEnabled("ARENA_ELO_SYNC_ENABLED");
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard shell renderer (KEA-7886): kit shell when true, legacy shell when false.
|
||||
* Read by the server dashboard layout, so a failing flag read (DB error) must never break the
|
||||
* render: it falls back to the definition default instead of throwing.
|
||||
*/
|
||||
export function isUiKitShellEnabled(
|
||||
reader: (key: string) => boolean = isFeatureFlagEnabled
|
||||
): boolean {
|
||||
try {
|
||||
return reader("UI_KIT_SHELL");
|
||||
} catch (error) {
|
||||
const fallback =
|
||||
FEATURE_FLAG_DEFINITIONS.find((d) => d.key === "UI_KIT_SHELL")?.defaultValue === "true";
|
||||
console.error(
|
||||
`[featureFlags] Failed to resolve UI_KIT_SHELL, defaulting to ${fallback ? "enabled" : "disabled"}:`,
|
||||
error instanceof Error ? error.message : error
|
||||
);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export function isControlPlaneProxyDirectFallbackEnabled(): boolean {
|
||||
try {
|
||||
return isFeatureFlagEnabled("OMNIROUTE_CONTROL_PLANE_PROXY_DIRECT_FALLBACK");
|
||||
|
||||
@@ -9,10 +9,7 @@ const tailwind = require("@tailwindcss/postcss");
|
||||
`@import "tailwindcss" source(none); @source "${resolve("src/app/(dashboard)/dashboard/usage/components/ProviderLimits/parts/QuotaCardExpanded.tsx")}";`,
|
||||
{ from: resolve("src/layout-test.css") }
|
||||
);
|
||||
const font = readFileSync(
|
||||
resolve("node_modules/material-symbols/material-symbols-outlined.woff2")
|
||||
).toString("base64");
|
||||
const fontCss = `@font-face{font-family:Symbols;src:url(data:font/woff2;base64,${font})}.material-symbols-outlined{font-family:Symbols;font-weight:normal;font-style:normal;line-height:1;white-space:nowrap;word-wrap:normal;font-feature-settings:'liga'}`;
|
||||
// Icons are inline Lucide SVGs (KEA-7886): no icon font to load into the page.
|
||||
const fixture = readFileSync(process.argv[2], "utf8");
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
@@ -29,7 +26,7 @@ const tailwind = require("@tailwindcss/postcss");
|
||||
String(messages[key] || key)
|
||||
);
|
||||
await page.setContent(
|
||||
`<style>${css}\n${fontCss}</style><div id="card" style="width:${width}px;overflow:hidden">${html}</div>`
|
||||
`<style>${css}</style><div id="card" style="width:${width}px;overflow:hidden">${html}</div>`
|
||||
);
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
const buttons = page.locator("#card button");
|
||||
|
||||
@@ -465,20 +465,17 @@ describe("Barrel Exports — shared/components/layouts", () => {
|
||||
// ─── Layout and Page Integration ────────────────────
|
||||
|
||||
describe("DashboardLayout Integration", () => {
|
||||
// DashboardLayout.tsx selects the shell (UI_KIT_SHELL); both shells mount the toast system.
|
||||
// DashboardLayout.tsx renders the kit shell (DashboardShell), which mounts the toast system.
|
||||
const src = readProjectFile("src/shared/components/layouts/DashboardShell.tsx");
|
||||
const legacySrc = readProjectFile(
|
||||
"src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx"
|
||||
);
|
||||
|
||||
it("should render NotificationToast globally", () => {
|
||||
assert.ok(src, "src/shared/components/layouts/DashboardShell.tsx should exist");
|
||||
assert.match(src, /NotificationToast/);
|
||||
assert.ok(
|
||||
legacySrc,
|
||||
"src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx should exist"
|
||||
assert.match(
|
||||
readProjectFile("src/shared/components/layouts/DashboardLayout.tsx"),
|
||||
/<DashboardShell\b/,
|
||||
"DashboardLayout renders the kit shell"
|
||||
);
|
||||
assert.match(legacySrc, /NotificationToast/);
|
||||
});
|
||||
|
||||
it.skip("should include Breadcrumbs in page wrapper", () => {
|
||||
|
||||
@@ -10,60 +10,11 @@ function readSrc(path: string): string {
|
||||
return readFileSync(join(ROOT, path), "utf8");
|
||||
}
|
||||
|
||||
// Regression guard: the desktop dashboard sidebar must stay visible on desktop.
|
||||
// The old `hidden ... lg:flex` Tailwind cascade is fragile — class ordering /
|
||||
// specificity can collapse the `lg:flex` and leave the sidebar permanently
|
||||
// hidden. The fix moves visibility into an explicit `.dashboard-sidebar-desktop`
|
||||
// class backed by a 1024px media query in globals.css.
|
||||
|
||||
// The `.dashboard-sidebar-desktop` contract belongs to the legacy shell (UI_KIT_SHELL=false kill
|
||||
// switch); the kit shell mounts the sidebar through SidebarProvider/SidebarInset (test below).
|
||||
test("DashboardLayout desktop sidebar uses the explicit visibility class, not the hidden/lg:flex cascade", () => {
|
||||
const source = readSrc("src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx");
|
||||
|
||||
// The desktop sidebar wrapper must reference the dedicated class.
|
||||
assert.match(
|
||||
source,
|
||||
/className="dashboard-sidebar-desktop"/,
|
||||
"Desktop sidebar wrapper must use the dashboard-sidebar-desktop class"
|
||||
);
|
||||
|
||||
// The fragile Tailwind cascade must be gone.
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/className="hidden[^"]*lg:flex"/,
|
||||
"Desktop sidebar wrapper must not rely on the hidden/lg:flex Tailwind cascade"
|
||||
);
|
||||
});
|
||||
|
||||
test("globals.css defines dashboard-sidebar-desktop hidden by default and flex at >=1024px", () => {
|
||||
const css = readSrc("src/app/globals.css");
|
||||
|
||||
// Class exists.
|
||||
assert.match(
|
||||
css,
|
||||
/\.dashboard-sidebar-desktop\s*\{/,
|
||||
"globals.css must define .dashboard-sidebar-desktop"
|
||||
);
|
||||
|
||||
// Hidden by default (mobile-first), then shown via a 1024px desktop media query.
|
||||
const classIndex = css.indexOf(".dashboard-sidebar-desktop");
|
||||
const desktopRule =
|
||||
/@media\s*\(min-width:\s*1024px\)\s*\{[^}]*\.dashboard-sidebar-desktop\s*\{[^}]*display:\s*flex/;
|
||||
assert.match(
|
||||
css.slice(classIndex - 200),
|
||||
desktopRule,
|
||||
"globals.css must show .dashboard-sidebar-desktop with display:flex at min-width:1024px"
|
||||
);
|
||||
|
||||
// Default state hides it (display:none) so mobile is unaffected.
|
||||
const baseRule = /\.dashboard-sidebar-desktop\s*\{[^}]*display:\s*none/;
|
||||
assert.match(
|
||||
css,
|
||||
baseRule,
|
||||
"globals.css must hide .dashboard-sidebar-desktop by default (display:none)"
|
||||
);
|
||||
});
|
||||
// Regression guard: the desktop dashboard sidebar must stay visible on desktop. The old
|
||||
// `hidden ... lg:flex` Tailwind cascade was fragile (class ordering / specificity could collapse
|
||||
// the `lg:flex` and hide the sidebar for good). The legacy shell answered with an explicit
|
||||
// `.dashboard-sidebar-desktop` class; since KEA-7886 F4 the only shell is the kit one, which
|
||||
// mounts the sidebar through SidebarProvider/SidebarInset and never uses that cascade.
|
||||
|
||||
test("the kit shell mounts the sidebar through SidebarProvider/SidebarInset (no hidden/lg:flex cascade)", () => {
|
||||
const shell = readSrc("src/shared/components/layouts/DashboardShell.tsx");
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { resolve, join } from "node:path";
|
||||
|
||||
// Regression guard for #3695: the dashboard icons turned into their literal
|
||||
// text names ("smart_toy", "visibility", ...) and the layout broke for users
|
||||
// on networks where the Google Fonts CDN (fonts.googleapis.com / fonts.gstatic.com)
|
||||
// is unreachable — e.g. mainland China. Root cause: the Material Symbols icon
|
||||
// font (the sole source of the .material-symbols-outlined @font-face) was loaded
|
||||
// only from that CDN in src/app/layout.tsx. The fix self-hosts the font via the
|
||||
// `material-symbols` npm package imported in globals.css. These assertions fail
|
||||
// on the pre-fix tree and stay green afterwards, preventing re-introduction of a
|
||||
// runtime CDN dependency for icons.
|
||||
|
||||
const cwd = process.cwd();
|
||||
const layoutPath = resolve(join(cwd, "src/app/layout.tsx"));
|
||||
const globalsPath = resolve(join(cwd, "src/app/globals.css"));
|
||||
|
||||
test("layout.tsx does not load the Material Symbols icon font from the Google Fonts CDN", () => {
|
||||
const layout = readFileSync(layoutPath, "utf8");
|
||||
assert.ok(
|
||||
!/fonts\.googleapis\.com[^"'\s]*Material\+Symbols/i.test(layout),
|
||||
"layout.tsx must not load Material Symbols from fonts.googleapis.com (blocked in some regions)"
|
||||
);
|
||||
assert.ok(
|
||||
!/fonts\.gstatic\.com/.test(layout),
|
||||
"layout.tsx must not preconnect to the Google Fonts CDN for the icon font"
|
||||
);
|
||||
});
|
||||
|
||||
test("globals.css imports the self-hosted Material Symbols font", () => {
|
||||
const globals = readFileSync(globalsPath, "utf8");
|
||||
assert.match(
|
||||
globals,
|
||||
/@import\s+["']material-symbols\/outlined\.css["']/,
|
||||
"globals.css must @import the self-hosted material-symbols/outlined.css"
|
||||
);
|
||||
});
|
||||
|
||||
test("the self-hosted material-symbols package is declared and resolvable", () => {
|
||||
const pkg = JSON.parse(readFileSync(resolve(join(cwd, "package.json")), "utf8")) as {
|
||||
dependencies?: Record<string, string>;
|
||||
};
|
||||
assert.ok(
|
||||
pkg.dependencies?.["material-symbols"],
|
||||
"package.json must declare the material-symbols dependency"
|
||||
);
|
||||
// The bundled CSS that supplies the @font-face + woff2 must exist on disk so the
|
||||
// build can inline it (only enforced when node_modules is installed).
|
||||
const cssPath = resolve(join(cwd, "node_modules/material-symbols/outlined.css"));
|
||||
if (existsSync(resolve(join(cwd, "node_modules/material-symbols")))) {
|
||||
assert.ok(
|
||||
existsSync(cssPath),
|
||||
"material-symbols/outlined.css must exist in the installed package"
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -29,7 +29,6 @@ test("globals.css loads the self-hosted Keak fonts and the vendored kit CSS righ
|
||||
'@import "@fontsource/ibm-plex-mono/600.css";',
|
||||
'@import "@fontsource/ibm-plex-mono/700.css";',
|
||||
'@import "../../packages/ui-kit/src/ci-ui.css";',
|
||||
'@import "material-symbols/outlined.css" layer(base);',
|
||||
].map((needle) => css.indexOf(needle));
|
||||
assert.ok(
|
||||
order.every((i) => i >= 0),
|
||||
@@ -63,9 +62,7 @@ test("the OmniRoute color tokens are aliases of kit tokens (no hex left in :root
|
||||
["--color-primary", "var(--ci-color-accent)"],
|
||||
["--color-primary-hover", "var(--ci-color-accent-hover)"],
|
||||
["--color-accent", "var(--ci-color-accent)"],
|
||||
["--color-accent-hover", "var(--ci-color-accent-hover)"],
|
||||
["--color-accent-light", "var(--ci-color-accent-surface-strong)"],
|
||||
["--grad-brand", "var(--ci-color-accent)"],
|
||||
["--color-success", "var(--ci-color-success)"],
|
||||
["--color-warning", "var(--ci-color-warning)"],
|
||||
["--color-error", "var(--ci-color-danger)"],
|
||||
@@ -77,7 +74,6 @@ test("the OmniRoute color tokens are aliases of kit tokens (no hex left in :root
|
||||
["--color-fd-background", "var(--ci-color-background)"],
|
||||
["--color-fd-primary", "var(--ci-color-accent)"],
|
||||
["--table-header-bg", "var(--ci-color-surface-muted)"],
|
||||
["--table-cell-border", "var(--ci-color-border-subtle)"],
|
||||
] as const) {
|
||||
assert.ok(root.includes(`${name}: ${target};`), `:root maps ${name} → ${target}`);
|
||||
}
|
||||
@@ -238,22 +234,17 @@ test("flow surfaces still express state with --orch-status-* tokens, not fixed h
|
||||
// ── Guards carried verbatim in spirit from design-grid-background.test.ts (383c5dc5d479) that
|
||||
// stay true after the bridge; the grid/14px/gradient/STATUS_HEX ones were obsolete by design.
|
||||
test("DashboardLayout content shell is fluid up to ~4K before centering", () => {
|
||||
// DashboardLayout.tsx is the UI_KIT_SHELL selector since trilha F: the content wrapper lives in
|
||||
// the kit shell (DashboardShell) and in the legacy shell kept behind the flag.
|
||||
for (const file of [
|
||||
"src/shared/components/layouts/DashboardShell.tsx",
|
||||
"src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx",
|
||||
]) {
|
||||
const dashboardLayout = read(file);
|
||||
assert.ok(
|
||||
dashboardLayout.includes("max-w-[3840px] mx-auto"),
|
||||
`${file}: content wrapper caps at 3840px (4K) and centers only beyond that`
|
||||
);
|
||||
assert.ok(
|
||||
!dashboardLayout.includes("max-w-7xl"),
|
||||
`${file}: the old 1280px max-w-7xl cap is gone`
|
||||
);
|
||||
}
|
||||
// The content wrapper lives in the kit shell (DashboardShell), the only shell since KEA-7886 F4.
|
||||
const file = "src/shared/components/layouts/DashboardShell.tsx";
|
||||
const dashboardLayout = read(file);
|
||||
assert.ok(
|
||||
dashboardLayout.includes("max-w-[3840px] mx-auto"),
|
||||
`${file}: content wrapper caps at 3840px (4K) and centers only beyond that`
|
||||
);
|
||||
assert.ok(
|
||||
!dashboardLayout.includes("max-w-7xl"),
|
||||
`${file}: the old 1280px max-w-7xl cap is gone`
|
||||
);
|
||||
});
|
||||
|
||||
test("DataTable is theme-aware via --table-* tokens, no color literal, no dead fallbacks", () => {
|
||||
@@ -413,6 +404,23 @@ test("text-primary resolves to a readable primary ink; lime stays on bg/border/r
|
||||
assert.match(css, /::selection \{[^}]*\n\s*color: var\(--color-primary-ink\);/);
|
||||
});
|
||||
|
||||
test("token aliases with no consumer are gone (KEA-7886 F4)", () => {
|
||||
for (const token of [
|
||||
"--grad-brand",
|
||||
"--color-accent-hover",
|
||||
"--color-traffic-red",
|
||||
"--color-traffic-yellow",
|
||||
"--color-traffic-green",
|
||||
"--table-row-zebra",
|
||||
"--table-row-hover",
|
||||
"--table-cell-border",
|
||||
"--table-row-selected",
|
||||
]) {
|
||||
assert.ok(!css.includes(`${token}:`), `${token} is no longer declared`);
|
||||
}
|
||||
assert.doesNotMatch(css, /\.traffic-lights?\b/, "the unused .traffic-light(s) chrome is gone");
|
||||
});
|
||||
|
||||
test("the primary Badge tone keeps dark ink in light and takes the lime ink in dark (F4)", () => {
|
||||
// Light: near-black ink on lime-100. Dark: the kit keeps --ci-color-accent-foreground near-black
|
||||
// while the surface becomes a 14 % lime tint over the dark background, so the "8 features"
|
||||
|
||||
@@ -58,7 +58,7 @@ const {
|
||||
// tool_call wrapper repair, default on) to 86.
|
||||
// OPENCODE_PUBLISHED_CATALOG_ROUTING_ENABLED (#16798, OpenCode model surface from the
|
||||
// published catalog, default off) takes it to 87.
|
||||
const EXPECTED_FEATURE_FLAG_COUNT = 112;
|
||||
const EXPECTED_FEATURE_FLAG_COUNT = 111;
|
||||
// tool_call wrapper repair, default on) to 86; OPENCODE_V2_CLIENT_FINGERPRINT_ENABLED
|
||||
// (#16571, OpenCode v2 client fingerprint, default off) to 87.
|
||||
// tool_call wrapper repair, default on) to 86; CLAUDE_OAUTH_SUMMARIZED_THINKING_UNREDACTED
|
||||
|
||||
@@ -6,7 +6,10 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
|
||||
test("every Material Symbols name used in src/ has an entry in ICON_MAP (Lucide or explicit null)", async () => {
|
||||
// KEA-7886 F4: the Material Symbols font is gone, so <Icon> has no ligature fallback — a name
|
||||
// missing from ICON_MAP draws a placeholder glyph. Every icon name used in src/ must therefore
|
||||
// map to a real Lucide component.
|
||||
test("every icon name used in src/ maps to a Lucide icon in ICON_MAP", async () => {
|
||||
const out = execFileSync(process.execPath, ["scripts/dev/gen-icon-map.mjs", "--names"], {
|
||||
cwd: ROOT,
|
||||
}).toString();
|
||||
@@ -16,43 +19,62 @@ test("every Material Symbols name used in src/ has an entry in ICON_MAP (Lucide
|
||||
.filter(Boolean);
|
||||
assert.ok(
|
||||
names.length > 250,
|
||||
`the scanner found ${names.length} names; expected the ~330 in use`
|
||||
`the scanner found ${names.length} names; expected the ~380 in use`
|
||||
);
|
||||
const { ICON_MAP } = await import("../../src/shared/constants/iconMap.ts");
|
||||
const missing = names.filter((n) => !(n in ICON_MAP));
|
||||
const unmapped = names.filter((n) => typeof ICON_MAP[n] !== "object" || ICON_MAP[n] === null);
|
||||
assert.deepEqual(
|
||||
missing,
|
||||
unmapped,
|
||||
[],
|
||||
`names without an ICON_MAP entry (run: npm run gen:icon-map):\n${missing.join("\n")}`
|
||||
`names without a Lucide icon in ICON_MAP:\n${unmapped.join("\n")}\n` +
|
||||
"Real icon → map it to a Lucide component in src/shared/constants/iconMap.ts (npm run gen:icon-map). " +
|
||||
"Not an icon (a logo key, a size key… in an `icon:` slot that never reaches <Icon>) → add it to " +
|
||||
"NOT_ICON_NAMES in scripts/dev/gen-icon-map.mjs with the proof, never map it to a fake glyph."
|
||||
);
|
||||
});
|
||||
|
||||
test("the generator never emits a name outside the Material Symbols vocabulary", async () => {
|
||||
const { collectNames, loadDtsNames, LEGACY_LIGATURES } =
|
||||
await import("../../scripts/dev/gen-icon-map.mjs");
|
||||
// Vocabulary rebuilt here from the two exported sources, not via loadMaterialNames(), so the
|
||||
// loop below checks the generator against an independent set instead of its own filter.
|
||||
const dts = loadDtsNames(ROOT);
|
||||
assert.ok(dts.size > 3000, `expected the full Material vocabulary, got ${dts.size}`);
|
||||
const vocabulary = new Set([...dts, ...LEGACY_LIGATURES]);
|
||||
const names = collectNames(ROOT);
|
||||
// Regression guard: these were ICON_MAP keys before the vocabulary filter existed.
|
||||
assert.ok(!names.includes("true") && !names.includes("anthropic"), "non-icon strings leaked");
|
||||
for (const n of names) assert.ok(vocabulary.has(n), `"${n}" is not a Material Symbols name`);
|
||||
test("ICON_MAP has no null entry and every value is a Lucide component", async () => {
|
||||
const { ICON_MAP } = await import("../../src/shared/constants/iconMap.ts");
|
||||
const bad = Object.entries(ICON_MAP)
|
||||
.filter(([, icon]) => !icon || typeof icon !== "object" || !("render" in icon))
|
||||
.map(([name]) => name);
|
||||
assert.deepEqual(bad, [], `entries that are not Lucide components:\n${bad.join("\n")}`);
|
||||
});
|
||||
|
||||
test("the scanner sees names already converted to <Icon name>", async () => {
|
||||
const { collectNamesFromSource, loadMaterialNames } =
|
||||
await import("../../scripts/dev/gen-icon-map.mjs");
|
||||
const vocabulary = loadMaterialNames(ROOT);
|
||||
test("the generator drops the known non-icon strings", async () => {
|
||||
const { collectNames, NOT_ICON_NAMES } = await import("../../scripts/dev/gen-icon-map.mjs");
|
||||
const names = collectNames(ROOT);
|
||||
// Regression guard: provider logo keys and size keys once leaked into ICON_MAP as fake icons.
|
||||
for (const n of ["anthropic", "server", "proxy", "icon", "generic"]) {
|
||||
assert.ok(!names.includes(n), `"${n}" is not an icon name`);
|
||||
}
|
||||
assert.ok(NOT_ICON_NAMES.size > 0);
|
||||
});
|
||||
|
||||
test("the scanner sees names in <Icon name>, icon props and ternaries, but not data-*-icon attrs", async () => {
|
||||
const { collectNamesFromSource } = await import("../../scripts/dev/gen-icon-map.mjs");
|
||||
const source = `
|
||||
<Icon name="settings" size={16} />
|
||||
<Icon name={x ? "light_mode" : "dark_mode"} className="shrink-0" />
|
||||
<Icon name={active ? "true" : "anthropic"} />
|
||||
<Button icon="add" iconRight={open ? "expand_less" : "expand_more"} />
|
||||
<span data-provider-icon="generic" />
|
||||
const TABS = [{ id: "a", icon: "tune" }];
|
||||
`;
|
||||
assert.deepEqual(collectNamesFromSource(source, vocabulary), [
|
||||
assert.deepEqual(collectNamesFromSource(source), [
|
||||
"add",
|
||||
"dark_mode",
|
||||
"expand_less",
|
||||
"expand_more",
|
||||
"light_mode",
|
||||
"settings",
|
||||
"tune",
|
||||
]);
|
||||
});
|
||||
|
||||
test("resolveIcon only resolves own ICON_MAP keys (no Object.prototype members)", async () => {
|
||||
const { resolveIcon } = await import("../../src/shared/constants/iconMap.ts");
|
||||
for (const name of ["constructor", "toString", "hasOwnProperty", "__proto__"]) {
|
||||
assert.equal(resolveIcon(name), null, `${name} is not an icon`);
|
||||
}
|
||||
assert.ok(resolveIcon("settings"), "a real key still resolves");
|
||||
});
|
||||
|
||||
@@ -141,6 +141,6 @@ test("every Material name the literal scanner finds resolves to Lucide (no null
|
||||
assert.deepEqual(
|
||||
unresolved,
|
||||
[],
|
||||
`names in use that still render the Material ligature:\n${unresolved.join("\n")}`
|
||||
`names in use without a Lucide icon (they would draw the <Icon> placeholder glyph):\n${unresolved.join("\n")}`
|
||||
);
|
||||
});
|
||||
|
||||
75
tests/unit/material-symbols-removed.test.ts
Normal file
75
tests/unit/material-symbols-removed.test.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
// KEA-7886 F4 (Task 41): the cutover is over — the legacy shell, its UI_KIT_SHELL kill switch and
|
||||
// the Material Symbols icon font are gone; every icon renders through <Icon> → Lucide.
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
const read = (p: string) => fs.readFileSync(path.join(ROOT, p), "utf8");
|
||||
|
||||
/** Files under `dirs` that contain `needle` (`grep -rl` exits 1 when nothing matches). */
|
||||
function filesContaining(needle: string, dirs: string[], includes: string[]): string {
|
||||
try {
|
||||
return execFileSync(
|
||||
"grep",
|
||||
["-rl", ...includes.map((glob) => `--include=${glob}`), needle, ...dirs],
|
||||
{ cwd: ROOT }
|
||||
)
|
||||
.toString()
|
||||
.trim();
|
||||
} catch (error) {
|
||||
if ((error as { status?: number }).status === 1) return "";
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
test("Material Symbols is gone: no import, no dependency, no ligature span, no null in ICON_MAP", () => {
|
||||
const css = read("src/app/globals.css");
|
||||
assert.doesNotMatch(css, /material-symbols/);
|
||||
const pkg = JSON.parse(read("package.json"));
|
||||
assert.equal(pkg.dependencies?.["material-symbols"], undefined);
|
||||
assert.equal(pkg.devDependencies?.["material-symbols"], undefined);
|
||||
assert.doesNotMatch(read("next.config.mjs"), /material-symbols/);
|
||||
const hits = filesContaining(
|
||||
"material-symbols-outlined",
|
||||
["src", "public"],
|
||||
["*.tsx", "*.ts", "*.css", "*.html"]
|
||||
);
|
||||
assert.equal(hits, "", `files still using the Material ligature:\n${hits}`);
|
||||
assert.doesNotMatch(read("src/shared/constants/iconMap.ts"), /:\s*null,/);
|
||||
});
|
||||
|
||||
test("the legacy shell, its CSS hooks and the UI_KIT_SHELL flag are removed", () => {
|
||||
assert.ok(
|
||||
!fs.existsSync(path.join(ROOT, "src/shared/components/layouts/legacy")),
|
||||
"legacy shell removed"
|
||||
);
|
||||
assert.doesNotMatch(read("src/shared/constants/featureFlagDefinitions.ts"), /UI_KIT_SHELL/);
|
||||
assert.doesNotMatch(read("src/shared/utils/featureFlags.ts"), /UI_KIT_SHELL|isUiKitShellEnabled/);
|
||||
assert.doesNotMatch(read("src/app/(dashboard)/layout.tsx"), /isUiKitShellEnabled|shell=/);
|
||||
// The hand-rolled desktop column / mobile drawer hooks only the legacy shell rendered.
|
||||
assert.doesNotMatch(read("src/app/globals.css"), /\.dashboard-sidebar-(desktop|mobile)\b/);
|
||||
for (const locale of ["en", "pt-BR", "vi"]) {
|
||||
assert.doesNotMatch(
|
||||
read(`src/i18n/messages/${locale}.json`),
|
||||
/featureFlagUiKitShellDescription/,
|
||||
`${locale}.json drops the flag description`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("no font is loaded from the Google Fonts CDN (#3695: unreachable in some regions)", () => {
|
||||
// Carried over from the deleted material-icons-self-hosted.test.ts: the guard is about the CDN,
|
||||
// not about Material — every font (Inter, Instrument Serif, IBM Plex Mono) stays self-hosted.
|
||||
for (const file of ["src/app/layout.tsx", "src/app/globals.css"]) {
|
||||
assert.doesNotMatch(
|
||||
read(file),
|
||||
/fonts\.(googleapis|gstatic)\.com/,
|
||||
`${file} must not load fonts from fonts.googleapis.com / fonts.gstatic.com`
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -96,12 +96,6 @@ test("connection rows use the compact shared ReorderControl and hide separators
|
||||
assert.match(read("src/shared/components/ReorderControl.tsx"), /size-5 min-h-5/);
|
||||
});
|
||||
|
||||
test("icon size utilities win over the Material Symbols base size", () => {
|
||||
const globals = read("src/app/globals.css");
|
||||
assert.match(globals, /@import "material-symbols\/outlined\.css" layer\(base\);/);
|
||||
assert.match(globals, /@layer base \{\s*:where\(\.material-symbols-outlined\) \{/);
|
||||
});
|
||||
|
||||
test("provider lists use the shared one-column-on-phones card grid", () => {
|
||||
const page = read("src/app/(dashboard)/dashboard/providers/page.tsx");
|
||||
assert.match(page, /<ProviderCardGrid>/);
|
||||
|
||||
@@ -76,9 +76,8 @@ describe("feature-flags-settings count update", () => {
|
||||
// default off) to 82; USAGE_LIMIT_IGNORE_UNPRICED (#14799, default off) to 83;
|
||||
// REASONING_REPLAY_ENABLED (#12486, default on) to 84; COMBO_AUTO_PRUNE_STALE_STEPS
|
||||
// (#13505, default off) to 85; KIRO_TOOL_CALL_REPAIR_ENABLED (default on) to 86;
|
||||
// OPENCODE_PUBLISHED_CATALOG_ROUTING_ENABLED (#16798, default off) to 87;
|
||||
// UI_KIT_SHELL (KEA-7886, default on) takes the catalog from 111 to 112.
|
||||
assert.equal(FEATURE_FLAG_DEFINITIONS.length, 112);
|
||||
// OPENCODE_PUBLISHED_CATALOG_ROUTING_ENABLED (#16798, default off) to 87.
|
||||
assert.equal(FEATURE_FLAG_DEFINITIONS.length, 111);
|
||||
// OPENCODE_V2_CLIENT_FINGERPRINT_ENABLED (#16571, default off) to 87.
|
||||
// COMBO_EMPTY_POOL_NO_ELIGIBLE_TARGETS_ENABLED (#16256, default off) to 87.
|
||||
// OPENCODE_ZEN_EGRESS_IP_LOCK_ENABLED (#16797, default off) to 87;
|
||||
|
||||
@@ -274,7 +274,7 @@ describe("Sidebar hierarchy, keyboard navigation and ARIA contract (#12869)", ()
|
||||
});
|
||||
|
||||
// The skip link moved to DashboardShell, before the sidebar (it must exist even when the sidebar
|
||||
// is a closed mobile Sheet); its first-in-DOM position is asserted in dashboard-layout-flag.
|
||||
// is a closed mobile Sheet); its first-in-DOM position is asserted in dashboard-layout-shell.
|
||||
it("keeps a natural Tab order: brand, search, then navigation", async () => {
|
||||
const user = userEvent.setup();
|
||||
const loaded = await loadSidebar();
|
||||
|
||||
@@ -6,23 +6,16 @@ import fs from "node:fs";
|
||||
// 1) @lobehub/icons v5.13+ dropped the Stepfun `Color` sub-component. Importing it
|
||||
// causes a build-time module-not-found error that breaks the whole dashboard.
|
||||
// Lock in the Mono fallback so a future bump can't silently re-import it.
|
||||
// 2) DashboardLayout must not read localStorage synchronously during the initial
|
||||
// `useState` render — that produces a client/server markup mismatch (hydration
|
||||
// error) because the server always renders the `false` (collapsed=false) branch.
|
||||
// The fix defers the localStorage read to a `useEffect`.
|
||||
// 2) The dashboard shell must not read the sidebar-collapsed state from localStorage during
|
||||
// the first render — that produces a client/server markup mismatch (hydration error).
|
||||
// The legacy shell deferred the read to a `useEffect`; the kit shell (the only shell since
|
||||
// KEA-7886 F4) gets it from the `ci_sidebar_state` cookie read on the server (test below).
|
||||
|
||||
const lobeProviderIconsSrc = fs.readFileSync(
|
||||
new URL("../../src/shared/components/lobeProviderIcons.ts", import.meta.url),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
// The localStorage-backed collapse state belongs to the legacy shell (UI_KIT_SHELL=false) since
|
||||
// trilha F; the kit shell's collapse state comes from the `ci_sidebar_state` cookie read on the
|
||||
// server, so its first client render matches the server markup by construction (tests below).
|
||||
const dashboardLayoutSrc = fs.readFileSync(
|
||||
new URL("../../src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx", import.meta.url),
|
||||
"utf8"
|
||||
);
|
||||
const readSrc = (relative: string) =>
|
||||
fs.readFileSync(new URL(`../../${relative}`, import.meta.url), "utf8");
|
||||
|
||||
@@ -44,18 +37,6 @@ test("lobeProviderIcons maps both Stepfun mono and color slots to StepfunMonoIco
|
||||
assert.equal(color, "StepfunMonoIcon", "color slot must fall back to the Mono icon");
|
||||
});
|
||||
|
||||
test("DashboardLayout does not read localStorage synchronously inside the collapsed useState initializer", () => {
|
||||
const collapsedStateMatch = dashboardLayoutSrc.match(
|
||||
/const \[collapsed, setCollapsed\] = useState\(([^)]*)\)/
|
||||
);
|
||||
assert.ok(collapsedStateMatch, "collapsed useState declaration must exist");
|
||||
assert.equal(
|
||||
collapsedStateMatch[1].trim(),
|
||||
"false",
|
||||
"collapsed must initialize to a constant so server and first client render match (no hydration mismatch)"
|
||||
);
|
||||
});
|
||||
|
||||
test("the kit shell reads no localStorage for the collapse state; the server passes the cookie", () => {
|
||||
for (const file of [
|
||||
"src/shared/components/layouts/DashboardShell.tsx",
|
||||
@@ -71,14 +52,3 @@ test("the kit shell reads no localStorage for the collapse state; the server pas
|
||||
/<SidebarProvider[\s\S]*?defaultOpen=\{sidebarDefaultOpen\}/
|
||||
);
|
||||
});
|
||||
|
||||
test("DashboardLayout defers the sidebar-collapsed localStorage read to a useEffect", () => {
|
||||
const effectIndex = dashboardLayoutSrc.indexOf("useEffect(() => {");
|
||||
assert.ok(effectIndex >= 0, "a useEffect must exist");
|
||||
const effectBody = dashboardLayoutSrc.slice(
|
||||
effectIndex,
|
||||
dashboardLayoutSrc.indexOf("}, []);", effectIndex)
|
||||
);
|
||||
assert.match(effectBody, /localStorage\.getItem\(SIDEBAR_COLLAPSED_KEY\)/);
|
||||
assert.match(effectBody, /setCollapsed\(true\)/);
|
||||
});
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { FEATURE_FLAG_DEFINITIONS } from "../../src/shared/constants/featureFlagDefinitions.ts";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
|
||||
test("UI_KIT_SHELL is a runtime boolean flag, default true on the integration branch", () => {
|
||||
const def = FEATURE_FLAG_DEFINITIONS.find((d) => d.key === "UI_KIT_SHELL");
|
||||
assert.ok(def, "flag defined");
|
||||
assert.equal(def.category, "runtime");
|
||||
assert.equal(def.type, "boolean");
|
||||
assert.equal(def.defaultValue, "true");
|
||||
assert.equal(def.requiresRestart, false);
|
||||
assert.equal(def.warningLevel, "info");
|
||||
assert.equal(def.descriptionI18nKey, "featureFlagUiKitShellDescription");
|
||||
for (const locale of ["en", "pt-BR"]) {
|
||||
const messages = JSON.parse(
|
||||
fs.readFileSync(path.join(ROOT, `src/i18n/messages/${locale}.json`), "utf8")
|
||||
);
|
||||
assert.equal(
|
||||
typeof messages.featureFlagUiKitShellDescription,
|
||||
"string",
|
||||
`${locale} has the description`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("isUiKitShellEnabled honours the env override (kill switch)", async () => {
|
||||
const { isUiKitShellEnabled } = await import("../../src/shared/utils/featureFlags.ts");
|
||||
const prev = process.env.UI_KIT_SHELL;
|
||||
try {
|
||||
delete process.env.UI_KIT_SHELL;
|
||||
assert.equal(isUiKitShellEnabled(), true);
|
||||
process.env.UI_KIT_SHELL = "false";
|
||||
assert.equal(isUiKitShellEnabled(), false);
|
||||
} finally {
|
||||
if (prev === undefined) delete process.env.UI_KIT_SHELL;
|
||||
else process.env.UI_KIT_SHELL = prev;
|
||||
}
|
||||
});
|
||||
|
||||
test("isUiKitShellEnabled falls back to the definition default when the flag read throws", async () => {
|
||||
const { isUiKitShellEnabled } = await import("../../src/shared/utils/featureFlags.ts");
|
||||
const logs: unknown[][] = [];
|
||||
const origError = console.error;
|
||||
console.error = (...args: unknown[]) => {
|
||||
logs.push(args);
|
||||
};
|
||||
try {
|
||||
const result = isUiKitShellEnabled(() => {
|
||||
throw new Error("db read failed");
|
||||
});
|
||||
assert.equal(result, true, "a throwing read must not disable the kit shell nor throw");
|
||||
assert.ok(
|
||||
logs.some((args) => String(args).includes("Failed to resolve UI_KIT_SHELL")),
|
||||
"the failure is logged with the flag key"
|
||||
);
|
||||
} finally {
|
||||
console.error = origError;
|
||||
}
|
||||
});
|
||||
@@ -3,12 +3,12 @@ import React from "react";
|
||||
import { cleanup, render } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { default: Icon } = await import("@/shared/components/Icon");
|
||||
const { default: Icon, MISSING_ICON_GLYPH } = await import("@/shared/components/Icon");
|
||||
const { ICON_MAP } = await import("@/shared/constants/iconMap");
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe("<Icon> adapter (Material name → Lucide, with Material fallback)", () => {
|
||||
describe("<Icon> adapter (icon name → Lucide only; no Material fallback)", () => {
|
||||
it("renders the mapped Lucide glyph, decorative by default", () => {
|
||||
const { container } = render(<Icon name="settings" />);
|
||||
const svg = container.querySelector("svg");
|
||||
@@ -26,20 +26,65 @@ describe("<Icon> adapter (Material name → Lucide, with Material fallback)", ()
|
||||
expect(svg.getAttribute("width")).toBe("16");
|
||||
});
|
||||
|
||||
it("falls back to the Material ligature for an unmapped name and warns once (Review Focus 2)", () => {
|
||||
it("draws a neutral placeholder glyph for an unmapped name and warns once in dev (KEA-7886 F4)", () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const { container, rerender } = render(<Icon name="rocket_launch_unmapped_xyz" />);
|
||||
const span = container.querySelector("span.material-symbols-outlined");
|
||||
expect(span).not.toBeNull();
|
||||
expect(span!.textContent).toBe("rocket_launch_unmapped_xyz");
|
||||
expect(span!.getAttribute("aria-hidden")).toBe("true");
|
||||
rerender(<Icon name="rocket_launch_unmapped_xyz" />);
|
||||
const { container, rerender } = render(<Icon name="rocket_launch_unmapped_xyz" size={16} />);
|
||||
const svg = container.querySelector("svg.oi-icon");
|
||||
expect(svg).not.toBeNull();
|
||||
expect(svg!.getAttribute("data-icon")).toBe("rocket_launch_unmapped_xyz");
|
||||
expect(svg!.getAttribute("data-icon-missing")).toBe("true");
|
||||
expect(svg!.getAttribute("aria-hidden")).toBe("true");
|
||||
expect(svg!.getAttribute("width")).toBe("16");
|
||||
// Never ligature text, never the Material font class.
|
||||
expect(container.textContent).toBe("");
|
||||
expect(container.querySelector(".material-symbols-outlined")).toBeNull();
|
||||
rerender(<Icon name="rocket_launch_unmapped_xyz" size={16} />);
|
||||
expect(
|
||||
warn.mock.calls.filter((c) => String(c[0]).includes("rocket_launch_unmapped_xyz")).length
|
||||
).toBe(1);
|
||||
expect(String(warn.mock.calls[0][0])).toContain("is not in ICON_MAP");
|
||||
warn.mockRestore();
|
||||
});
|
||||
|
||||
it("keeps the accessible name on the placeholder glyph and stays silent in production", () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const env = process.env.NODE_ENV;
|
||||
try {
|
||||
(process.env as Record<string, string>).NODE_ENV = "production";
|
||||
const { getByRole } = render(<Icon name="prod_only_unmapped_xyz" ariaLabel="Status" />);
|
||||
const svg = getByRole("img", { name: "Status" });
|
||||
expect(svg.getAttribute("data-icon-missing")).toBe("true");
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
(process.env as Record<string, string>).NODE_ENV = env as string;
|
||||
warn.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("the placeholder glyph is no ICON_MAP icon, so a gap never reads as a real icon/status", async () => {
|
||||
const { createElement } = await import("react");
|
||||
const { renderToStaticMarkup } = await import("react-dom/server");
|
||||
expect(Object.values(ICON_MAP)).not.toContain(MISSING_ICON_GLYPH);
|
||||
// Same drawing too (aliases are distinct objects): compare the rendered SVG paths.
|
||||
const paths = (C: unknown) =>
|
||||
renderToStaticMarkup(createElement(C as React.ComponentType)).replace(/class="[^"]*"/g, "");
|
||||
const placeholder = paths(MISSING_ICON_GLYPH);
|
||||
const clash = Object.entries(ICON_MAP).filter(([, C]) => paths(C) === placeholder);
|
||||
expect(clash.map(([name]) => name)).toEqual([]);
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const { container } = render(<Icon name="unmapped_glyph_check_xyz" />);
|
||||
warn.mockRestore();
|
||||
// The unmapped name really draws MISSING_ICON_GLYPH.
|
||||
expect(container.querySelector("svg")!.innerHTML.replace(/class="[^"]*"/g, "")).toBe(
|
||||
placeholder.replace(/^<svg[^>]*>|<\/svg>$/g, "")
|
||||
);
|
||||
});
|
||||
|
||||
it("a mapped icon never carries the missing marker", () => {
|
||||
const { container } = render(<Icon name="settings" />);
|
||||
expect(container.querySelector("svg")!.hasAttribute("data-icon-missing")).toBe(false);
|
||||
});
|
||||
|
||||
it("renders nothing for an empty name", () => {
|
||||
const { container } = render(
|
||||
<>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// @vitest-environment jsdom
|
||||
import React from "react";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { cleanup, render } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
@@ -16,15 +18,6 @@ vi.mock("@/shared/components/Header", () => ({
|
||||
default: () => <header data-testid="kit-header" />,
|
||||
}));
|
||||
vi.mock("@/shared/components/CommandPalette", () => ({ default: () => null }));
|
||||
vi.mock("@/shared/components/layouts/legacy/SidebarLegacy", () => ({
|
||||
default: () => <aside data-testid="legacy-sidebar" />,
|
||||
}));
|
||||
vi.mock("@/shared/components/layouts/legacy/HeaderLegacy", () => ({
|
||||
default: () => <header data-testid="legacy-header" />,
|
||||
}));
|
||||
vi.mock("@/shared/components/layouts/legacy/CommandPaletteLegacy", () => ({
|
||||
default: () => null,
|
||||
}));
|
||||
vi.mock("@/shared/components/MaintenanceBanner", () => ({ default: () => null }));
|
||||
vi.mock("@/shared/components/NavigationProgress", () => ({ default: () => null }));
|
||||
|
||||
@@ -32,10 +25,10 @@ const { default: DashboardLayout } = await import("@/shared/components/layouts/D
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe("DashboardLayout shell switch (UI_KIT_SHELL)", () => {
|
||||
it("shell=kit renders SidebarProvider + SidebarInset with the kit sidebar/header", () => {
|
||||
describe("DashboardLayout — the kit shell is the only shell (KEA-7886 F4)", () => {
|
||||
it("renders SidebarProvider + SidebarInset with the kit sidebar/header", () => {
|
||||
const { container, getByTestId } = render(
|
||||
<DashboardLayout shell="kit">
|
||||
<DashboardLayout>
|
||||
<p>page</p>
|
||||
</DashboardLayout>
|
||||
);
|
||||
@@ -62,7 +55,7 @@ describe("DashboardLayout shell switch (UI_KIT_SHELL)", () => {
|
||||
})) as unknown as typeof window.matchMedia;
|
||||
try {
|
||||
const { container } = render(
|
||||
<DashboardLayout shell="kit">
|
||||
<DashboardLayout>
|
||||
<p>page</p>
|
||||
</DashboardLayout>
|
||||
);
|
||||
@@ -84,7 +77,7 @@ describe("DashboardLayout shell switch (UI_KIT_SHELL)", () => {
|
||||
|
||||
it("on desktop the skip link precedes the kit sidebar in document order", () => {
|
||||
render(
|
||||
<DashboardLayout shell="kit">
|
||||
<DashboardLayout>
|
||||
<p>page</p>
|
||||
</DashboardLayout>
|
||||
);
|
||||
@@ -95,17 +88,35 @@ describe("DashboardLayout shell switch (UI_KIT_SHELL)", () => {
|
||||
expect(skip!.compareDocumentPosition(aside!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
});
|
||||
|
||||
it("shell=legacy renders the untouched legacy shell and nothing from the kit (kill switch)", () => {
|
||||
const { container, getAllByTestId, getByTestId, queryByTestId } = render(
|
||||
<DashboardLayout shell="legacy">
|
||||
it("starts expanded by default and collapsed when the server cookie says so", () => {
|
||||
const { container, unmount } = render(
|
||||
<DashboardLayout>
|
||||
<p>page</p>
|
||||
</DashboardLayout>
|
||||
);
|
||||
expect(container.querySelector(".dashboard-sidebar-desktop")).not.toBeNull();
|
||||
// The legacy shell mounts its Sidebar twice: the desktop column and the mobile drawer.
|
||||
expect(getAllByTestId("legacy-sidebar")).toHaveLength(2);
|
||||
getByTestId("legacy-header");
|
||||
expect(queryByTestId("kit-sidebar")).toBeNull();
|
||||
expect(container.querySelector("[data-slot=sidebar-provider]")).toBeNull();
|
||||
const provider = () => container.querySelector("[data-slot=sidebar-provider]");
|
||||
expect(provider()!.getAttribute("data-state")).toBe("expanded");
|
||||
unmount();
|
||||
const collapsed = render(
|
||||
<DashboardLayout sidebarDefaultOpen={false}>
|
||||
<p>page</p>
|
||||
</DashboardLayout>
|
||||
);
|
||||
expect(
|
||||
collapsed.container.querySelector("[data-slot=sidebar-provider]")!.getAttribute("data-state")
|
||||
).toBe("collapsed");
|
||||
});
|
||||
|
||||
it("has no shell switch left: no shell prop, no legacy import, no UI_KIT_SHELL read", () => {
|
||||
const layout = readFileSync(
|
||||
resolve(process.cwd(), "src/shared/components/layouts/DashboardLayout.tsx"),
|
||||
"utf8"
|
||||
);
|
||||
expect(layout).not.toMatch(/\bshell\??:|shell=|DashboardShellMode|[Ll]egacy/);
|
||||
const serverLayout = readFileSync(
|
||||
resolve(process.cwd(), "src/app/(dashboard)/layout.tsx"),
|
||||
"utf8"
|
||||
);
|
||||
expect(serverLayout).not.toMatch(/UI_KIT_SHELL|isUiKitShellEnabled|shell=/);
|
||||
});
|
||||
});
|
||||
@@ -25,51 +25,14 @@ function src(rel: string) {
|
||||
return readFileSync(resolve(cwd, rel), "utf-8");
|
||||
}
|
||||
|
||||
// ─── DashboardLayout.tsx ──────────────────────────────────────────────────────
|
||||
// ─── Dashboard shell ─────────────────────────────────────────────────────────
|
||||
// The hand-rolled mobile drawer (`start-0` + `.dashboard-sidebar-mobile` RTL anchoring in
|
||||
// globals.css) went away with the legacy shell (KEA-7886 F4). The kit shell's drawer is the kit
|
||||
// Sidebar's own Sheet, anchored by `side` (asserted in the "Kit shell" block below).
|
||||
|
||||
// The hand-rolled mobile drawer lives on in the legacy shell (UI_KIT_SHELL=false); the kit shell's
|
||||
// drawer is the kit Sidebar's own Sheet, anchored by `side` (asserted in the Sidebar block below).
|
||||
describe("DashboardLayout — mobile sidebar drawer uses logical classes", () => {
|
||||
const code = src("src/shared/components/layouts/legacy/DashboardLayoutLegacy.tsx");
|
||||
|
||||
it("uses start-0 (not bare left-0) for the mobile sidebar drawer", () => {
|
||||
// The drawer must anchor to the inline-start edge so it flips in RTL.
|
||||
expect(code).toContain("start-0");
|
||||
});
|
||||
|
||||
it("does not use bare left-0 for the mobile sidebar drawer", () => {
|
||||
// "inset-y-0 left-0" is the old physical class that breaks RTL.
|
||||
expect(code).not.toContain("inset-y-0 left-0");
|
||||
});
|
||||
|
||||
it("uses -translate-x-full only when combined with RTL-aware transform or logical alternative", () => {
|
||||
// We keep -translate-x-full/translate-x-0 for slide animation but anchor
|
||||
// with start-0 so physical translate still produces correct visual result
|
||||
// in both LTR and RTL (the drawer always slides in from its own start edge).
|
||||
// Just confirm start-0 is present (already asserted above).
|
||||
expect(code).toContain("start-0");
|
||||
});
|
||||
|
||||
it("carries the dashboard-sidebar-mobile hook class for explicit RTL anchoring", () => {
|
||||
// .dashboard-sidebar-mobile gets explicit right:0/translateX(100%) rules
|
||||
// under dir=rtl in globals.css, so the drawer cannot end up parked on the
|
||||
// left edge when closed (physical -translate-x-full alone would do that).
|
||||
expect(code).toContain("dashboard-sidebar-mobile");
|
||||
});
|
||||
});
|
||||
|
||||
// ─── globals.css ────────────────────────────────────────────────────────────
|
||||
|
||||
describe("globals.css — mobile sidebar has explicit RTL anchoring rules", () => {
|
||||
const css = src("src/app/globals.css");
|
||||
|
||||
it("pins .dashboard-sidebar-mobile to the right edge under dir=rtl", () => {
|
||||
expect(css).toContain(".dashboard-sidebar-mobile");
|
||||
expect(css).toContain("right: 0");
|
||||
});
|
||||
|
||||
it("slides the closed drawer off the right edge under dir=rtl", () => {
|
||||
expect(css).toContain("translateX(100%)");
|
||||
describe("globals.css — no leftover hooks of the removed hand-rolled drawer", () => {
|
||||
it("drops the .dashboard-sidebar-mobile RTL anchoring rules", () => {
|
||||
expect(src("src/app/globals.css")).not.toContain(".dashboard-sidebar-mobile");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user