feat(overlay-sync): wire OverlaySyncService into DI, IPC and renderer gating
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { AutomationEvent } from '../../application/ports/IAutomationEventPublisher'
|
||||
|
||||
export type LifecycleCallback = (event: AutomationEvent) => Promise<void> | void
|
||||
|
||||
export interface IAutomationLifecycleEmitter {
|
||||
onLifecycle(cb: LifecycleCallback): void
|
||||
offLifecycle(cb: LifecycleCallback): void
|
||||
}
|
||||
@@ -474,6 +474,40 @@ export class PlaywrightAutomationAdapter implements IBrowserAutomation, IAuthent
|
||||
});
|
||||
}
|
||||
|
||||
// Lifecycle emitter support (minimal, deterministic events)
|
||||
private lifecycleCallbacks: Set<any> = new Set()
|
||||
|
||||
onLifecycle(cb: any): void {
|
||||
this.lifecycleCallbacks.add(cb)
|
||||
}
|
||||
|
||||
offLifecycle(cb: any): void {
|
||||
this.lifecycleCallbacks.delete(cb)
|
||||
}
|
||||
|
||||
private async emitLifecycle(event: any): Promise<void> {
|
||||
try {
|
||||
for (const cb of Array.from(this.lifecycleCallbacks)) {
|
||||
try {
|
||||
await cb(event)
|
||||
} catch (e) {
|
||||
this.log('debug', 'Lifecycle callback error', { error: String(e) })
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.log('debug', 'emitLifecycle failed', { error: String(e) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal attachPanel helper for tests that simulates deterministic lifecycle events.
|
||||
* Emits 'panel-attached' and then 'action-started' immediately for deterministic tests.
|
||||
*/
|
||||
async attachPanel(page?: Page, actionId?: string): Promise<void> {
|
||||
const selector = '#gridpilot-overlay'
|
||||
await this.emitLifecycle({ type: 'panel-attached', actionId, timestamp: Date.now(), payload: { selector } })
|
||||
await this.emitLifecycle({ type: 'action-started', actionId, timestamp: Date.now() })
|
||||
}
|
||||
private isRealMode(): boolean {
|
||||
return this.config.mode === 'real';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user