mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Contributor GOUKI9999 session_reconnect/session_recover. Maintainer gate fix: do not report ready while still offline/connecting (pending instead); connected keeps advisory shellReady; regenerate capability tool specs. Unit tests 12/12. Electron smoke PASS (SSH shell path). Residual P2 hung-worker readiness left timeout-bounded. No release.
22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
type ReconnectRegistry = {
|
|
isActive: (sessionId: string) => boolean;
|
|
requestIfAvailable: (sessionId: string) => boolean;
|
|
};
|
|
|
|
/** Synchronous dispatch only: no queued recovery after scope/terminal disposal. */
|
|
export function requestAgentSessionReconnect(
|
|
sessionId: string,
|
|
status: string | undefined,
|
|
registry: ReconnectRegistry,
|
|
): Record<string, unknown> {
|
|
if (!status) return { ok: false, started: false, error: `Session "${sessionId}" was not found.` };
|
|
if (status === 'connected') return { ok: true, started: false, sessionId, status: 'connected', shellReady: false };
|
|
if (status === 'connecting' || registry.isActive(sessionId)) {
|
|
return { ok: true, started: false, sessionId, status: 'reconnecting' };
|
|
}
|
|
if (status !== 'disconnected' || !registry.requestIfAvailable(sessionId)) {
|
|
return { ok: false, started: false, sessionId, code: 'RECONNECT_UNAVAILABLE', error: 'Reconnect is unavailable: terminal may be unmounted, waiting for authentication, or recovering. Inspect session state and the Netcatty UI.' };
|
|
}
|
|
return { ok: true, started: true, sessionId, status: 'reconnecting', shellReady: false };
|
|
}
|