Skip to content

Add TUI lifecycle smoke harness#255

Merged
TraderSamwise merged 3 commits into
masterfrom
chore/tui-smoke-harness
Jun 27, 2026
Merged

Add TUI lifecycle smoke harness#255
TraderSamwise merged 3 commits into
masterfrom
chore/tui-smoke-harness

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an isolated tmux-backed TUI smoke harness with deterministic lifecycle and chaos modes
  • preserve Aimux env for tmux-owned dashboard processes so isolated/local installs connect to the intended daemon
  • reconcile transient project-service ensure races against final restart verification

Verification

  • yarn vitest run src/runtime-restart.test.ts src/dashboard/command-spec.test.ts
  • yarn smoke:tui -- --cycles 1
  • yarn smoke:tui -- --chaos --cycles 2
  • yarn smoke:tui -- --iterations 3 --chaos --cycles 2
  • yarn typecheck
  • yarn lint
  • node --check scripts/tui-smoke.mjs
  • yarn test

Summary by CodeRabbit

  • New Features

    • Added a new smoke:tui command to run a build followed by an automated TUI smoke check.
  • Bug Fixes

    • Improved restart handling so a transient startup hiccup no longer reports a failed service if the system is healthy after recovery.
    • Dashboard launches now preserve selected environment settings more reliably.
  • Tests

    • Added coverage for environment handling and restart recovery behavior.

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 27, 2026 1:25am

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@TraderSamwise, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 11 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 876fa1f4-cd55-440a-a14e-a716d1f8b6fa

📥 Commits

Reviewing files that changed from the base of the PR and between 3528ae6 and 3b3dcb3.

📒 Files selected for processing (3)
  • scripts/tui-smoke.mjs
  • src/dashboard/command-spec.test.ts
  • src/dashboard/command-spec.ts
📝 Walkthrough

Walkthrough

Adds a new smoke:tui npm script and an end-to-end TUI smoke runner that builds a temp repo, drives Aimux through tmux, and captures artifacts. It also threads selected environment variables into dashboard startup and reconciles restart results after healthy verification.

Changes

TUI smoke runner

Layer / File(s) Summary
Runner entrypoint and setup
package.json, scripts/tui-smoke.mjs
Adds the smoke:tui script and the runner entrypoint, argument parsing, build checks, repository setup, and project config patching used by the smoke run.
Dashboard and agent loop
scripts/tui-smoke.mjs
Starts the dashboard in tmux, spawns the smoke agent, and drives prompt/echo interactions plus optional restart and round-trip cycles.
Polling and process execution
scripts/tui-smoke.mjs
Adds dashboard stability checks, tmux discovery and capture helpers, and the child-process runner used by the smoke workflow.
Artifacts and cleanup
scripts/tui-smoke.mjs
Writes artifacts, wraps CLI calls, stops Aimux and tmux sessions, and adds supporting utilities for filenames, quoting, sleeping, and environment filtering.

Dashboard command environment

Layer / File(s) Summary
Command env prefix
src/dashboard/command-spec.ts, src/dashboard/command-spec.test.ts
Builds an env ... prefix from selected dashboard variables, threads an optional environment map into command construction, and verifies that secret values are omitted.

Runtime restart reconciliation

Layer / File(s) Summary
Verification reconciliation helper
src/runtime-restart.ts
Promotes failed service steps to ensured status and refreshes service state when verification reports a healthy service after restart.
Failure accounting and test
src/runtime-restart.ts, src/runtime-restart.test.ts
Invokes reconciliation before computing restart failures and adds a test for the transient service-ensure race with healthy verification.

Sequence Diagram(s)

TUI smoke run

sequenceDiagram
  participant SmokeTui as "smoke:tui"
  participant TuiSmoke as "scripts/tui-smoke.mjs"
  participant Tmux as tmux
  participant Dashboard as dashboard
  participant Agent as "smoke agent"
  SmokeTui->>TuiSmoke: node scripts/tui-smoke.mjs
  TuiSmoke->>Tmux: start detached dashboard session
  TuiSmoke->>Dashboard: wait for stable markers
  TuiSmoke->>Agent: spawn and read ready
  TuiSmoke->>Agent: send prompt and verify echo
  TuiSmoke->>Tmux: capture artifacts and clean up sessions
Loading

Restart reconciliation

sequenceDiagram
  participant Restart as restartAimuxControlPlane
  participant Coherence as buildRuntimeCoherenceReport
  participant Reconcile as reconcileProjectResultsWithVerification
  participant Projects as projects
  Restart->>Coherence: collect before and after reports
  Coherence-->>Restart: verification
  Restart->>Reconcile: apply healthy after-report to failed services
  Reconcile-->>Projects: update service status and state
  Restart->>Projects: count failures from reconciled statuses
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TraderSamwise/aimux#199 — Shares the restart reconciliation flow in src/runtime-restart.ts and related test coverage.
  • TraderSamwise/aimux#237 — Uses getDashboardCommandSpec(...), which this PR changes by adding an environment parameter and env-prefix command construction.

