feat: add ui debug on make start-debug

This commit is contained in:
Carlos Florêncio
2026-02-08 19:17:35 +00:00
parent b3cba6af00
commit 6baa7ffd55
4 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ export async function runStart({
...(debug ? { KANDEV_DEBUG_AGENT_MESSAGES: "true" } : {}),
},
});
const webEnv = buildWebEnv({ ports, includeMcp: true, production: true });
const webEnv = buildWebEnv({ ports, includeMcp: true, production: true, debug });
const supervisor = createProcessSupervisor();
supervisor.attachSignalHandlers();
+4 -2
View File
@@ -41,6 +41,7 @@ export default function RootLayout({
// This allows accessing the app from any device (iPhone, Tailscale, etc.)
const apiPort = extractPort(process.env.KANDEV_API_BASE_URL ?? "");
const mcpPort = extractPort(process.env.KANDEV_MCP_SERVER_URL ?? "");
const debugMode = process.env.NEXT_PUBLIC_KANDEV_DEBUG === "true";
return (
<html lang="en" suppressHydrationWarning>
@@ -48,14 +49,15 @@ export default function RootLayout({
<meta name="apple-mobile-web-app-title" content="Kandev" />
</head>
<body className="antialiased font-sans">
{(apiPort || mcpPort) ? (
// Inject runtime ports for production bundles where ports are chosen at launch.
{(apiPort || mcpPort || debugMode) ? (
// Inject runtime config for production bundles where ports are chosen at launch.
// Client will build full URLs using window.location.hostname + port
<script
dangerouslySetInnerHTML={{
__html: [
apiPort ? `window.__KANDEV_API_PORT = ${JSON.stringify(apiPort)};` : '',
mcpPort ? `window.__KANDEV_MCP_PORT = ${JSON.stringify(mcpPort)};` : '',
debugMode ? `window.__KANDEV_DEBUG = true;` : '',
].filter(Boolean).join('\n'),
}}
/>
+2
View File
@@ -8,5 +8,7 @@ declare global {
// Port-only injection (client builds URL from window.location.hostname + port)
__KANDEV_API_PORT?: string;
__KANDEV_MCP_PORT?: string;
// Debug mode flag (injected at runtime by layout.tsx)
__KANDEV_DEBUG?: boolean;
}
}
+3 -1
View File
@@ -11,7 +11,9 @@ const DEFAULT_MCP_PORT = 9090;
const DEFAULT_API_BASE_URL = `http://localhost:${DEFAULT_API_PORT}`;
const DEFAULT_MCP_SERVER_URL = `http://localhost:${DEFAULT_MCP_PORT}/sse`;
export const DEBUG_UI = process.env.NEXT_PUBLIC_KANDEV_DEBUG === 'true';
export const DEBUG_UI =
process.env.NEXT_PUBLIC_KANDEV_DEBUG === 'true' ||
(typeof window !== 'undefined' && window.__KANDEV_DEBUG === true);
/**
* Build URL from current page hostname and port.