Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a8b23d6
test(openclaw): cover TUI idle timeout regression
chengjiew Jul 6, 2026
9aec0ea
test(openclaw): cover TUI post-idle interactions
chengjiew Jul 6, 2026
22a89ab
test(cli): avoid conditional cache cleanup
chengjiew Jul 6, 2026
dac74e5
merge(main): sync fix branch with main
chengjiew Jul 6, 2026
f1fd44d
test(cli): align oclif runner mock shape
chengjiew Jul 6, 2026
afdd0ae
test(rebuild): accept notice in recovery harness
chengjiew Jul 6, 2026
646f1d0
test(openclaw): cover post-idle network approval
chengjiew Jul 6, 2026
e887c23
test(openclaw): address post-idle review follow-up
chengjiew Jul 6, 2026
c467c94
test(openclaw): tighten network approval markers
chengjiew Jul 6, 2026
933640c
test(openclaw): match issue 6194 session path
chengjiew Jul 6, 2026
ab81f28
test(openclaw): harden issue 6194 follow-up coverage
chengjiew Jul 6, 2026
8c3b773
test(openclaw): avoid appended tui capture
chengjiew Jul 6, 2026
02f22f4
test(openclaw): use sandbox access env for tui expect
chengjiew Jul 6, 2026
8bf393a
test(openclaw): factor issue 6194 expect helper
chengjiew Jul 6, 2026
ed93157
test(openclaw): document issue 6194 repro scope
chengjiew Jul 6, 2026
cbc0dcf
test(openclaw): isolate issue 6194 tui flow
chengjiew Jul 6, 2026
7737d07
Merge remote-tracking branch 'origin/main' into fix/6194_openclaw_tui…
chengjiew Jul 6, 2026
477e9f1
test(openclaw): tighten issue 6194 pr feedback
chengjiew Jul 6, 2026
ba4a799
test(openclaw): cover issue 6194 artifact redaction
chengjiew Jul 6, 2026
b79b7db
merge: sync main into TUI idle coverage
apurvvkumaria Jul 8, 2026
2fa6a09
test(openclaw): keep TUI idle coverage scoped
apurvvkumaria Jul 8, 2026
eceddf6
ci(e2e): install expect for TUI live target
apurvvkumaria Jul 8, 2026
bedfc31
test(openclaw): harden TUI idle live proof
apurvvkumaria Jul 8, 2026
2344f7d
test(e2e): keep workflow boundary linear
apurvvkumaria Jul 8, 2026
456b612
test(openclaw): match rendered slash status
apurvvkumaria Jul 8, 2026
feaf29a
merge(e2e): sync TUI idle coverage with main
apurvvkumaria Jul 9, 2026
b10ba53
merge(e2e): sync latest main
apurvvkumaria Jul 9, 2026
ee349c1
merge(main): sync PR #6296 with latest main
cv Jul 9, 2026
d56841c
test(e2e): reuse shared command result helper
cv Jul 9, 2026
2ca7642
test(openclaw): make network approval proof deterministic
apurvvkumaria Jul 9, 2026
d1f7a7f
test(openclaw): harden TUI exit diagnostics
cv Jul 9, 2026
c0afe57
test(openclaw): avoid capture read race
cv Jul 9, 2026
d5f4002
test(openclaw): avoid contract file race
cv Jul 9, 2026
b692e14
test(e2e): stabilize OpenShell approval PTY
cv Jul 9, 2026
56f9ae3
test(e2e): bind Expect waits to approval PTY
cv Jul 9, 2026
25bd2e6
test(e2e): match stable sandbox detail label
cv Jul 9, 2026
522186c
test(e2e): declare openshell approval boundary
cv Jul 9, 2026
6b0e91a
test(e2e): normalize approval rule output
cv Jul 9, 2026
db9ffca
test(e2e): tolerate styled approval acknowledgement
cv Jul 9, 2026
6073b64
Merge remote-tracking branch 'origin/main' into fix/6194_openclaw_tui…
jyaunches Jul 9, 2026
df8ed1e
test(e2e): lock phase artifact ordering
cv Jul 9, 2026
20e757a
test(e2e): prove approved policy is active
cv Jul 9, 2026
9f658aa
test(e2e): wait for approved policy revision
cv Jul 9, 2026
c82282a
Merge remote-tracking branch 'origin/main' into fix/6194_openclaw_tui…
jyaunches Jul 9, 2026
d1ea65a
test(e2e): allow policy reload deadline
cv Jul 9, 2026
aff5821
Merge remote-tracking branch 'origin/main' into fix/6194_openclaw_tui…
jyaunches Jul 9, 2026
3b0c037
Merge remote-tracking branch 'origin/main' into fix/6194_openclaw_tui…
jyaunches Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 125 additions & 8 deletions test/e2e/live/openclaw-tui-chat-correlation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// SPDX-License-Identifier: Apache-2.0

/**
* Live E2E: OpenClaw TUI/chat correlation regression guard (#2603 + #3145).
* Live E2E: OpenClaw TUI/chat correlation regression guards (#2603 + #3145 + #6194).
*
* Focused coverage slice for the protocol/history assertions migrated from
* entrypoint now hands off to this live target.
*
* Covered here: ordered, non-empty, correlated replies plus ordered,
* non-duplicated user turns against a real cloud OpenClaw sandbox. TUI
* rendering indicators and visible tool-call status stay out of scope.
* non-duplicated user turns against a real cloud OpenClaw sandbox, then
* terminal TUI input after the visible `connected idle` state.
*/

import { randomUUID } from "node:crypto";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
import { tmpdir } from "node:os";
import { join } from "node:path";

Expand Down Expand Up @@ -43,6 +43,10 @@ const EXPECTED_OPENCLAW_VERSION =

const LIVE_SCRIPT_NAME = "openclaw-issue2603-chat-correlation.cjs";
const SANDBOX_GATEWAY_PORT = 18789;
const ISSUE6194_TUI_TIMEOUT_SEC = Number.parseInt(
process.env.NEMOCLAW_ISSUE_6194_TUI_TIMEOUT_SEC ?? "240",
10,
);

// ─── Trace analyzer types + helpers (mirrored from
// test/openclaw-tui-chat-correlation.test.ts so the live test is
Expand Down Expand Up @@ -95,6 +99,18 @@ type Issue2603Analysis = {
};
type LiveIssue2603Trace = Issue2603Trace & { error?: string };

type CommandResultText = { stdout: string; stderr: string };

function resultText(result: CommandResultText): string {
return [result.stdout, result.stderr].filter(Boolean).join("\n");
}

function stripTerminalControl(value: string): string {
return value
.replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/gu, "")
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/gu, "");
}

