Skip to content

Commit 4a10b4e

Browse files
committed
fix(replay): re-consume shared #1381 predicate after rebase reintroduced local one
The branch's rebase onto main re-resolved the #1381 conflict without carrying forward the earlier fix, reintroducing a local ANDROID_CAPTURE_CONTENT_QUALITY_REASONS/isCaptureContentQualityFailure duplicate of the shared isUnreadableCaptureContentError predicate (src/snapshot/snapshot-quality.ts, landed by #1381). Two parallel copies of the same taxonomy can silently drift. Drop the local duplicate and its Android-platform-type import; consume the shared predicate directly, matching what ADR 0012 already documents.
1 parent fc60fd5 commit 4a10b4e

1 file changed

Lines changed: 5 additions & 39 deletions

File tree

‎src/daemon/handlers/session-replay-divergence.ts‎

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33
import { sleep } from '../../utils/timeouts.ts';
4-
import { normalizeError } from '../../kernel/errors.ts';
5-
import type { AndroidHelperContentRecoveryDecision } from '../../platforms/android/snapshot-content-recovery.ts';
64
import { markSessionPartialRefsIssued, setSessionSnapshot } from '../session-snapshot.ts';
7-
import { isSparseSnapshotQualityVerdict } from '../../snapshot/snapshot-quality.ts';
5+
import {
6+
isSparseSnapshotQualityVerdict,
7+
isUnreadableCaptureContentError,
8+
} from '../../snapshot/snapshot-quality.ts';
89
import { displayLabel, formatRole } from '../../snapshot/snapshot-lines.ts';
910
import { redactDiagnosticData } from '../../kernel/redaction.ts';
1011
import type { CommandFlags } from '../../core/dispatch.ts';
@@ -288,41 +289,6 @@ export async function captureDivergenceObservation(params: {
288289
return attempt.observation;
289290
}
290291

291-
// The ONLY three reason codes `rejectAndroidHelperContentUnavailable`
292-
// (`platforms/android/snapshot.ts`) attaches as
293-
// `androidSnapshotHelperFailureReason` — mirrors
294-
// `AndroidHelperContentRecoveryDecision['reason']`
295-
// (`platforms/android/snapshot-content-recovery.ts`), the SOLE site that
296-
// classifies a structurally-succeeded helper capture as too thin/foreign to
297-
// trust: the helper produced accessibility XML, but its content doesn't meet
298-
// the bar. This is deliberately narrower than the error's own `retriable`
299-
// flag: Android's adb layer (`adb-executor.ts`) ALSO marks transport-level
300-
// mechanism failures retriable (`connection_dropped`, `device_offline`,
301-
// `server_version_mismatch`) because an unchanged retry of the SAME adb
302-
// command can succeed there — a true statement about adb, but not evidence
303-
// this specific capture failure is a content-quality verdict rather than a
304-
// genuine mechanism failure (a crashed/timed-out helper invocation, a
305-
// dropped adb connection, a missing helper artifact) a launch-race retry
306-
// cannot fix. `androidSnapshotHelperCaptureError`'s generic capture-failure
307-
// wrap (`rejectAndroidHelperCaptureFailure`) ALSO sets
308-
// `androidSnapshotHelperFailureReason` — but to an arbitrary formatted
309-
// failure message, never one of these three literals, so this exact-value
310-
// membership check does not also catch that unrelated, non-content-quality
311-
// case.
312-
const ANDROID_CAPTURE_CONTENT_QUALITY_REASONS: ReadonlySet<
313-
AndroidHelperContentRecoveryDecision['reason']
314-
> = new Set(['empty-helper-output', 'system-window-only', 'content-poor-app-window']);
315-
316-
function isCaptureContentQualityFailure(error: unknown): boolean {
317-
const reason = normalizeError(error).details?.androidSnapshotHelperFailureReason;
318-
return (
319-
typeof reason === 'string' &&
320-
ANDROID_CAPTURE_CONTENT_QUALITY_REASONS.has(
321-
reason as AndroidHelperContentRecoveryDecision['reason'],
322-
)
323-
);
324-
}
325-
326292
type DivergenceCaptureAttempt = {
327293
observation: DivergenceObservation;
328294
/**
@@ -394,7 +360,7 @@ async function captureDivergenceObservationAttempt(params: {
394360
reason: 'capture-failed',
395361
hint: `Post-failure snapshot capture failed (${error instanceof Error ? error.message : String(error)}); the original replay failure is unaffected.`,
396362
},
397-
retryable: isCaptureContentQualityFailure(error),
363+
retryable: isUnreadableCaptureContentError(error),
398364
};
399365
}
400366
}

0 commit comments

Comments
 (0)