diff --git a/cc-haha/src/utils/bundledMode.ts b/cc-haha/src/utils/bundledMode.ts index f7e6c4d..2f32d97 100644 --- a/cc-haha/src/utils/bundledMode.ts +++ b/cc-haha/src/utils/bundledMode.ts @@ -11,12 +11,32 @@ export function isRunningWithBun(): boolean { /** * Detects if running as a Bun-compiled standalone executable. - * This checks for embedded files which are present in compiled binaries. + * + * Original heuristic only checked `Bun.embeddedFiles.length > 0`, which + * fails when the build doesn't explicitly embed data files (e.g. the + * Tauri sidecar built by `desktop/scripts/build-sidecars.ts`). + * + * Compiled Bun standalones always include built-in tools (ripgrep, etc.) + * dispatched via argv[0], so we need a broader detection: + * 1. Embedded files present → definitely bundled. + * 2. Running under Bun but process.execPath is NOT the bun runtime + * binary itself → we're inside a compiled standalone. + * + * See: https://github.com/NanmiCoder/cc-haha/issues/433 */ export function isInBundledMode(): boolean { - return ( - typeof Bun !== 'undefined' && - Array.isArray(Bun.embeddedFiles) && - Bun.embeddedFiles.length > 0 - ) + if (typeof Bun === 'undefined') { + return false + } + + // Check 1: explicit embedded files (original check) + if (Array.isArray(Bun.embeddedFiles) && Bun.embeddedFiles.length > 0) { + return true + } + + // Check 2: in `bun run script.ts`, process.execPath is the bun runtime + // binary (e.g. "/usr/local/bin/bun"). In a compiled standalone, it's + // the custom binary (e.g. "heicode-sidecar-aarch64-apple-darwin"). + const basename = process.execPath.split(/[/\\]/).pop()?.toLowerCase() ?? '' + return basename !== 'bun' && basename !== 'bun.exe' } diff --git a/cc-haha/src/utils/ripgrep.ts b/cc-haha/src/utils/ripgrep.ts index 8128aae..c554ff5 100644 --- a/cc-haha/src/utils/ripgrep.ts +++ b/cc-haha/src/utils/ripgrep.ts @@ -68,6 +68,45 @@ function findUsableSystemRipgrep(): string | null { return null } +/** + * Well-known directories where ripgrep may be installed but missing from + * the sidecar's PATH. Tauri collects env via `zsh -l -c "env -0"` which + * reads *login-shell* config (~/.zprofile) — interactive-shell additions + * in ~/.zshrc (e.g. Homebrew's `eval` block) are skipped, so + * /opt/homebrew/bin is often absent. + * + * See: https://github.com/NanmiCoder/cc-haha/issues/433 + */ +function wellKnownRipgrepPaths(): string[] { + if (process.platform === 'win32') { + // On Windows the PATH search + findExecutable is usually sufficient; + // add common Scoop / Cargo paths just in case. + const home = homedir() + return [ + path.join(home, 'scoop', 'shims', 'rg.exe'), + path.join(home, '.cargo', 'bin', 'rg.exe'), + ] + } + + const home = homedir() + return [ + // Homebrew — Apple Silicon + '/opt/homebrew/bin/rg', + // Homebrew — Intel Mac / Linuxbrew default + '/usr/local/bin/rg', + // System package manager (apt, dnf, pacman …) + '/usr/bin/rg', + // Cargo install + path.join(home, '.cargo', 'bin', 'rg'), + // Snap (Ubuntu) + '/snap/bin/rg', + // Nix single-user + path.join(home, '.nix-profile', 'bin', 'rg'), + // Nix multi-user + '/run/current-system/sw/bin/rg', + ] +} + function systemRipgrepCandidates(): string[] { const candidates: string[] = [] const seen = new Set() @@ -100,6 +139,12 @@ function systemRipgrepCandidates(): string[] { } } + // Fallback: well-known install locations that may not be in PATH, + // especially when launched as a Tauri sidecar from Finder/Dock. + for (const p of wellKnownRipgrepPaths()) { + addCandidate(p) + } + return candidates } diff --git a/heicode/web/classic/public/favicon.ico b/heicode/web/classic/public/favicon.ico index ab5f17b..206cbd1 100644 Binary files a/heicode/web/classic/public/favicon.ico and b/heicode/web/classic/public/favicon.ico differ diff --git a/heicode/web/classic/public/logo.png b/heicode/web/classic/public/logo.png index 851556f..f61ed78 100644 Binary files a/heicode/web/classic/public/logo.png and b/heicode/web/classic/public/logo.png differ diff --git a/heicode/web/default/public/favicon.ico b/heicode/web/default/public/favicon.ico index 2a5e496..206cbd1 100644 Binary files a/heicode/web/default/public/favicon.ico and b/heicode/web/default/public/favicon.ico differ diff --git a/heicode/web/default/public/heicode-logo.svg b/heicode/web/default/public/heicode-logo.svg index 5cf7e53..23e1e05 100644 --- a/heicode/web/default/public/heicode-logo.svg +++ b/heicode/web/default/public/heicode-logo.svg @@ -1,3 +1,3 @@ - - + + \ No newline at end of file