mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
fix(update): recognize bare TUI launches
This commit is contained in:
@@ -23,6 +23,9 @@ describe("local TUI processes", () => {
|
||||
" 501 110 Thu Aug 20 19:00:00 2026 openclaw --profile work tui --local",
|
||||
" 501 111 Thu Aug 20 19:00:00 2026 /usr/bin/node /usr/lib/node_modules/openclaw/openclaw.mjs --no-color terminal",
|
||||
" 501 112 Thu Aug 20 19:00:00 2026 openclaw --profile=work chat",
|
||||
" 501 114 Thu Aug 20 19:00:00 2026 openclaw",
|
||||
" 501 115 Thu Aug 20 19:00:00 2026 openclaw --profile work",
|
||||
" 501 116 Thu Aug 20 19:00:00 2026 /usr/bin/node /usr/lib/node_modules/openclaw/openclaw.mjs --no-color",
|
||||
" 502 113 Thu Aug 20 19:00:00 2026 openclaw tui",
|
||||
" 501 999 Thu Aug 20 19:00:00 2026 openclaw tui",
|
||||
].join("\n"),
|
||||
@@ -67,6 +70,17 @@ describe("local TUI processes", () => {
|
||||
command: "openclaw --profile=work chat",
|
||||
startTime: "Thu Aug 20 19:00:00 2026",
|
||||
},
|
||||
{ pid: 114, command: "openclaw", startTime: "Thu Aug 20 19:00:00 2026" },
|
||||
{
|
||||
pid: 115,
|
||||
command: "openclaw --profile work",
|
||||
startTime: "Thu Aug 20 19:00:00 2026",
|
||||
},
|
||||
{
|
||||
pid: 116,
|
||||
command: "/usr/bin/node /usr/lib/node_modules/openclaw/openclaw.mjs --no-color",
|
||||
startTime: "Thu Aug 20 19:00:00 2026",
|
||||
},
|
||||
]);
|
||||
expect(spawnSync).toHaveBeenCalledWith("ps", ["-axo", "uid=,pid=,lstart=,command="], {
|
||||
encoding: "utf8",
|
||||
|
||||
@@ -49,6 +49,10 @@ function normalizeExecutableName(value: string | undefined): string {
|
||||
);
|
||||
}
|
||||
|
||||
function isLocalTuiSubcommand(command: string | null | undefined): boolean {
|
||||
return command === undefined || (command !== null && LOCAL_TUI_SUBCOMMANDS.has(command));
|
||||
}
|
||||
|
||||
function isLocalTuiCommand(command: string, platform: NodeJS.Platform): boolean {
|
||||
const argv =
|
||||
platform === "win32" ? parseCmdScriptCommandLine(command) : tokenizeCommandLine(command);
|
||||
@@ -57,22 +61,21 @@ function isLocalTuiCommand(command: string, platform: NodeJS.Platform): boolean
|
||||
return true;
|
||||
}
|
||||
if (executable === "openclaw") {
|
||||
return LOCAL_TUI_SUBCOMMANDS.has(resolveOpenClawCommand(argv.slice(1)) ?? "");
|
||||
return isLocalTuiSubcommand(resolveOpenClawCommand(argv.slice(1)));
|
||||
}
|
||||
return (
|
||||
executable === "node" &&
|
||||
normalizeExecutableName(argv[1]) === "openclaw.mjs" &&
|
||||
LOCAL_TUI_SUBCOMMANDS.has(resolveOpenClawCommand(argv.slice(2)) ?? "")
|
||||
isLocalTuiSubcommand(resolveOpenClawCommand(argv.slice(2)))
|
||||
);
|
||||
}
|
||||
|
||||
function resolveOpenClawCommand(args: readonly string[]): string | undefined {
|
||||
return (
|
||||
getCommandPositionalsWithRootOptions(["node", "openclaw", ...args], {
|
||||
commandPath: [],
|
||||
maxPositionals: 1,
|
||||
})?.[0] ?? undefined
|
||||
);
|
||||
function resolveOpenClawCommand(args: readonly string[]): string | null | undefined {
|
||||
const positionals = getCommandPositionalsWithRootOptions(["node", "openclaw", ...args], {
|
||||
commandPath: [],
|
||||
maxPositionals: 1,
|
||||
});
|
||||
return positionals === null ? null : positionals[0];
|
||||
}
|
||||
|
||||
function parseLocalTuiProcessLine(line: string, currentUid: number, currentPid = process.pid) {
|
||||
|
||||
Reference in New Issue
Block a user