Skip to content

Fix restart zombie PID handling and document local install flow - #200

Merged
TraderSamwise merged 6 commits into
masterfrom
chore/tui-next-32
Jun 20, 2026
Merged

Fix restart zombie PID handling and document local install flow#200
TraderSamwise merged 6 commits into
masterfrom
chore/tui-next-32

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • treat zombie PIDs as exited during coherent restart waits
  • document that plain aimux uses the installed bundle behind ~/.local/bin/aimux
  • replace the source-build yarn link guidance with the local release install flow

Verification

  • yarn vitest run src/runtime-restart.test.ts
  • yarn typecheck
  • yarn lint
  • yarn test (pre-push)
  • local release install verified aimux restart --json and aimux doctor versions

Summary by CodeRabbit

  • Documentation

    • Clarified installation workflows for local builds with improved examples.
    • Distinguished between development symlinks and stable installed artifacts.
    • Added restart guidance following local CLI installation.
  • Improvements

    • Enhanced process state detection during daemon restart operations.

@vercel

vercel Bot commented Jun 20, 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 20, 2026 12:28pm

@coderabbitai

coderabbitai Bot commented Jun 20, 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 10 minutes and 6 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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ebf39a2-6d8b-4ec2-96a5-68e3d72f8560

📥 Commits

Reviewing files that changed from the base of the PR and between 8824181 and 36cab6b.

📒 Files selected for processing (4)
  • AGENTS.md
  • README.md
  • src/runtime-restart.test.ts
  • src/runtime-restart.ts
📝 Walkthrough

Walkthrough

Adds zombie-process detection to defaultIsPidAlive in runtime-restart.ts by invoking ps -o stat= and treating a Z-prefixed state as not alive. Updates README.md and AGENTS.md to replace the yarn link global-symlink approach with a yarn release:asset + scripts/install.sh local release workflow.

Changes

Zombie Process Liveness Fix

Layer / File(s) Summary
defaultIsPidAlive zombie detection
src/runtime-restart.ts
Adds execFileSync import and a ps -o stat= -p <pid> call; returns false when the reported state begins with Z, treating zombie processes as not alive on non-Windows.

Local Release Install Documentation

Layer / File(s) Summary
README and AGENTS.md local release workflow
README.md, AGENTS.md
README.md replaces the frozen-build snippet (was yarn link-based) with AIMUX_RELEASE_VERSION=local-$(git rev-parse --short HEAD) + scripts/install.sh, adds prose distinguishing stable install from live symlink, and notes aimux restart requirement; AGENTS.md adds matching guidance under the runtime verification rule.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TraderSamwise/aimux#199: Introduces the unified coherent restart flow in src/runtime-restart.ts that this PR's zombie-detection change directly builds on.

Poem

🐇 A zombie shall trouble us no more,
With ps -o stat= we check the score.
If "Z" is the letter, we call it dead,
Install your release with scripts/install.sh instead.
No symlinks needed—just bundle and run,
aimux restart and you're done! 🥕

🚥 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 directly captures the two main components of the changeset: fixing zombie PID handling in restart operations and documenting the local installation flow, matching both the code changes and PR objectives.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/tui-next-32

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

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/runtime-restart.ts (1)

117-131: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

ps unavailability causes false negatives for live processes.

If execFileSync("ps", ...) throws because ps is not installed (e.g., minimal Alpine containers, some embedded environments), the catch block returns false, incorrectly reporting an alive process as dead. This would cause waitForPidExit to return immediately without waiting, potentially racing with process cleanup.

Consider isolating the ps failure from "process not alive" by catching and handling the execFileSync error separately:

Proposed fix to handle ps unavailability gracefully
 function defaultIsPidAlive(pid: number): boolean {
   try {
     process.kill(pid, 0);
-    if (process.platform !== "win32") {
-      const state = execFileSync("ps", ["-o", "stat=", "-p", String(pid)], {
-        encoding: "utf8",
-        stdio: ["ignore", "pipe", "ignore"],
-      }).trim();
-      if (state.startsWith("Z")) return false;
-    }
-    return true;
   } catch {
     return false;
   }
+  if (process.platform !== "win32") {
+    try {
+      const state = execFileSync("ps", ["-o", "stat=", "-p", String(pid)], {
+        encoding: "utf8",
+        stdio: ["ignore", "pipe", "ignore"],
+      }).trim();
+      if (state.startsWith("Z")) return false;
+    } catch {
+      // ps unavailable or failed; fall through to treat as alive
+    }
+  }
+  return true;
 }
