feat(companion): add platform event subscription count passthrough
This commit is contained in:
@@ -35,6 +35,7 @@ function createRuntimeMock(): {
|
||||
waitForAgentTyping: ReturnType<typeof vi.fn>;
|
||||
waitForContextWarning: ReturnType<typeof vi.fn>;
|
||||
waitForAnyEvent: ReturnType<typeof vi.fn>;
|
||||
eventSubscriptionCount: number;
|
||||
} {
|
||||
const connect = vi.fn(async () => undefined);
|
||||
const disconnect = vi.fn(() => undefined);
|
||||
@@ -70,6 +71,7 @@ function createRuntimeMock(): {
|
||||
const waitForAgentTyping = vi.fn(async () => ({ active: true }));
|
||||
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
|
||||
const waitForAnyEvent = vi.fn(async () => ({ event: 'agent.stream', data: { token: 'any' } }));
|
||||
const eventSubscriptionCount = 3;
|
||||
|
||||
const runtime = {
|
||||
connect,
|
||||
@@ -99,6 +101,9 @@ function createRuntimeMock(): {
|
||||
waitForAgentTyping,
|
||||
waitForContextWarning,
|
||||
waitForAnyEvent,
|
||||
get eventSubscriptionCount() {
|
||||
return eventSubscriptionCount;
|
||||
},
|
||||
} as unknown as CompanionRuntimeClient;
|
||||
|
||||
return {
|
||||
@@ -130,6 +135,7 @@ function createRuntimeMock(): {
|
||||
waitForAgentTyping,
|
||||
waitForContextWarning,
|
||||
waitForAnyEvent,
|
||||
eventSubscriptionCount,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -244,6 +250,13 @@ describe('platform companion clients', () => {
|
||||
expect(events).toEqual(['agent.stream', 'agent.typing', 'context_warning']);
|
||||
});
|
||||
|
||||
it('platform eventSubscriptionCount forwards runtime getter value', async () => {
|
||||
const mock = createRuntimeMock();
|
||||
const client = new IOSCompanionClient({ runtime: mock.runtime, nodeId: 'ios-node' });
|
||||
|
||||
expect(client.eventSubscriptionCount).toBe(mock.eventSubscriptionCount);
|
||||
});
|
||||
|
||||
it('macOS client forwards canvas methods to runtime client', async () => {
|
||||
const mock = createRuntimeMock();
|
||||
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
|
||||
|
||||
@@ -260,6 +260,10 @@ export class MacOSCompanionClient {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
get eventSubscriptionCount(): number {
|
||||
return this.runtime.eventSubscriptionCount;
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
@@ -476,6 +480,10 @@ export class IOSCompanionClient {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
get eventSubscriptionCount(): number {
|
||||
return this.runtime.eventSubscriptionCount;
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
@@ -690,6 +698,10 @@ export class AndroidCompanionClient {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
get eventSubscriptionCount(): number {
|
||||
return this.runtime.eventSubscriptionCount;
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
|
||||
Reference in New Issue
Block a user