mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-11 00:30:57 +00:00
* fix(#3613): automated AI fix * fix(ai): preserve owners when reusing active host sessions * fix(ai): match opening connection identity before host tab reuse * fix(ai): preserve serial settings when matching reusable tabs * fix: capture restored plugin connection before host reuse --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
15 lines
733 B
TypeScript
15 lines
733 B
TypeScript
import type { TerminalSession } from './models';
|
|
|
|
export function findReusableHostSession(sessions: TerminalSession[], hostId: string) {
|
|
if (!hostId) return undefined;
|
|
// Auto-reconnect publishes connecting even during the retry delay. A plain
|
|
// disconnected/restored tab needs user action and cannot satisfy host_open.
|
|
const matches = sessions.filter((session) => (
|
|
session.hostId === hostId
|
|
&& session.restoreState !== 'restored-disconnected'
|
|
&& (session.status === 'connected' || session.status === 'connecting')
|
|
));
|
|
const picked = matches.find((session) => session.status === 'connected') ?? matches[0];
|
|
return picked ? { sessionId: picked.id, connected: picked.status === 'connected' } : undefined;
|
|
}
|