Skip to content

Commit 4ab00df

Browse files
authored
Merge pull request DeusData#657 from DeusData/feat/mcp-protocol-2025-11-25
feat(mcp): add structured tool metadata
2 parents aedb979 + b7f1a71 commit 4ab00df

35 files changed

Lines changed: 1868 additions & 313 deletions

‎graph-ui/src/App.tsx‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import { GraphTab } from "./components/GraphTab";
33
import { StatsTab } from "./components/StatsTab";
44
import { ControlTab } from "./components/ControlTab";
55
import type { TabId } from "./lib/types";
6-
7-
const TABS: { id: TabId; label: string }[] = [
8-
{ id: "graph", label: "Graph" },
9-
{ id: "stats", label: "Projects" },
10-
{ id: "control", label: "Control" },
11-
];
6+
import { useUiMessages } from "./lib/i18n";
127

138
export function App() {
9+
const t = useUiMessages();
1410
const [activeTab, setActiveTab] = useState<TabId>("stats");
1511
const [selectedProject, setSelectedProject] = useState<string | null>(null);
12+
const tabs: { id: TabId; label: string }[] = [
13+
{ id: "graph", label: t.tabs.graph },
14+
{ id: "stats", label: t.tabs.projects },
15+
{ id: "control", label: t.tabs.control },
16+
];
1617

1718
return (
1819
<div className="h-screen flex flex-col bg-background text-foreground">
@@ -28,25 +29,27 @@ export function App() {
2829

2930
{/* Tabs inline in header */}
3031
<nav className="flex items-center gap-0.5">
31-
{TABS.map((t) => (
32+
{tabs.map((tab) => (
3233
<button
33-
key={t.id}
34-
onClick={() => setActiveTab(t.id)}
34+
key={tab.id}
35+
onClick={() => setActiveTab(tab.id)}
3536
className={`px-3 py-1 rounded-md text-[12px] font-medium transition-all ${
36-
activeTab === t.id
37+
activeTab === tab.id
3738
? "bg-primary/15 text-primary"
3839
: "text-muted-foreground hover:text-foreground hover:bg-white/[0.04]"
3940
}`}
4041
>
41-
{t.label}
42+
{tab.label}
4243
</button>
4344
))}
4445
</nav>
4546
</div>
4647

4748
{selectedProject && (
4849
<div className="flex items-center gap-2 px-3 py-1 rounded-lg bg-white/[0.04] border border-border/30">
49-
<span className="text-[10px] text-foreground/30 uppercase tracking-wider">Graph</span>
50+
<span className="text-[10px] text-foreground/30 uppercase tracking-wider">
51+
{t.graph.selectedLabel}
52+
</span>
5053
<span className="text-[11px] text-primary font-mono truncate max-w-[300px]">
5154
{selectedProject}
5255
</span>

‎graph-ui/src/components/ControlTab.tsx‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect, useCallback } from "react";
22
import { ScrollArea } from "@/components/ui/scroll-area";
33
import type { ProcessInfo } from "../lib/types";
4+
import { useUiMessages } from "../lib/i18n";
45

56
/* ── Gauge component ────────────────────────────────────── */
67

@@ -30,6 +31,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
3031
proc: ProcessInfo; selected: boolean;
3132
onSelect: () => void; onKill: () => void;
3233
}) {
34+
const t = useUiMessages();
3335
return (
3436
<button
3537
onClick={onSelect}
@@ -46,15 +48,15 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
4648
PID {proc.pid}
4749
</span>
4850
{proc.is_self && (
49-
<span className="text-[9px] px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium">THIS</span>
51+
<span className="text-[9px] px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium">{t.control.thisProcess}</span>
5052
)}
5153
</div>
5254
{!proc.is_self && (
5355
<button
5456
onClick={(e) => { e.stopPropagation(); onKill(); }}
5557
className="px-2 py-1 rounded-lg text-[10px] text-foreground/20 hover:text-destructive hover:bg-destructive/10 transition-all"
5658
>
57-
Kill
59+
{t.control.kill}
5860
</button>
5961
)}
6062
</div>
@@ -69,7 +71,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
6971
<p className="text-[13px] font-semibold tabular-nums text-foreground/70">{proc.rss_mb.toFixed(0)} MB</p>
7072
</div>
7173
<div>
72-
<p className="text-[9px] text-foreground/20 uppercase">Uptime</p>
74+
<p className="text-[9px] text-foreground/20 uppercase">{t.control.uptime}</p>
7375
<p className="text-[13px] font-semibold tabular-nums text-foreground/70">{proc.elapsed}</p>
7476
</div>
7577
</div>
@@ -82,6 +84,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
8284
/* ── Log viewer ─────────────────────────────────────────── */
8385

8486
function LogViewer() {
87+
const t = useUiMessages();
8588
const [lines, setLines] = useState<string[]>([]);
8689

8790
useEffect(() => {
@@ -100,13 +103,13 @@ function LogViewer() {
100103
return (
101104
<div className="rounded-xl border border-border/30 bg-black/30 overflow-hidden">
102105
<div className="px-4 py-2 border-b border-border/20">
103-
<span className="text-[11px] font-medium text-foreground/40">Process Logs</span>
106+
<span className="text-[11px] font-medium text-foreground/40">{t.control.processLogs}</span>
104107
<span className="text-[10px] text-foreground/15 ml-2">{lines.length} lines</span>
105108
</div>
106109
<ScrollArea className="h-[400px]">
107110
<div className="p-3 font-mono text-[10px] leading-relaxed">
108111
{lines.length === 0 ? (
109-
<p className="text-foreground/15 text-center py-8">No logs yet</p>
112+
<p className="text-foreground/15 text-center py-8">{t.control.noLogs}</p>
110113
) : (
111114
lines.map((line, i) => {
112115
const isErr = line.includes("level=error");
@@ -132,6 +135,7 @@ function LogViewer() {
132135
/* ── Main Control Tab ───────────────────────────────────── */
133136

134137
export function ControlTab() {
138+
const t = useUiMessages();
135139
const [processes, setProcesses] = useState<ProcessInfo[]>([]);
136140
const [selfMetrics, setSelfMetrics] = useState({ rss_mb: 0, user_cpu: 0, sys_cpu: 0 });
137141
const [selectedPid, setSelectedPid] = useState<number | null>(null);
@@ -156,7 +160,7 @@ export function ControlTab() {
156160
}, [fetchProcesses]);
157161

158162
const killProcess = useCallback(async (pid: number) => {
159-
if (!confirm(`Kill process ${pid}?`)) return;
163+
if (!confirm(t.control.killConfirm(pid))) return;
160164
try {
161165
await fetch("/api/process-kill", {
162166
method: "POST",
@@ -165,7 +169,7 @@ export function ControlTab() {
165169
});
166170
setTimeout(fetchProcesses, 1000);
167171
} catch { /* ignore */ }
168-
}, [fetchProcesses]);
172+
}, [fetchProcesses, t.control]);
169173

170174
/* Aggregates */
171175
const totalCpu = processes.reduce((s, p) => s + p.cpu, 0);
@@ -174,32 +178,32 @@ export function ControlTab() {
174178
return (
175179
<ScrollArea className="h-full">
176180
<div className="p-8 max-w-4xl mx-auto">
177-
<h2 className="text-[15px] font-semibold text-foreground/80 mb-6">Control Panel</h2>
181+
<h2 className="text-[15px] font-semibold text-foreground/80 mb-6">{t.control.panel}</h2>
178182

179183
{/* Aggregate gauges */}
180184
<div className="flex gap-4 mb-8">
181-
<Gauge label="Total CPU" value={totalCpu} max={100 * processes.length || 100} unit="%" color="text-foreground/80" />
182-
<Gauge label="Total RAM" value={totalRam} max={4096} unit="MB" color="text-foreground/80" />
183-
<Gauge label="Processes" value={processes.length} max={10} unit="" color="text-primary" />
184-
<Gauge label="Self RAM" value={selfMetrics.rss_mb} max={2048} unit="MB" color="text-primary" />
185+
<Gauge label={t.control.totalCpu} value={totalCpu} max={100 * processes.length || 100} unit="%" color="text-foreground/80" />
186+
<Gauge label={t.control.totalRam} value={totalRam} max={4096} unit="MB" color="text-foreground/80" />
187+
<Gauge label={t.control.processes} value={processes.length} max={10} unit="" color="text-primary" />
188+
<Gauge label={t.control.selfRam} value={selfMetrics.rss_mb} max={2048} unit="MB" color="text-primary" />
185189
</div>
186190

187191
{/* Process grid */}
188192
<div className="mb-8">
189193
<div className="flex items-center justify-between mb-4">
190194
<h3 className="text-[13px] font-medium text-foreground/50">
191-
Active Processes
195+
{t.control.activeProcesses}
192196
</h3>
193197
<button
194198
onClick={fetchProcesses}
195199
className="text-[11px] text-primary/60 hover:text-primary transition-colors"
196200
>
197-
Refresh
201+
{t.common.refresh}
198202
</button>
199203
</div>
200204

201205
{processes.length === 0 ? (
202-
<p className="text-foreground/20 text-[12px] text-center py-8">No processes found</p>
206+
<p className="text-foreground/20 text-[12px] text-center py-8">{t.control.noProcesses}</p>
203207
) : (
204208
<div className="grid grid-cols-2 gap-3">
205209
{processes.map((p) => (
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, it } from "vitest";
2+
import { GRAPH_CANVAS_DPR } from "./GraphScene";
3+
4+
describe("GraphScene render limits", () => {
5+
it("caps the high-DPI WebGL backing store below the MSAA failure range", () => {
6+
expect(GRAPH_CANVAS_DPR[0]).toBe(1);
7+
expect(GRAPH_CANVAS_DPR[1]).toBeLessThanOrEqual(1.5);
8+
});
9+
});

‎graph-ui/src/components/GraphScene.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function CameraAnimator({ target }: { target: CameraTarget | null }) {
4545
/* ── Idle auto-rotation ──────────────────────────────────── */
4646

4747
const IDLE_TIMEOUT_MS = 60_000;
48+
export const GRAPH_CANVAS_DPR: [number, number] = [1, 1.5];
49+
export const GRAPH_COMPOSER_MULTISAMPLING = 0;
4850

4951
function IdleAutoRotate({
5052
controlsRef,
@@ -108,8 +110,12 @@ export function GraphScene({
108110
<Canvas
109111
camera={{ position: [0, 0, 800], fov: 50, near: 0.1, far: 100000 }}
110112
style={{ background: "#06090f" }}
111-
dpr={[1, 2]}
112-
gl={{ antialias: true, alpha: false }}
113+
dpr={GRAPH_CANVAS_DPR}
114+
gl={{
115+
antialias: false,
116+
alpha: false,
117+
powerPreference: "high-performance",
118+
}}
113119
>
114120
<color attach="background" args={["#06090f"]} />
115121
<ambientLight intensity={0.5} />
@@ -176,7 +182,7 @@ export function GraphScene({
176182
<CameraAnimator target={cameraTarget} />
177183
<IdleAutoRotate controlsRef={controlsRef} />
178184

179-
<EffectComposer>
185+
<EffectComposer multisampling={GRAPH_COMPOSER_MULTISAMPLING}>
180186
<Bloom
181187
luminanceThreshold={0.3}
182188
luminanceSmoothing={0.7}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { describe, expect, it } from "vitest";
2+
import { formatGraphLimitNotice } from "./GraphTab";
3+
import type { GraphData } from "../lib/types";
4+
5+
describe("formatGraphLimitNotice", () => {
6+
it("reports when the graph response is truncated for render safety", () => {
7+
const data = {
8+
nodes: Array.from({ length: 2000 }, (_, id) => ({
9+
id,
10+
x: 0,
11+
y: 0,
12+
z: 0,
13+
label: "Function",
14+
name: `fn${id}`,
15+
size: 1,
16+
color: "#ffffff",
17+
})),
18+
edges: [],
19+
total_nodes: 43729,
20+
} satisfies GraphData;
21+
22+
expect(formatGraphLimitNotice(data)).toBe(
23+
"Showing 2,000 of 43,729 nodes. Use filters to narrow.",
24+
);
25+
});
26+
27+
it("stays quiet when the full graph is rendered", () => {
28+
const data = {
29+
nodes: [],
30+
edges: [],
31+
total_nodes: 0,
32+
} satisfies GraphData;
33+
34+
expect(formatGraphLimitNotice(data)).toBeNull();
35+
});
36+
});

‎graph-ui/src/components/GraphTab.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ interface GraphTabProps {
2929
project: string | null;
3030
}
3131

32+
export function formatGraphLimitNotice(data: GraphData | null): string | null {
33+
if (!data || data.total_nodes <= data.nodes.length) return null;
34+
return `Showing ${data.nodes.length.toLocaleString()} of ${data.total_nodes.toLocaleString()} nodes. Use filters to narrow.`;
35+
}
36+
3237
export function GraphTab({ project }: GraphTabProps) {
3338
const { data, loading, error, fetchOverview } = useGraphData();
3439
const [highlightedIds, setHighlightedIds] = useState<Set<number> | null>(null);
@@ -38,6 +43,7 @@ export function GraphTab({ project }: GraphTabProps) {
3843
const [showLabels, setShowLabels] = useState(true);
3944
const [leftWidth, setLeftWidth] = useState(() => loadWidth("cbm-left-w", 260));
4045
const [rightWidth, setRightWidth] = useState(() => loadWidth("cbm-right-w", 280));
46+
const limitNotice = formatGraphLimitNotice(data);
4147

4248
/* Filter state — all enabled by default */
4349
const [enabledLabels, setEnabledLabels] = useState<Set<string>>(new Set());
@@ -282,6 +288,9 @@ export function GraphTab({ project }: GraphTabProps) {
282288
filtered from {data.nodes.length.toLocaleString()}
283289
</p>
284290
)}
291+
{limitNotice && (
292+
<p className="text-amber-300/80 mt-0.5">{limitNotice}</p>
293+
)}
285294
{highlightedIds && highlightedIds.size > 0 && (
286295
<p className="text-cyan-400/50 mt-0.5">
287296
{highlightedIds.size} selected

‎graph-ui/src/components/Sidebar.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useMemo, useState } from "react";
22
import { ScrollArea } from "@/components/ui/scroll-area";
33
import type { GraphNode } from "../lib/types";
4+
import { useUiMessages } from "../lib/i18n";
45

56
interface SidebarProps {
67
nodes: GraphNode[];
@@ -105,6 +106,7 @@ function TreeItem({ dir, depth, onSelect, selectedPath }: {
105106
}
106107

107108
export function Sidebar({ nodes, onSelectPath, selectedPath }: SidebarProps) {
109+
const t = useUiMessages();
108110
const [search, setSearch] = useState("");
109111
const tree = useMemo(() => flattenSingleChild(buildFileTree(nodes)), [nodes]);
110112

@@ -122,7 +124,7 @@ export function Sidebar({ nodes, onSelectPath, selectedPath }: SidebarProps) {
122124
<div className="relative">
123125
<input
124126
type="text"
125-
placeholder="Search..."
127+
placeholder={t.graph.search}
126128
value={search}
127129
onChange={(e) => setSearch(e.target.value)}
128130
className="w-full bg-white/[0.04] border border-white/[0.06] rounded-lg px-3 py-1.5 text-[12px] text-foreground placeholder-foreground/25 outline-none focus:border-primary/40 focus:bg-white/[0.06] transition-all"
@@ -134,7 +136,9 @@ export function Sidebar({ nodes, onSelectPath, selectedPath }: SidebarProps) {
134136
<div className="py-1">
135137
{filtered ? (
136138
filtered.length === 0 ? (
137-
<p className="text-foreground/20 text-[12px] px-4 py-6 text-center">No matches</p>
139+
<p className="text-foreground/20 text-[12px] px-4 py-6 text-center">
140+
{t.common.noMatches}
141+
</p>
138142
) : (
139143
filtered.map((n) => (
140144
<button
@@ -160,7 +164,7 @@ export function Sidebar({ nodes, onSelectPath, selectedPath }: SidebarProps) {
160164
onClick={() => onSelectPath("", new Set())}
161165
className="w-full px-3 py-1.5 rounded-lg bg-white/[0.04] hover:bg-white/[0.07] text-[11px] text-foreground/40 font-medium transition-all"
162166
>
163-
Clear selection
167+
{t.graph.clearSelection}
164168
</button>
165169
</div>
166170
)}

0 commit comments

Comments
 (0)