test: diagnose paired host tab notification delivery

This commit is contained in:
Neil
2026-09-05 22:14:38 -07:00
parent 86fda1ac69
commit 5b7e00a707
4 changed files with 11 additions and 0 deletions
@@ -34,6 +34,8 @@ export class OrcaRuntimeWithScheduleMobileSessionTabsChanged extends OrcaRuntime
}
protected notifyMobileSessionTabsChangedNow(worktreeId: string, changeSequence: number): void {
const diagnosticSnapshot = this.mobileSessionTabsByWorktree.get(worktreeId)
console.info('[paired-host-tab-delivery] ' + JSON.stringify({ phase: 'notify', worktreeId, changeSequence, listeners: this.mobileSessionTabListeners.size, epoch: diagnosticSnapshot?.publicationEpoch, version: diagnosticSnapshot?.snapshotVersion, tabs: diagnosticSnapshot?.tabs.map(tab => tab.id) }))
if (this.mobileSessionTabListeners.size === 0) {
return
}
@@ -211,6 +211,7 @@ export async function subscribeSessionTabsInventory(
}
const unsubscribe = runtime.onMobileSessionTabsChanged((runtimeSnapshot, changeSequence) => {
const snapshot = runtimeSnapshot as SessionTabsChange
console.info('[paired-host-tab-delivery] ' + JSON.stringify({ phase: 'listener', subscriptionId, initialized, closed, changeSequence, censusChangeSequence, delivered: deliveredChangeSequenceByWorktree.get(snapshot.worktree), epoch: snapshot.publicationEpoch, version: snapshot.snapshotVersion, tabs: snapshot.tabs.map(tab => tab.id) }))
if (!initialized) {
bufferChange(snapshot, changeSequence)
return
@@ -226,6 +227,7 @@ export async function subscribeSessionTabsInventory(
runtime.registerSubscriptionCleanup(
subscriptionId,
() => {
console.info('[paired-host-tab-delivery] ' + JSON.stringify({ phase: 'cleanup', subscriptionId, initialized }))
closed = true
inventoryController.abort()
unsubscribe()
@@ -273,6 +275,7 @@ export async function subscribeSessionTabsInventory(
}
const { inventory, changeSequence } = collected
censusChangeSequence = changeSequence
console.info('[paired-host-tab-delivery] ' + JSON.stringify({ phase: 'census', subscriptionId, changeSequence }))
emit({ type: 'snapshots', ...inventory })
for (const snapshot of inventory.snapshots) {
publishedSnapshotsByWorktree.set(snapshot.worktree, withoutNavigationIntent(snapshot))
@@ -164,6 +164,10 @@ export function installGlobalSessionTabsSubscriptions({
},
{
onResponse: (response) => {
const diagnostic = globalThis as typeof globalThis & { __pairedTabRawTrace?: unknown[] }
const trace = (diagnostic.__pairedTabRawTrace ??= [])
trace.push({ current: isCurrent(), revision: getRuntimeEnvironmentRevision(environmentId), expectedRevision: expectedEnvironmentPairingRevision, response })
if (trace.length > 80) trace.shift()
if (
!isCurrent() ||
getRuntimeEnvironmentRevision(environmentId) !== expectedEnvironmentPairingRevision
@@ -482,6 +482,8 @@ test('paired client keeps revealed remote terminals interactive', async ({
} finally {
const frameTrace = await client.page.evaluate(() => (window as any).__pairedTabFrameTrace).catch(() => null)
console.info(`[paired-tab-frame-trace] ${JSON.stringify(frameTrace)}`)
const rawTrace = await client.page.evaluate(() => (globalThis as typeof globalThis & { __pairedTabRawTrace?: unknown[] }).__pairedTabRawTrace ?? [])
console.info('[paired-tab-raw-trace] ' + JSON.stringify(rawTrace))
await testInfo.attach('paired-tab-frame-trace', { body: JSON.stringify(frameTrace), contentType: 'application/json' })
if (previousParkDelay === undefined) {
delete process.env.ORCA_E2E_TERMINAL_PARKING_DELAY_MS