Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(kg): make the knowledge-graph info panel collapsible (#579)
Raghav Chamadiya1a8c6ee3e95f
diff --git a/packages/types/src/overview.ts b/packages/types/src/overview.tsindex 3686bf38b..625ad7a22 100644--- a/packages/types/src/overview.ts+++ b/packages/types/src/overview.ts@@ -13,6 +13,14 @@ export interface OverviewRepoMeta {default_branch: string;head_commit: string | null;updated_at: string | null;+ /** GitHub owner/login. Hosted-only — lets surfaces like the MCP connect+ * card build the `owner/name` server URL without resolving the repo+ * through the viewer's own repo list (so it works on public shares for+ * non-owners). Absent/`""` for the OSS CLI, which has no remote owner. */+ owner?: string;+ /** Whether the repo is publicly browsable. Hosted-only; drives the+ * public/private connect copy. Defaults to public when absent. */+ is_public?: boolean;}export interface OverviewStatDeltas {diff --git a/packages/ui/src/c4/panels/Sidebar.tsx b/packages/ui/src/c4/panels/Sidebar.tsxindex f2ef40d5e..7e181f39b 100644--- a/packages/ui/src/c4/panels/Sidebar.tsx+++ b/packages/ui/src/c4/panels/Sidebar.tsx@@ -1,7 +1,7 @@"use client";-import { useState } from "react";-import { Info, FolderOpen } from "lucide-react";+import { useEffect, useState } from "react";+import { Info, FolderOpen, PanelRightOpen, X } from "lucide-react";import { useArchitectureStore } from "../store/use-architecture-store";import { ProjectOverview } from "./ProjectOverview";import { ArchNodeInfo } from "./ArchNodeInfo";@@ -50,10 +50,56 @@ export function Sidebar(props: SidebarProps) {const view = useArchitectureStore((s) => s.view);const selectedNodeId = useArchitectureStore((s) => s.selectedNodeId);const tourActive = useArchitectureStore((s) => s.tourActive);+ const sidebarOpen = useArchitectureStore((s) => s.sidebarOpen);+ const setSidebarOpen = useArchitectureStore((s) => s.setSidebarOpen);const [activeTab, setActiveTab] = useState<SidebarTab>("info");+ // Collapse on small screens at first mount — a 320px overlay swallows the+ // whole graph on a phone. Runs once; the user's manual toggle wins after.+ useEffect(() => {+ if (+ typeof window !== "undefined" &&+ window.matchMedia("(max-width: 767px)").matches+ ) {+ setSidebarOpen(false);+ }+ }, [setSidebarOpen]);+if (!view) return null;+ // Collapsed: a small floating affordance to bring the panel back, kept in+ // the same corner so it reads as "the panel lives here".+ if (!sidebarOpen) {+ return (+ <button+ type="button"+ aria-label="Open Knowledge Graph panel"+ onClick={() => setSidebarOpen(true)}+ style={{+ position: "absolute",+ top: 12,+ right: 12,+ zIndex: 5,+ display: "flex",+ alignItems: "center",+ gap: 6,+ padding: "8px 10px",+ fontSize: 12,+ fontWeight: 600,+ cursor: "pointer",+ color: "var(--color-text-primary)",+ background: "var(--color-bg-elevated, rgba(17,24,39,0.96))",+ border: "1px solid var(--color-border-default)",+ borderRadius: 8,+ boxShadow: "0 10px 30px rgba(0,0,0,0.35)",+ }}+ >+ <PanelRightOpen size={14} />+ Details+ </button>+ );+ }+return (<asidearia-label="Knowledge Graph sidebar"@@ -61,7 +107,9 @@ export function Sidebar(props: SidebarProps) {position: "absolute",top: 12,right: 12,- width: 320,+ // Cap to the viewport on phones so the panel never overflows the+ // canvas edge-to-edge.+ width: "min(320px, calc(100vw - 24px))",maxHeight: "calc(100% - 24px)",background: "var(--color-bg-elevated, rgba(17,24,39,0.96))",border: "1px solid var(--color-border-default)",@@ -79,6 +127,7 @@ export function Sidebar(props: SidebarProps) {aria-label="Sidebar tabs"style={{display: "flex",+ alignItems: "stretch",borderBottom: "1px solid var(--color-border-default)",flexShrink: 0,}}@@ -107,6 +156,25 @@ export function Sidebar(props: SidebarProps) {<FolderOpen size={13} />Files</button>+ <button+ type="button"+ aria-label="Close panel"+ onClick={() => setSidebarOpen(false)}+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ width: 34,+ flexShrink: 0,+ cursor: "pointer",+ background: "none",+ border: "none",+ borderLeft: "1px solid var(--color-border-default)",+ color: "var(--color-text-secondary)",+ }}+ >+ <X size={14} />+ </button></nav><div style={{ flex: 1, overflowY: "auto", minHeight: 0 }}>diff --git a/packages/ui/src/c4/store/use-architecture-store.ts b/packages/ui/src/c4/store/use-architecture-store.tsindex b555c7b57..c4d9fa9b9 100644--- a/packages/ui/src/c4/store/use-architecture-store.ts+++ b/packages/ui/src/c4/store/use-architecture-store.ts@@ -62,6 +62,11 @@ interface ArchitectureStoreState {pathFinderOpen: boolean;reactFlowInstance: ReactFlowInstance | null;++ /** Whether the right-hand info/files panel is visible. Open on desktop;+ * the panel itself collapses this on small screens at mount so it doesn't+ * obstruct the graph. */+ sidebarOpen: boolean;}interface ArchitectureStoreActions {@@ -112,6 +117,9 @@ interface ArchitectureStoreActions {setPathFinderOpen: (open: boolean) => void;setReactFlowInstance: (instance: ReactFlowInstance | null) => void;++ setSidebarOpen: (open: boolean) => void;+ toggleSidebar: () => void;}export type ArchitectureStore = ArchitectureStoreState & ArchitectureStoreActions;@@ -308,6 +316,8 @@ const INITIAL_STATE: ArchitectureStoreState = {pathFinderOpen: false,reactFlowInstance: null,++ sidebarOpen: true,};export const useArchitectureStore = create<ArchitectureStore>()(@@ -407,6 +417,9 @@ export const useArchitectureStore = create<ArchitectureStore>()(...drillStateForNode(state, nodeId),selectedNodeId: nodeId,focusNodeId: null,+ // Selecting a node surfaces its details — reopen the panel if the+ // user had collapsed it (key on mobile, where it starts closed).+ ...(nodeId ? { sidebarOpen: true } : {}),});},@@ -637,6 +650,14 @@ export const useArchitectureStore = create<ArchitectureStore>()(setReactFlowInstance: (instance: ReactFlowInstance | null) => {set({ reactFlowInstance: instance });},++ setSidebarOpen: (open: boolean) => {+ set({ sidebarOpen: open });+ },++ toggleSidebar: () => {+ set({ sidebarOpen: !get().sidebarOpen });+ },}),{ name: "architecture-store" },),