mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* Add Mosh client detection and override in Settings → Terminal Builds on PR #847 (auto-detection across PATH gaps). Power users with non-standard install locations (containers, custom builds, multiple mosh versions) can now point the app at a specific mosh binary; less technical users get a one-click "Detect" button to confirm where mosh was found, with a Browse fallback for clicker-only flows. Backend (electron/bridges/terminalBridge.cjs): - detectMoshClient() returns { platform, found, path, searchedPaths }. Reuses resolvePosixExecutable; surfaces the searched dirs so the UI can tell users where to look when nothing was found. - pickMoshClient() opens a native file picker via dialog.showOpenDialog. - startMoshSession honors options.moshClientPath when provided. Strict failure: a missing/non-executable explicit path produces a clear error instead of falling back to auto-detect, so users notice typos and stale paths instead of getting silent recovery. UI (components/settings/tabs/SettingsTerminalTab.tsx): - New SettingRow under "Connection" with text input + Detect + Browse buttons, mirroring the localShell validation pattern. Shows inline validation (notFound/isDirectory) and the last detect result with searched directories on miss. Plumbing: - TerminalSettings.moshClientPath: string field with default "" so empty == auto-detect (matches existing PR #847 semantics). - preload exposes detectMoshClient + pickMoshClient. - createTerminalSessionStarters passes terminalSettings.moshClientPath into the IPC call, undefined when blank. - en.ts / zh-CN.ts get the 9 new strings. Verified locally: - vite build succeeds; settings tab renders. - detectMoshClient() against the live machine returns /opt/homebrew/bin/mosh with the expected searchedPaths list. - Existing PR #847 auto-detection path is unchanged when the field is empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Skip POSIX execute-bit check for explicit Windows mosh path Address Codex P2 on PR #849 commit88e5c596. isExecutableFile used `(stat.mode & 0o111) !== 0` to gate the explicit moshClientPath in startMoshSession, but Windows Node returns mode 0o100666 even for .exe / .bat / .cmd files (NTFS has no POSIX execute bits). Result: a Windows user who picked a perfectly valid `mosh.exe` via the new Browse dialog or typed an absolute path was rejected with "Configured Mosh client not usable…" — making the manual override unusable on Windows. Make isExecutableFile platform-aware: still require isFile() and the Unix execute bit on POSIX, but treat any regular file as executable on Win32 and let spawn-time PATHEXT / extension handling filter non-executables. Resolver paths are unaffected — resolvePosixExecutable returns null on Win32 before isExecutableFile is reached. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Augment Windows env when explicit mosh path is outside PATH Address Codex P2 on PR #849 commit69782471. When a Windows user selected a mosh.exe outside %PATH% via Browse / custom path, the explicit-client branch left resolvedMoshDir null, so the later PATH/MOSH_CLIENT injection was skipped. The Mosh wrapper still exec's `mosh-client` (and `ssh`) by name, so a valid selection failed unless that directory was already on PATH. - Always set resolvedMoshDir for explicit moshClientPath, regardless of platform. - Use path.delimiter so PATH composition uses ";" on Win32 and ":" on POSIX. Compare directory membership with path.normalize so trailing-slash / case differences don't double-add. - When picking mosh-client, try .exe / .bat / .cmd extensions on Win32 before the bare name; POSIX still uses just `mosh-client`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Validate Mosh client is executable in Settings UI Address Codex P2 on PR #849 commitb6c384af. UI's debounced validator called validatePath which only reported exists / isFile / isDirectory, so a regular file without the POSIX execute bit (e.g. a stray /etc/hosts-style path) was marked as valid in Settings — but startMoshSession's isExecutableFile check then rejected the same path at connect time, deferring the error until the user actually tried to use Mosh. - validatePath now returns `isExecutable: boolean`, mirroring isExecutableFile semantics (POSIX: stat.mode & 0o111; Win32: any regular file is treated as executable since NTFS lacks POSIX bits). Existing callers (localShell, localStartDir) ignore the new field. - global.d.ts ValidatePath return type extended. - SettingsTerminalTab Mosh validator surfaces a `notExecutable` message when the file exists but lacks exec permissions, keeping the UI in lockstep with main-process gating. - en / zh-CN strings for the new state. Verified: /bin/sh -> isExecutable:true, /etc/hosts -> false, /etc -> false (directory). UI now warns immediately on the regression case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Require absolute Mosh client paths in Settings UI and main Address Codex P2 on PR #849 commit2eba549e. The shared validatePath bridge resolves bare names through PATH (necessary for localShell where 'powershell.exe' is a valid choice), so a user typing 'mosh' or 'mosh.exe' into the new Mosh field would get a green check in Settings — but startMoshSession treats moshClientPath as a literal filesystem path and calls isExecutableFile on the raw value. The saved setting then disables auto-detection and Mosh sessions fail unless a matching file happens to exist in the app's cwd. Gate on absolute paths at both layers so UI validation and the runtime check agree: - startMoshSession: path.isAbsolute(expanded) before isExecutableFile, with a distinct error message naming the constraint. - SettingsTerminalTab: same shape — UI checks looksAbsolute (POSIX /, leading ~, Windows drive letter, or UNC \\\\) before sending the IPC, surfacing notAbsolute inline. Tolerant across platforms so pasting a Windows-style path on macOS still produces a real downstream error rather than a misleading 'not absolute'. - en / zh-CN strings. Verified against the full case matrix (relative names, ./, ../, bare basenames, POSIX absolute, ~/, Windows drive, UNC) — UI flags every relative entry without an IPC round-trip, and any value that passes UI also passes main-process validation (or both reject). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>