Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

Fix web UI serve: standalone path, server-side API routing, and dashboard stats

swati510402177579c1e
diff --git a/.gitignore b/.gitignore
index eb242c2b7..c0af38667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+# IDE/tool caches
+.sfdx/
+
# Python
__pycache__/
*.py[cod]
diff --git a/packages/cli/src/repowise/cli/commands/serve_cmd.py b/packages/cli/src/repowise/cli/commands/serve_cmd.py
index 603be0334..6d04fff9d 100644
--- a/packages/cli/src/repowise/cli/commands/serve_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/serve_cmd.py
@@ -39,17 +39,19 @@ def _web_is_cached(version: str) -> bool:
def _find_local_web() -> Path | None:
"""Check if running from the repo with packages/web available."""
- # Walk up from this file to find the repo root
- candidate = Path(__file__).resolve()
- for _ in range(10):
- candidate = candidate.parent
- pkg_web = candidate / "packages" / "web"
- if (pkg_web / "package.json").exists():
- # Check if it's been built
- standalone = pkg_web / ".next" / "standalone" / "server.js"
- if standalone.exists():
- return pkg_web
- return pkg_web # exists but may need build
+ # Check from both __file__ (source installs) and cwd (pip-installed runs)
+ roots = [Path(__file__).resolve(), Path.cwd().resolve()]
+ for start in roots:
+ candidate = start
+ for _ in range(10):
+ candidate = candidate.parent
+ pkg_web = candidate / "packages" / "web"
+ if (pkg_web / "package.json").exists():
+ # Next.js standalone in monorepos nests server under package path
+ standalone = pkg_web / ".next" / "standalone" / "packages" / "web" / "server.js"
+ if standalone.exists():
+ return pkg_web
+ return pkg_web # exists but may need build
return None
@@ -144,21 +146,22 @@ def _start_frontend(node: str, backend_port: int, frontend_port: int) -> subproc
local_web = _find_local_web()
if local_web:
standalone_dir = local_web / ".next" / "standalone"
- server_js = standalone_dir / "server.js"
+ # Next.js standalone in monorepos nests server under the package path
+ server_js = standalone_dir / "packages" / "web" / "server.js"
if server_js.exists():
# Copy static files into standalone (Next.js requirement)
static_src = local_web / ".next" / "static"
- static_dst = standalone_dir / ".next" / "static"
+ static_dst = standalone_dir / "packages" / "web" / ".next" / "static"
if static_src.exists() and not static_dst.exists():
shutil.copytree(str(static_src), str(static_dst))
public_src = local_web / "public"
- public_dst = standalone_dir / "public"
+ public_dst = standalone_dir / "packages" / "web" / "public"
if public_src.exists() and not public_dst.exists():
shutil.copytree(str(public_src), str(public_dst))
return subprocess.Popen(
[node, str(server_js)],
- cwd=str(standalone_dir),
+ cwd=str(standalone_dir / "packages" / "web"),
env=env,
)
@@ -209,7 +212,7 @@ def serve_command(port: int, host: str, workers: int, ui_port: int, no_ui: bool)
if not ready:
local_web = _find_local_web()
if local_web:
- standalone = local_web / ".next" / "standalone" / "server.js"
+ standalone = local_web / ".next" / "standalone" / "packages" / "web" / "server.js"
if standalone.exists():
ready = True
elif npm:
diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx
index c1decc6e0..f175eb11f 100644
--- a/packages/web/src/app/page.tsx
+++ b/packages/web/src/app/page.tsx
@@ -9,7 +9,7 @@ import {
RefreshCw,
Clock,
} from "lucide-react";
-import { listRepos } from "@/lib/api/repos";
+import { listRepos, getRepoStats } from "@/lib/api/repos";
import { listJobs } from "@/lib/api/jobs";
import { StatCard } from "@/components/shared/stat-card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
@@ -33,9 +33,22 @@ export default async function DashboardPage() {
const jobList = jobs.status === "fulfilled" ? jobs.value : [];
// Aggregate stats across all repos
- const totalPages = 0; // fetched per repo in future
- const freshPages = 0;
- const stalePages = 0;
+ const statsResults = await Promise.allSettled(
+ repoList.map((r) => getRepoStats(r.id)),
+ );
+ const allStats = statsResults
+ .filter((r): r is PromiseFulfilledResult<Awaited<ReturnType<typeof getRepoStats>>> => r.status === "fulfilled")
+ .map((r) => r.value);
+
+ const totalFiles = allStats.reduce((s, st) => s + st.file_count, 0);
+ const totalSymbols = allStats.reduce((s, st) => s + st.symbol_count, 0);
+ const avgCoverage = allStats.length > 0
+ ? Math.round(allStats.reduce((s, st) => s + st.doc_coverage_pct, 0) / allStats.length)
+ : 0;
+ const avgFreshness = allStats.length > 0
+ ? Math.round(allStats.reduce((s, st) => s + st.freshness_score, 0) / allStats.length)
+ : 0;
+ const totalDeadCode = allStats.reduce((s, st) => s + st.dead_export_count, 0);
return (
<div className="p-4 sm:p-6 space-y-6 max-w-[1200px]">
@@ -50,26 +63,25 @@ export default async function DashboardPage() {
{/* Stat Cards */}
<div className="grid grid-cols-2 gap-4 lg:grid-cols-4">
<StatCard
- label="Total Pages"
- value={formatNumber(totalPages)}
+ label="Files"
+ value={formatNumber(totalFiles)}
icon={<FileText className="h-4 w-4" />}
/>
<StatCard
- label="Fresh Pages"
- value={formatNumber(freshPages)}
- description="Confidence ≥ 80%"
- icon={<CheckCircle2 className="h-4 w-4 text-green-500" />}
+ label="Symbols"
+ value={formatNumber(totalSymbols)}
+ icon={<Activity className="h-4 w-4" />}
/>
<StatCard
- label="Stale Pages"
- value={formatNumber(stalePages)}
- description="Need regeneration"
- icon={<AlertCircle className="h-4 w-4 text-yellow-500" />}
+ label="Doc Coverage"
+ value={`${avgCoverage}%`}
+ description={`Freshness ${avgFreshness}%`}
+ icon={<CheckCircle2 className="h-4 w-4 text-green-500" />}
/>
<StatCard
label="Dead Code"
- value="—"
- description="Analyze to detect"
+ value={formatNumber(totalDeadCode)}
+ description="Unused exports"
icon={<Skull className="h-4 w-4 text-[var(--color-text-tertiary)]" />}
/>
</div>
diff --git a/packages/web/src/lib/api/client.ts b/packages/web/src/lib/api/client.ts
index e1e05825f..aaf9ef5f5 100644
--- a/packages/web/src/lib/api/client.ts
+++ b/packages/web/src/lib/api/client.ts
@@ -10,7 +10,12 @@
import type { ApiError } from "./types";
-const BASE_URL = process.env.NEXT_PUBLIC_REPOWISE_API_URL ?? "";
+// Client-side: empty string → relative requests proxied via Next.js rewrites.
+// Server-side: use REPOWISE_API_URL (the backend) since server `fetch` bypasses rewrites.
+const BASE_URL =
+ typeof window !== "undefined"
+ ? (process.env.NEXT_PUBLIC_REPOWISE_API_URL ?? "")
+ : (process.env.REPOWISE_API_URL || process.env.NEXT_PUBLIC_REPOWISE_API_URL || "http://localhost:7337");
function getApiKey(): string | null {
// In browser: check localStorage (set by settings page)