peekSession method
Fetches the current screen snapshot of one of the caller's sessions on
nodeId — running (attached) or detached — named by sessionRef (a
full id, short handle, or unambiguous prefix), without attaching to it.
The returned bytes are exactly what a resume would paint; no input is ever
delivered to the session. The node enforces that the caller owns it.
Implementation
Future<SessionScreenResult> peekSession({
required String nodeId,
required String sessionRef,
}) {
_ensureConnected();
final id = newId();
final completer = Completer<SessionScreenResult>();
_pendingSessionScreens[id] = completer;
_connection!.send(
ControlFrame(
SessionScreenRequest(
requestId: id,
nodeId: nodeId,
sessionRef: sessionRef,
),
),
);
return completer.future;
}