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
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { normalizeDistroId } from "./host";
|
|
import type { Host } from "./models";
|
|
|
|
/**
|
|
* True when the host entry represents a persisted vault host. Ephemeral
|
|
* hosts (password deep links) live in the terminal host list but must not
|
|
* be treated as saved hosts for persistence-routing decisions.
|
|
*/
|
|
export const isSavedVaultHost = (host: Host | null | undefined): boolean =>
|
|
Boolean(host) && host?.ephemeral !== true;
|
|
|
|
export interface EphemeralHostsUpdateSplit {
|
|
vaultHosts: Host[];
|
|
ephemeralHosts: Host[];
|
|
}
|
|
|
|
export const splitHostsUpdateByEphemeral = (
|
|
nextHosts: Host[],
|
|
ephemeralHostIds: ReadonlySet<string>,
|
|
): EphemeralHostsUpdateSplit => {
|
|
const vaultHosts: Host[] = [];
|
|
const ephemeralHosts: Host[] = [];
|
|
for (const host of nextHosts) {
|
|
if (ephemeralHostIds.has(host.id)) {
|
|
ephemeralHosts.push(host);
|
|
} else {
|
|
vaultHosts.push(host);
|
|
}
|
|
}
|
|
return { vaultHosts, ephemeralHosts };
|
|
};
|
|
|
|
export const applyEphemeralHostsUpdate = (
|
|
previous: Host[],
|
|
updated: Host[],
|
|
): Host[] => {
|
|
if (updated.length === 0) return previous;
|
|
const updatedById = new Map(updated.map((host) => [host.id, host]));
|
|
return previous.map((host) => updatedById.get(host.id) ?? host);
|
|
};
|
|
|
|
/** Detection updates stay in memory and never create a host after its session closes. */
|
|
export const applyEphemeralHostDistroUpdate = (previous: Host[], hostId: string, distro: string): Host[] => {
|
|
const normalized = normalizeDistroId(distro);
|
|
if (!previous.some((host) => host.id === hostId && host.distro !== normalized)) return previous;
|
|
return previous.map((host) => host.id === hostId ? { ...host, distro: normalized } : host);
|
|
};
|