Poem

I hopped through tmux with twitchy ears,
And sniffed the env for secret fears.
A smoke test squeaked, “All clear today!”
Then bounced through restarts on its way.
🐇✨

🚥 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 clearly describes the main change: adding a TUI lifecycle smoke harness.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/tui-smoke-harness

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/dashboard/command-spec.test.ts (1)

17-29: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Add a shell-escaping case for env values.

This test covers spaces and secret omission, but the new shell interpolation should also lock down values containing ' or shell metacharacters so shellQuote regressions are caught.

Suggested test extension
     const spec = getDashboardCommandSpec("/tmp/repo", {
-      AIMUX_HOME: "/tmp/custom-home",
+      AIMUX_HOME: "/tmp/custom'home; echo unsafe",
       AIMUX_DAEMON_PORT: "43219",
       AIMUX_CLI_BIN: "/tmp/bin/aimux smoke",
       SECRET_TOKEN: "not-for-tmux",
     } as NodeJS.ProcessEnv);
     const command = spec.dashboardCommand.args[1] ?? "";
-    expect(command).toContain("env AIMUX_HOME='/tmp/custom-home'");
+    expect(command).toContain(`env AIMUX_HOME='/tmp/custom'"'"'home; echo unsafe'`);
🤖 Prompt for 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.

In `@src/dashboard/command-spec.test.ts` around lines 17 - 29, Add an additional
assertion case in getDashboardCommandSpec’s test to cover shell-escaping of
environment values that include single quotes or shell metacharacters, so
shellQuote regressions are detected. Extend the existing command string checks
in command-spec.test.ts by setting one env var with a tricky value and verifying
the generated dashboardCommand args still contain a safely escaped form, using
the same getDashboardCommandSpec and command inspection pattern already in the
test.
🤖 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 `@scripts/tui-smoke.mjs`:
- Around line 245-253: The tmux command construction in startDashboard is
serializing the entire inherited env object, which can leak secrets and clobber
tmux-managed variables. Change the env prefixing to include only the specific
dashboard-needed variables instead of spreading all entries, and keep the rest
of the command assembly intact. Apply the same selective env handling in the
other affected command builder referenced by the comment so both paths avoid
shell-prefixing the full parent environment.
- Line 1: The new tui-smoke script is failing lint because Node globals are
being used without being declared and one catch block is rethrowing a different
variable than the original error. Update the script’s top-level Node usage so
ESLint recognizes the runtime globals, and in the catch handling around the code
path near the existing error handler, preserve and rethrow the caught error
object directly instead of substituting another variable. Keep the fix within
scripts/tui-smoke.mjs so the file passes no-undef and preserve-caught-error.
- Around line 513-518: Honor allowFailure in the spawn error path for the child
process helper, not just in the close handler. Update the logic around
child.on("error", finish) in the smoke runner so the function can treat missing
executables the same way it treats nonzero exits when opts.allowFailure is true,
preserving the original failure context. Use the existing helper around child
process execution (the same code that handles stdout, stderr, and
child.on("close")) to route spawn errors through the same allowFailure decision
before rejecting.

In `@src/runtime-restart.ts`:
- Around line 258-271: The reconciliation logic in
reconcileProjectResultsWithVerification is fine, but this runtime behavior
change must be reflected in the built artifacts. After updating the source in
src/runtime-restart.ts, run the project build so dist/ is regenerated and the
shipped runtime restart logic matches the source change.

---

Nitpick comments:
In `@src/dashboard/command-spec.test.ts`:
- Around line 17-29: Add an additional assertion case in
getDashboardCommandSpec’s test to cover shell-escaping of environment values
that include single quotes or shell metacharacters, so shellQuote regressions
are detected. Extend the existing command string checks in command-spec.test.ts
by setting one env var with a tricky value and verifying the generated
dashboardCommand args still contain a safely escaped form, using the same
getDashboardCommandSpec and command inspection pattern already in the test.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71efcc08-a8a1-4ae6-a22e-6a430bfdef99

📥 Commits

Reviewing files that changed from the base of the PR and between 6cbceb9 and 3528ae6.

📒 Files selected for processing (6)
  • package.json
  • scripts/tui-smoke.mjs
  • src/dashboard/command-spec.test.ts
  • src/dashboard/command-spec.ts
  • src/runtime-restart.test.ts
  • src/runtime-restart.ts

Comment thread scripts/tui-smoke.mjs
Comment thread scripts/tui-smoke.mjs
Comment thread scripts/tui-smoke.mjs Outdated
Comment thread src/runtime-restart.ts
@TraderSamwise

Copy link
Copy Markdown
Owner Author

Independent sub-agent review found that dashboard build stamps did not include the env-dependent generated dashboard command. Fixed in 5f76191 by hashing the wrapped dashboard command into the stamp and adding a regression test that env changes invalidate the stamp.

@TraderSamwise
TraderSamwise merged commit 56b4375 into master Jun 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant