mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
* feat: AI translations at release, 7 new languages and regional fallback * fix: proper plural forms for count strings and full translations * fix: plural forms for selected, hidden and active counts * fix: synced plugin updates failing on desktop and server-only plugins shown as stopped * fix: restore rounded corners on app icons and favicon * feat: desktop app auto updates with automatic, ask first or never modes * feat: community and custom plugin registries * feat: plugin guide for AI tools in the SDK with a lint check * fix: keep the terminal WebSocket open past nginx's 60s default (#1588) * chore: update changelog * feat: show plugin download counts only and stop CI builds inflating them * feat: hide installed plugins in the browse tab by default * chore: pin bundled plugins to latest releases * chore: update translations * fix: focusing a saved password field and saving no longer erases it * fix: tell desktop users when their 2.8 data needs 2.9 first * fix: point windows update info at the x64 installer * fix: keep desktop client tunnel sockets alive behind proxies * chore: pin bundled plugins to latest releases * fix: cover client tunnel keepalive in the c2s runtime tests * fix: typing after opening a host no longer goes to the host search * fix: accept tab and = separators in SSH config import (#1598) * chore: update changelog * chore: drop plugin versions from core changelog * chore: update translations * chore: lint, format, and bump version to 26.10.1 --------- Co-authored-by: Darnel Hunter <68697450+innotelinc@users.noreply.github.com> Co-authored-by: Iain <Iain1970@protonmail.com>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { isElectron } from "@/lib/electron";
|
|
|
|
export type EmbeddedServerFailureReason =
|
|
"port-in-use" | "old-database" | "crashed";
|
|
|
|
export interface EmbeddedServerFailure {
|
|
reason: EmbeddedServerFailureReason;
|
|
port: number | null;
|
|
}
|
|
|
|
type EmbeddedServerStatusWindow = Window &
|
|
typeof globalThis & {
|
|
electronAPI?: {
|
|
getEmbeddedServerStatus?: () => Promise<{
|
|
running?: boolean;
|
|
failure?: { reason?: string; port?: number | null } | null;
|
|
}>;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Asks the Electron main process whether the embedded backend has failed for
|
|
* good.
|
|
*
|
|
* Returns null in every case where waiting is still the right thing to do:
|
|
* outside Electron, while the backend is only slow to boot, and on a desktop
|
|
* build old enough not to expose the channel at all. A non-null result means
|
|
* the backend process is gone and no amount of retrying will bring it back.
|
|
*/
|
|
export async function getEmbeddedServerFailure(): Promise<EmbeddedServerFailure | null> {
|
|
if (!isElectron()) return null;
|
|
|
|
const getStatus = (window as EmbeddedServerStatusWindow).electronAPI
|
|
?.getEmbeddedServerStatus;
|
|
if (typeof getStatus !== "function") return null;
|
|
|
|
try {
|
|
const status = await getStatus();
|
|
const failure = status?.failure;
|
|
if (!failure) return null;
|
|
|
|
// An unrecognized reason from a newer/older main process still means the
|
|
// backend is down, which is the part the caller acts on -- so it is
|
|
// reported as the generic crash rather than dropped.
|
|
if (failure.reason === "port-in-use") {
|
|
return { reason: "port-in-use", port: failure.port ?? null };
|
|
}
|
|
if (failure.reason === "old-database") {
|
|
return { reason: "old-database", port: null };
|
|
}
|
|
return { reason: "crashed", port: null };
|
|
} catch {
|
|
// No status channel, or the main process is tearing down. Neither is
|
|
// evidence that the backend failed, so keep waiting.
|
|
return null;
|
|
}
|
|
}
|