feat(companion): expose platform connected state passthrough

This commit is contained in:
William Valentin
2026-02-16 19:36:01 -08:00
parent 78466c7e71
commit 274c49acbc
4 changed files with 39 additions and 1 deletions
+13
View File
@@ -38,6 +38,7 @@ function createRuntimeMock(): {
waitForContextWarning: ReturnType<typeof vi.fn>;
waitForAnyEvent: ReturnType<typeof vi.fn>;
eventSubscriptionCount: number;
connected: boolean;
} {
const connect = vi.fn(async () => undefined);
const disconnect = vi.fn(() => undefined);
@@ -76,6 +77,7 @@ function createRuntimeMock(): {
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
const waitForAnyEvent = vi.fn(async () => ({ event: 'agent.stream', data: { token: 'any' } }));
const eventSubscriptionCount = 3;
const connected = true;
const runtime = {
connect,
@@ -110,6 +112,9 @@ function createRuntimeMock(): {
get eventSubscriptionCount() {
return eventSubscriptionCount;
},
get connected() {
return connected;
},
} as unknown as CompanionRuntimeClient;
return {
@@ -144,6 +149,7 @@ function createRuntimeMock(): {
waitForContextWarning,
waitForAnyEvent,
eventSubscriptionCount,
connected,
};
}
@@ -204,6 +210,13 @@ describe('platform companion clients', () => {
expect(mock.dispose).toHaveBeenCalledOnce();
});
it('platform connected getter forwards to runtime connected state', async () => {
const mock = createRuntimeMock();
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
expect(client.connected).toBe(mock.connected);
});
it('platform stream helper methods forward to runtime client', async () => {
const mock = createRuntimeMock();
const client = new AndroidCompanionClient({ runtime: mock.runtime, nodeId: 'android-node' });
+12
View File
@@ -101,6 +101,10 @@ export class MacOSCompanionClient {
return this.runtime.connect();
}
get connected(): boolean {
return this.runtime.connected;
}
disconnect(): void {
this.runtime.disconnect();
}
@@ -339,6 +343,10 @@ export class IOSCompanionClient {
return this.runtime.connect();
}
get connected(): boolean {
return this.runtime.connected;
}
disconnect(): void {
this.runtime.disconnect();
}
@@ -577,6 +585,10 @@ export class AndroidCompanionClient {
return this.runtime.connect();
}
get connected(): boolean {
return this.runtime.connected;
}
disconnect(): void {
this.runtime.disconnect();
}