mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-26 19:07:17 +00:00
* feat(tabs): move a tab to its own window without reconnecting (#4201) Adds "Move Tab to New Window" to the tab context menu. Instead of opening a new connection like "Copy Tab to New Window", the tab is hidden from the tab bar and an attach popup takes over the same live PTY, so bastion sessions are not re-authenticated and no extra seat is used. Closing the popup returns the tab (with its screen state) to the window it came from. - popup lifecycle notifies the home window via terminal-popup:attach-closed - new runtime poppedOut flag; popped-out tabs still persist for restore and are not labelled as AI silent sessions in the tray * fix(tabs): keep moved tabs alive when their source window closes - A moved-tab popup registers as the lifetime heir of its session. If the source window is destroyed, ownership passes to the popup instead of the session being closed (worker and in-process paths). AI observe popups are unchanged. - If the source window is gone when the popup closes, skip the hand-back so the popup's ownership closes the session. - Only offer/allow Move Tab to New Window for connected sessions; attach mode cannot connect or reconnect a backend. * fix(tabs): expose Move Tab to New Window through TerminalHost The handler was registered but not passed into the terminal domain bag, so AppView received undefined and the menu item never rendered. * fix(tabs): address move-to-window focus, crash ownership, live count, history, and AI context review findings * fix(tabs): activate moved-tab lifetime heir only after output rebind succeeds * fix(tabs): wait for popup attachment before hiding tab and exclude plugin sessions * fix(tabs): confirm renderer reattach before resolving move and await output restore before unhiding tab * fix(tabs): preserve detached output across popup crashes and avoid focusing main window from tray * fix(tabs): deliver attach snapshots and output restore directly to peer session windows * fix(tabs): schedule automatic output restore retries when popup recovery fails * fix(tabs): handle reopen replay preservation, stale restore cancellation, startup workspace move, and shutdown log capture * fix(tabs): reassert popped-out state after tray reopen * test(terminal): provide log finalizer stubs in popup snapshot harness --------- Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
249 lines
6.4 KiB
TypeScript
249 lines
6.4 KiB
TypeScript
export type TargetOs = 'linux' | 'darwin' | 'win32' | 'unknown';
|
|
|
|
export interface SessionCapabilities {
|
|
targetOs: TargetOs;
|
|
hasTmux: boolean;
|
|
hasDocker: boolean;
|
|
/** `podman` binary present. A podman-docker shim may also set hasDocker. */
|
|
hasPodman?: boolean;
|
|
/** `nerdctl` binary present. */
|
|
hasNerdctl?: boolean;
|
|
/** `kubectl` binary present on the remote host. */
|
|
hasKubectl?: boolean;
|
|
hasNvidiaSmi: boolean;
|
|
hasNpuSmi: boolean;
|
|
/** `ss` binary present (preferred listening-port collector). */
|
|
hasSs?: boolean;
|
|
/** `netstat` binary present (ports fallback). */
|
|
hasNetstat?: boolean;
|
|
/** `lsof` binary present (macOS / process-aware ports fallback). */
|
|
hasLsof?: boolean;
|
|
/** `systemctl` binary present. */
|
|
hasSystemctl?: boolean;
|
|
probedAt: number;
|
|
}
|
|
|
|
export type ListeningPortProtocol = 'tcp' | 'udp' | 'tcp6' | 'udp6' | 'unknown';
|
|
|
|
export interface ListeningPortInfo {
|
|
protocol: ListeningPortProtocol;
|
|
address: string;
|
|
port: number;
|
|
pid: number | null;
|
|
processName: string;
|
|
/** Stable row id for list merging: protocol|address|port|pid */
|
|
id: string;
|
|
}
|
|
|
|
export type SystemdUnitActiveState =
|
|
| 'active'
|
|
| 'inactive'
|
|
| 'failed'
|
|
| 'activating'
|
|
| 'deactivating'
|
|
| 'reloading'
|
|
| 'unknown';
|
|
|
|
export type SystemdUnitLoadState = 'loaded' | 'not-found' | 'bad-setting' | 'error' | 'masked' | 'unknown';
|
|
export type SystemdUnitSubState = string;
|
|
|
|
export interface SystemdUnitInfo {
|
|
name: string;
|
|
loadState: SystemdUnitLoadState;
|
|
activeState: SystemdUnitActiveState;
|
|
subState: SystemdUnitSubState;
|
|
description: string;
|
|
/** system or --user instance */
|
|
scope: 'system' | 'user';
|
|
}
|
|
|
|
export type SystemdUnitAction = 'start' | 'stop' | 'restart' | 'enable' | 'disable' | 'reload';
|
|
|
|
export type AcceleratorVendor = 'nvidia' | 'ascend';
|
|
|
|
export interface AcceleratorDeviceInfo {
|
|
vendor: AcceleratorVendor;
|
|
index: number;
|
|
uuid: string;
|
|
name: string;
|
|
utilizationPercent: number | null;
|
|
memoryUsedMb: number | null;
|
|
memoryTotalMb: number | null;
|
|
temperatureC: number | null;
|
|
powerDrawW: number | null;
|
|
powerLimitW: number | null;
|
|
fanPercent: number | null;
|
|
driverVersion: string | null;
|
|
health: string | null;
|
|
}
|
|
|
|
export interface AcceleratorProcessInfo {
|
|
vendor: AcceleratorVendor;
|
|
gpuIndex: number;
|
|
pid: number;
|
|
processName: string;
|
|
memoryUsedMb: number | null;
|
|
}
|
|
|
|
export interface AcceleratorSnapshot {
|
|
devices: AcceleratorDeviceInfo[];
|
|
processes: AcceleratorProcessInfo[];
|
|
nvidiaDriverVersion: string | null;
|
|
probedAt: number;
|
|
}
|
|
|
|
export interface SystemProcessInfo {
|
|
pid: number;
|
|
ppid: number;
|
|
user: string;
|
|
stat: string;
|
|
cpuPercent: number;
|
|
memPercent: number;
|
|
rssKb: number;
|
|
vszKb: number;
|
|
elapsed: string;
|
|
command: string;
|
|
}
|
|
|
|
export interface TmuxSessionInfo {
|
|
name: string;
|
|
windows: number;
|
|
attached: boolean;
|
|
created: number;
|
|
activity?: string;
|
|
group?: string;
|
|
}
|
|
|
|
export interface TmuxWindowInfo {
|
|
index: number;
|
|
name: string;
|
|
panes: number;
|
|
active: boolean;
|
|
layout: string;
|
|
}
|
|
|
|
export interface TmuxPaneInfo {
|
|
index: number;
|
|
title: string;
|
|
command: string;
|
|
active: boolean;
|
|
pid: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface TmuxClientInfo {
|
|
name: string;
|
|
tty: string;
|
|
activity: string;
|
|
session: string;
|
|
}
|
|
|
|
export type TmuxManageAction =
|
|
| { action: 'killSession'; sessionName: string }
|
|
| { action: 'renameSession'; sessionName: string; newName: string }
|
|
| { action: 'detachSession'; sessionName: string }
|
|
| { action: 'createWindow'; sessionName: string; windowName?: string }
|
|
| { action: 'killWindow'; sessionName: string; windowIndex: number }
|
|
| { action: 'renameWindow'; sessionName: string; windowIndex: number; newName: string }
|
|
| { action: 'killPane'; sessionName: string; windowIndex: number; paneIndex: number }
|
|
| { action: 'splitPane'; sessionName: string; windowIndex: number; paneIndex?: number; direction: 'horizontal' | 'vertical' }
|
|
| { action: 'sendKeys'; sessionName: string; windowIndex: number; paneIndex: number; keys: string; enter?: boolean }
|
|
| { action: 'selectWindow'; sessionName: string; windowIndex: number }
|
|
| { action: 'killServer' };
|
|
|
|
export interface DockerContainerInfo {
|
|
id: string;
|
|
name: string;
|
|
image: string;
|
|
status: string;
|
|
state: string;
|
|
ports: string;
|
|
createdAt: string;
|
|
}
|
|
|
|
export interface DockerStatInfo {
|
|
id: string;
|
|
name: string;
|
|
cpuPercent: number;
|
|
memUsage: string;
|
|
memPercent: number;
|
|
netIO: string;
|
|
blockIO: string;
|
|
pids: number;
|
|
}
|
|
|
|
export interface DockerImageInfo {
|
|
id: string;
|
|
repository: string;
|
|
tag: string;
|
|
size: string;
|
|
createdAt: string;
|
|
digest?: string;
|
|
name: string;
|
|
}
|
|
|
|
/** Unique per `docker images` row — same layer id can have multiple repo:tag lines. */
|
|
export function dockerImageRowKey(image: DockerImageInfo): string {
|
|
return `${image.id}\0${image.repository}\0${image.tag}`;
|
|
}
|
|
|
|
export type DockerContainerAction =
|
|
| 'start'
|
|
| 'stop'
|
|
| 'restart'
|
|
| 'rm'
|
|
| 'pause'
|
|
| 'unpause'
|
|
| 'kill'
|
|
| 'rename';
|
|
|
|
export type DockerImageManageAction =
|
|
| { action: 'pull'; imageRef: string }
|
|
| { action: 'rm'; imageId: string; force?: boolean; repository?: string; tag?: string }
|
|
| { action: 'prune'; all?: boolean }
|
|
| { action: 'tag'; imageId: string; repository: string; tag?: string };
|
|
|
|
export type SystemManagerSubTab =
|
|
| 'overview'
|
|
| 'processes'
|
|
| 'ports'
|
|
| 'services'
|
|
| 'tmux'
|
|
| 'docker'
|
|
| 'gpu';
|
|
|
|
export interface TerminalPopupIcon {
|
|
kind: 'image';
|
|
src: string;
|
|
backgroundColor?: string;
|
|
alt?: string;
|
|
}
|
|
|
|
export interface TerminalPopupPayload {
|
|
popupId?: string;
|
|
title: string;
|
|
icon?: TerminalPopupIcon;
|
|
parentSessionId: string;
|
|
sourceSession: import('../../types').TerminalSession;
|
|
startupCommand: string;
|
|
/**
|
|
* System-manager panel rectangle in renderer viewport pixels. The popup is
|
|
* placed in the remaining source-window area so it does not cover this panel.
|
|
*/
|
|
avoidClientRect?: { x: number; y: number; width: number; height: number };
|
|
localShellType?: import('../../types').TerminalSession['shellType'];
|
|
/**
|
|
* When set, the popup attaches to this already-running backend session
|
|
* (same PTY) instead of starting a new shell. Used for AI silent sessions.
|
|
*/
|
|
attachSessionId?: string;
|
|
/**
|
|
* With attachSessionId: a user tab moved into this popup. The popup inherits
|
|
* the session if its source window closes, instead of the session ending.
|
|
*/
|
|
moveSession?: boolean;
|
|
/** Ephemeral main-process grant bound to the attach popup window. */
|
|
attachAuthorization?: string;
|
|
}
|