import { navigateWithAgentChatViewTransition } from "@agent-native/core/client/agent-chat"; import { configureTracking } from "@agent-native/core/client/analytics"; import { appPath } from "@agent-native/core/client/api-path"; import { useDbSync } from "@agent-native/core/client/hooks"; import { AppProviders, createAgentNativeQueryClient, } from "@agent-native/core/client/hooks"; import { getLocaleInitScript, useT } from "@agent-native/core/client/i18n"; import { CommandMenu, useCommandMenuShortcut, } from "@agent-native/core/client/navigation"; import { getThemeInitScript } from "@agent-native/core/client/ui"; import { IconHierarchy2, IconMoon, IconScribble, IconShape2, IconSun, } from "@tabler/icons-react"; import { useQueryClient } from "@tanstack/react-query"; import { useTheme } from "next-themes"; import { useCallback, useEffect, useState } from "react"; import { Links, Meta, Outlet, Scripts, ScrollRestoration, useLocation, useNavigate, } from "react-router"; import type { LinksFunction } from "react-router"; import { Layout as AppLayout } from "@/components/layout/Layout"; import { toggleWireframeStyle, useWireframeStyle, } from "@/components/plan/wireframe/use-wireframe-style"; import { Toaster } from "@/components/ui/sonner"; import { AppToolkitProvider } from "@/components/ui/toolkit-provider"; import { useNavigationState } from "@/hooks/use-navigation-state"; // Side effect: register Plan's native chat renderers so visual answers render // their diagram/wireframe/api-spec blocks inline in the agent chat. import "@/lib/register-chat-renderers"; import { APP_TITLE } from "@/lib/app-config"; import { shouldCapturePlanContent } from "@/lib/plan-tracking"; import { TAB_ID } from "@/lib/tab-id"; import changelog from "../CHANGELOG.md?raw"; import { i18nCatalog } from "./i18n"; import stylesheet from "./global.css?url"; // Keep standard pageviews, explicit analytics, and Sentry on local-plan routes, // but disable DOM/session capture so rendered plan contents stay on-device. configureTracking({ contentCaptureForPath: shouldCapturePlanContent, getDefaultProps: (_name, properties) => ({ ...properties, app: "plan", }), }); export const links: LinksFunction = () => [ { rel: "stylesheet", href: stylesheet }, ]; const THEME_INIT_SCRIPT_SELECTOR = "script[data-agent-native-theme-init]"; const LOCALE_INIT_SCRIPT_SELECTOR = "script[data-agent-native-locale-init]"; function getHydrationStableThemeInitScript() { if (typeof document !== "undefined") { const existing = document.querySelector( THEME_INIT_SCRIPT_SELECTOR, ); if (existing?.innerHTML) return existing.innerHTML; } return getThemeInitScript(); } function getHydrationStableLocaleInitScript() { if (typeof document !== "undefined") { const existing = document.querySelector( LOCALE_INIT_SCRIPT_SELECTOR, ); if (existing?.innerHTML) return existing.innerHTML; } return getLocaleInitScript(); } const THEME_INIT_SCRIPT = getHydrationStableThemeInitScript(); const LOCALE_INIT_SCRIPT = getHydrationStableLocaleInitScript(); export function Layout({ children }: { children: React.ReactNode }) { return (