Файли
openidea/src/features/remote-dev/RemoteStatus.tsx
T
Deng Liuтаdengliu 264bf6969f feat(remote-dev): add remote host resource indicator and dashboard (#6425)
A remote window (SSH, WSL, Dev Container) shows a compact CPU and memory indicator beside the connection status; network and disk badges appear only when saturated. Clicking it, or Show Remote Host Resources, opens a dashboard with 60-second sparklines for CPU (cores, load), memory, network (with RPC round-trip latency) and disk (I/O and free space), the OpenIDEA processes on the host grouped by kind, and the top other host processes.

End Process asks for confirmation naming the process and PID, and ends only processes in the backend's own tree. Linux /proc and cgroup v2 limits are read for containers.

Co-authored-by: dengliu <[email protected]>
2026-11-27 23:34:21 +08:00

68 рядки
2.3 KiB
TypeScript

import { executeAction } from "@/platform/actions";
import { tx } from "@/platform/i18n";
import type { RemoteSession } from "@/platform/ipc";
import { useRemote } from "@/platform/remote";
import { BarButton, Icon, showContextMenu, Spinner } from "@/ui";
import { canMonitorRemoteHost } from "./resources";
import styles from "./RemoteDev.module.css";
const BADGE: Record<RemoteSession["target"]["kind"], string> = {
ssh: "SSH",
wsl: "WSL",
devContainer: "Dev Container",
};
/** Status bar label of a remote window: where its project runs. */
export function remoteBadge(session: Pick<RemoteSession, "target" | "host">): string {
return `${BADGE[session.target.kind]}: ${session.host}`;
}
export function RemoteStatus() {
const session = useRemote((s) => s.session);
const lost = useRemote((s) => s.lost !== null);
const takenOver = useRemote((s) => s.takenOver);
const reconnecting = useRemote((s) => s.reconnecting);
if (!session) return null;
const label = remoteBadge(session);
if (lost)
return (
<BarButton
tooltip={
reconnecting
? tx`Reconnecting to ${session.host}…`
: takenOver
? tx("Another window took over this remote session")
: tx`Lost the connection to ${session.host}. Click to reconnect.`
}
aria-label={tx`${label} (disconnected)`}
disabled={reconnecting}
onClick={() => void executeAction("remote.reconnect")}
>
<span className={styles.lost}>
{reconnecting ? <Spinner size={10} /> : <Icon name="warning" size={13} />}
{label}
</span>
</BarButton>
);
return (
<BarButton
tooltip={tx`Project runs on ${label}`}
aria-label={label}
onClick={() => void executeAction("remote.connect")}
onContextMenu={(e) => {
e.preventDefault();
showContextMenu(e, [
{ kind: "action", action: "remote.connect" },
...(canMonitorRemoteHost(session) ? [{ kind: "action" as const, action: "remote.showResources" }] : []),
{ kind: "action", action: "remote.reloadEnvironment" },
{ kind: "separator" },
{ kind: "action", action: "remote.disconnect" },
{ kind: "action", action: "remote.stopBackend" },
]);
}}
>
{label}
</BarButton>
);
}