This commit is contained in:
2025-11-30 23:00:48 +01:00
parent 4b8c70978f
commit 645f537895
41 changed files with 738 additions and 1631 deletions

View File

@@ -51,7 +51,7 @@ export class OverlaySyncService implements IOverlaySyncPort {
const cleanup = () => {
try {
this.lifecycleEmitter.offLifecycle(cb)
} catch (e) {
} catch {
// ignore
}
}
@@ -59,36 +59,45 @@ export class OverlaySyncService implements IOverlaySyncPort {
let resolveAck: (ack: ActionAck) => void = () => {}
const promise = new Promise<ActionAck>((resolve) => {
resolveAck = resolve
// subscribe
try {
this.lifecycleEmitter.onLifecycle(cb)
} catch (e) {
this.logger?.error?.('OverlaySyncService: failed to subscribe to lifecycleEmitter', e)
const error = e instanceof Error ? e : new Error(String(e))
this.logger?.error?.('OverlaySyncService: failed to subscribe to lifecycleEmitter', error, {
actionId: action.id,
})
}
})
// publish overlay request (best-effort)
try {
this.publisher.publish({
void this.publisher.publish({
type: 'modal-opened',
timestamp: Date.now(),
payload: { actionId: action.id, label: action.label },
actionId: action.id,
} as AutomationEvent)
} catch (e) {
this.logger?.warn?.('OverlaySyncService: publisher.publish failed', e)
const error = e instanceof Error ? e : new Error(String(e))
this.logger?.warn?.('OverlaySyncService: publisher.publish failed', {
actionId: action.id,
error,
})
}
// timeout handling
const timeoutPromise = new Promise<ActionAck>((res) => {
setTimeout(() => {
if (!settled) {
settled = true
cleanup()
this.logger?.info?.('OverlaySyncService: timeout waiting for confirmation', { actionId: action.id, timeoutMs })
// log recent events truncated
this.logger?.info?.('OverlaySyncService: timeout waiting for confirmation', {
actionId: action.id,
timeoutMs,
})
const lastEvents = seenEvents.slice(-10)
this.logger?.debug?.('OverlaySyncService: recent lifecycle events', lastEvents)
this.logger?.debug?.('OverlaySyncService: recent lifecycle events', {
actionId: action.id,
events: lastEvents,
})
res({ id: action.id, status: 'tentative', reason: 'timeout' })
}
}, timeoutMs)
@@ -98,7 +107,6 @@ export class OverlaySyncService implements IOverlaySyncPort {
}
async cancelAction(actionId: string): Promise<void> {
// best-effort: publish cancellation
try {
await this.publisher.publish({
type: 'panel-missing',
@@ -106,7 +114,11 @@ export class OverlaySyncService implements IOverlaySyncPort {
actionId,
} as AutomationEvent)
} catch (e) {
this.logger?.warn?.('OverlaySyncService: cancelAction publish failed', e)
const error = e instanceof Error ? e : new Error(String(e))
this.logger?.warn?.('OverlaySyncService: cancelAction publish failed', {
actionId,
error,
})
}
}
}

View File

@@ -16,22 +16,15 @@ export class VerifyAuthenticatedPageUseCase {
const result = await this.authService.verifyPageAuthentication();
if (result.isErr()) {
return Result.err(result.error);
const error = result.error ?? new Error('Page verification failed');
return Result.err<BrowserAuthenticationState>(error);
}
const browserState = result.unwrap();
// Log verification result
if (browserState.isFullyAuthenticated()) {
// Success case - no logging needed in use case
} else if (browserState.requiresReauthentication()) {
// Requires re-auth - caller should handle
}
return Result.ok(browserState);
return Result.ok<BrowserAuthenticationState>(browserState);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
return Result.err(new Error(`Page verification failed: ${message}`));
return Result.err<BrowserAuthenticationState>(new Error(`Page verification failed: ${message}`));
}
}
}