feat: move session sharing and collab rooms into a plugin (B12)

This commit is contained in:
LukeGus committed 2026-09-23 23:42:46 -05:00
1 parent 791d8656a1
commit a276f6898c
207 files changed
+35771 -11072

No files matched your search

+7 -38
View File
@@ -1,17 +1,17 @@
/**
* What core needs from live SSH terminal sessions, through the plugin
* service "sessions.live" rather than an import.
* service "sessions.live" (the "ssh" provider) rather than an import.
*
* Session sharing, collab and the open-tabs route still live in core and
* reach the sessions the ssh-terminal plugin holds. With no provider (the
* plugin is off) a lookup finds nothing and a control call does nothing,
* because "no such live session" and "the terminal is off" mean the same
* thing to every caller here.
* The open-tabs route lists the caller's sessions and ties saved tabs to the
* terminal's idle timeout. With no provider (the terminal is off) a lookup
* finds nothing, because "no live session" and "the terminal is off" mean the
* same thing there.
*/
import { getServiceImplementation } from "../plugins/service-registry.js";
export const LIVE_SESSIONS_SERVICE = "sessions.live";
const SSH_PROVIDER = "ssh";
export interface LiveSessionInfo {
id: string;
@@ -28,19 +28,7 @@ export interface LiveSessionInfo {
}
interface LiveSessionsV1 {
getSession: (sessionId: string) => LiveSessionInfo | null;
listForUser: (userId: string) => LiveSessionInfo[];
ownerEndSession: (sessionId: string, reason: string) => void;
disconnectParticipants: (
sessionId: string,
shareId: string,
options: { reason: string; userId?: string | null },
) => number;
setRoomShareControl: (
sessionId: string,
shareId: string,
controllerUserId: string | null,
) => void;
idleTimeoutMinutes: () => number;
}
@@ -48,33 +36,14 @@ function provider(): LiveSessionsV1 | undefined {
return getServiceImplementation<LiveSessionsV1>(
LIVE_SESSIONS_SERVICE,
"^1.0.0",
SSH_PROVIDER,
);
}
export const liveTerminalSessions = {
getSession(sessionId: string): LiveSessionInfo | null {
return provider()?.getSession(sessionId) ?? null;
},
listForUser(userId: string): LiveSessionInfo[] {
return provider()?.listForUser(userId) ?? [];
},
ownerEndSession(sessionId: string, reason: string): void {
provider()?.ownerEndSession(sessionId, reason);
},
disconnectShareParticipants(
sessionId: string,
shareId: string,
options: { reason: string; userId?: string | null },
): number {
return provider()?.disconnectParticipants(sessionId, shareId, options) ?? 0;
},
setRoomShareControl(
sessionId: string,
shareId: string,
controllerUserId: string | null,
): void {
provider()?.setRoomShareControl(sessionId, shareId, controllerUserId);
},
/** How long the terminal keeps a detached session, or null while it is off. */
idleTimeoutMinutes(): number | null {
return provider()?.idleTimeoutMinutes() ?? null;