Finder-launched terminals now inherit a login PATH so tools like ollama resolve, destructive SFTP/editor actions require confirmation, and terminal search plus window dragging work again. SSH forwards and RDP sessions keep listeners and survive reconnect without FastPath crashes. Co-authored-by: Cursor <cursoragent@cursor.com>
88 lines
2.5 KiB
TypeScript
88 lines
2.5 KiB
TypeScript
/**
|
|
* Connection Types - 统一的连接类型定义
|
|
* 在主进程和渲染进程间共享
|
|
*/
|
|
|
|
import type { SSHConnectionConfig } from './session.types'
|
|
|
|
// Re-export for convenience
|
|
export type { SSHConnectionConfig as ConnectionConfig } from './session.types'
|
|
|
|
// 连接状态
|
|
export type ConnectionState =
|
|
| 'disconnected' // 初始/已关闭
|
|
| 'connecting' // 正在连接
|
|
| 'connected' // 活跃连接
|
|
| 'background' // 后台保持
|
|
| 'suspended' // 挂起 (长时间未操作)
|
|
| 'error' // 连接错误
|
|
| 'reconnecting' // 正在重连
|
|
|
|
// 连接统计信息
|
|
export interface ConnectionStats {
|
|
connectedAt: number // 连接建立时间
|
|
lastActivityAt: number // 最后活动时间
|
|
lastBackgroundAt?: number // 进入后台时间
|
|
bytesTransferred: number // 传输字节数
|
|
commandsExecuted: number // 执行的命令数 (估算)
|
|
}
|
|
|
|
// 连接池配置
|
|
export interface PoolConfig {
|
|
maxConnections: number // 最大连接数 (默认 10)
|
|
maxBackgroundConnections: number // 最大后台连接数 (默认 5)
|
|
idleTimeoutMs: number // 空闲超时 (默认 30 分钟)
|
|
suspendTimeoutMs: number // 挂起超时 (默认 60 分钟)
|
|
keepaliveIntervalMs: number // 保活间隔 (默认 15 秒)
|
|
maxReconnectAttempts: number // 最大重连次数 (默认 3)
|
|
}
|
|
|
|
// 连接池中的连接项
|
|
export interface PooledConnection {
|
|
connectionId: string
|
|
config: SSHConnectionConfig
|
|
state: ConnectionState
|
|
error?: string
|
|
|
|
// 引用管理
|
|
refCount: number // 引用计数
|
|
tabIds: Set<string> // 哪些标签在使用这个连接
|
|
activeTabId: string | null // 当前活跃的标签
|
|
|
|
// 会话 ID
|
|
sessionId?: string
|
|
|
|
// Shell/SFTP 会话
|
|
shellIds: Set<string> // 该连接上创建的 shell 会话
|
|
sftpIds: Set<string> // 该连接上创建的 sftp 会话
|
|
|
|
// 统计
|
|
stats: ConnectionStats
|
|
|
|
// 定时器 ID (浏览器环境)
|
|
keepaliveInterval?: number // 保活定时器 ID
|
|
idleTimeout?: number // 空闲超时定时器 ID
|
|
|
|
// 重连
|
|
reconnectAttempts: number // 重连尝试次数
|
|
maxReconnectAttempts: number // 最大重连次数
|
|
/** Consecutive keepalive failures before tearing down (ClientAliveCountMax-like). */
|
|
keepaliveFailures?: number
|
|
}
|
|
|
|
// 连接结果
|
|
export interface ConnectionResult {
|
|
success: boolean
|
|
connectionId?: string
|
|
error?: string
|
|
isExisting?: boolean
|
|
}
|
|
|
|
// Shell 会话信息
|
|
export interface ShellInfo {
|
|
shellId: string
|
|
connectionId: string
|
|
cols: number
|
|
rows: number
|
|
}
|