Skip to content

Commit 1d6f71e

Browse files
committed
fix: report if connected surface is remote
1 parent 90521ea commit 1d6f71e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/companion-surface-host/src/plugin.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ export class PluginWrapper<TInfo = unknown> {
143143
const info = this.#plugin.checkSupportsHidDevice(hidDevice)
144144
if (!info) return null
145145

146-
return this.#openDeviceInner(surfaceId, info.description, info.pluginInfo)
146+
return this.#openDeviceInner(surfaceId, info.description, info.pluginInfo, false)
147147
}
148148

149149
async #offerOpenDevice(
150150
info: DetectionSurfaceInfo<TInfo>,
151-
mode: string,
151+
mode: 'detection' | 'outbound',
152152
rejectFn: (info: DetectionSurfaceInfo<TInfo>) => void,
153153
): Promise<void> {
154154
if (this.#openSurfaces.has(info.surfaceId)) {
@@ -173,7 +173,12 @@ export class PluginWrapper<TInfo = unknown> {
173173
}
174174

175175
// All clear, open it
176-
const openInfo = await this.#openDeviceInner(shouldOpen.resolvedSurfaceId, info.description, info.pluginInfo)
176+
const openInfo = await this.#openDeviceInner(
177+
shouldOpen.resolvedSurfaceId,
178+
info.description,
179+
info.pluginInfo,
180+
mode === 'outbound',
181+
)
177182
if (!openInfo) return
178183

179184
this.#logger.info(`Opened discovered ${mode} surface: ${openInfo.surfaceId}`)
@@ -189,6 +194,7 @@ export class PluginWrapper<TInfo = unknown> {
189194
resolvedSurfaceId: string,
190195
description: string,
191196
pluginInfo: TInfo,
197+
isRemote: boolean,
192198
): Promise<OpenDeviceResult | null> {
193199
if (this.#openSurfaces.has(resolvedSurfaceId)) {
194200
throw new Error(`Surface with id ${resolvedSurfaceId} is already opened`)
@@ -231,6 +237,7 @@ export class PluginWrapper<TInfo = unknown> {
231237
surfaceLayout: surface.registerProps.surfaceLayout,
232238
transferVariables: surface.registerProps.transferVariables ?? null,
233239
location: surface.registerProps.location ?? null,
240+
isRemote,
234241
configFields: structuredClone(surface.registerProps.configFields) ?? null,
235242
}
236243
}
@@ -281,7 +288,7 @@ export class PluginWrapper<TInfo = unknown> {
281288

282289
this.#logger.info(`Opening scanned device ${surfaceId}`)
283290

284-
return this.#openDeviceInner(surfaceId, cachedInfo.description, cachedInfo.pluginInfo)
291+
return this.#openDeviceInner(surfaceId, cachedInfo.description, cachedInfo.pluginInfo, false)
285292
}
286293

287294
#cleanupSurfaceById(surfaceId: string): void {

packages/companion-surface-host/src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export interface OpenDeviceResult {
5555
*/
5656
location: string | null
5757

58+
/**
59+
* Whether the surface is a remote surface (connected over network) or a local surface (connected via USB/HID/etc)
60+
*/
61+
isRemote: boolean
62+
5863
/**
5964
* Any configuration fields for the surface
6065
*/

0 commit comments

Comments
 (0)