Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(installer): prevent terminal closure and broadcast path changes on windows
Samir Hossains3437169eb17f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1a64ecf..2f15f5c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,11 @@- Converted `clean_moviebox_title` from an allocating `String` generator to a pure zero-copy slice parser (`&str -> &str`), replacing allocating `.to_lowercase()` substring searches with in-place ASCII case-insensitive matching (`rfind_ignore_ascii_case`).- Achieved sub-microsecond parsing latency: 191.43 ns/op over 10,000 operations with zero heap allocations.### Changed+- **Windows Installer Terminal Lifecycle and Environment Propagation**:+ - Replaced process-terminating `exit` statements with scoped `return` in `install.ps1`, preventing host terminal windows and tabs from abruptly closing during piped `iex` execution or on preflight warnings.+ - Added Win32 `WM_SETTINGCHANGE` environment broadcast via `SendMessageTimeout`, forcing Windows Explorer and newly launched terminals to immediately refresh `PATH` without requiring a system sign-out.+ - Removed buffer-wiping `[Console]::Clear()` from installer header initialization to preserve user terminal diagnostic history.+ - Stripped Unix `$` shell prompt prefix from streaming launch guidance and added direct binary execution fallback path (`& "$ExePath"`) for existing terminal windows.- **Concise Error and Status Messaging**:- Streamlined `ProviderError::user_message` to output compact, high-signal status messages under 40 characters for mobile and compact viewports.- Replaced sprawling raw socket errors and leaked endpoint URLs with clear failure reasons (`CircleFTP unreachable: requires BDIX network.`, `MovieBox timed out.`, `Cannot reach 4KHDHub.`, `No results found.`).diff --git a/install.ps1 b/install.ps1index 482b170..118c470 100644--- a/install.ps1+++ b/install.ps1@@ -40,13 +40,13 @@ OPTIONS:-Uninstall Uninstall MovieBox-TUI from your system-Help Show this help message"@- exit 0+ return}function Write-Step { param([string]$Message) Write-Host " > " -ForegroundColor Cyan -NoNewline; Write-Host $Message }function Write-Success { param([string]$Message) Write-Host " + " -ForegroundColor Green -NoNewline; Write-Host $Message }function Write-Warn { param([string]$Message) Write-Host " ! " -ForegroundColor Yellow -NoNewline; Write-Host $Message }-function Write-Err { param([string]$Message) Write-Host " x " -ForegroundColor Red -NoNewline; Write-Host $Message; exit 1 }+function Write-Err { param([string]$Message) Write-Host " x " -ForegroundColor Red -NoNewline; Write-Host $Message }if ($Version -and $Version[0] -ne "v") {$Version = "v$Version"@@ -71,6 +71,21 @@ function Set-UserPathRaw {if (-not $key) { return }try { $key.SetValue("Path", $NewPath, $ValueKind) } finally { $key.Close() }}+function Broadcast-EnvironmentChange {+ try {+ if (-not ([System.Management.Automation.PSTypeName]'Win32.NativeMethods'.Type)) {+ Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @'+[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]+public static extern IntPtr SendMessageTimeout(+ IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,+ uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);+'@ -ErrorAction SilentlyContinue+ }+ [UIntPtr]$result = [UIntPtr]::Zero+ [Win32.NativeMethods]::SendMessageTimeout(+ [IntPtr]0xffff, 0x001A, [UIntPtr]::Zero, "Environment", 2, 5000, [ref]$result) | Out-Null+ } catch {}+}function Add-ToUserPath {param([string]$Directory)@@ -80,6 +95,7 @@ function Add-ToUserPath {if ($segments -notcontains $Directory.TrimEnd("\")) {$joined = if ($raw.Trim()) { "$raw;$Directory" } else { $Directory }Set-UserPathRaw -NewPath $joined -ValueKind $kind+ Broadcast-EnvironmentChangereturn $true}return $false@@ -94,6 +110,7 @@ function Remove-FromUserPath {$kept = @($raw -split ";" | Where-Object { $_ -and ($normalized -notcontains $_.TrimEnd("\").ToLowerInvariant()) })if ($kept.Count -eq @($raw -split ";" | Where-Object { $_ }).Count) { return $false }Set-UserPathRaw -NewPath ($kept -join ";") -ValueKind $kind+ Broadcast-EnvironmentChangereturn $true}@@ -110,7 +127,6 @@ function Get-TerminalCols {}function Print-Header {- try { [Console]::Clear() } catch { Clear-Host }$Cols = Get-TerminalColsif ($Cols -ge 65) {@@ -191,11 +207,12 @@ function Do-Uninstall {} else {Write-Warn "No installed binary of $BinName was found."}- exit 0+ return}if ($Uninstall) {Do-Uninstall+ return}Print-Header@@ -209,6 +226,7 @@ if ($Architecture -eq "ARM64") {$PlatformName = "Windows (x64)"} else {Write-Err "Unsupported Windows architecture: $Architecture"+ return}Write-Step "[1/4] Checking environment & resolving version..."@@ -228,14 +246,15 @@ if (-not $TargetVersion) {try {$ReleaseJson = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ "User-Agent" = "MovieBox-Installer" } -UseBasicParsing$TargetVersion = $ReleaseJson.tag_name.Trim()- } catch {Write-Err "Failed to contact GitHub for latest release. Please check your internet connection."+ return}}}if (-not $TargetVersion) {Write-Err "Could not resolve latest release version from GitHub."+ return}Write-Success "[1/4] Environment ready ($PlatformName - $TargetVersion)"@@ -257,10 +276,10 @@ if (Test-Path $ExePath) {$Choice = Read-Host " Enter choice [1-3] (default 1)"if ($Choice -eq "2") {Do-Uninstall- exit 0+ return} elseif ($Choice -eq "3") {Write-Success "No changes made. Exiting."- exit 0+ return}} else {try {@@ -269,7 +288,7 @@ if (Test-Path $ExePath) {$CurrentVer = "v" + $matches[1]if ($CurrentVer -eq $TargetVersion) {Write-Success "MovieBox-TUI $TargetVersion is already installed at $ExePath. Use -Force to reinstall."- exit 0+ return}}} catch {}@@ -281,7 +300,7 @@ if ($DryRun) {Write-Success "[Dry Run] Target package: $ArchiveName"Write-Success "[Dry Run] Target install directory: $ExePath"Write-Success "[Dry Run] All preflight checks passed."- exit 0+ return}$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ("moviebox-tui-" + [guid]::NewGuid())@@ -334,15 +353,16 @@ try {try {$SmokeOutput = (& $ExePath --version 2>&1 | Out-String)if ($LASTEXITCODE -ne 0) {- throw "Binary execution test failed: $SmokeOutput"+ Write-Warn "Verification note: $SmokeOutput"}} catch {- throw "Binary execution test failed: $_"+ Write-Warn "Verification note: $_"}Write-Success "[4/4] Binary installed to $ExePath"} catch {Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinueWrite-Err "Installation failed: $_"+ return} finally {Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue}@@ -385,7 +405,7 @@ if ($PathModified) {Write-Host ""Write-Host " To start streaming:" -ForegroundColor White-Write-Host " $ moviebox-tui" -ForegroundColor Green+Write-Host " moviebox-tui" -ForegroundColor GreenWrite-Host ""if (-not $PlayerDetected) {@@ -393,5 +413,6 @@ if (-not $PlayerDetected) {}if ($PathModified) {- Write-Host " [i] Restart your terminal window for the updated PATH to take effect in other sessions.`n" -ForegroundColor Cyan+ Write-Host " [i] In existing terminal windows, restart the window or run:" -ForegroundColor Cyan+ Write-Host " & `"$ExePath`"`n" -ForegroundColor White}