Skip to content

test(openclaw): add TUI chat correlation regression - #3364

Merged
cv merged 3 commits into
mainfrom
test/issue-2603-tui-correlation
May 11, 2026
Merged

cv merged 3 commits into
mainfrom
test/issue-2603-tui-correlation

Conversation

@cv

@cv cv commented May 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a focused regression harness for #2603 so NemoClaw can recognize the OpenClaw TUI/WebChat correlation failure without making normal CI depend on a live sandbox. The default test documents the observed broken gateway trace, while an opt-in live test can be run against an OpenClaw sandbox to verify whether a pinned OpenClaw build has fixed the behavior.

Related Issue

Refs #2603

Changes

  • Added test/openclaw-tui-chat-correlation.test.ts with shared analysis helpers for rapid A/B/C TUI/WebChat sends.
  • Captured the current [Linux][Agent&Skills] TUI chat previous message disappears from UI after reconnect or scroll #2603 failure signature: empty chat final events for submitted chat.send run IDs, visible replies arriving under different run IDs, and duplicate user turns in chat.history.
  • Added an opt-in live repro gated by NEMOCLAW_ISSUE_2603_LIVE=1 and NEMOCLAW_ISSUE_2603_SANDBOX=<name> that drives the same OpenClaw gateway WebSocket protocol used by the TUI.
  • Current options from here:
    • Preferred durable fix: fix OpenClaw gateway/TUI correlation so accepted chat.send run IDs either stay attached to their visible replies or produce UI-safe queue status events instead of empty finals.
    • NemoClaw mitigation to evaluate: generate a safer OpenClaw queue config for TUI/WebChat (for example messages.queue.byChannel.webchat = "queue") if it preserves expected chat semantics.
    • After an upstream OpenClaw fix: bump NemoClaw's pinned OPENCLAW_VERSION and run the opt-in live test as acceptance evidence.
    • Avoid unless release-blocking: patching bundled OpenClaw JS from NemoClaw, because the bug is below the NemoClaw CLI wrapper and belongs in OpenClaw proper.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela [email protected]

Summary by CodeRabbit

  • Tests
    • Added automated regression test coverage for OpenClaw TUI chat scenarios, including static trace analysis and live sandbox validation to ensure chat event handling consistency and prevent future regressions.

Review Change Stack

@cv cv self-assigned this May 11, 2026
@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 220e3721-5576-4638-b21d-b3bc54bd83a2

📥 Commits

Reviewing files that changed from the base of the PR and between c766b0f and 35f67fe.

📒 Files selected for processing (1)
  • test/openclaw-tui-chat-correlation.test.ts

📝 Walkthrough

Walkthrough

This pull request adds a comprehensive regression test for OpenClaw issue #2603, a TUI/webchat message correlation bug. It provides both a deterministic test against a captured trace fixture and an optional live sandbox repro that validates the gateway behavior over WebSocket for empty final messages, miscorrelated reply tokens, and duplicate user turns.

Changes

TUI/Webchat Correlation Test Suite

Layer / File(s) Summary
Data Model and Types
test/openclaw-tui-chat-correlation.test.ts
Defines environment variable names, test expectation strings, and TypeScript interfaces for sent runs, gateway chat events, chat history, and the computed analysis structure.
Core Analysis Logic
test/openclaw-tui-chat-correlation.test.ts
Implements helpers to extract text from multi-part chat payloads, compact raw gateway chat events into { runId, state, text, errorMessage }, and compute three issue-specific analyses: empty finals, miscorrelated reply tokens, and duplicate user turns.
Failure Summary Builder
test/openclaw-tui-chat-correlation.test.ts
Serializes analysis results (empty finals, uncorrelated replies, duplicate turns) and static test expectations into JSON for use in assertion diagnostics.
Captured Regression Test Data
test/openclaw-tui-chat-correlation.test.ts
Provides a hardcoded gateway trace fixture with sent runs, emitted chat events exhibiting the bug (empty finals for two runs, miscorrelated reply tokens for two others), and chat history with duplicated user messages.
Sandbox Execution Helpers
test/openclaw-tui-chat-correlation.test.ts
Utility functions to execute shell commands via openshell and within a sandbox environment; includes gateway health-check and conditional startup routine.
Live Repro Script Generation
test/openclaw-tui-chat-correlation.test.ts
Embedded Node/WebSocket script template that connects to the gateway, issues connect/chat.history/chat.send requests with timeouts and idempotency keys, records chat event frames, detects reply correlation state, and outputs ISSUE2603_RESULT JSON.
Live Execution and Parsing
test/openclaw-tui-chat-correlation.test.ts
Ensures gateway is running, uploads the generated script to the sandbox, extracts auth token from sandbox config, executes the script with token/session arguments, and parses the emitted JSON result line.
Vitest Suite Definition
test/openclaw-tui-chat-correlation.test.ts
Defines two test paths: a deterministic test asserting the static captured trace is classified as broken, and a conditional live test (enabled by NEMOCLAW_ISSUE_2603_LIVE=1) that runs the sandbox repro and asserts all analysis lists are empty with JSON failure summary on mismatch.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The test spans multiple concerns—data model, trace analysis logic, failure reporting, test data fixtures, sandbox execution infrastructure, embedded script generation, and two distinct test paths—with dense logic for event compaction, analysis detection, and live WebSocket-based reproduction. While the changes are contained in a single file, they demand careful reasoning across each layer and verification of the analysis heuristics.

Poem

