Skip to content

Commit 9106725

Browse files
authored
Fix local dev setup on launcher branch
Add Node.js prerequisite detection, setup log launching fixes, WSL diagnostics updates, and WinAppCLI executable selection on top of the local launcher branch.
1 parent 191f4d6 commit 9106725

9 files changed

Lines changed: 500 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
dotnet-version: 10.0.x
9191

9292
- name: Cache NuGet packages
93+
continue-on-error: true
9394
uses: actions/cache@v5
9495
with:
9596
path: ~/.nuget/packages
@@ -290,6 +291,7 @@ jobs:
290291
dotnet-version: 10.0.x
291292

292293
- name: Cache NuGet packages
294+
continue-on-error: true
293295
uses: actions/cache@v5
294296
with:
295297
path: ~/.nuget/packages
@@ -358,6 +360,7 @@ jobs:
358360
dotnet-version: 10.0.x
359361

360362
- name: Cache NuGet packages
363+
continue-on-error: true
361364
uses: actions/cache@v5
362365
with:
363366
path: ~/.nuget/packages
@@ -447,6 +450,7 @@ jobs:
447450
dotnet --version
448451
449452
- name: Cache NuGet packages
453+
continue-on-error: true
450454
uses: actions/cache@v5
451455
with:
452456
path: ~/.nuget/packages

‎README.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ dotnet build src/OpenClaw.Tray.WinUI -r win-x64 -p:PackageMsix=true # x64 MSI
6767
### Run Tray App
6868

6969
```powershell
70-
# Build and launch through the Windows App SDK activation path
70+
# Build and launch the unpackaged WinUI tray app
7171
.\run-app-local.ps1
7272
7373
# If you already built, skip rebuild and launch the existing Debug output
7474
.\run-app-local.ps1 -NoBuild
7575
76-
# Manual equivalent (replace win-x64 with win-arm64 on ARM64)
77-
winapp run ".\src\OpenClaw.Tray.WinUI\bin\Debug\net10.0-windows10.0.22621.0\win-x64" --manifest ".\src\OpenClaw.Tray.WinUI\Package.appxmanifest" --debug-output
76+
# Run isolated from your normal tray settings so multiple worktrees can run together
77+
.\run-app-local.ps1 -Isolated
78+
79+
# Alpha update testing from a Release build
80+
.\run-app-local.ps1 -Configuration Release -Isolated -UpdateChannel alpha
81+
82+
# Optional: launch through WinAppCLI with Package.appxmanifest
83+
.\run-app-local.ps1 -UseWinApp -NoBuild
7884
```
7985

86+
The default path starts the unpackaged executable directly. `-UseWinApp` requires
87+
Microsoft WinAppCLI (`winget install Microsoft.WinAppCLI`) and is only needed when
88+
you want manifest/MSIX-adjacent launch validation.
89+
8090
### Run CLI WebSocket Validator
8191

8292
Use the CLI to validate gateway connectivity and `chat.send` outside the tray UI.

‎build.ps1‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ if (-not $dotnetVersion) {
9090
}
9191
}
9292

