Add Herdr update and live handoff menu actions

The Ctrl+A h command menu gains two host-scoped actions: a plain
`herdr update` that streams updater output into the popup, and an
experimental update-and-hot-restart flow that verifies a live server
handoff and reconnects the originating Hub tab once the popup closes.

Remote updates use the remote host's own proxy settings. A standalone
helper reads literal proxy assignments from shell profiles and running
Clash/Mihomo listeners without executing startup files; Windows reads
process, user and machine proxy variables through PowerShell.
This commit is contained in:
2026-10-03 02:51:44 +00:00
parent a5e8e32f1e
commit 6f933e1c80
10 changed files with 1130 additions and 38 deletions
+15 -1
View File
@@ -717,6 +717,7 @@ def remote_control_command(
*,
platform: str,
unset_environment: Sequence[str] = (),
load_proxy_environment: bool = False,
) -> list[str]:
"""Build one non-replayed mutation with platform-specific argv encoding.
@@ -746,8 +747,21 @@ def remote_control_command(
return "'" + value.replace("'", "''") + "'"
unset = "".join(f"Remove-Item Env:{key} -ErrorAction SilentlyContinue; " for key in unset_environment)
proxy_setup = ""
if load_proxy_environment:
proxy_setup = (
"foreach ($key in @('http_proxy','https_proxy','all_proxy','no_proxy')) { "
"$value=[Environment]::GetEnvironmentVariable($key,'Process'); "
"if ([string]::IsNullOrEmpty($value)) { "
"$value=[Environment]::GetEnvironmentVariable($key,'User'); "
"if ([string]::IsNullOrEmpty($value)) { $value=[Environment]::GetEnvironmentVariable($key,'Machine') }; "
"if (![string]::IsNullOrEmpty($value)) { [Environment]::SetEnvironmentVariable($key,$value,'Process') } } }; "
"if ($env:https_proxy -or $env:http_proxy -or $env:all_proxy) { "
"Write-Output 'Using remote proxy environment (process/user/machine).' "
"} else { Write-Output 'No remote proxy environment found; using remote network defaults.' }; "
)
script_text = (
"$ErrorActionPreference='Stop'; " + unset
"$ErrorActionPreference='Stop'; " + unset + proxy_setup
+ "$exe=Join-Path $HOME '.local\\bin\\herdr.exe'; "
"if (!(Test-Path -LiteralPath $exe)) { $exe=(Get-Command herdr -ErrorAction Stop).Source }; "
"$p=New-Object System.Diagnostics.Process; "