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
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
export const MAX_SFTP_SIDE_PANEL_REMEMBERED_PATHS = 32;
|
|
|
|
export function canApplySftpSidePanelInitialLocation(params: {
|
|
activeHostId: string;
|
|
initialLocation: { hostId: string; path: string };
|
|
expectedConnectionKey: string;
|
|
actualConnectionKey: string | null;
|
|
pendingRequiresExactTarget: boolean;
|
|
pendingTargetConnectionId: string | null;
|
|
connection: {
|
|
id: string;
|
|
hostId: string;
|
|
isLocal: boolean;
|
|
status: string;
|
|
} | null | undefined;
|
|
}): boolean {
|
|
const { connection } = params;
|
|
if (!params.initialLocation.path) return false;
|
|
if (params.initialLocation.hostId !== params.activeHostId) return false;
|
|
if (!connection || connection.isLocal || connection.status !== "connected") return false;
|
|
if (connection.hostId !== params.activeHostId) return false;
|
|
if (params.actualConnectionKey !== params.expectedConnectionKey) return false;
|
|
if (
|
|
params.pendingRequiresExactTarget
|
|
&& (
|
|
!params.pendingTargetConnectionId
|
|
|| connection.id !== params.pendingTargetConnectionId
|
|
)
|
|
) return false;
|
|
return true;
|
|
}
|
|
|
|
export function pruneSftpSidePanelState<Value>(
|
|
valuesById: Map<string, Value>,
|
|
activeIdsInput: Iterable<string>,
|
|
): void {
|
|
const activeIds = new Set(activeIdsInput);
|
|
for (const id of valuesById.keys()) {
|
|
if (!activeIds.has(id)) {
|
|
valuesById.delete(id);
|
|
}
|
|
}
|
|
}
|
|
|
|
export function rememberSftpSidePanelPath(
|
|
paths: Map<string, string>,
|
|
connectionKey: string,
|
|
remotePath: string,
|
|
limit = MAX_SFTP_SIDE_PANEL_REMEMBERED_PATHS,
|
|
): void {
|
|
paths.delete(connectionKey);
|
|
paths.set(connectionKey, remotePath);
|
|
while (paths.size > limit) {
|
|
const oldestKey = paths.keys().next().value;
|
|
if (oldestKey === undefined) break;
|
|
paths.delete(oldestKey);
|
|
}
|
|
}
|
|
|
|
export function recallSftpSidePanelPath(
|
|
paths: Map<string, string>,
|
|
connectionKey: string,
|
|
): string | undefined {
|
|
const remotePath = paths.get(connectionKey);
|
|
if (remotePath === undefined) return undefined;
|
|
paths.delete(connectionKey);
|
|
paths.set(connectionKey, remotePath);
|
|
return remotePath;
|
|
}
|