Skip to content

Commit fbc0716

Browse files
author
Linus Huang
committed
Remove Gateway cleanup from the MSIX host
Limit the bootstrapper to payload preparation and repair. Leave Gateway shutdown and shared-state removal to OpenClaw's documented uninstall flow, while preserving atomic replacement of stale prepared payloads. Co-authored-by: Copilot <[email protected]> Copilot-Session: 44c67666-9bfb-4db1-bda6-becae62926cb
1 parent af68085 commit fbc0716

11 files changed

Lines changed: 19 additions & 650 deletions

File tree

‎packaging/gateway-msix/README.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ openclaw gateway run
2626
On later launches, the bootstrapper offers these choices:
2727

2828
- **C**: continue with fast verification (recommended);
29-
- **R**: fully verify every prepared file and repair if needed;
30-
- **G**: remove the prepared gateway files while preserving OpenClaw user
31-
configuration and state;
32-
- **A**: remove both the prepared gateway and `%USERPROFILE%\.openclaw`.
29+
- **R**: fully verify every prepared file and repair if needed.
3330

34-
The destructive full reset requires typing `RESET`. Cleanup first asks
35-
OpenClaw to stop its gateway. If necessary, it terminates only the recorded
36-
packaged gateway process, never every `node.exe` process.
31+
When preparation is required, the host extracts into a temporary directory,
32+
moves any existing prepared payload aside, and promotes the new payload only
33+
after extraction and verification succeed. The previous payload is removed
34+
after successful promotion, preserving rollback if preparation fails.
3735

3836
All explicit arguments are forwarded unchanged to the bundled OpenClaw CLI
3937
after payload preparation. The host does not reserve, consume, reject, or
@@ -111,7 +109,10 @@ key is stored in the repository.
111109

112110
The prepared gateway and OpenClaw user state are outside the immutable MSIX
113111
installation directory. Updating or removing the MSIX does not automatically
114-
delete those directories.
112+
delete those directories or stop a running Gateway. Use OpenClaw's documented
113+
[`openclaw uninstall`](https://docs.openclaw.ai/install/uninstall) flow before
114+
removing the MSIX. The prepared `%USERPROFILE%\.openclaw-msix` directory may
115+
be removed manually after OpenClaw is stopped.
115116

116117
## Integrity and isolation boundary
117118

‎packaging/gateway-msix/src/OpenClaw.Gateway.MSIXHost/BootstrapConsole.cs‎

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,32 @@ namespace OpenClaw.MSIXHost;
33
public enum BootstrapAction
44
{
55
PrepareFast,
6-
PrepareFull,
7-
ResetGateway,
8-
ResetAll
6+
PrepareFull
97
}
108

119
public static class BootstrapConsole
1210
{
1311
public static BootstrapAction PromptForAction(
1412
string installDirectory,
15-
string stateDirectory,
1613
TextReader input,
1714
TextWriter output)
1815
{
19-
string? installRoot = Path.GetDirectoryName(
20-
Path.GetFullPath(installDirectory));
21-
bool hasGatewayData =
22-
Directory.Exists(installDirectory) ||
23-
(installRoot is not null &&
24-
string.Equals(
25-
Path.GetFileName(installRoot),
26-
".openclaw-msix",
27-
StringComparison.OrdinalIgnoreCase) &&
28-
Directory.Exists(installRoot));
29-
if (!hasGatewayData &&
30-
!Directory.Exists(stateDirectory))
16+
if (!Directory.Exists(installDirectory))
3117
{
3218
return BootstrapAction.PrepareFast;
3319
}
3420

3521
output.WriteLine();
36-
if (Directory.Exists(installDirectory))
37-
{
38-
output.WriteLine("OpenClaw gateway files were prepared by an earlier launch:");
39-
output.WriteLine($" {installDirectory}");
40-
output.WriteLine();
41-
output.WriteLine("If OpenClaw is already configured and working, you can close");
42-
output.WriteLine("this window and launch it with:");
43-
output.WriteLine(" openclaw gateway run");
44-
}
45-
else if (hasGatewayData)
46-
{
47-
output.WriteLine("Existing OpenClaw MSIX gateway data was found:");
48-
output.WriteLine($" {installRoot}");
49-
}
50-
else
51-
{
52-
output.WriteLine("Existing OpenClaw configuration or user data was found:");
53-
output.WriteLine($" {stateDirectory}");
54-
}
22+
output.WriteLine("OpenClaw gateway files were prepared by an earlier launch:");
23+
output.WriteLine($" {installDirectory}");
24+
output.WriteLine();
25+
output.WriteLine("If OpenClaw is already configured and working, you can close");
26+
output.WriteLine("this window and launch it with:");
27+
output.WriteLine(" openclaw gateway run");
5528

5629
output.WriteLine();
5730
output.WriteLine("[C] Continue with fast verification [recommended]");
5831
output.WriteLine("[R] Retry preparation with full verification and repair");
59-
output.WriteLine("[G] Reset prepared gateway files, then exit");
60-
output.WriteLine("[A] Reset gateway files and all OpenClaw user data, then exit");
6132

6233
while (true)
6334
{
@@ -74,38 +45,7 @@ public static BootstrapAction PromptForAction(
7445
return BootstrapAction.PrepareFull;
7546
}
7647

77-
if (response.Equals("g", StringComparison.OrdinalIgnoreCase))
78-
{
79-
output.Write(
80-
"Remove the prepared gateway files? The MSIX will remain installed. [y/N]: ");
81-
if (IsYes(input.ReadLine()))
82-
{
83-
return BootstrapAction.ResetGateway;
84-
}
85-
86-
output.WriteLine("Gateway reset canceled.");
87-
continue;
88-
}
89-
90-
if (response.Equals("a", StringComparison.OrdinalIgnoreCase))
91-
{
92-
output.WriteLine(
93-
"This removes prepared gateway files, configuration, credentials, " +
94-
"agents, and sessions.");
95-
output.Write("Type RESET to continue: ");
96-
if (string.Equals(
97-
input.ReadLine()?.Trim(),
98-
"RESET",
99-
StringComparison.Ordinal))
100-
{
101-
return BootstrapAction.ResetAll;
102-
}
103-
104-
output.WriteLine("Full reset canceled.");
105-
continue;
106-
}
107-
108-
output.WriteLine("Enter C, R, G, or A.");
48+
output.WriteLine("Enter C or R.");
10949
}
11050
}
11151

@@ -140,8 +80,4 @@ public static void WaitForExit(TextReader input, TextWriter output)
14080
output.Write("Press Enter to close this window...");
14181
input.ReadLine();
14282
}
143-
144-
private static bool IsYes(string? value) =>
145-
string.Equals(value?.Trim(), "y", StringComparison.OrdinalIgnoreCase) ||
146-
string.Equals(value?.Trim(), "yes", StringComparison.OrdinalIgnoreCase);
14783
}

