feat(companion): add connection snapshot helper

This commit is contained in:
William Valentin
2026-02-16 22:24:16 -08:00
parent 965267d67e
commit c8f6d76638
7 changed files with 107 additions and 2 deletions
+20
View File
@@ -59,6 +59,15 @@ export interface EventSurfaceSnapshot {
pendingEventWaitCount: number;
}
export interface ConnectionSnapshot {
connected: boolean;
eventSubscriptionCount: number;
pendingRequestCount: number;
pendingEventWaitCount: number;
hasPendingWork: boolean;
idle: boolean;
}
export type CompanionEventHandler = (event: string, data: unknown) => void;
export type CompanionTypedEventHandler<TData = unknown> = (data: TData) => void;
export type CompanionEventPredicate<TData = unknown> = (data: TData) => boolean;
@@ -352,6 +361,17 @@ export class CompanionRuntimeClient {
};
}
getConnectionSnapshot(): ConnectionSnapshot {
return {
connected: this.connected,
eventSubscriptionCount: this.eventSubscriptionCount,
pendingRequestCount: this.pendingRequestCount,
pendingEventWaitCount: this.pendingEventWaitCount,
hasPendingWork: this.hasPendingWork,
idle: this.idle,
};
}
async connect(): Promise<void> {
if (this.connected) {
return;