Files
reverse-engineering-anything/src/application/HopperLauncherDiscovery.ts
T
Paritosh LahreandClaude Opus 5.5 8f91e60558 fix(doctor): check only the current platform's Hopper launcher candidates (#6253)
* fix(doctor): check only the current platform's Hopper launcher candidates

Doctor built one launcher list for every platform, so on macOS it could
report a Linux-only path as a healthy Hopper ahead of a renamed bundle,
and setup then registered that path. Give per-platform automatic
candidates one owner that runtime configuration and doctor both read,
scan renamed macOS bundles and probe the Homebrew cask only on macOS,
and share runtime's renamed-bundle scan with the doctor host.

Fixes #6228

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(doctor): keep the renamed Hopper bundle scan asynchronous

Sharing runtime's synchronous scan made the doctor host read
~/Applications with readdirSync, which blocks the event loop on a slow
or network-mounted home. Give MacHopperPaths an asynchronous scan for
doctor beside runtime's lazy synchronous one, sharing the directory
filter and candidate builder, and check that both return the same
candidates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(doctor): model renamed launchers with runtime's POSIX joins

Since #5235, runtime builds macOS launcher paths with posix.join, so on
Windows the discovery table's native-join renamed launcher no longer
matched runtime's candidate. Model launchers with posix.join and keep
filesystem setup native, as MacHopperPaths.test.ts does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 23:41:54 +09:00

50 lines
1.6 KiB
TypeScript

import {
linuxHopperLauncherCandidates,
REA_MANAGED_LINUX_HOPPER_LAUNCHER,
} from "./LinuxHopper.js";
import {
MAC_HOPPER_SYSTEM_LAUNCHER,
macHopperCanonicalLauncherCandidates,
} from "./MacHopperPaths.js";
/**
* Where automatic Hopper discovery looks on one platform. Runtime configuration
* and doctor both read it, so doctor checks the same candidates, in the same
* order, as CLI/MCP startup.
*/
export interface HopperLauncherDiscovery {
/** Fixed launcher paths, probed in order. */
readonly candidates: readonly string[];
/**
* Whether renamed `Hopper*.app` bundles are probed after the fixed paths.
* Doctor also reports the Homebrew cask application only when this is set.
*/
readonly probesMacApplicationBundles: boolean;
/** Launcher runtime configures when no candidate is executable. */
readonly fallback: string;
}
/** Select the automatic Hopper launcher candidates for one platform. */
export const hopperLauncherDiscovery = (
platform: NodeJS.Platform,
homeDirectory: string,
): HopperLauncherDiscovery => {
if (platform === "darwin")
return {
candidates: macHopperCanonicalLauncherCandidates(homeDirectory),
probesMacApplicationBundles: true,
fallback: MAC_HOPPER_SYSTEM_LAUNCHER,
};
if (platform === "linux")
return {
candidates: linuxHopperLauncherCandidates(homeDirectory),
probesMacApplicationBundles: false,
fallback: REA_MANAGED_LINUX_HOPPER_LAUNCHER,
};
return {
candidates: [],
probesMacApplicationBundles: false,
fallback: MAC_HOPPER_SYSTEM_LAUNCHER,
};
};