diff --git a/components/herdr-t3/README.md b/components/herdr-t3/README.md index 69aa093..6ee5ee9 100644 --- a/components/herdr-t3/README.md +++ b/components/herdr-t3/README.md @@ -1,7 +1,9 @@ # herdr-t3 stable component Managed install of [rebuildup/herdr-t3](https://github.com/rebuildup/herdr-t3) -for macOS and Windows 11 (Issue #220, herdr-t3 ADR-0004). +as a native Electron desktop app for macOS and Windows 11 +(Issue #220, herdr-t3 ADR-0004, pc-setup ADR-0028). The earlier browser/PWA +bridge design is superseded and must not be revived. ## Layout @@ -10,7 +12,9 @@ $STATE_DIR/ # ~/.local/share/herdr-t3 or %LOCALAPPDATA%\her releases// # one self-contained checkout+build per ref current # text file naming the selected release previous # release superseded by the last update - run/bridge.pid logs/ # runtime state + current_app # path to the staged .app / built .exe + installed # selected release name + commit + logs/ # build logs ``` Only `v*` tags or full commit SHAs are install targets; dev branches and @@ -27,23 +31,28 @@ of scope — the herdr TUI keeps its existing operation there. | verify | `verify.sh [--live]` | `verify.ps1 [-Live]` | | rollback | `rollback.sh` | `rollback.ps1` | -`launch` is idempotent: a healthy bridge on `127.0.0.1:4737` is reused and -the browser just opens; a foreign listener on the port is reported rather -than hijacked. Builds happen at install/update/rollback-prep time only — -never at launch. A failed update or install leaves `current` (and the -running bridge) untouched; `rollback` flips the pointer back to the -previous release dir, which is kept on disk. +macOS stages the built `.app` into `~/Applications` so it behaves like a +normal app (Finder, Spotlight, Launch Services, Dock). Windows keeps the +built `win-unpacked` tree under the release dir and registers a Start Menu +shortcut (`%APPDATA%\Microsoft\Windows\Start Menu\Programs\herdr-t3.lnk`) +that tracks the selected executable. -`verify --live` additionally checks `GET /api/health` reports `ok`, -`herdr.reachable`, and exposes the installed version/commit. +`launch` is idempotent: it activates the already-running app. Builds happen +at install/update time only — never at launch. A failed install or update +leaves `current` (and the installed app / shortcut) untouched; `rollback` +flips the pointer back to the previous release dir, which is kept on disk, +and re-stages it. + +`verify --live` additionally checks that the app process is running, the +herdr endpoint is reachable (macOS: `~/.config/herdr/herdr.sock`; Windows: +the named-pipe endpoint `\\.\pipe\`), and — on macOS — +that the app's own `bridge-status.json` reports a fresh successful herdr +snapshot. ## Integration notes - Requires `git`, `mise` (herdr-t3 pins bun+node via `mise.toml`), `bun`, `curl` (POSIX) / `Invoke-RestMethod` (Windows). -- The dev profile (`scripts/dev.sh` in herdr-t3) uses port 4738 and never - collides with the stable 4737. -- Windows herdr connectivity goes through the named-pipe endpoint - (`\\.\pipe\`); the bridge handles that transparently - once herdr-t3#6 lands — until then `verify --live` on Windows may report - `herdr.reachable=false`. +- Windows herdr connectivity goes through the named-pipe endpoint; the app + handles that transparently once herdr-t3#6 lands — until then + `verify.ps1 -Live` on Windows may report `herdr.reachable=false`. diff --git a/components/herdr-t3/install.ps1 b/components/herdr-t3/install.ps1 index a0035bc..b010d32 100644 --- a/components/herdr-t3/install.ps1 +++ b/components/herdr-t3/install.ps1 @@ -60,6 +60,20 @@ try { $exe = Join-Path $target "release\win-unpacked\herdr-t3.exe" if (-not (Test-Path $exe)) { Die "built app missing: $exe" } -Set-Content $CurrentFile $name -Set-Content $AppFile $exe +. (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "shortcut.ps1") + +$prevCurrent = if (Test-Path $CurrentFile) { (Get-Content $CurrentFile -Raw).Trim() } else { $null } +$prevApp = if (Test-Path $AppFile) { (Get-Content $AppFile -Raw).Trim() } else { $null } +$prevShortcut = Get-HerdrT3ShortcutTarget + +try { + Set-Content $CurrentFile $name + Set-Content $AppFile $exe + Set-HerdrT3Shortcut -ExePath $exe +} catch { + if ($null -ne $prevCurrent) { Set-Content $CurrentFile $prevCurrent } else { Remove-Item $CurrentFile -Force -ErrorAction SilentlyContinue } + if ($null -ne $prevApp) { Set-Content $AppFile $prevApp } else { Remove-Item $AppFile -Force -ErrorAction SilentlyContinue } + if ($prevShortcut) { try { Set-HerdrT3Shortcut -ExePath $prevShortcut } catch { } } + Die "shortcut registration failed; previous selection restored" +} Log "installed $name ($commit); current -> $name ($exe)" diff --git a/components/herdr-t3/rollback.ps1 b/components/herdr-t3/rollback.ps1 index 5a43c98..1ed620a 100644 --- a/components/herdr-t3/rollback.ps1 +++ b/components/herdr-t3/rollback.ps1 @@ -10,6 +10,21 @@ if (-not (Test-Path $PrevFile)) { Write-Host "[herdr-t3] no previous release rec $prev = (Get-Content $PrevFile -Raw).Trim() $prevExe = Join-Path $StateDir "releases\$prev\release\win-unpacked\herdr-t3.exe" if (-not (Test-Path $prevExe)) { Write-Host "[herdr-t3] previous release $prev has no built app" -ForegroundColor Red; exit 1 } -Set-Content $CurrentFile $prev -Set-Content $AppFile $prevExe +$prevCurrent = if (Test-Path $CurrentFile) { (Get-Content $CurrentFile -Raw).Trim() } else { $null } +$prevApp = if (Test-Path $AppFile) { (Get-Content $AppFile -Raw).Trim() } else { $null } + +. (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "shortcut.ps1") +$rollbackShortcut = Get-HerdrT3ShortcutTarget + +try { + Set-Content $CurrentFile $prev + Set-Content $AppFile $prevExe + Set-HerdrT3Shortcut -ExePath $prevExe +} catch { + if ($null -ne $prevCurrent) { Set-Content $CurrentFile $prevCurrent } else { Remove-Item $CurrentFile -Force -ErrorAction SilentlyContinue } + if ($null -ne $prevApp) { Set-Content $AppFile $prevApp } else { Remove-Item $AppFile -Force -ErrorAction SilentlyContinue } + if ($rollbackShortcut) { try { Set-HerdrT3Shortcut -ExePath $rollbackShortcut } catch { } } + Write-Host "[herdr-t3] shortcut update failed; previous selection restored" -ForegroundColor Red + exit 1 +} Write-Host "[herdr-t3] rolled back to $prev ($prevExe); relaunch the app to apply" diff --git a/components/herdr-t3/shortcut.ps1 b/components/herdr-t3/shortcut.ps1 new file mode 100644 index 0000000..a138634 --- /dev/null +++ b/components/herdr-t3/shortcut.ps1 @@ -0,0 +1,23 @@ +# Shared Start Menu shortcut management for the stable herdr-t3 app. +# Dot-source this file; it defines Set-/Test-HerdrT3Shortcut only. + +$script:HerdrT3ShortcutPath = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\herdr-t3.lnk" + +function Set-HerdrT3Shortcut { + param([Parameter(Mandatory = $true)][string]$ExePath) + if (-not (Test-Path -LiteralPath $ExePath)) { throw "shortcut target missing: $ExePath" } + $shell = New-Object -ComObject WScript.Shell + $shortcut = $shell.CreateShortcut($script:HerdrT3ShortcutPath) + $shortcut.TargetPath = $ExePath + $shortcut.WorkingDirectory = Split-Path -Parent $ExePath + $shortcut.Description = "herdr-t3 — Herdr desktop client" + $icon = Join-Path (Split-Path -Parent $ExePath) "herdr-t3.exe" + if (Test-Path -LiteralPath $icon) { $shortcut.IconLocation = "$icon,0" } + $shortcut.Save() +} + +function Get-HerdrT3ShortcutTarget { + if (-not (Test-Path -LiteralPath $script:HerdrT3ShortcutPath)) { return $null } + $shell = New-Object -ComObject WScript.Shell + return $shell.CreateShortcut($script:HerdrT3ShortcutPath).TargetPath +} diff --git a/components/herdr-t3/verify.ps1 b/components/herdr-t3/verify.ps1 index 2564002..176146a 100644 --- a/components/herdr-t3/verify.ps1 +++ b/components/herdr-t3/verify.ps1 @@ -22,6 +22,12 @@ if (-not (Test-Path $exe)) { Fail "no built app for $name ($exe)" } $commit = (git -C $release rev-parse HEAD).Trim() Write-Host "[herdr-t3] installed: $name @ $($commit.Substring(0,12)) -> $exe" +. (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "shortcut.ps1") +$lnk = Get-HerdrT3ShortcutTarget +if (-not $lnk) { Fail "Start Menu shortcut missing ($script:HerdrT3ShortcutPath)" } +if ($lnk -ne $exe) { Fail "Start Menu shortcut points to $lnk, expected $exe" } +Write-Host "[herdr-t3] start menu: $lnk" + if ($Live) { if (-not (Get-Process -Name "herdr-t3" -ErrorAction SilentlyContinue)) { Fail "app is not running (run launch.ps1)" } $sock = if ($env:HERDR_SOCKET) { $env:HERDR_SOCKET } else { Join-Path $env:APPDATA "herdr\herdr.sock" }