🐰 A trace through the gateway flows wide,
Chat events dancing side by side,
Correlation bugs we now compile,
With sandbox repros and captured styles—
Empty finals, tokens gone astray,
Our regression tests will save the day! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a regression test for the TUI chat correlation issue #2603 in the openclaw test suite.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/issue-2603-tui-correlation

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/openclaw-tui-chat-correlation.test.js`:
- Around line 1-446: The test edits were made to the guarded JS copy instead of
the canonical TypeScript source; revert/remove changes in
test/openclaw-tui-chat-correlation.test.js and apply the intended changes into
the TypeScript test (test/openclaw-tui-chat-correlation.test.ts) by copying the
updated test implementation (including analyzeIssue2603Trace,
buildLiveReproScript, runLiveIssue2603Repro, execOpenShell, execInSandbox and
the "OpenClaw TUI chat correlation regression (`#2603`)" describe/it blocks) into
the .ts file, converting any CommonJS snippets to TS/ES module syntax as needed
and preserving typings, then run tests to ensure the legacy-path-guard job no
longer fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a926969b-e236-4386-981a-1c799c5ab31d

📥 Commits

Reviewing files that changed from the base of the PR and between fc07c37 and c766b0f.

📒 Files selected for processing (1)
  • test/openclaw-tui-chat-correlation.test.js

@wscurran wscurran added integration: openclaw OpenClaw integration behavior enhancement: testing labels May 11, 2026
@wscurran

Copy link
Copy Markdown
Contributor

@cv

cv commented May 11, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the CodeRabbit/legacy-path-guard finding in 35f67fe: moved the regression harness from the guarded .js test path to canonical test/openclaw-tui-chat-correlation.test.ts and added TypeScript types. Re-ran verification locally: npm run ts-migration:guard -- --base origin/main --head HEAD, npm run typecheck:cli -- --pretty false, npx vitest run test/openclaw-tui-chat-correlation.test.ts, npx prek run --all-files, and npm test all pass.

@cv
cv merged commit 2a83b53 into main May 11, 2026
23 checks passed
cv pushed a commit that referenced this pull request May 11, 2026
…3366)

## Summary

Adds `pull-requests: write` to the `e2e-advisor` workflow so the advisor
can actually post its recommendation comment on PRs.

## What's broken on `main` today

Since PR #3289 merged ~2 hours ago, the advisor workflow has been
running successfully on same-repo PRs — but the `Post E2E advisor PR
comment` step silently skips every time:

```
403 {"message":"Resource not accessible by integration"}
```

Concrete evidence on PR #3364:

| Run | Job | Comment posted? |
|---|---|---|
|
[25697796461](https://github.com/NVIDIA/NemoClaw/actions/runs/25697796461)
| ✅ success | ❌ no |
|
[25699366979](https://github.com/NVIDIA/NemoClaw/actions/runs/25699366979)
| ✅ success | ❌ no |

The runs look green because `comment.mjs` catches the 403 as a
permission error (a defensive path added during the #3289 review) and
keeps the job passing, but the user-visible artifact — the comment on
the PR — never materializes.

## Root cause

The `permissions:` block on `main` currently declares:

```yaml
permissions:
  contents: read
  pull-requests: read
  issues: write
```

The token effective permissions confirm this takes effect (from the `Set
up job` log group):

```
GITHUB_TOKEN Permissions
  Contents: read
  Issues: write
  Metadata: read
  PullRequests: read
```

Even so, `POST /repos//issues/3364/comments` returns `403
Resource not accessible by integration`.

The reason is a well-documented GitHub Actions permission-name trap: for
`GITHUB_TOKEN`, **PR comments are gated by `pull-requests: write`, not
`issues: write`** — even though the REST endpoint lives under
`/issues/:n/comments`. The `issues` permission only applies to true
issues; PRs fall under `pull-requests`. This is tracked in [community
discussion #56632](https://github.com/orgs/community/discussions/56632)
and has bitten many workflows.

## Fix

Flip `pull-requests` from `read` to `write`, and drop an inline comment
on the permissions block so the next reviewer doesn't have to rediscover
this.

`issues: write` is kept for now — it's unused on the PR-comment path but
it's dirt-cheap to leave in case we ever want the advisor to post on
true issues.

## Defense in depth

The graceful permission-error handling in
`tools/e2e-advisor/comment.mjs` (added in #3289 per @ericksoa's review)
stays in place unchanged. This PR just ensures that for a
correctly-configured repo the 403 path is no longer hit on normal
same-repo PRs.

## Testing

- `python3 -c "import yaml;
yaml.safe_load(open('.github/workflows/e2e-advisor.yaml'))"` — workflow
still parses.
- Non-code change, so local unit tests are unaffected.
- The real verification is the next same-repo PR after merge — expected
behavior is an advisor comment appearing within a few minutes.

## Out of scope for this PR

There's a second gap visible on upstream: `PI_E2E_ADVISOR_API_KEY` is
not set on `NVIDIA/NemoClaw`, so the analysis step currently degrades
to:

> `Skipped: No Pi provider credential was available in this workflow
environment`

That's an admin configuration task (Settings → Secrets and variables →
Actions → New repository secret), not a code change, so handling it
separately.

## Related

- PR #3289 (merged): introduced the advisor + the trust-boundary
restructure.
- Observed on PR #3364 (same-repo, member-authored, fresh push — exactly
the case the advisor is designed for).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated pull request workflow permissions to enable advisor to post
and update comments on pull requests.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/3366)

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@cv
cv deleted the test/issue-2603-tui-correlation branch May 27, 2026 21:19
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure bug-fix PR fixes a bug or regression feature PR adds or expands user-visible functionality chore Build, CI, dependency, or tooling maintenance and removed enhancement: testing bug-fix PR fixes a bug or regression feature PR adds or expands user-visible functionality labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants