Skip to content

test(tui): reuse real gateway PTY fixture - #118567

Merged
steipete merged 2 commits into
mainfrom
codex/tui-pty-performance
Aug 3, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/tui-pty-performance

Conversation

@steipete

@steipete steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The built-artifact check was dominated by the serial TUI PTY lane. In main run 30789242864, channels and core-support completed in about 30 seconds and gateway-watch reported 14.24 seconds, while TUI PTY held the step for about 359 seconds.

The real Gateway and mock model server were already shared, but each retained Gateway scenario still launched a new TUI process and cold-initialized a dedicated agent. This change keeps the suite serial and reuses one real Gateway PTY across the unique full-stack scenarios. Every case still gets a fresh session, an explicit per-session model, request/output offsets, and abort cleanup. Repeated output markers are scoped to the session-switch boundary so an earlier case cannot satisfy a later assertion.

The real-local smoke and steering contracts now run in one isolated local PTY. Backend-free helper regressions move to a fast owner test.

Redundant real-Gateway cases were removed only where dedicated owners retain the behavior:

  • Ctrl+D editing and empty-editor exit: src/tui/tui-pty-harness.e2e.test.ts plus src/tui/components/custom-editor.test.ts.
  • Blocked /reset during an active run: src/tui/tui-pty-harness.e2e.test.ts plus src/tui/tui-command-handlers.test.ts.
  • Gateway /new: the real-local smoke retains fresh-context proof, while the fake PTY and command-handler suites own create/adopt/serialization behavior.
  • Local validation-loop duplication: the retained real-Gateway case adds the unique session.tool projection proof; embedded-backend and event-handler suites own local mechanics.

No production code, test sharding, worker count, or concurrency changed. The test patch is net 115 lines smaller.

Evidence

Exact main baseline:

After, using the built CLI path:

OPENCLAW_TUI_PTY_INCLUDE_LOCAL=1 \
OPENCLAW_TUI_PTY_USE_BUILT_CLI=1 \
node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.tui-pty.config.ts \
  --reporter=verbose
  • Full TUI PTY shard: 3/3 files, 61/61 tests, 139.01 seconds.
  • Retained real-local file: 8/8 tests, 91.00 seconds.
  • Measured TUI lane saving: about 220 seconds.

Coverage-owner proof:

  • Moved helper regressions: 2/2 passed in 631ms.
  • Targeted Ctrl+D, /new, and /reset owners: 15/15 passed.
  • Real external-client behavior evidence remained present in the full-shard run.
  • git diff --check and oxfmt passed.
  • Autoreview initially found stale shared-output matching; the finding was accepted and fixed. Final P1 review was clean.

check-changed was attempted through Crabbox/Daytona but provider hydration failed before repository checks because /var/cache/crabbox was not writable. The owned lease was cleaned up; focused and sibling proof above completed locally.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete steipete self-assigned this Aug 3, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 4:46 AM ET / 08:46 UTC.

ClawSweeper review

What this changes

The PR reuses one real Gateway pseudo-terminal across serial TUI end-to-end scenarios, preserves isolated sessions and mock-model behavior per case, and moves fixture helper coverage into a fast test.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The branch is a focused test-only performance refactor with a clear session-isolation boundary and no actionable code defect found. It should remain open for the assigned maintainer to review and for the in-progress required checks on the current head to finish.

Priority: P3
Reviewed head: 365ef7ca3761b12cb6d1342370bfc5ea79e40c19

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong focused proof and a well-contained fixture refactor support maintainer review; no discrete correctness defect was found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides after-fix built-CLI terminal evidence for the full TUI PTY shard and targeted owner checks, including 61/61 shard tests and the observed duration reduction.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix built-CLI terminal evidence for the full TUI PTY shard and targeted owner checks, including 61/61 shard tests and the observed duration reduction.
Evidence reviewed 6 items Shared fixture boundary: The PR starts one Gateway, control client, mock model server, and PTY, then creates and patches a fresh session before each scenario; the returned fixture scopes model requests and visible output to that per-case boundary.
Shared lifecycle cleanup: The suite initializes the shared fixture once in beforeAll, performs teardown ownership through cleanupStartedFixture, and registers the validation-terminalizing case last.
Stale-output guard: The extracted helper waits for the accepted session marker and then that session's subsequent idle redraw; its focused test confirms an old busy frame cannot trigger a second /new submission.
Findings None None.
Security None None.

How this fits together

The TUI end-to-end suite drives a terminal client through a real local Gateway and a mock model server. This change shares expensive Gateway and terminal setup while each scenario switches to a new session and asserts its own model requests and terminal output.

flowchart LR
  A[Serial TUI scenarios] --> B[Fresh Gateway session]
  B --> C[Shared terminal PTY]
  C --> D[Real Gateway]
  D --> E[Mock model server]
  E --> F[Per-scenario response and request assertions]
  F --> G[Abort cleanup and next scenario]
Loading

