[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
118
domain/systemManager/systemTarget.ts
Normal file
118
domain/systemManager/systemTarget.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
import { classifyDistroId, resolveHostOs } from '../host';
|
||||
import type { Host } from '../models/connection';
|
||||
import type { TerminalSession } from '../../types';
|
||||
import type { SessionCapabilities, SystemManagerSubTab } from './types';
|
||||
|
||||
export function isNetworkDeviceTarget(host: Host | null | undefined): boolean {
|
||||
if (host?.deviceType === 'network') return true;
|
||||
return classifyDistroId(host?.distro) === 'network-device';
|
||||
}
|
||||
|
||||
export function isDefiniteLinuxTarget(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
_session: TerminalSession | null | undefined,
|
||||
): boolean {
|
||||
if (capabilities?.targetOs && capabilities.targetOs !== 'unknown') return capabilities.targetOs === 'linux';
|
||||
if (isNetworkDeviceTarget(host)) return false;
|
||||
if (resolveHostOs(host) === 'linux') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldShowProcessesTab(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
): boolean {
|
||||
// Network appliances often lack a usable process table; only show after OS probe confirms.
|
||||
if (isNetworkDeviceTarget(host)) {
|
||||
const os = capabilities?.targetOs;
|
||||
return os === 'linux' || os === 'darwin' || os === 'win32';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function shouldShowTmuxTab(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
session: TerminalSession | null | undefined,
|
||||
): boolean {
|
||||
// Network appliances: detect-first only — do not guess from a Linux-like probe.
|
||||
if (isNetworkDeviceTarget(host)) return capabilities?.hasTmux === true;
|
||||
if (isDefiniteLinuxTarget(host, capabilities, session)) return true;
|
||||
if (capabilities?.targetOs === 'darwin') return true;
|
||||
if (resolveHostOs(host) === 'macos') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldShowDockerTab(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
session: TerminalSession | null | undefined,
|
||||
): boolean {
|
||||
if (capabilities?.hasDocker === true) return true;
|
||||
// Network appliances: never show Docker from an OS guess alone.
|
||||
if (isNetworkDeviceTarget(host)) return false;
|
||||
return isDefiniteLinuxTarget(host, capabilities, session);
|
||||
}
|
||||
|
||||
/** GPU tab only appears after nvidia-smi / npu-smi is actually detected. */
|
||||
export function shouldShowGpuTab(
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
): boolean {
|
||||
return capabilities?.hasNvidiaSmi === true || capabilities?.hasNpuSmi === true;
|
||||
}
|
||||
|
||||
/** Ports tab only appears after a collector binary is detected (same detect-first model as GPU). */
|
||||
export function shouldShowPortsTab(
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
): boolean {
|
||||
return (
|
||||
capabilities?.hasSs === true
|
||||
|| capabilities?.hasNetstat === true
|
||||
|| capabilities?.hasLsof === true
|
||||
);
|
||||
}
|
||||
|
||||
/** Destructive port/service actions stay off for network appliances. */
|
||||
export function allowSystemManagerMutations(
|
||||
host: Host | null | undefined,
|
||||
): boolean {
|
||||
return !isNetworkDeviceTarget(host);
|
||||
}
|
||||
|
||||
/** Services tab only appears after systemctl is detected. */
|
||||
export function shouldShowServicesTab(
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
): boolean {
|
||||
return capabilities?.hasSystemctl === true;
|
||||
}
|
||||
|
||||
export function shouldCollectServerStats(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
_session: TerminalSession | null | undefined,
|
||||
): boolean {
|
||||
const detectedDeviceClass = classifyDistroId(host?.distro);
|
||||
if (isNetworkDeviceTarget(host) || detectedDeviceClass === 'network-device') return false;
|
||||
if (capabilities?.targetOs && capabilities.targetOs !== 'unknown') {
|
||||
return capabilities.targetOs === 'linux' || capabilities.targetOs === 'darwin' || capabilities.targetOs === 'windows';
|
||||
}
|
||||
const hostOs = resolveHostOs(host);
|
||||
if (hostOs === 'linux' || hostOs === 'macos' || hostOs === 'windows') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function buildSystemManagerTabs(
|
||||
host: Host | null | undefined,
|
||||
capabilities: SessionCapabilities | undefined,
|
||||
session: TerminalSession | null | undefined,
|
||||
): SystemManagerSubTab[] {
|
||||
const tabs: SystemManagerSubTab[] = ['overview'];
|
||||
if (shouldShowProcessesTab(host, capabilities)) tabs.push('processes');
|
||||
if (shouldShowPortsTab(capabilities)) tabs.push('ports');
|
||||
if (shouldShowServicesTab(capabilities)) tabs.push('services');
|
||||
if (shouldShowTmuxTab(host, capabilities, session)) tabs.push('tmux');
|
||||
if (shouldShowDockerTab(host, capabilities, session)) tabs.push('docker');
|
||||
if (shouldShowGpuTab(capabilities)) tabs.push('gpu');
|
||||
return tabs;
|
||||
}
|
||||
Reference in New Issue
Block a user