feat(companion): add platform event teardown passthrough

This commit is contained in:
William Valentin
2026-02-16 19:29:39 -08:00
parent 0eb8126349
commit 4d6bed72d8
4 changed files with 39 additions and 1 deletions
+13
View File
@@ -29,6 +29,7 @@ function createRuntimeMock(): {
subscribeAgentTyping: ReturnType<typeof vi.fn>;
subscribeContextWarning: ReturnType<typeof vi.fn>;
subscribeEvents: ReturnType<typeof vi.fn>;
clearEventSubscriptions: ReturnType<typeof vi.fn>;
waitForAgentStream: ReturnType<typeof vi.fn>;
waitForAgentTyping: ReturnType<typeof vi.fn>;
waitForContextWarning: ReturnType<typeof vi.fn>;
@@ -62,6 +63,7 @@ function createRuntimeMock(): {
const subscribeAgentTyping = vi.fn(() => () => undefined);
const subscribeContextWarning = vi.fn(() => () => undefined);
const subscribeEvents = vi.fn(() => () => undefined);
const clearEventSubscriptions = vi.fn(() => undefined);
const waitForAgentStream = vi.fn(async () => ({ token: 'streamed' }));
const waitForAgentTyping = vi.fn(async () => ({ active: true }));
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
@@ -89,6 +91,7 @@ function createRuntimeMock(): {
subscribeAgentTyping,
subscribeContextWarning,
subscribeEvents,
clearEventSubscriptions,
waitForAgentStream,
waitForAgentTyping,
waitForContextWarning,
@@ -118,6 +121,7 @@ function createRuntimeMock(): {
subscribeAgentTyping,
subscribeContextWarning,
subscribeEvents,
clearEventSubscriptions,
waitForAgentStream,
waitForAgentTyping,
waitForContextWarning,
@@ -217,6 +221,15 @@ describe('platform companion clients', () => {
unsubscribeEvents();
});
it('platform clearEventSubscriptions forwards to runtime client', async () => {
const mock = createRuntimeMock();
const client = new IOSCompanionClient({ runtime: mock.runtime, nodeId: 'ios-node' });
client.clearEventSubscriptions();
expect(mock.clearEventSubscriptions).toHaveBeenCalledOnce();
});
it('macOS client forwards canvas methods to runtime client', async () => {
const mock = createRuntimeMock();
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
+12
View File
@@ -251,6 +251,10 @@ export class MacOSCompanionClient {
return this.runtime.subscribeEvents(handler);
}
clearEventSubscriptions(): void {
this.runtime.clearEventSubscriptions();
}
waitForAnyEvent<TData = unknown>(
eventNames: readonly string[],
options?: {
@@ -459,6 +463,10 @@ export class IOSCompanionClient {
return this.runtime.subscribeEvents(handler);
}
clearEventSubscriptions(): void {
this.runtime.clearEventSubscriptions();
}
waitForAnyEvent<TData = unknown>(
eventNames: readonly string[],
options?: {
@@ -665,6 +673,10 @@ export class AndroidCompanionClient {
return this.runtime.subscribeEvents(handler);
}
clearEventSubscriptions(): void {
this.runtime.clearEventSubscriptions();
}
waitForAnyEvent<TData = unknown>(
eventNames: readonly string[],
options?: {