Before merge

  • Resolve merge risk (P1) - The shared serial fixture intentionally concentrates Gateway and PTY lifecycle state; merge only after the exact head's remaining build and validation checks complete, so any ordering or cleanup regression is caught on the integrated branch.
  • Complete next step (P2) - The patch has no mechanical repair blocker, but the protected maintainer label and in-progress required checks mean the next action is an assigned maintainer review of the exact head.
Agent review details

Security

None.

PR surface

Source +56, Tests -148. Total -92 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 56 0 +56
Tests 2 271 419 -148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 327 419 -92

Review metrics

Metric Value Why it matters
TUI PTY duration about 359s to 139s (about 220s saved) Contributor-provided built-CLI proof shows the intended reduction in the serial test bottleneck.
Production versus test delta production 0; tests -92 net lines The patch changes only test infrastructure and reduces the retained test implementation rather than expanding runtime behavior.

Stored data model

Persistent data-model change detected: serialized state: src/tui/tui-pty-local-test-support.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the single shared fixture, retain explicit per-session offsets, model routing, and abort cleanup, then merge only after the exact head is refreshed against current main and its required checks complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the single shared fixture, retain explicit per-session offsets, model routing, and abort cleanup, then merge only after the exact head is refreshed against current main and its required checks complete.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR optimizes an existing test lane rather than reporting a user-facing defect. The contributor supplies a built-CLI before/after terminal run plus targeted owner-test results.

Is this the best way to solve the issue?

Yes. Sharing the expensive Gateway and PTY while retaining a fresh session, scoped model-request offsets, output offsets, and per-case abort cleanup is the narrowest maintainable way to reduce this serial lane.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7571679ecc7c.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This is a test-only performance and maintenance improvement with no user-facing runtime behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix built-CLI terminal evidence for the full TUI PTY shard and targeted owner checks, including 61/61 shard tests and the observed duration reduction.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix built-CLI terminal evidence for the full TUI PTY shard and targeted owner checks, including 61/61 shard tests and the observed duration reduction.

Evidence

What I checked:

  • Shared fixture boundary: The PR starts one Gateway, control client, mock model server, and PTY, then creates and patches a fresh session before each scenario; the returned fixture scopes model requests and visible output to that per-case boundary. (src/tui/tui-pty-local.e2e.test.ts:813, 365ef7ca3761)
  • Shared lifecycle cleanup: The suite initializes the shared fixture once in beforeAll, performs teardown ownership through cleanupStartedFixture, and registers the validation-terminalizing case last. (src/tui/tui-pty-local.e2e.test.ts:1391, 365ef7ca3761)
  • Stale-output guard: The extracted helper waits for the accepted session marker and then that session's subsequent idle redraw; its focused test confirms an old busy frame cannot trigger a second /new submission. (src/tui/tui-pty-local-test-support.ts:24, 365ef7ca3761)
  • Prior review continuity: The prior ClawSweeper cycle recorded no findings at 7168e9e; the follow-up commit adds shared mock-model routing without reopening a previously fixed blocker. (src/tui/tui-pty-local.e2e.test.ts:55, 365ef7ca3761)
  • Area history: Available history identifies prior TUI session-isolation and PTY lifecycle work, including 2242b96 ('prevent duplicate session rollover after stale terminal redraw') and recent current-main maintenance by joshavant; the PR head is authored by steipete. (src/tui/tui-pty-local.e2e.test.ts:830, 365ef7ca3761)
  • Current-head status: The supplied review context reports the PR cleanly mergeable but behind main, with build-artifacts and several required validation checks still in progress on the current head. (365ef7ca3761)

Likely related people:

  • steipete: The PR head and available TUI session/PTY history show substantial prior contribution in this test area. (role: primary TUI test-area contributor and current PR author; confidence: high; commits: 365ef7ca3761, 7168e9ed590c; files: src/tui/tui-pty-local.e2e.test.ts, src/tui/tui-command-handlers.ts)
  • joshavant: The current checkout's latest available history for the real-backend PTY test is joshavant's terminal behavior coverage change. (role: recent TUI test-area contributor; confidence: medium; commits: cd8985c2fc41; files: src/tui/tui-pty-local.e2e.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-03T07:48:07.215Z sha 7168e9e :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft August 3, 2026 08:40
@steipete
steipete marked this pull request as ready for review August 3, 2026 08:40
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 3, 2026
@steipete
steipete merged commit 2923ee4 into main Aug 3, 2026
181 of 220 checks passed
@steipete
steipete deleted the codex/tui-pty-performance branch August 3, 2026 08:53
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
…ion-routing

* origin/main:
  refactor(agents): remove stale runner state plumbing (#118495)
  test(gateway): skip servers for handler fixtures (#118581)
  test(tui): reuse real gateway PTY fixture (#118567)
  fix: keep command tests independent of ambient Gateway tokens (#118577)
  fix: show effective channel model in Telegram status (#118548)
  test(system-agent): reuse approval CLI fixture (#118572)
  test(macos): deduplicate Claude session catalog fixtures (#118571)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
* test(tui): reuse real gateway PTY fixture

* test(tui): share gateway mock model

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant