Skip to content

Commit dae64b6

Browse files
authored
feat: support side-by-side dev and release installs (#922)
Thanks @karkarl for the original dev/release identity implementation. This completes runtime, setup, WSL, updater, installer, and cleanup isolation. Co-authored-by: Karen Lai <[email protected]>
1 parent e0a2301 commit dae64b6

56 files changed

Lines changed: 825 additions & 296 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎installer.iss‎

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
; OpenClaw Companion Inno Setup Script (WinUI version)
2-
#define MyAppName "OpenClaw Companion"
3-
#define MyAppPublisher "Scott Hanselman"
2+
; Pass /DDevBuild=1 to produce a side-by-side dev installer.
3+
#ifdef DevBuild
4+
#define MyAppName "OpenClaw Companion (Dev)"
5+
#define MyAppId "{{M0LTB0T-TRAY-4PP1-DEV}"
6+
#define MyInstallDir "OpenClawTray-Dev"
7+
#define MyMutex "OpenClawTray-Dev"
8+
#define MyAutoStartName "OpenClawTray-Dev"
9+
#define MyStartupTaskName "OpenClaw Companion (Dev)"
10+
#define MyDistroName "OpenClawGateway-Dev"
11+
#define MyProtocol "openclaw-dev"
12+
#define MyOutputSuffix "-Dev"
13+
#else
14+
#define MyAppName "OpenClaw Companion"
15+
#define MyAppId "{{M0LTB0T-TRAY-4PP1-D3N7}"
16+
#define MyInstallDir "OpenClawTray"
17+
#define MyMutex "OpenClawTray"
18+
#define MyAutoStartName "OpenClawTray"
19+
#define MyStartupTaskName "OpenClaw Companion"
20+
#define MyDistroName "OpenClawGateway"
21+
#define MyProtocol "openclaw"
22+
#define MyOutputSuffix ""
23+
#endif
24+
#define MyAppPublisher "OpenClaw Foundation"
425
#define MyAppURL "https://github.com/openclaw/openclaw-windows-node"
526
#define MyAppExeName "OpenClaw.Tray.WinUI.exe"
627

@@ -20,28 +41,27 @@
2041
[Setup]
2142
; Inno requires "{{" to emit a literal opening brace in AppId.
2243
; Do not add a second closing brace here; that creates a malformed uninstall registry key.
23-
AppId={{M0LTB0T-TRAY-4PP1-D3N7}
44+
AppId={#MyAppId}
2445
AppName={#MyAppName}
2546
AppVersion={#MyAppVersion}
2647
AppPublisher={#MyAppPublisher}
2748
AppPublisherURL={#MyAppURL}
2849
AppSupportURL=https://github.com/openclaw/openclaw-windows-node/issues
2950
AppUpdatesURL=https://github.com/openclaw/openclaw-windows-node/releases
30-
DefaultDirName={localappdata}\OpenClawTray
51+
DefaultDirName={localappdata}\{#MyInstallDir}
3152
DefaultGroupName={#MyAppName}
3253
DisableProgramGroupPage=yes
33-
OutputBaseFilename=OpenClawCompanion-Setup-{#MyAppArch}
54+
OutputBaseFilename=OpenClawCompanion{#MyOutputSuffix}-Setup-{#MyAppArch}
3455
Compression={#MyCompression}
3556
SolidCompression={#MySolidCompression}
3657
WizardStyle=modern
3758
PrivilegesRequired=lowest
3859
SetupIconFile=src\OpenClaw.Tray.WinUI\Assets\openclaw.ico
3960
UninstallDisplayIcon={app}\{#MyAppExeName}
4061
; Round 2 (Scott #5): block install/uninstall while the tray is running.
41-
; Mutex name matches App.xaml.cs (`new Mutex(true, "OpenClawTray", …)`).
42-
; Tray and Inno run in the same user session, so the bare name resolves
43-
; against Local\OpenClawTray — no Global\ prefix needed.
44-
AppMutex=OpenClawTray
62+
; Mutex name matches AppIdentity.MutexBaseName for this build variant.
63+
; Tray and Inno run in the same user session, so no Global\ prefix is needed.
64+
AppMutex={#MyMutex}
4565
#if MyAppArch == "arm64"
4666
ArchitecturesInstallIn64BitMode=arm64
4767
ArchitecturesAllowed=arm64
@@ -74,7 +94,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
7494

7595
[Tasks]
7696
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
77-
Name: "startupicon"; Description: "Start OpenClaw Companion when Windows starts"; GroupDescription: "Startup:"; Flags: unchecked
97+
Name: "startupicon"; Description: "Start {#MyAppName} when Windows starts"; GroupDescription: "Startup:"; Flags: unchecked
7898

7999
[Files]
80100
; WinUI Tray app - include all files (WinUI needs DLLs, not single-file)
@@ -86,17 +106,17 @@ Source: "{#vcRedist}"; DestDir: "{tmp}"; DestName: "vc_redist.exe"; Flags: delet
86106
#endif
87107

88108
[Registry]
89-
Root: HKCU; Subkey: "Software\Classes\openclaw"; ValueType: string; ValueName: ""; ValueData: "URL:OpenClaw Protocol"; Flags: uninsdeletekey
90-
Root: HKCU; Subkey: "Software\Classes\openclaw"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""
91-
Root: HKCU; Subkey: "Software\Classes\openclaw\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"",0"
92-
Root: HKCU; Subkey: "Software\Classes\openclaw\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
109+
Root: HKCU; Subkey: "Software\Classes\{#MyProtocol}"; ValueType: string; ValueName: ""; ValueData: "URL:OpenClaw Protocol"; Flags: uninsdeletekey
110+
Root: HKCU; Subkey: "Software\Classes\{#MyProtocol}"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""
111+
Root: HKCU; Subkey: "Software\Classes\{#MyProtocol}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"",0"
112+
Root: HKCU; Subkey: "Software\Classes\{#MyProtocol}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
93113

94114
[Icons]
95115
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
96-
Name: "{group}\OpenClaw Gateway Setup"; Filename: "{app}\{#MyAppExeName}"; Parameters: "openclaw://setup"; IconFilename: "{app}\{#MyAppExeName}"
97-
Name: "{group}\OpenClaw Companion Settings"; Filename: "{app}\{#MyAppExeName}"; Parameters: "openclaw://commandcenter"; IconFilename: "{app}\{#MyAppExeName}"
98-
Name: "{group}\OpenClaw Chat"; Filename: "{app}\{#MyAppExeName}"; Parameters: "openclaw://chat"; IconFilename: "{app}\{#MyAppExeName}"
99-
Name: "{group}\Check for Updates"; Filename: "{app}\{#MyAppExeName}"; Parameters: "openclaw://check-updates"; IconFilename: "{app}\{#MyAppExeName}"
116+
Name: "{group}\OpenClaw Gateway Setup"; Filename: "{app}\{#MyAppExeName}"; Parameters: "{#MyProtocol}://setup"; IconFilename: "{app}\{#MyAppExeName}"
117+
Name: "{group}\OpenClaw Companion Settings"; Filename: "{app}\{#MyAppExeName}"; Parameters: "{#MyProtocol}://commandcenter"; IconFilename: "{app}\{#MyAppExeName}"
118+
Name: "{group}\OpenClaw Chat"; Filename: "{app}\{#MyAppExeName}"; Parameters: "{#MyProtocol}://chat"; IconFilename: "{app}\{#MyAppExeName}"
119+
Name: "{group}\Check for Updates"; Filename: "{app}\{#MyAppExeName}"; Parameters: "{#MyProtocol}://check-updates"; IconFilename: "{app}\{#MyAppExeName}"
100120
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
101121
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
102122
Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: startupicon
@@ -170,7 +190,7 @@ begin
170190
LocalGatewayCleanupRequested :=
171191
MsgBox(
172192
'Do you also want to remove the OpenClaw local WSL gateway?' + #13#10#13#10 +
173-
'Choose Yes to unregister the OpenClawGateway WSL distro and remove generated local gateway state.' + #13#10 +
193+
'Choose Yes to unregister the {#MyDistroName} WSL distro and remove generated local gateway state.' + #13#10 +
174194
'Choose No to leave the local gateway and generated local state on this computer.',
175195
mbConfirmation,
176196
MB_YESNO) = IDYES;
@@ -212,7 +232,11 @@ begin
212232
213233
Params :=
214234
'-NoProfile -ExecutionPolicy Bypass -File ' + AddQuotes(TempScriptPath) +
215-
' -AppRoot ' + AddQuotes(ExpandConstant('{app}'));
235+
' -AppRoot ' + AddQuotes(ExpandConstant('{app}')) +
236+
' -DataDirectoryName ' + AddQuotes('{#MyInstallDir}') +
237+
' -AutoStartName ' + AddQuotes('{#MyAutoStartName}') +
238+
' -StartupTaskName ' + AddQuotes('{#MyStartupTaskName}') +
239+
' -DistroName ' + AddQuotes('{#MyDistroName}');
216240
217241
Log('Running local gateway cleanup script from {tmp}.');
218242
Result :=
@@ -282,10 +306,38 @@ begin
282306
Log('Generated app state in {app} could not be fully deleted; continuing uninstall.');
283307
end;
284308
309+
procedure RemoveAppAutoStart;
310+
var
311+
ResultCode: Integer;
312+
Started: Boolean;
313+
begin
314+
if RegDeleteValue(
315+
HKCU,
316+
'SOFTWARE\Microsoft\Windows\CurrentVersion\Run',
317+
'{#MyAutoStartName}') then
318+
Log('Removed {#MyAutoStartName} autostart registry value.')
319+
else
320+
Log('{#MyAutoStartName} autostart registry value already absent.');
321+
322+
Started :=
323+
Exec(
324+
ExpandConstant('{sys}\schtasks.exe'),
325+
'/Delete /TN ' + AddQuotes('{#MyStartupTaskName}') + ' /F',
326+
'',
327+
SW_HIDE,
328+
ewWaitUntilTerminated,
329+
ResultCode);
330+
if Started and (ResultCode = 0) then
331+
Log('Removed {#MyStartupTaskName} startup task.')
332+
else
333+
Log('{#MyStartupTaskName} startup task already absent or unavailable.');
334+
end;
335+
285336
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
286337
begin
287338
if CurUninstallStep = usUninstall then
288339
begin
340+
RemoveAppAutoStart;
289341
EnsureLocalGatewayCleanupChoice;
290342
RunLocalGatewayCleanup;
291343
end

‎scripts/Uninstall-LocalGateway.ps1‎

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,27 @@
1111

1212
[CmdletBinding()]
1313
param(
14-
[string]$AppRoot = $PSScriptRoot
14+
[string]$AppRoot = $PSScriptRoot,
15+
[string]$DataDirectoryName = 'OpenClawTray',
16+
[string]$AutoStartName = 'OpenClawTray',
17+
[string]$StartupTaskName = 'OpenClaw Companion',
18+
[string]$DistroName = 'OpenClawGateway'
1519
)
1620

1721
$ErrorActionPreference = 'Stop'
1822

19-
$DistroName = 'OpenClawGateway'
2023
$resultPath = Join-Path $AppRoot 'uninstall-gateway-result.json'
2124
$errorPath = Join-Path $AppRoot 'uninstall-gateway-error.log'
2225
$wslLogPath = Join-Path $AppRoot 'uninstall-gateway-wsl.log'
2326
$cleanupWarnings = New-Object 'System.Collections.Generic.List[string]'
2427

28+
if ($DataDirectoryName -notmatch '^[A-Za-z0-9._-]+$') {
29+
throw "Invalid data directory name '$DataDirectoryName'."
30+
}
31+
if ($DistroName -notmatch '^[A-Za-z0-9._-]+$') {
32+
throw "Invalid WSL distro name '$DistroName'."
33+
}
34+
2535
function Ensure-AppRoot {
2636
if (-not [string]::IsNullOrWhiteSpace($AppRoot) -and -not (Test-Path -LiteralPath $AppRoot)) {
2737
New-Item -ItemType Directory -Path $AppRoot -Force | Out-Null
@@ -74,19 +84,19 @@ function Resolve-AppDataDir {
7484
return $env:OPENCLAW_TRAY_DATA_DIR
7585
}
7686

77-
return Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)) 'OpenClawTray'
87+
return Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)) $DataDirectoryName
7888
}
7989

8090
function Resolve-LocalDataDir {
8191
if ($env:OPENCLAW_TRAY_LOCALAPPDATA_DIR) {
82-
return Join-Path $env:OPENCLAW_TRAY_LOCALAPPDATA_DIR 'OpenClawTray'
92+
return Join-Path $env:OPENCLAW_TRAY_LOCALAPPDATA_DIR $DataDirectoryName
8393
}
8494

8595
if ($env:OPENCLAW_TRAY_LOCAL_DATA_DIR) {
8696
return $env:OPENCLAW_TRAY_LOCAL_DATA_DIR
8797
}
8898

89-
return Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData)) 'OpenClawTray'
99+
return Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData)) $DataDirectoryName
90100
}
91101

92102
function Get-JsonPropertyValue {
@@ -228,15 +238,34 @@ function Resolve-AppDataDir {
228238
function Remove-AutostartRegistryValue {
229239
$runKey = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
230240
try {
231-
$value = Get-ItemProperty -LiteralPath $runKey -Name 'OpenClawTray' -ErrorAction SilentlyContinue
241+
$value = Get-ItemProperty -LiteralPath $runKey -Name $AutoStartName -ErrorAction SilentlyContinue
232242
if ($null -ne $value) {
233-
Remove-ItemProperty -LiteralPath $runKey -Name 'OpenClawTray' -ErrorAction Stop
234-
Write-GatewayLog 'Removed OpenClawTray autostart registry value.'
243+
Remove-ItemProperty -LiteralPath $runKey -Name $AutoStartName -ErrorAction Stop
244+
Write-GatewayLog "Removed $AutoStartName autostart registry value."
245+
} else {
246+
Write-GatewayLog "$AutoStartName autostart registry value already absent."
247+
}
248+
} catch {
249+
Add-CleanupWarning "Failed to remove $AutoStartName autostart registry value: $($_.Exception.Message)"
250+
}
251+
}
252+
253+
function Remove-ScheduledStartupTask {
254+
$schtasks = Join-Path $env:WINDIR 'System32\schtasks.exe'
255+
if (-not (Test-Path -LiteralPath $schtasks)) {
256+
Add-CleanupWarning "schtasks.exe was not found; could not remove startup task '$StartupTaskName'."
257+
return
258+
}
259+
260+
try {
261+
$output = & $schtasks /Delete /TN $StartupTaskName /F 2>&1
262+
if ($LASTEXITCODE -eq 0) {
263+
Write-GatewayLog "Removed startup task '$StartupTaskName'."
235264
} else {
236-
Write-GatewayLog 'OpenClawTray autostart registry value already absent.'
265+
Write-GatewayLog "Startup task '$StartupTaskName' was absent or could not be removed: $output"
237266
}
238267
} catch {
239-
Add-CleanupWarning "Failed to remove OpenClawTray autostart registry value: $($_.Exception.Message)"
268+
Add-CleanupWarning "Failed to remove startup task '$StartupTaskName': $($_.Exception.Message)"
240269
}
241270
}
242271

@@ -418,6 +447,7 @@ function Resolve-AppDataDir {
418447
Write-GatewayLog "Cleaning Windows-side local gateway artifacts. AppData='$dataDir'; LocalData='$localDataDir'."
419448

420449
Remove-AutostartRegistryValue
450+
Remove-ScheduledStartupTask
421451
Remove-FileIfExists -Path (Join-Path $dataDir 'setup-state.json') -Label 'legacy setup-state.json'
422452
Remove-FileIfExists -Path (Join-Path $localDataDir 'setup-state.json') -Label 'setup-state.json'
423453
Remove-FileIfExists -Path (Join-Path $localDataDir 'run.marker') -Label 'run.marker'
@@ -538,7 +568,7 @@ function Test-DistroListed {
538568
}
539569

540570
function Remove-GatewayDirectory {
541-
$gatewayDirectory = Join-Path $AppRoot 'wsl\OpenClawGateway'
571+
$gatewayDirectory = Join-Path $AppRoot "wsl\$DistroName"
542572

543573
if (-not (Test-Path -LiteralPath $gatewayDirectory)) {
544574
Write-GatewayLog "Gateway directory does not exist: $gatewayDirectory"
@@ -592,10 +622,6 @@ try {
592622
Write-GatewayLog "Ignoring terminate exit code $($terminateResult.ExitCode); unregister handles stopped or missing distros."
593623
}
594624

595-
$shutdownResult = Invoke-Wsl -Arguments @('--shutdown')
596-
if ($shutdownResult.ExitCode -ne 0) {
597-
Write-GatewayLog "Ignoring shutdown exit code $($shutdownResult.ExitCode); unregister will still be attempted."
598-
}
599625
Start-Sleep -Seconds 2
600626

601627
$unregisterResult = Invoke-Wsl -Arguments @('--unregister', $DistroName)

‎scripts/build-inno-local.ps1‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
.EXAMPLE
1313
.\scripts\build-inno-local.ps1 -Arch x64 -Fast
14+
.\scripts\build-inno-local.ps1 -Arch x64 -Dev -Fast
1415
.\scripts\build-inno-local.ps1 -Arch All
1516
.\scripts\build-inno-local.ps1 -Arch x64 -NoPublish -Fast
1617
#>
@@ -29,6 +30,8 @@ param(
2930

3031
[switch]$Fast,
3132

33+
[switch]$Dev,
34+
3235
[switch]$InstallInno
3336
)
3437

@@ -100,7 +103,8 @@ function Publish-ArchitecturePayload {
100103
"-r", $RuntimeIdentifier,
101104
"--self-contained",
102105
"-o", $publishDir,
103-
"-v:minimal"
106+
"-v:minimal",
107+
"-p:DevBuild=$($Dev.IsPresent.ToString().ToLowerInvariant())"
104108
)
105109
if ($PublishVersion) {
106110
$trayPublishArgs += "-p:Version=$PublishVersion"
@@ -122,6 +126,16 @@ function Assert-PayloadReady {
122126
throw "Missing tray payload at $trayExe. Rerun without -NoPublish."
123127
}
124128

129+
$identityMarker = Join-Path $publishDir "app-identity.txt"
130+
$expectedIdentity = if ($Dev) { "dev" } else { "release" }
131+
if (-not (Test-Path -LiteralPath $identityMarker)) {
132+
throw "Missing payload identity marker at $identityMarker. Rerun without -NoPublish."
133+
}
134+
$actualIdentity = (Get-Content -LiteralPath $identityMarker -Raw).Trim()
135+
if ($actualIdentity -ne $expectedIdentity) {
136+
throw "Payload identity '$actualIdentity' does not match requested '$expectedIdentity' installer. Rerun without -NoPublish."
137+
}
138+
125139
$setupExe = Get-ChildItem -LiteralPath $publishDir -Recurse -File -Filter "OpenClaw.SetupEngine.UI.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
126140
if ($setupExe) {
127141
throw "SetupEngine.UI.exe should not be present in the installer payload: $($setupExe.FullName)"
@@ -151,6 +165,10 @@ function Invoke-InnoCompiler {
151165
$args += "/DMySolidCompression=no"
152166
}
153167

168+
if ($Dev) {
169+
$args += "/DDevBuild=1"
170+
}
171+
154172
$args += ".\installer.iss"
155173

156174
& $InnoCompiler @args
@@ -176,6 +194,7 @@ $architectures = if ($Arch -eq "All") { @("x64", "arm64") } else { @($Arch) }
176194
Write-Step "Using ISCC: $iscc"
177195
Write-Host "Version: $Version"
178196
Write-Host "Configuration: $Configuration"
197+
Write-Host "Identity: $(if ($Dev) { 'dev' } else { 'release' })"
179198
Write-Host "Fast compression: $($Fast.IsPresent)"
180199
Write-Host "No publish: $($NoPublish.IsPresent)"
181200

@@ -191,7 +210,7 @@ foreach ($architecture in $architectures) {
191210
}
192211

193212
Write-Step "Built installers"
194-
Get-ChildItem -Path (Join-Path $repoRoot "Output\OpenClawCompanion-Setup-*.exe") |
213+
Get-ChildItem -Path (Join-Path $repoRoot "Output\OpenClawCompanion*-Setup-*.exe") |
195214
Sort-Object Name |
196215
ForEach-Object {
197216
"{0}`t{1:N2} MB`t{2}" -f $_.FullName, ($_.Length / 1MB), $_.LastWriteTime

‎src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ private void WriteCapabilities()
205205

206206
private void ApplySetupReviewSummary(SetupConfig config)
207207
{
208-
var summary = SetupReviewSummaryBuilder.Build(config);
208+
var summary = SetupReviewSummaryBuilder.Build(
209+
config,
210+
SetupWindow.Active?.DataDir,
211+
SetupWindow.Active?.LocalDataDir);
209212
InstallDistroTitleText.Text = summary.DistroTitle;
210213
InstallDistroDetailText.Text = summary.DistroDescription;
211214
InstallCliDetailText.Text = summary.InstallerDescription;

0 commit comments

Comments
 (0)