@@ -195,17 +195,6 @@ function isCliRemoteRefinementSpec(
195195const isVcsProcessTimeoutError = Schema . is ( VcsProcessTimeoutError ) ;
196196const isVcsProcessExitError = Schema . is ( VcsProcessExitError ) ;
197197
198- /** An installed CLI whose version probe failed needs a repair, not install advice. */
199- function probeFailureHint ( spec : SourceControlCliDiscoverySpec , cause : unknown ) : string {
200- const command = `\`${ [ spec . executable , ...spec . versionArgs ] . join ( " " ) } \`` ;
201- const outcome = isVcsProcessTimeoutError ( cause )
202- ? `timed out after ${ cause . timeoutMs } ms`
203- : isVcsProcessExitError ( cause )
204- ? `exited with status ${ cause . exitCode } `
205- : "failed" ;
206- return `${ command } ${ outcome } . Check the \`${ spec . executable } \` that the server's PATH resolves.` ;
207- }
208-
209198function probeCli ( input : {
210199 readonly spec : SourceControlCliDiscoverySpec ;
211200 readonly process : SourceControlHost . SourceControlHost [ "Service" ] [ "process" ] ;
@@ -238,22 +227,13 @@ function probeCli(input: {
238227 ) ,
239228 Effect . catch ( ( cause ) =>
240229 Effect . gen ( function * ( ) {
241- const hint = yield * unavailableInstallHint (
242- input . spec . executable ,
243- input . spec . installHint ,
244- cause ,
245- ) ;
246230 return {
247231 kind : input . spec . kind ,
248232 label : input . spec . label ,
249233 executable : input . spec . executable ,
250234 status : "missing" as const ,
251235 version : Option . none < string > ( ) ,
252- // A wrong-CPU hint or an absent executable keeps its advice; other failures need repair.
253- installHint :
254- hint !== input . spec . installHint || isMissingExecutable ( cause )
255- ? hint
256- : probeFailureHint ( input . spec , cause ) ,
236+ installHint : yield * failedProbeHint ( input . spec , cause ) ,
257237 detail : detailFromCause ( cause ) ,
258238 } satisfies DiscoveryProbeResult ;
259239 } ) ,
@@ -361,7 +341,7 @@ export function isMissingExecutable(error: unknown): boolean {
361341// Intel-only `gh` on Apple Silicon without Rosetta.
362342const BAD_CPU_TYPE_ERRNO = - 86 ;
363343
364- export const unavailableInstallHint = Effect . fn ( "discovery.unavailableInstallHint" ) ( function * (
344+ const unavailableInstallHint = Effect . fn ( "discovery.unavailableInstallHint" ) ( function * (
365345 executable : string ,
366346 installHint : string ,
367347 cause : unknown ,
@@ -382,6 +362,35 @@ export const unavailableInstallHint = Effect.fn("discovery.unavailableInstallHin
382362 return `\`${ path ?? executable } \` is built for another CPU architecture, so this ${ architecture } machine cannot run it. Remove or replace it. ${ installHint } ` ;
383363} ) ;
384364
365+ /** An installed CLI whose version probe failed needs a repair, not install advice. */
366+ function probeFailureHint (
367+ probe : { readonly executable : string ; readonly versionArgs : ReadonlyArray < string > } ,
368+ cause : unknown ,
369+ ) : string {
370+ const command = `\`${ [ probe . executable , ...probe . versionArgs ] . join ( " " ) } \`` ;
371+ const outcome = isVcsProcessTimeoutError ( cause )
372+ ? `timed out after ${ cause . timeoutMs } ms`
373+ : isVcsProcessExitError ( cause )
374+ ? `exited with status ${ cause . exitCode } `
375+ : "failed" ;
376+ return `${ command } ${ outcome } . Check the \`${ probe . executable } \` that the server's PATH resolves.` ;
377+ }
378+
379+ export const failedProbeHint = Effect . fn ( "discovery.failedProbeHint" ) ( function * (
380+ probe : {
381+ readonly executable : string ;
382+ readonly versionArgs : ReadonlyArray < string > ;
383+ readonly installHint : string ;
384+ } ,
385+ cause : unknown ,
386+ ) {
387+ const hint = yield * unavailableInstallHint ( probe . executable , probe . installHint , cause ) ;
388+ // A wrong-CPU hint or an absent executable keeps its advice; other failures need repair.
389+ return hint !== probe . installHint || isMissingExecutable ( cause )
390+ ? hint
391+ : probeFailureHint ( probe , cause ) ;
392+ } ) ;
393+
385394class UnknownRemoteUnanswered extends Schema . TaggedError < UnknownRemoteUnanswered > ( ) (
386395 "UnknownRemoteUnanswered" ,
387396 { } ,
0 commit comments