🤖 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/runtime-restart.ts` around lines 117 - 131, The defaultIsPidAlive
function conflates two different failure scenarios: when the process is truly
not alive and when the ps command is unavailable. When execFileSync throws an
exception (e.g., ps command not found), the outer catch block returns false,
incorrectly marking alive processes as dead. To fix this, wrap only the
execFileSync call in a separate try-catch block that gracefully handles the
error by returning true (since process.kill(pid, 0) already succeeded), and
reserve the outer catch block only for when process.kill itself throws an
exception, indicating the process is actually not alive. This way,
unavailability of ps does not cause false negatives for live processes.
♻️ Duplicate comments (2)
README.md (1)

87-89: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same hardcoded darwin-arm64 platform issue in "Build from source" section.

Line 89 has the same platform hardcoding concern as the earlier "frozen local build" example. Users on non-ARM64 systems will not be able to copy this command as-is.

🤖 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 `@README.md` around lines 87 - 89, The scripts/install.sh command on line 89
contains a hardcoded platform reference aimux-darwin-arm64.tar.gz which assumes
ARM64 architecture and will fail for users on other platforms. Replace the
hardcoded platform string with a variable or dynamic reference that detects the
current system architecture and selects the appropriate binary file (such as
aimux-darwin-x86_64.tar.gz for Intel systems). Consider using a pattern that
matches the output from the yarn release:asset command or documenting
platform-specific variations for different architectures.
AGENTS.md (1)

102-103: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same hardcoded darwin-arm64 platform issue in AGENTS.md code block.

The bash example in the added code block (lines 102–103) has the same platform-hardcoding concern as README.md. Users on non-Apple-Silicon systems will not be able to copy this command verbatim.

🤖 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 `@AGENTS.md` around lines 102 - 103, The bash example in AGENTS.md has a
hardcoded platform identifier `darwin-arm64` in the file path
`release/aimux-darwin-arm64.tar.gz`, which will not work for users on different
platforms or architectures. Replace the hardcoded platform string in the tar.gz
filename with a variable placeholder or instruction that allows users to
dynamically specify their appropriate platform (such as darwin-arm64,
darwin-x64, linux-x64, etc.) so the command is usable across different systems.
🤖 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 `@README.md`:
- Around line 66-67: The install example in the README hardcodes darwin-arm64
platform identifier, which leaves users on other platforms (Intel macOS, Linux,
Windows) without clear guidance on which tarball to use. Replace the hardcoded
darwin-arm64 example with either: a documentation section listing all supported
platform identifiers (darwin-x64, linux-x64, linux-arm64, win32-x64,
darwin-arm64) with brief descriptions of which systems they target, or add
instructions showing how to determine the correct platform identifier for the
user's system before running the scripts/install.sh command. Ensure the example
or guidance makes it clear how to substitute the correct platform identifier for
the AIMUX_RELEASE_VERSION and scripts/install.sh lines.

---

Outside diff comments:
In `@src/runtime-restart.ts`:
- Around line 117-131: The defaultIsPidAlive function conflates two different
failure scenarios: when the process is truly not alive and when the ps command
is unavailable. When execFileSync throws an exception (e.g., ps command not
found), the outer catch block returns false, incorrectly marking alive processes
as dead. To fix this, wrap only the execFileSync call in a separate try-catch
block that gracefully handles the error by returning true (since
process.kill(pid, 0) already succeeded), and reserve the outer catch block only
for when process.kill itself throws an exception, indicating the process is
actually not alive. This way, unavailability of ps does not cause false
negatives for live processes.

---

Duplicate comments:
In `@AGENTS.md`:
- Around line 102-103: The bash example in AGENTS.md has a hardcoded platform
identifier `darwin-arm64` in the file path `release/aimux-darwin-arm64.tar.gz`,
which will not work for users on different platforms or architectures. Replace
the hardcoded platform string in the tar.gz filename with a variable placeholder
or instruction that allows users to dynamically specify their appropriate
platform (such as darwin-arm64, darwin-x64, linux-x64, etc.) so the command is
usable across different systems.

In `@README.md`:
- Around line 87-89: The scripts/install.sh command on line 89 contains a
hardcoded platform reference aimux-darwin-arm64.tar.gz which assumes ARM64
architecture and will fail for users on other platforms. Replace the hardcoded
platform string with a variable or dynamic reference that detects the current
system architecture and selects the appropriate binary file (such as
aimux-darwin-x86_64.tar.gz for Intel systems). Consider using a pattern that
matches the output from the yarn release:asset command or documenting
platform-specific variations for different architectures.
🪄 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: 26c53c29-a2a4-4ce6-885b-03f1fe2d4126

📥 Commits

Reviewing files that changed from the base of the PR and between 4cd8ad2 and 8824181.

📒 Files selected for processing (3)
  • AGENTS.md
  • README.md
  • src/runtime-restart.ts

Comment thread README.md Outdated
@TraderSamwise
TraderSamwise merged commit 76b16ed into master Jun 20, 2026
1 check 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