MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / SysinfoPreview

Function SysinfoPreview

frontend/preview/previews/sysinfo.preview.tsx:19–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17const PreviewNodeId = "preview-sysinfo-node";
18
19export default function SysinfoPreview() {
20 const historyRef = React.useRef(makeMockSysinfoHistory());
21 const nodeModel = React.useMemo(
22 () => makeMockNodeModel({ nodeId: PreviewNodeId, blockId: SysinfoBlockId, innerRect: { width: "920px", height: "560px" }, numLeafs: 2 }),
23 []
24 );
25
26 useRpcOverride("EventReadHistoryCommand", async (_client, data) => {
27 if (data.event !== "sysinfo" || data.scope !== MockSysinfoConnection) {
28 return [];
29 }
30 const maxItems = data.maxitems ?? historyRef.current.length;
31 return historyRef.current.slice(-maxItems);
32 });
33
34 React.useEffect(() => {
35 let nextStep = historyRef.current.length;
36 let nextTs = (historyRef.current[historyRef.current.length - 1]?.data?.ts ?? Date.now()) + 1000;
37 const intervalId = window.setInterval(() => {
38 const nextEvent = makeMockSysinfoEvent(nextTs, nextStep);
39 historyRef.current = [...historyRef.current.slice(-(DefaultSysinfoHistoryPoints - 1)), nextEvent];
40 handleWaveEvent(nextEvent);
41 nextStep++;
42 nextTs += 1000;
43 }, 1000);
44
45 return () => {
46 window.clearInterval(intervalId);
47 };
48 }, []);
49
50 return (
51 <div className="flex w-full max-w-[980px] flex-col gap-2 px-6 py-6">
52 <div className="text-xs text-muted font-mono">full sysinfo block (mock WOS + FE-only WPS events)</div>
53 <div className="rounded-md border border-border bg-panel p-4">
54 <div className="h-[620px]">
55 <Block preview={false} nodeModel={nodeModel} />
56 </div>
57 </div>
58 </div>
59 );
60}

Callers

nothing calls this directly

Calls 5

makeMockSysinfoHistoryFunction · 0.90
makeMockNodeModelFunction · 0.90
useRpcOverrideFunction · 0.90
makeMockSysinfoEventFunction · 0.90
handleWaveEventFunction · 0.90

Tested by

no test coverage detected