93+
# Check Node.js + npm (WinUI build runs `npm ci` to restore @microsoft/mxc-sdk
94+
# so it can copy wxc-exec.exe into the build output)
95+
$nodeVersion = $null
96+
try { $nodeVersion = & node --version 2>$null } catch {}
97+
if (-not $nodeVersion) {
98+
Write-Error "Node.js not found (required by WinUI build to restore @microsoft/mxc-sdk)"
99+
Write-Info "Install via: winget install OpenJS.NodeJS.LTS"
100+
Write-Info "Or download from: https://nodejs.org/"
101+
$issues += "Missing Node.js"
102+
} else {
103+
Write-Success "Node.js: $nodeVersion"
104+
105+
$npmVersion = $null
106+
try { $npmVersion = & npm --version 2>$null } catch {}
107+
if (-not $npmVersion) {
108+
Write-Error "npm not found on PATH (WinUI build invokes `npm ci`)"
109+
Write-Info "npm normally ships with Node.js - reinstall Node.js or repair the install"
110+
$issues += "Missing npm"
111+
} else {
112+
Write-Success "npm: $npmVersion"
113+
}
114+
}
115+
93116
# Check Windows SDK (for WinUI)
94117
$windowsSdkPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Include"
95118
if (Test-Path $windowsSdkPath) {
@@ -267,7 +290,9 @@ if ($failCount -eq 0) {
267290
$winUIOutputDirectory = ".\$winUIProjectDirectory\bin\$Configuration\$winUITargetFramework\$rid"
268291
$winUIManifestPath = ".\$winUIProjectDirectory\Package.appxmanifest"
269292
Write-Host " WinUI: .\run-app-local.ps1 -NoBuild" -ForegroundColor White
270-
Write-Host " winapp run `"$winUIOutputDirectory`" --manifest `"$winUIManifestPath`" --debug-output" -ForegroundColor DarkGray
293+
Write-Host " Isolated: .\run-app-local.ps1 -NoBuild -Isolated" -ForegroundColor White
294+
Write-Host " WinApp: .\run-app-local.ps1 -NoBuild -UseWinApp" -ForegroundColor White
295+
Write-Host " Direct launch is default. -UseWinApp runs: winapp run `"$winUIOutputDirectory`" --manifest `"$winUIManifestPath`" --executable `"OpenClaw.Tray.WinUI.exe`" --debug-output" -ForegroundColor DarkGray
271296
} else {
272297
Write-Warning "Unable to determine WinUI target framework from $winUIProjectPath"
273298
}

‎run-app-local.ps1‎

Lines changed: 173 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
Builds and launches the WinUI tray app for local development.
44
55
.DESCRIPTION
6-
Uses `winapp run` with the app package manifest so local launches match the
7-
Windows App SDK activation path used during validation. Do not launch the
8-
generated OpenClaw.Tray.WinUI.exe directly; direct EXE startup bypasses the
9-
manifest/package identity path and can hide launch-time issues.
6+
Builds the tray app, then launches the unpackaged WinUI executable directly
7+
for the common local-development path.
8+
9+
Use -UseWinApp when you specifically want Microsoft WinAppCLI (`winapp run`)
10+
to launch with Package.appxmanifest for packaged/MSIX-adjacent validation.
11+
12+
Use -Isolated (or -DataDir) to run multiple worktrees side-by-side without
13+
sharing settings, logs, run markers, device identities, or mutex names.
1014
1115
By default this helper refuses to run outside `master` to avoid accidentally
1216
launching a stale or experimental worktree. Use -AllowNonMaster when you
@@ -21,14 +25,45 @@
2125
.PARAMETER AllowNonMaster
2226
Allow launching from a branch other than master.
2327
28+
.PARAMETER Isolated
29+
Set OPENCLAW_TRAY_DATA_DIR to a stable temp directory unique to this worktree
30+
and branch so multiple local launches can run side-by-side.
31+
32+
.PARAMETER DataDir
33+
Set OPENCLAW_TRAY_DATA_DIR to an explicit directory for this launch.
34+
35+
.PARAMETER UpdateChannel
36+
Set OPENCLAW_UPDATE_CHANNEL for this launch. Use alpha for prerelease update
37+
testing after building a lower-version Release baseline.
38+
39+
.PARAMETER UseWinApp
40+
Launch through Microsoft WinAppCLI (`winapp run`) with Package.appxmanifest
41+
instead of directly starting the unpackaged executable.
42+
43+
.PARAMETER NoDebugOutput
44+
With -UseWinApp, launch without winapp --debug-output.
45+
46+
.PARAMETER Wait
47+
Wait for the launched process to exit. Direct launches return immediately by
48+
default after printing the PID.
49+
50+
.PARAMETER DryRun
51+
Print the launch command and environment without starting the app.
52+
2453
.EXAMPLE
2554
.\run-app-local.ps1
2655
2756
.EXAMPLE
2857
.\run-app-local.ps1 -NoBuild
2958
3059
.EXAMPLE
31-
.\run-app-local.ps1 -AllowNonMaster
60+
.\run-app-local.ps1 -Isolated
61+
62+
.EXAMPLE
63+
.\run-app-local.ps1 -Configuration Release -Isolated -UpdateChannel alpha -AllowNonMaster
64+
65+
.EXAMPLE
66+
.\run-app-local.ps1 -UseWinApp -NoBuild
3267
#>
3368
[CmdletBinding()]
3469
param(
@@ -37,15 +72,61 @@ param(
3772
[ValidateSet("Debug", "Release")]
3873
[string]$Configuration = "Debug",
3974

40-
[switch]$AllowNonMaster
75+
[switch]$AllowNonMaster,
76+
77+
[switch]$Isolated,
78+
79+
[string]$DataDir,
80+
81+
[ValidateSet("stable", "alpha", "prerelease")]
82+
[string]$UpdateChannel,
83+
84+
[switch]$UseWinApp,
85+
86+
[switch]$NoDebugOutput,
87+
88+
[switch]$Wait,
89+
90+
[switch]$DryRun
4191
)
4292

4393
$ErrorActionPreference = "Stop"
4494

4595
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
4696
Set-Location $repoRoot
4797

48-
$branch = (git rev-parse --abbrev-ref HEAD).Trim()
98+
function Resolve-FullPath {
99+
param([Parameter(Mandatory = $true)][string]$Path)
100+
101+
$expanded = [Environment]::ExpandEnvironmentVariables($Path)
102+
if ([System.IO.Path]::IsPathRooted($expanded)) {
103+
return [System.IO.Path]::GetFullPath($expanded)
104+
}
105+
106+
return [System.IO.Path]::GetFullPath((Join-Path $repoRoot $expanded))
107+
}
108+
109+
function Get-SafePathSegment {
110+
param([Parameter(Mandatory = $true)][string]$Value)
111+
112+
$safe = [regex]::Replace($Value, "[^A-Za-z0-9._-]+", "-").Trim("-")
113+
if ($safe) { return $safe }
114+
return "default"
115+
}
116+
117+
function Get-ShortHash {
118+
param([Parameter(Mandatory = $true)][string]$Value)
119+
120+
$sha = [System.Security.Cryptography.SHA256]::Create()
121+
try {
122+
$bytes = $sha.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Value.ToLowerInvariant()))
123+
return -join ($bytes[0..3] | ForEach-Object { $_.ToString("x2") })
124+
} finally {
125+
$sha.Dispose()
126+
}
127+
}
128+
129+
$branch = (git -C $repoRoot rev-parse --abbrev-ref HEAD).Trim()
49130
if ($branch -ne "master" -and -not $AllowNonMaster) {
50131
throw "Refusing to run: current branch is '$branch', expected 'master'. Use -AllowNonMaster to preview this branch intentionally."
51132
}
@@ -57,11 +138,6 @@ if (-not $NoBuild) {
57138
}
58139
}
59140

