From 1de78f855f11b39f07db4aa9000945d539bde95d Mon Sep 17 00:00:00 2001 From: Nexus Dev Date: Sat, 11 Apr 2026 11:11:06 +0000 Subject: [PATCH] fix(nexus): tighten settings-route guard in ModeBreadcrumb (phase 8) Code-quality review for Task 2 caught a startsWith false-positive: `/instance/settings-foo` was matching the settings branch of deriveBreadcrumbSegments and producing nonsense output like ["SETTINGS", "-FOO"]. Tightened the guard to require an exact match or a literal trailing slash before entering the settings branch. Added three test cases to lock it in: - /instance/settings (exact, no trailing) -> ["SETTINGS"] - /instance/settings-foo -> ["HOME"] - /instance/settings-foo/bar -> ["HOME"] 22 tests pass. No behavior change for any previously-tested path. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/src/components/frame/ModeBreadcrumb.test.tsx | 3 +++ ui/src/components/frame/ModeBreadcrumb.tsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/src/components/frame/ModeBreadcrumb.test.tsx b/ui/src/components/frame/ModeBreadcrumb.test.tsx index 735b731b..68b28768 100644 --- a/ui/src/components/frame/ModeBreadcrumb.test.tsx +++ b/ui/src/components/frame/ModeBreadcrumb.test.tsx @@ -38,6 +38,9 @@ describe("deriveBreadcrumbSegments", () => { ["/NEX/routines", ["PROJECTS"]], ["/instance/settings/general", ["SETTINGS"]], ["/instance/settings/integrations", ["SETTINGS", "INTEGRATIONS"]], + ["/instance/settings", ["SETTINGS"]], + ["/instance/settings-foo", ["HOME"]], + ["/instance/settings-foo/bar", ["HOME"]], ["/", ["HOME"]], ["/unknown/path", ["HOME"]], ])("maps %s to %o", (input, expected) => { diff --git a/ui/src/components/frame/ModeBreadcrumb.tsx b/ui/src/components/frame/ModeBreadcrumb.tsx index 2112b992..237f7275 100644 --- a/ui/src/components/frame/ModeBreadcrumb.tsx +++ b/ui/src/components/frame/ModeBreadcrumb.tsx @@ -21,7 +21,7 @@ import { cn } from "@/lib/utils"; */ export function deriveBreadcrumbSegments(pathname: string): string[] { // /instance/settings/... - if (pathname.startsWith("/instance/settings")) { + if (pathname === "/instance/settings" || pathname.startsWith("/instance/settings/")) { const rest = pathname.replace(/^\/instance\/settings\/?/, ""); if (!rest) return ["SETTINGS"]; const leaf = rest.split("/")[0] ?? "";