From 21b5c5460db1f1e95b83fa223cd086ab6f5477c3 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 15 Nov 2026 21:30:20 +0800 Subject: [PATCH] refactor(hopper): type the elapsed-deadline guidance as AnalysisTimeoutRecovery (#11135) --- src/domain/analysisErrorPresentation.ts | 40 ++++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/domain/analysisErrorPresentation.ts b/src/domain/analysisErrorPresentation.ts index 0f9e608b75..ec62082ca2 100644 --- a/src/domain/analysisErrorPresentation.ts +++ b/src/domain/analysisErrorPresentation.ts @@ -9,6 +9,7 @@ import { AnalysisUnsupportedTargetError, AnalysisResourceConstraintError, AnalysisTimeoutError, + type AnalysisTimeoutRecovery, } from "./analysisErrorCore.js"; import { ArtifactOperationError } from "./artifactOperationError.js"; import { OPENABLE_APPLE_BUNDLE_TYPES_TEXT } from "./apple/appleBundleTypes.js"; @@ -164,9 +165,7 @@ export const analysisErrorRemediationAction = ( ) return "Use an artifact within the capacity reported in details.detail. Changing output detail or retrying the unchanged input does not remove this boundary."; if (error instanceof HopperTimeoutError) - return error.operation === undefined - ? HOPPER_STARTUP_TIMEOUT_REMEDIATION - : RERUN_HOPPER_INVOCATION; + return hopperTimeoutRecovery(error).remediationAction; if (error instanceof HopperProcessError) return error.failureCode !== undefined && error.userMessage !== undefined ? error.userMessage @@ -621,14 +620,8 @@ const unclassifiedProviderRemediation = (providerId: string): string => : "Review the reported details for the provider's reason; REA has no specific recovery for this unclassified failure. Repeating the unchanged request is not expected to succeed."; const hopperErrorUserMessage = (error: AnalysisError): string | undefined => { - if (error instanceof HopperTimeoutError) { - if (error.operation === undefined) - return "REA timed out waiting for Hopper bridge readiness, which includes initial analysis. Hopper may still be analyzing the target or waiting for a loader, demo, or license dialog. Review the captured launcher outcome and resolve retained cleanup before retrying."; - const request = error.operation; - return error.providerState === "busy" - ? `Hopper timed out during ${request} while the provider remained busy.` - : `Hopper timed out during ${request} before it started.`; - } + if (error instanceof HopperTimeoutError) + return hopperTimeoutRecovery(error).userMessage; if (error instanceof HopperProcessError) return hopperProcessMessage(error); if (error instanceof HopperStartError) { if (hopperAppleEventsAuthorizationDenied(error.launchRejection)) @@ -643,6 +636,31 @@ const hopperErrorUserMessage = (error: AnalysisError): string | undefined => { return undefined; }; +/** + * The invocation caller's recovery for an elapsed Hopper deadline: the startup + * deadline (bridge readiness) or one request's deadline. + */ +const hopperTimeoutRecovery = ( + error: HopperTimeoutError, +): Required< + Pick +> => { + if (error.operation === undefined) + return { + userMessage: + "REA timed out waiting for Hopper bridge readiness, which includes initial analysis. Hopper may still be analyzing the target or waiting for a loader, demo, or license dialog. Review the captured launcher outcome and resolve retained cleanup before retrying.", + remediationAction: HOPPER_STARTUP_TIMEOUT_REMEDIATION, + }; + const request = error.operation; + return { + userMessage: + error.providerState === "busy" + ? `Hopper timed out during ${request} while the provider remained busy.` + : `Hopper timed out during ${request} before it started.`, + remediationAction: RERUN_HOPPER_INVOCATION, + }; +}; + const RESTART_OWNED_PROVIDER = "Restart the owned provider by calling close_binary, then open the target again and retry."; const RESTART_UNREACHABLE_HOPPER = `${RESTART_OWNED_PROVIDER} close_binary preserves retained Evidence and Unknown history on this connection; export_evidence_bundle before ending the REA process if you need to resume later.`;