60-
$winapp = Get-Command winapp -ErrorAction SilentlyContinue
61-
if (-not $winapp) {
62-
throw "winapp CLI was not found. Install Microsoft WinAppCLI or run this from an environment where winapp is on PATH."
63-
}
64-
65141
$projectPath = Join-Path $repoRoot "src\OpenClaw.Tray.WinUI\OpenClaw.Tray.WinUI.csproj"
66142
$manifestPath = Join-Path $repoRoot "src\OpenClaw.Tray.WinUI\Package.appxmanifest"
67143
[xml]$projectXml = Get-Content -LiteralPath $projectPath -Raw -Encoding UTF8
@@ -73,14 +149,95 @@ if (-not $targetFramework) {
73149
$architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
74150
$runtimeIdentifier = if ($architecture -eq [System.Runtime.InteropServices.Architecture]::Arm64) { "win-arm64" } else { "win-x64" }
75151
$outputDir = Join-Path $repoRoot "src\OpenClaw.Tray.WinUI\bin\$Configuration\$targetFramework\$runtimeIdentifier"
152+
$exePath = Join-Path $outputDir "OpenClaw.Tray.WinUI.exe"
76153

77154
if (-not (Test-Path $outputDir)) {
78155
throw "Build output folder not found: $outputDir. Run without -NoBuild first."
79156
}
80-
if (-not (Test-Path $manifestPath)) {
157+
if (-not (Test-Path $exePath)) {
158+
throw "Tray executable not found: $exePath. Run without -NoBuild first."
159+
}
160+
161+
$winapp = $null
162+
if ($UseWinApp) {
163+
$winapp = Get-Command winapp -ErrorAction SilentlyContinue
164+
if (-not $winapp) {
165+
throw "winapp CLI was not found. Install Microsoft WinAppCLI (winget install Microsoft.WinAppCLI) or run /winui-setup."
166+
}
167+
}
168+
169+
if ($UseWinApp -and -not (Test-Path $manifestPath)) {
81170
throw "Manifest not found: $manifestPath."
82171
}
83172

84-
Write-Host "Launching OpenClaw Tray with winapp ($runtimeIdentifier, $Configuration)..."
85-
& $winapp.Source run $outputDir --manifest $manifestPath --debug-output
86-
exit $LASTEXITCODE
173+
$previousDataDir = $env:OPENCLAW_TRAY_DATA_DIR
174+
$previousUpdateChannel = $env:OPENCLAW_UPDATE_CHANNEL
175+
$exitCode = 0
176+
177+
try {
178+
$effectiveDataDir = $null
179+
if ($DataDir) {
180+
$effectiveDataDir = Resolve-FullPath $DataDir
181+
} elseif ($Isolated) {
182+
$repoName = Get-SafePathSegment (Split-Path -Leaf $repoRoot)
183+
$safeBranch = Get-SafePathSegment $branch
184+
$repoHash = Get-ShortHash $repoRoot
185+
$effectiveDataDir = Join-Path $env:TEMP "OpenClawTray\$repoName-$safeBranch-$repoHash"
186+
}
187+
188+
if ($effectiveDataDir) {
189+
New-Item -ItemType Directory -Path $effectiveDataDir -Force | Out-Null
190+
$env:OPENCLAW_TRAY_DATA_DIR = $effectiveDataDir
191+
}
192+
193+
if ($UpdateChannel) {
194+
$env:OPENCLAW_UPDATE_CHANNEL = $UpdateChannel
195+
}
196+
197+
if ($UseWinApp) {
198+
$winappArgs = @("run", $outputDir, "--manifest", $manifestPath, "--executable", "OpenClaw.Tray.WinUI.exe")
199+
if (-not $NoDebugOutput) {
200+
$winappArgs += "--debug-output"
201+
}
202+
}
203+
204+
Write-Host "Launching OpenClaw Tray" -ForegroundColor Cyan
205+
Write-Host " Branch: $branch"
206+
Write-Host " Configuration: $Configuration"
207+
Write-Host " Runtime: $runtimeIdentifier"
208+
Write-Host " Output: $outputDir"
209+
Write-Host " Mode: $(if ($UseWinApp) { 'WinAppCLI manifest activation' } else { 'Direct unpackaged executable' })"
210+
if ($env:OPENCLAW_TRAY_DATA_DIR) {
211+
Write-Host " Data dir: $env:OPENCLAW_TRAY_DATA_DIR"
212+
}
213+
if ($env:OPENCLAW_UPDATE_CHANNEL) {
214+
Write-Host " Update channel: $env:OPENCLAW_UPDATE_CHANNEL"
215+
}
216+
if ($UseWinApp) {
217+
Write-Host " Launcher: $($winapp.Source)"
218+
Write-Host " Command: winapp $($winappArgs -join ' ')"
219+
} else {
220+
Write-Host " Launcher: $exePath"
221+
}
222+
223+
if ($DryRun) {
224+
return
225+
}
226+
227+
if ($UseWinApp) {
228+
& $winapp.Source @winappArgs
229+
$exitCode = $LASTEXITCODE
230+
} elseif ($Wait) {
231+
$process = Start-Process -FilePath $exePath -WorkingDirectory $outputDir -Wait -PassThru
232+
$exitCode = $process.ExitCode
233+
} else {
234+
$process = Start-Process -FilePath $exePath -WorkingDirectory $outputDir -PassThru
235+
Write-Host "Started OpenClaw Tray (PID: $($process.Id))" -ForegroundColor Green
236+
$exitCode = 0
237+
}
238+
} finally {
239+
$env:OPENCLAW_TRAY_DATA_DIR = $previousDataDir
240+
$env:OPENCLAW_UPDATE_CHANNEL = $previousUpdateChannel
241+
}
242+
243+
exit $exitCode

0 commit comments

Comments
 (0)