function textFromContent(content: unknown): string {
if (typeof content === "string") return content;
if (!Array.isArray(content)) return "";
Expand Down Expand Up @@ -217,6 +233,68 @@ function analyzeIssue2603Trace({
};
}

function buildIssue6194TuiExpectScript(): string {
return `set timeout $env(NEMOCLAW_ISSUE_6194_TUI_TIMEOUT)
set sandbox $env(NEMOCLAW_ISSUE_6194_SANDBOX)
set capture $env(NEMOCLAW_ISSUE_6194_CAPTURE)
log_file -a $capture
spawn openshell sandbox exec --name $sandbox --tty -- sh -lc {export TERM=xterm-256color; cd /sandbox; openclaw tui}
expect {
-nocase -re {connected[^\\r\\n]*idle} { puts "ISSUE6194_MARK connected_idle_initial" }
timeout {
send "\\003"
exit 10
}
eof { exit 11 }
}
send -- "Reply exactly NEMOCLAW6194_CHAT_OK and nothing else. Do not use tools.\\r"
expect {
-nocase -re {NEMOCLAW6194_CHAT_OK} { puts "ISSUE6194_MARK chat_reply" }
timeout {
send "\\003"
exit 20
}
eof { exit 21 }
}
expect {
-nocase -re {connected[^\\r\\n]*idle} { puts "ISSUE6194_MARK connected_idle_after_chat" }
timeout { puts "ISSUE6194_MARK connected_idle_after_chat_missing" }
eof { exit 22 }
}
send -- "/nemoclaw status\\r"
expect {
-nocase -re {(nemoclaw|sandbox|docker|status|managed|openclaw)} { puts "ISSUE6194_MARK slash_status_output" }
timeout {
send "\\003"
exit 30
}
eof { exit 31 }
}
expect {
-nocase -re {connected[^\\r\\n]*idle} { puts "ISSUE6194_MARK connected_idle_after_status" }
timeout { puts "ISSUE6194_MARK connected_idle_after_status_missing" }
eof { exit 32 }
}
send "\\003"
expect {
eof {
puts "ISSUE6194_MARK clean_exit"
exit 0
}
timeout {
send "\\003"
expect {
eof {
puts "ISSUE6194_MARK clean_exit"
exit 0
}
timeout { exit 40 }
}
}
}
`;
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// The zero-chat-events failure is an observability race at the live
// repro boundary: OpenClaw accepts the chat.send requests, but the
// websocket client captures no chat stream events before assertions.
Expand Down Expand Up @@ -484,15 +562,15 @@ async function runLiveIssue2603ReproWithEventCaptureRetry(
// ─── The live regression guard ─────────────────────────────────────

test(
"openclaw-tui-chat-correlation keeps rapid TUI and webchat sends correlated on a real OpenClaw sandbox (#2603, #3145)",
async ({ artifacts, environment, onboard, sandbox, secrets }) => {
"openclaw-tui-chat-correlation keeps rapid sends correlated and accepts terminal input after connected idle (#2603, #3145, #6194)",
async ({ artifacts, environment, host, onboard, sandbox, secrets }) => {
secrets.required("NVIDIA_INFERENCE_API_KEY");

await artifacts.writeJson("target.json", {
id: "openclaw-tui-chat-correlation",
runner: "vitest",
boundary: "openclaw-gateway-websocket",
issues: ["#2603", "#3145"],
boundary: ["openclaw-gateway-websocket", "openclaw-tui-terminal-after-connected-idle"],
issues: ["#2603", "#3145", "#6194"],
ownerIssue: "#4347",
pinnedOpenClawVersion: EXPECTED_OPENCLAW_VERSION,
});
Expand Down Expand Up @@ -574,6 +652,45 @@ test(
);
expect(analysis.missingUserTurns, failureSummary).toEqual([]);
expect(analysis.duplicateUserTurns, failureSummary).toEqual([]);

const captureFile = artifacts.pathFor("issue6194-openclaw-tui-capture.log");
const expectScript = artifacts.pathFor("issue6194-openclaw-tui.expect");
writeFileSync(expectScript, buildIssue6194TuiExpectScript(), { mode: 0o700 });
const tui = await host.command("expect", [expectScript], {
artifactName: "issue6194-openclaw-tui-post-idle",
env: {
...buildAvailabilityProbeEnv(),
NEMOCLAW_ISSUE_6194_SANDBOX: instance.sandboxName,
NEMOCLAW_ISSUE_6194_CAPTURE: captureFile,
NEMOCLAW_ISSUE_6194_TUI_TIMEOUT: String(ISSUE6194_TUI_TIMEOUT_SEC),
},
timeoutMs: (ISSUE6194_TUI_TIMEOUT_SEC + 30) * 1000,
});
const plainCapture = stripTerminalControl(readFileSync(captureFile, "utf8"));
const combined = `${resultText(tui)}\n${plainCapture}`;
await artifacts.writeText("issue6194-openclaw-tui-capture.plain.log", plainCapture);
await artifacts.writeJson("issue6194-target-result.json", {
id: "issue-6194-tui-post-connected-idle",
expectExitCode: tui.exitCode,
connectedIdleInitial: combined.includes("ISSUE6194_MARK connected_idle_initial"),
chatReply: combined.includes("ISSUE6194_MARK chat_reply"),
slashStatusOutput: combined.includes("ISSUE6194_MARK slash_status_output"),
cleanExit: combined.includes("ISSUE6194_MARK clean_exit"),
});

expect(tui.exitCode, combined).toBe(0);
expect(combined, "TUI must reach connected idle before post-idle input").toContain(
"ISSUE6194_MARK connected_idle_initial",
);
expect(combined, "post-idle chat must return a visible reply before timeout").toContain(
"ISSUE6194_MARK chat_reply",
);
expect(combined, "post-idle slash command must render status output before timeout").toContain(
"ISSUE6194_MARK slash_status_output",
);
expect(combined, "post-idle Ctrl+C must close the TUI session").toContain(
"ISSUE6194_MARK clean_exit",
);
},
// 75-minute budget covers cloud onboarding, sandbox provisioning, gateway
// warmup, the 120-second wait-for-replies window, and retry.
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/support/issue-6194-tui-post-idle-contract.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { readFileSync } from "node:fs";

import { describe, expect, it } from "vitest";

const LIVE_TUI_SOURCE = "test/e2e/live/openclaw-tui-chat-correlation.test.ts";

describe("live TUI post-idle coverage contract (#6194)", () => {
it("drives the real terminal TUI after connected idle", () => {
const source = readFileSync(LIVE_TUI_SOURCE, "utf8");

expect(source).toContain('"#6194"');
expect(source).toContain("openclaw-tui-terminal-after-connected-idle");
expect(source).toContain("spawn openshell sandbox exec --name $sandbox --tty");
expect(source).toContain("openclaw tui");
expect(source).toContain("connected[^\\\\r\\\\n]*idle");
expect(source).toContain("NEMOCLAW6194_CHAT_OK");
expect(source).toContain("/nemoclaw status");
expect(source).toContain('send "\\\\003"');
expect(source).toContain("ISSUE6194_MARK clean_exit");
});
});
4 changes: 2 additions & 2 deletions test/nemoclaw-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ describe("nemoclaw-start auto-pair slow-mode keepalive (#4263)", () => {
// Shared late-CLI poll timeline:
// 1-2: first-time browser pairing request pending.
// 3-6: browser paired, nothing pending (watcher converges to slow mode).
// 7-10: late CLI scope upgrade arrives.
// 7-10: late CLI scope upgrade arrives after browser pairing converges.
// 11+: cli paired alongside browser.
function setupLateCliFixture(prefix: string): {
tmpDir: string;
Expand Down Expand Up @@ -1716,7 +1716,7 @@ exit 2
expect(run.stdout).toContain(
"[auto-pair] browser pairing converged; entering slow-mode approvals=1",
);
// Concurrent late wave — proxy for two sibling sandboxes' upgrades.
// Concurrent late wave after the watcher has already dropped to slow mode.
expect(run.stdout).toContain(
"[auto-pair] approved request=late-cli client=openclaw-cli mode=cli",
);
Expand Down
47 changes: 46 additions & 1 deletion test/package-contract/cli/config-set-cli-dispatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,45 @@ function deferred<T>() {
describe("config set CLI dispatch", () => {
it("awaits configSet before completing the dispatcher", async () => {
const cliPath = require.resolve("../../../dist/nemoclaw.js");
const publicDispatchPath = require.resolve("../../../dist/lib/cli/public-dispatch.js");
const oclifRunnerPath = require.resolve("../../../dist/lib/cli/oclif-runner.js");
const registryPath = require.resolve("../../../dist/lib/state/registry.js");
const sandboxConfigPath = require.resolve("../../../dist/lib/sandbox/config.js");
const runnerPath = require.resolve("../../../dist/lib/runner.js");

const priorCli = require.cache[cliPath];
const priorPublicDispatch = require.cache[publicDispatchPath];
const priorOclifRunner = require.cache[oclifRunnerPath];
const priorRegistry = require.cache[registryPath];
const priorSandboxConfig = require.cache[sandboxConfigPath];
const priorRunner = require.cache[runnerPath];
const priorDisableAutoDispatch = process.env.NEMOCLAW_DISABLE_AUTO_DISPATCH;

const configSetDeferred = deferred<void>();
const validateName = vi.fn();
const configSet = vi.fn(() => configSetDeferred.promise);
const configSet = vi.fn((_sandboxName: string, _opts: Record<string, unknown>) => {
return configSetDeferred.promise;
});
const runOclifArgv = vi.fn(async () => {
throw new Error("config set should dispatch by command id");
});
const runOclifCommandById = vi.fn(async (commandId: string, args: string[]) => {
expect(commandId).toBe("sandbox:config:set");
expect(args).toEqual([
"test-sandbox",
"--key",
"inference.endpoints",
"--value",
"HTTP://93.184.216.34/v1",
"--config-accept-new-path",
]);
await configSet("test-sandbox", {
key: "inference.endpoints",
value: "HTTP://93.184.216.34/v1",
restart: false,
acceptNewPath: true,
});
});

process.env.NEMOCLAW_DISABLE_AUTO_DISPATCH = "1";

Expand All @@ -52,6 +78,16 @@ describe("config set CLI dispatch", () => {
),
} as any;

requireCache[oclifRunnerPath] = {
id: oclifRunnerPath,
filename: oclifRunnerPath,
loaded: true,
exports: {
runOclifArgv,
runOclifCommandById,
},
} as any;

requireCache[registryPath] = {
id: registryPath,
filename: registryPath,
Expand All @@ -75,6 +111,7 @@ describe("config set CLI dispatch", () => {

try {
delete require.cache[cliPath];
delete require.cache[publicDispatchPath];
const { dispatchCli } = require(cliPath);

const dispatchPromise = dispatchCli([
Expand All @@ -94,6 +131,8 @@ describe("config set CLI dispatch", () => {
});

await vi.waitFor(() => expect(configSet).toHaveBeenCalledTimes(1));
expect(runOclifArgv).not.toHaveBeenCalled();
expect(runOclifCommandById).toHaveBeenCalledTimes(1);
expect(configSet).toHaveBeenCalledTimes(1);
expect(configSet).toHaveBeenCalledWith("test-sandbox", {
key: "inference.endpoints",
Expand All @@ -116,6 +155,12 @@ describe("config set CLI dispatch", () => {
if (priorCli) requireCache[cliPath] = priorCli;
else delete requireCache[cliPath];

if (priorPublicDispatch) requireCache[publicDispatchPath] = priorPublicDispatch;
else delete requireCache[publicDispatchPath];

if (priorOclifRunner) requireCache[oclifRunnerPath] = priorOclifRunner;
else delete requireCache[oclifRunnerPath];

if (priorRegistry) requireCache[registryPath] = priorRegistry;
else delete requireCache[registryPath];

Expand Down
Loading