‎packaging/gateway-msix/src/OpenClaw.Gateway.MSIXHost/GatewayLauncher.cs‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ public static async Task<int> RunAsync(
2424
using Process process = Process.Start(startInfo) ??
2525
throw new InvalidOperationException("Unable to start the OpenClaw process.");
2626
log?.Invoke($"OpenClaw child process started with PID {process.Id}.");
27-
GatewayProcessRegistration? registration = null;
28-
if (IsGatewayRun(openClawArguments))
29-
{
30-
try
31-
{
32-
registration = GatewayProcessRegistration.Create(
33-
process,
34-
payloadDirectory,
35-
nodePath);
36-
}
37-
catch (Exception exception) when (
38-
exception is IOException or
39-
UnauthorizedAccessException or
40-
InvalidOperationException or
41-
System.ComponentModel.Win32Exception)
42-
{
43-
log?.Invoke(
44-
$"Unable to record the gateway process for reset: {exception.Message}");
45-
}
46-
}
4727

4828
Task stderrForwarding = startInfo.RedirectStandardError
4929
? ForwardStandardErrorAsync(
@@ -68,10 +48,6 @@ InvalidOperationException or
6848

6949
throw;
7050
}
71-
finally
72-
{
73-
registration?.Dispose();
74-
}
7551
}
7652

7753
public static ProcessStartInfo CreateStartInfo(
@@ -116,18 +92,6 @@ public static ProcessStartInfo CreateStartInfo(
11692
return startInfo;
11793
}
11894

119-
private static bool IsGatewayRun(IReadOnlyList<string> arguments) =>
120-
arguments.Count == 0 ||
121-
(arguments.Count >= 2 &&
122-
string.Equals(
123-
arguments[0],
124-
"gateway",
125-
StringComparison.OrdinalIgnoreCase) &&
126-
string.Equals(
127-
arguments[1],
128-
"run",
129-
StringComparison.OrdinalIgnoreCase));
130-
13195
public static async Task ForwardStandardErrorAsync(
13296
TextReader reader,
13397
TextWriter writer,

0 commit comments

Comments
 (0)