Files
OmniRoute/src/shared/components/Header.tsx
Diego Rodrigues de Sa e Souza 3ec9ca11b1 Release v3.7.6 (#1803)
* feat(api-keys): add rename support in permissions modal

Add an editable key name field at the top of the permissions modal,
allowing users to rename API keys alongside existing permission settings.

The backend already supported name updates via PATCH /api/keys/:id — this
wires the UI to send the name field and refreshes the key list on success.

Changes:
- Add keyName state and text input to PermissionsModal
- Update handleUpdatePermissions to validate and send name in PATCH body
- Add integration test for rename via PATCH (valid, empty, too-long names)
- Update E2E mock to handle PATCH requests

* chore(release): bump version to 3.7.6

* chore(release): v3.7.6 — merge API key rename feature and sync docs

* chore(release): expand contributor credits to 155 PRs across full project history

- Expanded acknowledgment table from 29 to 53 contributors
- Added 100+ previously uncredited PRs from project inception through v3.7.5
- Moved contributor credits section to v3.7.6 (current release)
- Synced llm.txt version to 3.7.6

* fix: resolve security ReDoS in codex and bugs #1797 #1789

* feat(dashboard): implement remaining v3.7.6 dashboard features and fixes

* fix(xiaomi-mimo): update models to V2.5, fix Token Plan validation and default region (#1823)

Integrated into release/v3.7.6

* fix(dashboard): correct loadPresets ReferenceError in CostOverviewTab

* fix(codex): omit compact client metadata (#1822)

Integrated into release/v3.7.6

* feat(chatgpt-web): support thinking_effort (Standard/Extended) for thinking-capable models (#1821)

Integrated into release/v3.7.6

* Fix endpoint visibility, A2A status, and API catalog (#1806)

Integrated into release/v3.7.6

* fix(analytics): use pure SQL aggregations — no history rows loaded (#1802)

Integrated into release/v3.7.6

* fix(stability): resolve codex input validation, enable combo circuit breaker, and fix broken unit tests

* docs(changelog): update for stability bug fixes #1804 #1805

* fix: clear active requests and recover providers (#1824)

Integrated into release/v3.7.6

* feat: inject fallback tool names to prevent upstream 400 errors (#1775)

* feat: auto-restore probe-failed database to prevent data loss (#1810)

* fix: safely cast inputs to strings before calling trim() to avoid crashes on numeric fields in proxy modal (#1825)

* chore(release): v3.7.6 — final stability patches for production

* test: update expected db probe-failure error message for auto-restore feature

* chore(workflow): mandate implementation plan generation in resolve-issues

* docs(changelog): rewrite v3.7.6 with complete commit-accurate entries

* feat(analytics): add cost-based usage insights and activity streaks

Expand usage analytics to report total cost, per-series cost totals,
API key counts, and current activity streaks using pricing-aware token
calculations.

Also make probe-failed database recovery choose the newest backup by
its embedded timestamp instead of filesystem mtime so auto-restore
selects the intended snapshot reliably.

* fix(mitm): enforce transparent interception on port 443 only

Reject non-443 MITM port updates in the settings API and normalize
stored configuration back to the required transparent interception
port.

Lock the dashboard port field to 443, update the validation copy, and
add integration coverage to prevent stale custom ports from being
accepted or surfaced.

* docs(changelog): update for analytics and mitm features

---------

Co-authored-by: Andrew Munsell <andrew@wizardapps.net>
Co-authored-by: Antigravity Assistant <bot@antigravity.local>
Co-authored-by: Gi99lin <74502520+Gi99lin@users.noreply.github.com>
Co-authored-by: Sergey Morozov <tr0st@bk.ru>
Co-authored-by: payne <baboialex95@gmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com>
Co-authored-by: ipanghu <bypanghu@163.com>
2026-04-30 14:08:50 -03:00

248 lines
8.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { usePathname, useRouter } from "next/navigation";
import Link from "next/link";
import Image from "next/image";
import ThemeToggle from "./ThemeToggle";
import TokenHealthBadge from "./TokenHealthBadge";
import DegradationBadge from "./DegradationBadge";
import LanguageSelector from "./LanguageSelector";
import ProviderIcon from "./ProviderIcon";
import { useTranslations } from "next-intl";
import {
OAUTH_PROVIDERS,
APIKEY_PROVIDERS,
FREE_PROVIDERS,
CLAUDE_CODE_COMPATIBLE_PREFIX,
OPENAI_COMPATIBLE_PREFIX,
ANTHROPIC_COMPATIBLE_PREFIX,
} from "@/shared/constants/providers";
import { useIsElectron } from "@/shared/hooks/useElectron";
const isE2EMode = process.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE === "1";
type HeaderProps = {
onMenuClick?: () => void;
showMenuButton?: boolean;
};
function usePageInfo(pathname: string | null): {
title: string;
description: string;
breadcrumbs: { label: string; href?: string; image?: string; providerId?: string }[];
} {
const t = useTranslations("header");
if (!pathname) return { title: "", description: "", breadcrumbs: [] };
// Provider detail page: /dashboard/providers/[id]
const providerMatch = pathname.match(/\/providers\/([^/]+)$/);
if (providerMatch) {
const providerId = providerMatch[1];
const providerInfo =
OAUTH_PROVIDERS[providerId] || FREE_PROVIDERS[providerId] || APIKEY_PROVIDERS[providerId];
if (providerInfo) {
return {
title: providerInfo.name,
description: "",
breadcrumbs: [
{ label: t("providers"), href: "/dashboard/providers" },
{ label: providerInfo.name, providerId: providerInfo.id },
],
};
}
if (providerId.startsWith(CLAUDE_CODE_COMPATIBLE_PREFIX)) {
return {
title: "CC Compatible",
description: "",
breadcrumbs: [
{ label: t("providers"), href: "/dashboard/providers" },
{ label: "CC Compatible", providerId: "claude" },
],
};
}
if (providerId.startsWith(OPENAI_COMPATIBLE_PREFIX)) {
return {
title: t("openaiCompatible"),
description: "",
breadcrumbs: [
{ label: t("providers"), href: "/dashboard/providers" },
{ label: t("openaiCompatible"), providerId: "oai-cc" },
],
};
}
if (providerId.startsWith(ANTHROPIC_COMPATIBLE_PREFIX)) {
return {
title: t("anthropicCompatible"),
description: "",
breadcrumbs: [
{ label: t("providers"), href: "/dashboard/providers" },
{ label: t("anthropicCompatible"), providerId: "anthropic-m" },
],
};
}
}
if (pathname.includes("/providers"))
return {
title: t("providers"),
description: t("providerDescription"),
breadcrumbs: [],
};
if (pathname.includes("/combos"))
return { title: t("combos"), description: t("comboDescription"), breadcrumbs: [] };
if (pathname.includes("/usage"))
return {
title: t("usage"),
description: t("usageDescription"),
breadcrumbs: [],
};
if (pathname.includes("/analytics"))
return {
title: t("analytics"),
description: t("analyticsDescription"),
breadcrumbs: [],
};
if (pathname.includes("/cli-tools"))
return { title: t("cliTools"), description: t("cliToolsDescription"), breadcrumbs: [] };
if (pathname === "/dashboard")
return { title: t("home"), description: t("homeDescription"), breadcrumbs: [] };
if (pathname.includes("/mcp"))
return { title: t("mcp"), description: t("mcpDescription"), breadcrumbs: [] };
if (pathname.includes("/a2a"))
return { title: t("a2a"), description: t("a2aDescription"), breadcrumbs: [] };
if (pathname.includes("/endpoint"))
return { title: t("endpoint"), description: t("endpointDescription"), breadcrumbs: [] };
if (pathname.includes("/profile"))
return { title: t("settings"), description: t("settingsDescription"), breadcrumbs: [] };
// Note: /themes page removed theme settings live in /settings → AppearanceTab
return { title: "", description: "", breadcrumbs: [] };
}
export default function Header({ onMenuClick, showMenuButton = true }: HeaderProps) {
const pathname = usePathname();
const router = useRouter();
const isElectron = useIsElectron();
const t = useTranslations("header");
const { title, description, breadcrumbs } = 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-5 dark:border-white/5"
style={{
paddingTop: isMacElectron ? "calc(1.25rem + var(--desktop-safe-top))" : undefined,
}}
>
{/* 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 breadcrumbs - desktop */}
<div className="hidden lg:flex flex-col">
{breadcrumbs.length > 0 ? (
<div className="flex items-center gap-2">
{breadcrumbs.map((crumb, index) => (
<div
key={`${crumb.label}-${crumb.href || "current"}`}
className="flex items-center gap-2"
>
{index > 0 && (
<span className="material-symbols-outlined text-text-muted text-base">
chevron_right
</span>
)}
{crumb.href ? (
<Link
href={crumb.href}
className="text-text-muted hover:text-primary transition-colors"
>
{crumb.label}
</Link>
) : (
<div className="flex items-center gap-2">
{crumb.image && (
<Image
src={crumb.image}
alt={crumb.label}
width={28}
height={28}
className="object-contain rounded max-w-[28px] max-h-[28px]"
sizes="28px"
onError={(e) => {
e.currentTarget.style.display = "none";
}}
/>
)}
{crumb.providerId && (
<ProviderIcon providerId={crumb.providerId} size={28} type="color" />
)}
<h1 className="text-2xl font-semibold text-text-main tracking-tight">
{crumb.label}
</h1>
</div>
)}
</div>
))}
</div>
) : title ? (
<div>
<h1 className="text-2xl font-semibold text-text-main tracking-tight">{title}</h1>
{description && <p className="text-sm text-text-muted">{description}</p>}
</div>
) : null}
</div>
{/* Right actions */}
<div className="flex items-center gap-3 ml-auto">
{/* Language selector */}
<LanguageSelector />
{/* Theme toggle */}
<ThemeToggle />
{/* Degradation & Token health */}
{!isE2EMode && <DegradationBadge />}
{!isE2EMode && <TokenHealthBadge />}
{/* Logout button */}
<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")}
>
<span className="material-symbols-outlined">logout</span>
</button>
</div>
</header>
);
}