mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
8be5865b76
Store per-session font size in workspace splits so Ctrl+wheel zoom no longer changes sibling panes or reverts on blur when terminalSettings re-sync runs. Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import type { TerminalSession } from "../../domain/models";
|
|
|
|
export function canReuseTerminalConnection(session: TerminalSession): boolean {
|
|
return (
|
|
(session.protocol === "ssh" || session.protocol === undefined) &&
|
|
!session.moshEnabled &&
|
|
!session.etEnabled &&
|
|
session.status === "connected"
|
|
);
|
|
}
|
|
|
|
type CloneSessionOptions = {
|
|
id: string;
|
|
localShellType?: TerminalSession["shellType"];
|
|
workspaceId?: string;
|
|
};
|
|
|
|
function getClonedShellType(
|
|
session: TerminalSession,
|
|
localShellType?: TerminalSession["shellType"],
|
|
): TerminalSession["shellType"] {
|
|
return session.protocol === "local" ? localShellType : session.shellType;
|
|
}
|
|
|
|
function createTerminalSessionClone(
|
|
session: TerminalSession,
|
|
options: CloneSessionOptions,
|
|
): TerminalSession {
|
|
const clonedSession: TerminalSession = {
|
|
id: options.id,
|
|
hostId: session.hostId,
|
|
hostLabel: session.hostLabel,
|
|
hostname: session.hostname,
|
|
username: session.username,
|
|
status: "connecting",
|
|
protocol: session.protocol,
|
|
port: session.port,
|
|
moshEnabled: session.moshEnabled,
|
|
etEnabled: session.etEnabled,
|
|
shellType: getClonedShellType(session, options.localShellType),
|
|
charset: session.charset,
|
|
localShell: session.localShell,
|
|
localShellArgs: session.localShellArgs,
|
|
localShellName: session.localShellName,
|
|
localShellIcon: session.localShellIcon,
|
|
fontSize: session.fontSize,
|
|
fontSizeOverride: session.fontSizeOverride,
|
|
reuseConnectionFromSessionId: canReuseTerminalConnection(session) ? session.id : undefined,
|
|
};
|
|
|
|
if (options.workspaceId) {
|
|
clonedSession.workspaceId = options.workspaceId;
|
|
}
|
|
|
|
return clonedSession;
|
|
}
|
|
|
|
export function createSplitTerminalSessionClone(
|
|
session: TerminalSession,
|
|
options: CloneSessionOptions,
|
|
): TerminalSession {
|
|
return createTerminalSessionClone(session, options);
|
|
}
|
|
|
|
export function createCopiedTerminalSessionClone(
|
|
session: TerminalSession,
|
|
options: CloneSessionOptions,
|
|
): TerminalSession {
|
|
return {
|
|
...createTerminalSessionClone(session, options),
|
|
serialConfig: session.serialConfig,
|
|
};
|
|
}
|