Files
Netcatty/domain/systemManager/types.ts
T
陈大猫 f99efa8ac1 fix(ui): open AI silent sessions in an attach terminal popup (#2380)
* fix(ui): open AI silent sessions in an attach terminal popup

Tray jumps for hidden MCP sessions attach the existing terminal popup
to the live PTY instead of activating a tab-less main-window surface.
Output is rebound to the popup and restored when the popup closes.

* fix(terminal): register rebindOutput handlers under worker mode

Worker-enabled builds returned early from terminalBridge.registerHandlers
without registering rebind/restore IPC, so the first AI silent-session
attach popup always failed with "No handler registered". Register those
handlers in both paths and rebind display routing via terminalWorkerManager.

* fix(terminal): harden AI attach popup for worker mode lifecycle

Address codex review P1s: resume flow control before restoring output,
route exit/events to the rebound renderer, and replay home scrollback
via a snapshot request before rebinding display output.

* fix(terminal): restore attach routing on popup close and dual-notify exit

Hardening for AI observe popups: restore output from BrowserWindow closed
lifecycle (not only React cleanup), keep attach home for exit events so
main/tray lifecycle updates, and resume paused backend flow on attach.

* fix(terminal): resume flow on attach restore and close snapshot gaps

Resume backend output when attach popups are force-closed, fan out
lifecycle exit events to home+display in non-worker mode, and pause
during snapshot→rebind so live bytes are not dropped from the popup.

* fix(terminal): harden attach restore and worker lifecycle edges

Prefer live display for ZMODEM dialogs after rebind, dual-notify worker
crash exits to attach-home, and avoid clearing attach-home when restore
targets a dead renderer.

* fix(terminal): sync observe-popup state home and fan out SSH exits

Push popup serializations home before restore, fall back to hibernate
snapshots, settle briefly after pause for worker handoff, and dual-notify
SSH exits to attach-home owners in non-worker mode.

* fix(terminal): fan out exits for mosh/telnet/et attach owners

Use shared fanout for in-process protocol exits so attach-home and
display renderers both receive netcatty:exit under non-worker mode.

* fix(terminal): restore attach only onto main app windows

Avoid routing silent-session output to settings/prewarm windows when the
original home renderer is gone; fall back only to registered main windows.

* fix(terminal): harden silent session popup handoff

* fix(terminal): close observed popup with session

* fix(terminal): keep observe popup from reconnecting

* fix(terminal): preserve cleared observe snapshots

* fix(terminal): route transfer prompts to observer

* fix(terminal): keep context after observe restore
2026-07-22 08:58:58 +08:00

147 lines
3.6 KiB
TypeScript

export type TargetOs = 'linux' | 'darwin' | 'win32' | 'unknown';
export interface SessionCapabilities {
targetOs: TargetOs;
hasTmux: boolean;
hasDocker: boolean;
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 }
| { action: 'prune'; all?: boolean }
| { action: 'tag'; imageId: string; repository: string; tag?: string };
export type SystemManagerSubTab = 'overview' | 'processes' | 'tmux' | 'docker';
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;
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;
/** Ephemeral main-process grant bound to the attach popup window. */
attachAuthorization?: string;
}