@hienlh/ppm 0.13.54 → 0.13.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +8 -1
- package/dist/web/assets/ai-settings-section-BH2UOQH-.js +1 -0
- package/dist/web/assets/{api-settings-C3T95dWg.js → api-settings-uQKmeGkl.js} +1 -1
- package/dist/web/assets/architecture-PBZL5I3N-DLKD1Xjj.js +1 -0
- package/dist/web/assets/arrow-down-D825m4vm.js +1 -0
- package/dist/web/assets/{audio-preview-BF1LU0eY.js → audio-preview-LCxWo-25.js} +1 -1
- package/dist/web/assets/chat-tab-3GUmdAJN.js +16 -0
- package/dist/web/assets/chevron-down-BMo4cBth.js +1 -0
- package/dist/web/assets/code-editor-Cd7NZ0VX.js +8 -0
- package/dist/web/assets/{conflict-editor-DcVj0Z-q.js → conflict-editor-No7IVPRN.js} +3 -3
- package/dist/web/assets/csv-parser-D8VHWVA6.js +6 -0
- package/dist/web/assets/{csv-preview-B3Dyhgho.js → csv-preview-DgArUJhd.js} +2 -2
- package/dist/web/assets/{data-grid-overlay-editor-C1UUm7Ob.js → data-grid-overlay-editor-CmduzuPM.js} +1 -1
- package/dist/web/assets/database-viewer-zeQXxkg-.js +1 -0
- package/dist/web/assets/diff-viewer-DmSkyBaT.js +4 -0
- package/dist/web/assets/{esm-DCbn6xno.js → esm-JPvheKDJ.js} +1 -1
- package/dist/web/assets/{extension-webview-DCmfZH6p.js → extension-webview-DCwz2Wso.js} +1 -1
- package/dist/web/assets/eye-off-BacF7RVS.js +1 -0
- package/dist/web/assets/git-log-panel-Bk7Eh-Bn.js +1 -0
- package/dist/web/assets/gitGraph-HDMCJU4V-2a0r4GHr.js +1 -0
- package/dist/web/assets/glide-data-grid-ha8hjunf.js +136 -0
- package/dist/web/assets/{image-preview-BIJGvZ5-.js → image-preview-C1VLHLdJ.js} +1 -1
- package/dist/web/assets/index-CP6EIXkh.js +27 -0
- package/dist/web/assets/index-DwvSM9vu.css +2 -0
- package/dist/web/assets/info-3K5VOQVL-CWKw4e0V.js +1 -0
- package/dist/web/assets/{input-_LFQwhzd.js → input-B78ol0hV.js} +1 -1
- package/dist/web/assets/keybindings-store-Rf9YKWAp.js +1 -0
- package/dist/web/assets/{markdown-renderer-CwKRCQuc.js → markdown-renderer-C7ZoGWso.js} +3 -3
- package/dist/web/assets/notification-store-C3tg-ZXm.js +1 -0
- package/dist/web/assets/{number-overlay-editor-CyEqxXcg.js → number-overlay-editor-DS-qf63L.js} +1 -1
- package/dist/web/assets/packet-RMMSAZCW-Ar00Wbhd.js +1 -0
- package/dist/web/assets/panel-store-B1pOXkyS.js +1 -0
- package/dist/web/assets/{pdf-preview-CbUTv4dX.js → pdf-preview-BdmR2RsT.js} +1 -1
- package/dist/web/assets/pie-UPGHQEXC-Q4ssDdib.js +1 -0
- package/dist/web/assets/port-forwarding-tab-BMb8neu0.js +1 -0
- package/dist/web/assets/{postgres-viewer-C-A4MMtt.js → postgres-viewer-DkM6ndux.js} +3 -3
- package/dist/web/assets/project-store-BnvrVKBw.js +1 -0
- package/dist/web/assets/radar-KQ55EAFF-kq5v4OKX.js +1 -0
- package/dist/web/assets/{settings-store-8FpQDjEA.js → settings-store-CSDOihqv.js} +2 -2
- package/dist/web/assets/settings-tab-WdL5pYxG.js +1 -0
- package/dist/web/assets/{sql-query-editor-Cu9mYyfb.js → sql-query-editor-CNwOnFgF.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-D6ngJJgP.js → sqlite-viewer-FFlsRPWf.js} +1 -1
- package/dist/web/assets/system-monitor-tab-CefzxLVi.js +1 -0
- package/dist/web/assets/{tab-store-CNas5Ny8.js → tab-store-DzftzxTL.js} +1 -1
- package/dist/web/assets/{terminal-tab-CyuBxW2x.js → terminal-tab-C4MNU5S3.js} +2 -2
- package/dist/web/assets/{x-BPReZWnP.js → trash-2-DkIfBY8d.js} +1 -1
- package/dist/web/assets/treemap-KZPCXAKY-DChODgHt.js +1 -0
- package/dist/web/assets/{use-blob-url-DB4nNruT.js → use-blob-url-CI2h4qu0.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-DEI-tJAh.js → use-monaco-theme-qx6SfVRk.js} +1 -1
- package/dist/web/assets/{vendor-mermaid-D2KKkqNs.js → vendor-mermaid-DCie7hiR.js} +2 -2
- package/dist/web/assets/{video-preview-ChP5ypMo.js → video-preview-izCy3xj7.js} +1 -1
- package/dist/web/assets/wifi-LJEyIdXf.js +1 -0
- package/dist/web/assets/x-DfF6D5Js.js +1 -0
- package/dist/web/index.html +22 -20
- package/dist/web/sw.js +1 -1
- package/docs/project-changelog.md +38 -1
- package/docs/system-architecture.md +2 -1
- package/package.json +1 -1
- package/packages/ext-git-graph/src/webview-html.ts +29 -8
- package/src/server/index.ts +4 -0
- package/src/server/middleware/auth.ts +9 -0
- package/src/server/routes/resources.ts +88 -0
- package/src/services/resource-monitor-utils.ts +129 -0
- package/src/services/resource-monitor.service.ts +122 -0
- package/src/web/components/git/git-log-panel.tsx +206 -0
- package/src/web/components/git/git-ref-badge.tsx +150 -0
- package/src/web/components/git/git-status-panel.tsx +18 -0
- package/src/web/components/layout/mobile-nav.tsx +2 -0
- package/src/web/components/layout/sidebar.tsx +6 -0
- package/src/web/components/layout/tab-bar.tsx +3 -0
- package/src/web/components/layout/tab-content.tsx +10 -0
- package/src/web/components/layout/tab-pool.tsx +2 -0
- package/src/web/components/system/resource-status-bar.tsx +66 -0
- package/src/web/components/system/sparkline-canvas.tsx +64 -0
- package/src/web/components/system/system-monitor-group-row.tsx +133 -0
- package/src/web/components/system/system-monitor-tab.tsx +186 -0
- package/src/web/hooks/use-resource-monitor.ts +114 -0
- package/src/web/stores/panel-store.ts +1 -1
- package/src/web/stores/tab-store.ts +3 -1
- package/dist/web/assets/ai-settings-section-AuV6Lzz2.js +0 -1
- package/dist/web/assets/architecture-PBZL5I3N-fAJMexNi.js +0 -1
- package/dist/web/assets/chat-tab-CCOkAmh8.js +0 -16
- package/dist/web/assets/code-editor-BptkAFVa.js +0 -8
- package/dist/web/assets/csv-parser-Dly5nqE1.js +0 -6
- package/dist/web/assets/database-viewer-CYrsNjRy.js +0 -1
- package/dist/web/assets/diff-viewer-DMBviO6l.js +0 -4
- package/dist/web/assets/file-store-DOxcU_7s.js +0 -1
- package/dist/web/assets/gitGraph-HDMCJU4V-ClRAoBAn.js +0 -1
- package/dist/web/assets/glide-data-grid-DhZjCUqu.js +0 -136
- package/dist/web/assets/index-BA8zQtSN.js +0 -27
- package/dist/web/assets/index-CKKoR3gY.css +0 -2
- package/dist/web/assets/info-3K5VOQVL-D8uyBfC_.js +0 -1
- package/dist/web/assets/keybindings-store-BXumit4n.js +0 -1
- package/dist/web/assets/notification-store-B3Fgo6Qw.js +0 -1
- package/dist/web/assets/packet-RMMSAZCW-BJj3FH_w.js +0 -1
- package/dist/web/assets/panel-store-C8wwxBpn.js +0 -1
- package/dist/web/assets/pie-UPGHQEXC-BKfHRBz7.js +0 -1
- package/dist/web/assets/port-forwarding-tab-Nn3-C-Vu.js +0 -1
- package/dist/web/assets/radar-KQ55EAFF-DkybKTt9.js +0 -1
- package/dist/web/assets/scroll-area-BDi_FNzr.js +0 -1
- package/dist/web/assets/settings-tab-Bzlcvim9.js +0 -1
- package/dist/web/assets/treemap-KZPCXAKY-BvDgIWW9.js +0 -1
- /package/dist/web/assets/{api-client-DIhJ5qVW.js → api-client-DiZgVOok.js} +0 -0
- /package/dist/web/assets/{chevron-right-DnHIvvcy.js → chevron-right-CD8e6Aj4.js} +0 -0
- /package/dist/web/assets/{code-DGBecc50.js → code-DiNmA3eR.js} +0 -0
- /package/dist/web/assets/{data-grid-types-D2cHE8hx.js → data-grid-types-C29KDkZJ.js} +0 -0
- /package/dist/web/assets/{database-DOWH9-Vv.js → database-Dc8mr-dP.js} +0 -0
- /package/dist/web/assets/{dist-DVk8T0R5.js → dist-DeY41KFi.js} +0 -0
- /package/dist/web/assets/{dist-BoIkGNC8.js → dist-PPUhQONj.js} +0 -0
- /package/dist/web/assets/{file-exclamation-point-BwzaQ50n.js → file-exclamation-point-B__2Hrd6.js} +0 -0
- /package/dist/web/assets/{globe-B4Ilypbs.js → globe-CQ8NAYvi.js} +0 -0
- /package/dist/web/assets/{katex-C10ndCVt.js → katex-DUj5OG1J.js} +0 -0
- /package/dist/web/assets/{lib-C2D8j3K3.js → lib-DrypSCq8.js} +0 -0
- /package/dist/web/assets/{react-DMIOAtcX.js → react-CfveccaI.js} +0 -0
- /package/dist/web/assets/{refresh-cw-BjrAbUJe.js → refresh-cw-CRD2qr4U.js} +0 -0
- /package/dist/web/assets/{search-tM8K5zWU.js → search-D90WJ5fo.js} +0 -0
- /package/dist/web/assets/{sparkles-CulWHe4c.js → sparkles-KCOEy7QI.js} +0 -0
- /package/dist/web/assets/{table-BzjWcs87.js → table-2wDtM4_B.js} +0 -0
- /package/dist/web/assets/{text-wrap-DJz9Bgpa.js → text-wrap-AZErifCu.js} +0 -0
- /package/dist/web/assets/{utils-CQux7CsO.js → utils-E0yyGxXt.js} +0 -0
- /package/dist/web/assets/{vendor-xterm-D1P36hcr.js → vendor-xterm-t3d5xZdz.js} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useRef, useEffect, memo } from "react";
|
|
2
|
+
|
|
3
|
+
interface SparklineCanvasProps {
|
|
4
|
+
data: number[];
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const SparklineCanvas = memo(function SparklineCanvas({
|
|
11
|
+
data,
|
|
12
|
+
width = 120,
|
|
13
|
+
height = 24,
|
|
14
|
+
color = "#3b82f6",
|
|
15
|
+
}: SparklineCanvasProps) {
|
|
16
|
+
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
17
|
+
const lastDrawRef = useRef(0);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const now = Date.now();
|
|
21
|
+
// Throttle redraws to 1fps
|
|
22
|
+
if (now - lastDrawRef.current < 1000) return;
|
|
23
|
+
lastDrawRef.current = now;
|
|
24
|
+
|
|
25
|
+
const canvas = canvasRef.current;
|
|
26
|
+
if (!canvas || data.length < 2) return;
|
|
27
|
+
|
|
28
|
+
const ctx = canvas.getContext("2d");
|
|
29
|
+
if (!ctx) return;
|
|
30
|
+
|
|
31
|
+
const dpr = window.devicePixelRatio || 1;
|
|
32
|
+
canvas.width = width * dpr;
|
|
33
|
+
canvas.height = height * dpr;
|
|
34
|
+
ctx.scale(dpr, dpr);
|
|
35
|
+
|
|
36
|
+
ctx.clearRect(0, 0, width, height);
|
|
37
|
+
|
|
38
|
+
const max = Math.max(...data, 1);
|
|
39
|
+
const stepX = width / (data.length - 1);
|
|
40
|
+
const padding = 2;
|
|
41
|
+
const drawH = height - padding * 2;
|
|
42
|
+
|
|
43
|
+
ctx.beginPath();
|
|
44
|
+
ctx.strokeStyle = color;
|
|
45
|
+
ctx.lineWidth = 1.5;
|
|
46
|
+
ctx.lineJoin = "round";
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < data.length; i++) {
|
|
49
|
+
const x = i * stepX;
|
|
50
|
+
const y = padding + drawH - (data[i]! / max) * drawH;
|
|
51
|
+
if (i === 0) ctx.moveTo(x, y);
|
|
52
|
+
else ctx.lineTo(x, y);
|
|
53
|
+
}
|
|
54
|
+
ctx.stroke();
|
|
55
|
+
}, [data, width, height, color]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<canvas
|
|
59
|
+
ref={canvasRef}
|
|
60
|
+
style={{ width, height }}
|
|
61
|
+
className="inline-block"
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { memo, useMemo } from "react";
|
|
2
|
+
import { ChevronRight, ChevronDown, HelpCircle, X, ArrowUp, ArrowDown } from "lucide-react";
|
|
3
|
+
import type { ResourceGroup } from "@/hooks/use-resource-monitor";
|
|
4
|
+
import { SparklineCanvas } from "./sparkline-canvas";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
export type SortKey = "cpu" | "ram" | null;
|
|
8
|
+
export type SortDir = "asc" | "desc";
|
|
9
|
+
|
|
10
|
+
function cpuColor(cpu: number) {
|
|
11
|
+
if (cpu > 80) return "text-red-500";
|
|
12
|
+
if (cpu > 50) return "text-yellow-500";
|
|
13
|
+
return "text-green-500";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function formatRam(mb: number) {
|
|
17
|
+
return mb < 1024 ? `${mb.toFixed(0)} MB` : `${(mb / 1024).toFixed(1)} GB`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface GroupRowProps {
|
|
21
|
+
group: ResourceGroup;
|
|
22
|
+
Icon: React.ElementType;
|
|
23
|
+
isExpanded: boolean;
|
|
24
|
+
sparkData: number[];
|
|
25
|
+
isMobile: boolean;
|
|
26
|
+
sortKey: SortKey;
|
|
27
|
+
sortDir: SortDir;
|
|
28
|
+
onToggle: () => void;
|
|
29
|
+
onKill: (pid: number) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const GroupRow = memo(function GroupRow({
|
|
33
|
+
group, Icon, isExpanded, sparkData, isMobile, sortKey, sortDir, onToggle, onKill,
|
|
34
|
+
}: GroupRowProps) {
|
|
35
|
+
const Chevron = isExpanded ? ChevronDown : ChevronRight;
|
|
36
|
+
|
|
37
|
+
const sortedProcesses = useMemo(() => {
|
|
38
|
+
if (!sortKey) return group.processes;
|
|
39
|
+
return [...group.processes].sort((a, b) => {
|
|
40
|
+
const av = sortKey === "cpu" ? a.cpu : a.ramMB;
|
|
41
|
+
const bv = sortKey === "cpu" ? b.cpu : b.ramMB;
|
|
42
|
+
return sortDir === "asc" ? av - bv : bv - av;
|
|
43
|
+
});
|
|
44
|
+
}, [group.processes, sortKey, sortDir]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<tr
|
|
49
|
+
className="hover:bg-surface-hover cursor-pointer transition-colors"
|
|
50
|
+
onClick={onToggle}
|
|
51
|
+
>
|
|
52
|
+
<td className="py-1.5 px-3">
|
|
53
|
+
<div className="flex items-center gap-1.5">
|
|
54
|
+
<Chevron className="size-3 text-text-subtle shrink-0" />
|
|
55
|
+
<Icon className="size-3.5 text-text-secondary shrink-0" />
|
|
56
|
+
<span className="truncate">{group.label}</span>
|
|
57
|
+
<span className="text-text-subtle">({group.processes.length})</span>
|
|
58
|
+
</div>
|
|
59
|
+
</td>
|
|
60
|
+
<td className={cn("text-right py-1.5 px-2", cpuColor(group.cpu))}>
|
|
61
|
+
{group.cpu.toFixed(1)}%
|
|
62
|
+
</td>
|
|
63
|
+
<td className="text-right py-1.5 px-2 text-text-secondary">
|
|
64
|
+
{formatRam(group.ramMB)}
|
|
65
|
+
</td>
|
|
66
|
+
{!isMobile && (
|
|
67
|
+
<td className="py-1.5 px-2">
|
|
68
|
+
{sparkData.length > 1 && (
|
|
69
|
+
<SparklineCanvas data={sparkData} width={120} height={20} />
|
|
70
|
+
)}
|
|
71
|
+
</td>
|
|
72
|
+
)}
|
|
73
|
+
</tr>
|
|
74
|
+
{isExpanded && sortedProcesses.map((proc) => (
|
|
75
|
+
<tr key={proc.pid} className="text-text-subtle group/proc hover:bg-surface-hover transition-colors">
|
|
76
|
+
<td className="py-1 px-3 pl-10">
|
|
77
|
+
<div className="flex items-start gap-1.5">
|
|
78
|
+
<span className="text-text-subtle shrink-0">{proc.pid}</span>
|
|
79
|
+
<span className="break-all text-text-secondary" title={proc.command}>
|
|
80
|
+
{proc.command}
|
|
81
|
+
</span>
|
|
82
|
+
</div>
|
|
83
|
+
</td>
|
|
84
|
+
<td className="text-right py-1 px-2 align-top">{proc.cpu.toFixed(1)}%</td>
|
|
85
|
+
<td className="text-right py-1 px-2 align-top">{formatRam(proc.ramMB)}</td>
|
|
86
|
+
{!isMobile && (
|
|
87
|
+
<td className="align-top py-1 px-2">
|
|
88
|
+
<button
|
|
89
|
+
onClick={(e) => { e.stopPropagation(); onKill(proc.pid); }}
|
|
90
|
+
className="opacity-0 group-hover/proc:opacity-100 p-0.5 rounded hover:bg-red-500/20 hover:text-red-500 transition-all"
|
|
91
|
+
title={`End process ${proc.pid}`}
|
|
92
|
+
>
|
|
93
|
+
<X className="size-3" />
|
|
94
|
+
</button>
|
|
95
|
+
</td>
|
|
96
|
+
)}
|
|
97
|
+
</tr>
|
|
98
|
+
))}
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ── Sortable column header ─────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
export function SortableHeader({ label, field, activeKey, activeDir, onClick, className }: {
|
|
106
|
+
label: string;
|
|
107
|
+
field: "cpu" | "ram";
|
|
108
|
+
activeKey: SortKey;
|
|
109
|
+
activeDir: SortDir;
|
|
110
|
+
onClick: (field: "cpu" | "ram") => void;
|
|
111
|
+
className?: string;
|
|
112
|
+
}) {
|
|
113
|
+
const isActive = activeKey === field;
|
|
114
|
+
const Arrow = isActive ? (activeDir === "asc" ? ArrowUp : ArrowDown) : null;
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<th
|
|
118
|
+
className={cn(
|
|
119
|
+
"text-right py-1.5 px-2 font-medium cursor-pointer select-none hover:text-text-primary transition-colors",
|
|
120
|
+
isActive && "text-text-primary",
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
123
|
+
onClick={() => onClick(field)}
|
|
124
|
+
>
|
|
125
|
+
<div className="flex items-center justify-end gap-0.5">
|
|
126
|
+
<span>{label}</span>
|
|
127
|
+
{Arrow && <Arrow className="size-3" />}
|
|
128
|
+
</div>
|
|
129
|
+
</th>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { cpuColor, formatRam };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { useState, useMemo, useCallback, memo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Server, Monitor, Bot, Hammer, HelpCircle,
|
|
4
|
+
Wifi, WifiOff,
|
|
5
|
+
} from "lucide-react";
|
|
6
|
+
import { useResourceMonitor, type ResourceGroup } from "@/hooks/use-resource-monitor";
|
|
7
|
+
import { useIsMobile } from "@/hooks/use-is-mobile";
|
|
8
|
+
import { api } from "@/lib/api-client";
|
|
9
|
+
import { toast } from "sonner";
|
|
10
|
+
import { cn } from "@/lib/utils";
|
|
11
|
+
import {
|
|
12
|
+
GroupRow, SortableHeader, cpuColor, formatRam,
|
|
13
|
+
type SortKey, type SortDir,
|
|
14
|
+
} from "./system-monitor-group-row";
|
|
15
|
+
|
|
16
|
+
const GROUP_ICONS: Record<ResourceGroup["type"], React.ElementType> = {
|
|
17
|
+
server: Server,
|
|
18
|
+
terminal: Monitor,
|
|
19
|
+
"ai-tool": Bot,
|
|
20
|
+
build: Hammer,
|
|
21
|
+
unknown: HelpCircle,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const SPARKLINE_POINTS = 200;
|
|
25
|
+
|
|
26
|
+
function toggleSort(
|
|
27
|
+
current: SortKey, dir: SortDir, clicked: "cpu" | "ram",
|
|
28
|
+
): [SortKey, SortDir] {
|
|
29
|
+
if (current !== clicked) return [clicked, "desc"];
|
|
30
|
+
if (dir === "desc") return [clicked, "asc"];
|
|
31
|
+
return [null, "desc"]; // third click resets
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function sortGroups(groups: ResourceGroup[], key: SortKey, dir: SortDir) {
|
|
35
|
+
if (!key) return groups;
|
|
36
|
+
const sorted = [...groups].sort((a, b) => {
|
|
37
|
+
const av = key === "cpu" ? a.cpu : a.ramMB;
|
|
38
|
+
const bv = key === "cpu" ? b.cpu : b.ramMB;
|
|
39
|
+
return dir === "asc" ? av - bv : bv - av;
|
|
40
|
+
});
|
|
41
|
+
return sorted;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const SystemMonitorTab = memo(function SystemMonitorTab() {
|
|
45
|
+
const { latest, history, isConnected } = useResourceMonitor();
|
|
46
|
+
const [expanded, setExpanded] = useState<Set<string>>(() => new Set(["server"]));
|
|
47
|
+
const [sortKey, setSortKey] = useState<SortKey>(null);
|
|
48
|
+
const [sortDir, setSortDir] = useState<SortDir>("desc");
|
|
49
|
+
const isMobile = useIsMobile();
|
|
50
|
+
|
|
51
|
+
const groupSparklines = useMemo(() => {
|
|
52
|
+
const map = new Map<string, number[]>();
|
|
53
|
+
const recentHistory = history.slice(-SPARKLINE_POINTS);
|
|
54
|
+
for (const snap of recentHistory) {
|
|
55
|
+
for (const group of snap.groups) {
|
|
56
|
+
const key = `${group.type}:${group.label}`;
|
|
57
|
+
const arr = map.get(key) ?? [];
|
|
58
|
+
arr.push(group.cpu);
|
|
59
|
+
map.set(key, arr);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return map;
|
|
63
|
+
}, [history]);
|
|
64
|
+
|
|
65
|
+
const sortedGroups = useMemo(() => {
|
|
66
|
+
if (!latest) return [];
|
|
67
|
+
return sortGroups(latest.groups, sortKey, sortDir);
|
|
68
|
+
}, [latest, sortKey, sortDir]);
|
|
69
|
+
|
|
70
|
+
const killProcess = useCallback(async (pid: number) => {
|
|
71
|
+
try {
|
|
72
|
+
await api.post(`/api/system/resources/kill/${pid}`);
|
|
73
|
+
toast.success(`Sent SIGTERM to PID ${pid}`);
|
|
74
|
+
} catch (e: any) {
|
|
75
|
+
toast.error(e.message || `Failed to kill PID ${pid}`);
|
|
76
|
+
}
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
const toggle = (key: string) => {
|
|
80
|
+
setExpanded((prev) => {
|
|
81
|
+
const next = new Set(prev);
|
|
82
|
+
if (next.has(key)) next.delete(key);
|
|
83
|
+
else next.add(key);
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleSort = (clicked: "cpu" | "ram") => {
|
|
89
|
+
const [newKey, newDir] = toggleSort(sortKey, sortDir, clicked);
|
|
90
|
+
setSortKey(newKey);
|
|
91
|
+
setSortDir(newDir);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
if (!latest) {
|
|
95
|
+
return (
|
|
96
|
+
<div className="flex items-center justify-center h-full text-text-subtle text-sm">
|
|
97
|
+
{isConnected ? "Waiting for data..." : "Connecting to resource monitor..."}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const elapsed = Math.round((Date.now() - latest.timestamp) / 1000);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div className="h-full flex flex-col overflow-hidden">
|
|
106
|
+
{/* Header */}
|
|
107
|
+
<div className="flex items-center justify-between px-3 py-2 border-b border-border shrink-0">
|
|
108
|
+
<h2 className="text-sm font-medium">System Monitor</h2>
|
|
109
|
+
<div className="flex items-center gap-1.5 text-[10px] text-text-subtle">
|
|
110
|
+
{isConnected
|
|
111
|
+
? <Wifi className="size-3 text-green-500" />
|
|
112
|
+
: <WifiOff className="size-3 text-red-500" />}
|
|
113
|
+
<span>{isConnected ? `Updated ${elapsed}s ago` : "Disconnected"}</span>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
{/* Group list */}
|
|
118
|
+
<div className="flex-1 overflow-y-auto min-h-0">
|
|
119
|
+
<table className="w-full text-xs">
|
|
120
|
+
<thead>
|
|
121
|
+
<tr className="text-text-subtle border-b border-border">
|
|
122
|
+
<th className="text-left py-1.5 px-3 font-medium">Process</th>
|
|
123
|
+
<SortableHeader
|
|
124
|
+
label="CPU"
|
|
125
|
+
field="cpu"
|
|
126
|
+
activeKey={sortKey}
|
|
127
|
+
activeDir={sortDir}
|
|
128
|
+
onClick={handleSort}
|
|
129
|
+
className="w-16"
|
|
130
|
+
/>
|
|
131
|
+
<SortableHeader
|
|
132
|
+
label="RAM"
|
|
133
|
+
field="ram"
|
|
134
|
+
activeKey={sortKey}
|
|
135
|
+
activeDir={sortDir}
|
|
136
|
+
onClick={handleSort}
|
|
137
|
+
className="w-20"
|
|
138
|
+
/>
|
|
139
|
+
{!isMobile && (
|
|
140
|
+
<th className="py-1.5 px-2 font-medium w-[130px]">Trend</th>
|
|
141
|
+
)}
|
|
142
|
+
</tr>
|
|
143
|
+
</thead>
|
|
144
|
+
<tbody>
|
|
145
|
+
{sortedGroups.map((group) => {
|
|
146
|
+
const key = `${group.type}:${group.label}`;
|
|
147
|
+
const Icon = GROUP_ICONS[group.type] ?? HelpCircle;
|
|
148
|
+
const isExpanded = expanded.has(key);
|
|
149
|
+
const sparkData = groupSparklines.get(key) ?? [];
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<GroupRow
|
|
153
|
+
key={key}
|
|
154
|
+
group={group}
|
|
155
|
+
Icon={Icon}
|
|
156
|
+
isExpanded={isExpanded}
|
|
157
|
+
sparkData={sparkData}
|
|
158
|
+
isMobile={isMobile}
|
|
159
|
+
sortKey={sortKey}
|
|
160
|
+
sortDir={sortDir}
|
|
161
|
+
onToggle={() => toggle(key)}
|
|
162
|
+
onKill={killProcess}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
})}
|
|
166
|
+
</tbody>
|
|
167
|
+
{/* Total row */}
|
|
168
|
+
<tfoot>
|
|
169
|
+
<tr className="border-t border-border font-medium">
|
|
170
|
+
<td className="py-1.5 px-3">
|
|
171
|
+
Total ({latest.total.processCount} processes)
|
|
172
|
+
</td>
|
|
173
|
+
<td className={cn("text-right py-1.5 px-2", cpuColor(latest.total.cpu))}>
|
|
174
|
+
{latest.total.cpu.toFixed(1)}%
|
|
175
|
+
</td>
|
|
176
|
+
<td className="text-right py-1.5 px-2 text-text-secondary">
|
|
177
|
+
{formatRam(latest.total.ramMB)}
|
|
178
|
+
</td>
|
|
179
|
+
{!isMobile && <td />}
|
|
180
|
+
</tr>
|
|
181
|
+
</tfoot>
|
|
182
|
+
</table>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, useCallback } from "react";
|
|
2
|
+
import { getAuthToken } from "@/lib/api-client";
|
|
3
|
+
|
|
4
|
+
// ── Types (mirrors backend) ────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export interface ResourceGroup {
|
|
7
|
+
type: "server" | "terminal" | "ai-tool" | "build" | "unknown";
|
|
8
|
+
label: string;
|
|
9
|
+
cpu: number;
|
|
10
|
+
ramMB: number;
|
|
11
|
+
processes: { pid: number; cpu: number; ramMB: number; command: string }[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ResourceSnapshot {
|
|
15
|
+
timestamp: number;
|
|
16
|
+
server: { pid: number; cpu: number; ramMB: number };
|
|
17
|
+
total: { cpu: number; ramMB: number; processCount: number };
|
|
18
|
+
groups: ResourceGroup[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const HISTORY_MAX = 600;
|
|
22
|
+
|
|
23
|
+
// ── Shared singleton state (multiple components share one EventSource) ─
|
|
24
|
+
|
|
25
|
+
let sharedEs: EventSource | null = null;
|
|
26
|
+
let refCount = 0;
|
|
27
|
+
let sharedLatest: ResourceSnapshot | null = null;
|
|
28
|
+
let sharedHistory: ResourceSnapshot[] = [];
|
|
29
|
+
let sharedConnected = false;
|
|
30
|
+
const listeners = new Set<() => void>();
|
|
31
|
+
|
|
32
|
+
function notify() {
|
|
33
|
+
for (const cb of listeners) cb();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function connect() {
|
|
37
|
+
if (sharedEs) return;
|
|
38
|
+
const token = getAuthToken();
|
|
39
|
+
const params = token ? `?token=${encodeURIComponent(token)}` : "";
|
|
40
|
+
const es = new EventSource(`/api/system/resources/stream${params}`);
|
|
41
|
+
|
|
42
|
+
es.addEventListener("snapshot", (e) => {
|
|
43
|
+
try {
|
|
44
|
+
const snapshot: ResourceSnapshot = JSON.parse(e.data);
|
|
45
|
+
sharedLatest = snapshot;
|
|
46
|
+
sharedHistory = [...sharedHistory, snapshot];
|
|
47
|
+
if (sharedHistory.length > HISTORY_MAX) {
|
|
48
|
+
sharedHistory = sharedHistory.slice(-HISTORY_MAX);
|
|
49
|
+
}
|
|
50
|
+
sharedConnected = true;
|
|
51
|
+
notify();
|
|
52
|
+
} catch {}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
es.onerror = () => {
|
|
56
|
+
sharedConnected = false;
|
|
57
|
+
// Close stale ES and manually reconnect with backoff to avoid duplicate connections
|
|
58
|
+
if (sharedEs) {
|
|
59
|
+
sharedEs.close();
|
|
60
|
+
sharedEs = null;
|
|
61
|
+
}
|
|
62
|
+
notify();
|
|
63
|
+
if (refCount > 0) {
|
|
64
|
+
setTimeout(() => { if (!sharedEs && refCount > 0) connect(); }, 5000);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
es.onopen = () => {
|
|
69
|
+
sharedConnected = true;
|
|
70
|
+
notify();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
sharedEs = es;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function disconnect() {
|
|
77
|
+
if (sharedEs) {
|
|
78
|
+
sharedEs.close();
|
|
79
|
+
sharedEs = null;
|
|
80
|
+
sharedConnected = false;
|
|
81
|
+
notify();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ── Hook ───────────────────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
export function useResourceMonitor() {
|
|
88
|
+
const [, forceUpdate] = useState(0);
|
|
89
|
+
const mounted = useRef(true);
|
|
90
|
+
|
|
91
|
+
const rerender = useCallback(() => {
|
|
92
|
+
if (mounted.current) forceUpdate((n) => n + 1);
|
|
93
|
+
}, []);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
mounted.current = true;
|
|
97
|
+
listeners.add(rerender);
|
|
98
|
+
refCount++;
|
|
99
|
+
if (refCount === 1) connect();
|
|
100
|
+
|
|
101
|
+
return () => {
|
|
102
|
+
mounted.current = false;
|
|
103
|
+
listeners.delete(rerender);
|
|
104
|
+
refCount--;
|
|
105
|
+
if (refCount === 0) disconnect();
|
|
106
|
+
};
|
|
107
|
+
}, [rerender]);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
latest: sharedLatest,
|
|
111
|
+
history: sharedHistory,
|
|
112
|
+
isConnected: sharedConnected,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./panel-utils";
|
|
17
17
|
|
|
18
18
|
/** Tab types that can only have 1 instance per project */
|
|
19
|
-
const SINGLETON_TYPES = new Set<TabType>(["settings"]);
|
|
19
|
+
const SINGLETON_TYPES = new Set<TabType>(["settings", "git-log"]);
|
|
20
20
|
|
|
21
21
|
/** Tab types removed in a prior version — filter them out when loading persisted state */
|
|
22
22
|
const OBSOLETE_TAB_TYPES = new Set(["projects", "git-status", "git-graph"]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{S as r,a as i,c as a,d as o,f as s,g as c,h as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./vendor-ui-UXCWAcmi.js";import{t as v}from"./createLucideIcon-BjHrJDVb.js";import{n as y}from"./globe-B4Ilypbs.js";import{t as b}from"./input-_LFQwhzd.js";import{n as x}from"./x-BPReZWnP.js";import{t as S}from"./refresh-cw-BjrAbUJe.js";import{i as C,t as w}from"./api-client-DIhJ5qVW.js";import{n as T}from"./utils-CQux7CsO.js";import{a as E,h as D}from"./api-settings-C3T95dWg.js";var O=v(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),k=v(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=v(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),j=v(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=v(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),N=v(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),P=v(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),F=e(n(),1),I=t();function L({className:e,...t}){return(0,I.jsx)(r,{"data-slot":`label`,className:T(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var R=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(f,{className:T(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,I.jsx)(h,{className:T(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));R.displayName=f.displayName;function z({...e}){return(0,I.jsx)(o,{"data-slot":`select`,...e})}function B({...e}){return(0,I.jsx)(l,{"data-slot":`select-value`,...e})}function V({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(d,{"data-slot":`select-trigger`,"data-size":t,className:T(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(p,{asChild:!0,children:(0,I.jsx)(j,{className:`size-4 opacity-50`})})]})}function H({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(_,{children:(0,I.jsxs)(i,{"data-slot":`select-content`,className:T(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,I.jsx)(W,{}),(0,I.jsx)(c,{className:T(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(G,{})]})})}function U({className:e,children:t,...n}){return(0,I.jsxs)(g,{"data-slot":`select-item`,className:T(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(a,{children:(0,I.jsx)(y,{className:`size-4`})})}),(0,I.jsx)(u,{children:t})]})}function W({className:e,...t}){return(0,I.jsx)(m,{"data-slot":`select-scroll-up-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(M,{className:`size-4`})})}function G({className:e,...t}){return(0,I.jsx)(s,{"data-slot":`select-scroll-down-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(j,{className:`size-4`})})}var K={claude:`C`,cursor:`▶`,codex:`◆`,gemini:`G`};function q({value:e,onChange:t,projectName:n}){let[r,i]=(0,F.useState)([]),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),c=(0,F.useRef)(0);(0,F.useEffect)(()=>{n&&w.get(`${C(n)}/chat/providers`).then(i).catch(()=>{})},[n]),(0,F.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,F.useEffect)(()=>{a&&(c.current=Math.max(0,r.findIndex(t=>t.id===e)))},[a,e,r]);let l=(0,F.useCallback)(e=>{if(e.key===`Escape`){o(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;c.current=(c.current+t+r.length)%r.length,(s.current?.querySelector(`[data-idx="${c.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=r[c.current];n&&(t(n.id),o(!1))}},[t,r]);if(r.length<=1)return null;let u=r.find(t=>t.id===e),d=K[e]||`?`;return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(e=>!e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`AI Provider: ${u?.name??e}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center rounded text-[9px] font-bold bg-surface-elevated shrink-0`,children:d}),(0,I.jsx)(`span`,{className:`max-w-[80px] truncate capitalize`,children:u?.name??e})]}),a&&(0,I.jsxs)(`div`,{ref:s,role:`listbox`,"aria-label":`AI Providers`,onKeyDown:l,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-56 rounded-lg border border-border bg-surface shadow-lg`,children:[(0,I.jsx)(`div`,{className:`px-3 py-2 border-b border-border`,children:(0,I.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Provider`})}),(0,I.jsx)(`div`,{className:`py-1`,children:r.map((n,r)=>{let i=K[n.id]||`?`,a=n.id===e;return(0,I.jsxs)(`button`,{"data-idx":r,role:`option`,"aria-selected":a,tabIndex:0,onClick:()=>{t(n.id),o(!1)},className:`w-full flex items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${a?`bg-surface-elevated`:``}`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 items-center justify-center rounded text-[11px] font-bold bg-surface-elevated text-text-subtle shrink-0`,children:i}),(0,I.jsx)(`span`,{className:`flex-1 text-sm font-medium text-text-primary capitalize`,children:n.name}),a&&(0,I.jsx)(y,{className:`size-4 shrink-0 text-primary`})]},n.id)})})]})]})}function J({providerId:e}){return(0,I.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center rounded text-[10px] font-bold bg-surface-elevated text-text-subtle shrink-0`,title:e,children:K[e]||`?`})}var Y=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],X=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],Z={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function Q({compact:e}={}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)([]),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(0);(0,F.useEffect)(()=>{E().then(e=>{n(e),i(e.default_provider??`claude`)}).catch(e=>f(e.message))},[]),(0,F.useEffect)(()=>{r&&(c(!0),w.get(`/api/settings/ai/providers/${r}/models`).then(o).catch(()=>o([])).finally(()=>c(!1)))},[r]);let h=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:Z[e]??e})):[],g=t?.providers[r],_=g?.type===`agent-sdk`||!g?.type&&r===`claude`,v=async(e,i)=>{if(t){u(!0),f(null);try{n(await D({providers:{[r]:{[e]:i}}})),m(e=>e+1)}catch(e){f(e.message)}finally{u(!1)}}},y=e?`text-[11px]`:`text-sm`,x=e?`text-xs`:`text-sm`,S=e?`space-y-2`:`space-y-4`,C=e?`space-y-1.5`:`space-y-3`,T=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,I.jsxs)(`div`,{className:C,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),(0,I.jsx)(`p`,{className:`${y} text-text-subtle`,children:d?`Error: ${d}`:`Loading...`})]});let O=_?a:[{value:`__default__`,label:`Auto (default)`},...a];return(0,I.jsxs)(`div`,{className:S,children:[(0,I.jsx)(`h3`,{className:`${x} font-medium text-text-secondary`,children:`AI Settings`}),h.length>1&&(0,I.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:h.map(e=>(0,I.jsxs)(`button`,{onClick:()=>i(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,I.jsx)(J,{providerId:e.id}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,I.jsxs)(`div`,{className:C,children:[a.length>0&&(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-model`,className:e?y:void 0,children:`Model`}),(0,I.jsxs)(z,{value:_?g?.model??a[0]?.value:g?.model||`__default__`,onValueChange:e=>v(`model`,e===`__default__`?void 0:e),disabled:s,children:[(0,I.jsx)(V,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{placeholder:s?`Loading models...`:`Select model`})}),(0,I.jsx)(H,{className:`max-h-[300px]`,children:O.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),_&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-base-url`,className:e?y:void 0,children:`Base URL`}),(0,I.jsx)(b,{id:`ai-base-url`,type:`url`,defaultValue:g?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{v(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-api-key`,className:e?y:void 0,children:`API Key / Token`}),(0,I.jsx)(b,{id:`ai-api-key`,type:`password`,defaultValue:g?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||v(`api_key`,t||void 0)}},`apikey-${r}-${p}`),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-effort`,className:e?y:void 0,children:`Effort`}),(0,I.jsxs)(z,{value:g?.effort??`high`,onValueChange:e=>v(`effort`,e),children:[(0,I.jsx)(V,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:Y.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-max-turns`,className:e?y:void 0,children:`Max Turns (1-500)`}),(0,I.jsx)(b,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:g?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||v(`max_turns`,t)}},`turns-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-budget`,className:e?y:void 0,children:`Max Budget (USD)`}),(0,I.jsx)(b,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:g?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);v(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-thinking`,className:e?y:void 0,children:`Thinking Budget (tokens)`}),(0,I.jsx)(b,{id:`ai-thinking`,type:`number`,min:0,defaultValue:g?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);v(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${p}`)]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(L,{htmlFor:`ai-agent-teams`,className:e?y:void 0,children:`Agent Teams`}),(0,I.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,I.jsx)(R,{id:`ai-agent-teams`,checked:g?.agent_teams??!1,onCheckedChange:e=>v(`agent_teams`,e)})]}),g?.agent_teams&&(0,I.jsx)($,{compact:e})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-permission-mode`,className:e?y:void 0,children:`Default Permission Mode`}),(0,I.jsxs)(z,{value:g?.permission_mode??`bypassPermissions`,onValueChange:e=>v(`permission_mode`,e),children:[(0,I.jsx)(V,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,I.jsx)(B,{})}),(0,I.jsx)(H,{children:X.map(e=>(0,I.jsx)(U,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:T,children:[(0,I.jsx)(L,{htmlFor:`ai-system-prompt`,className:e?y:void 0,children:`Additional Instructions`}),(0,I.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:g?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{v(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${p}`)]})]}),l&&(0,I.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),d&&(0,I.jsx)(`p`,{className:`text-xs text-red-500`,children:d})]})}function $({compact:e}){let[t,n]=(0,F.useState)([]),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),s=(0,F.useCallback)(async()=>{i(!0);try{n(await w.get(`/api/teams`)??[])}catch{}i(!1)},[]);(0,F.useEffect)(()=>{s()},[s]);let c=async e=>{try{await w.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),o(null)}catch{}};return t.length===0&&!r?null:(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(L,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,I.jsx)(`button`,{onClick:s,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,I.jsx)(S,{className:`size-3 ${r?`animate-spin`:``}`})})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,I.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,I.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),a===e.name?(0,I.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,I.jsx)(`button`,{onClick:()=>c(e.name),className:`px-2 py-1 bg-red-600 text-white rounded text-[10px]`,children:`Delete`}),(0,I.jsx)(`button`,{onClick:()=>o(null),className:`px-2 py-1 bg-zinc-600 text-white rounded text-[10px]`,children:`Cancel`})]}):(0,I.jsx)(`button`,{onClick:()=>o(e.name),className:`shrink-0 text-text-subtle hover:text-red-500 p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,I.jsx)(x,{className:`size-3.5`})})]},e.name))]})}export{O as _,H as a,B as c,P as d,N as f,k as g,A as h,z as i,R as l,j as m,J as n,U as o,M as p,q as r,V as s,Q as t,L as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e}from"./vendor-mermaid-D2KKkqNs.js";export{e as createArchitectureServices};
|