Skip to content

Add isolated aimux-dev runtime#9

Merged
TraderSamwise merged 3 commits into
masterfrom
feat/dev-runtime
May 22, 2026
Merged

Add isolated aimux-dev runtime#9
TraderSamwise merged 3 commits into
masterfrom
feat/dev-runtime

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • add AIMUX_HOME and daemon host/port overrides for isolated runtimes
  • add an aimux-dev CLI entrypoint using ~/.aimux-dev and port 43191
  • add local GUI dev scripts and documentation
  • include relay deploy/runtime fixes needed from the dev setup work

Verification

  • yarn typecheck
  • yarn test src/paths.test.ts src/daemon.test.ts
  • yarn build
  • yarn --cwd app typecheck
  • yarn --cwd app test
  • yarn lint
  • yarn --cwd app lint
  • git diff --check
  • aimux-dev daemon restart/status on port 43191
  • aimux daemon status remains on port 43190
  • local Expo web dev server returned HTTP 200 on localhost:8081

Summary by CodeRabbit

  • New Features

    • New aimux-dev CLI and local dev scripts (dev:local, dev:gui, dev:daemon) for an isolated GUI/daemon development workflow
    • Support for AIMUX_HOME to customize global installation/dev directory
  • Documentation

    • README: new "For GUI and daemon development" setup section
    • Added detailed dev-runtime guide with step‑by‑step isolated dev loop
  • Refactor

    • Improved daemon host/port handling and networking configuration

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e3c745c1-94ee-42b5-9048-b4c8529e9c85

📥 Commits

Reviewing files that changed from the base of the PR and between b854b08 and c9ef29f.

📒 Files selected for processing (2)
  • src/daemon.test.ts
  • src/daemon.ts

📝 Walkthrough

Walkthrough

The PR adds an isolated dev runtime (aimux-dev) with env-driven paths and daemon host/port, refactors daemon networking and stdio handling to use dynamic configuration, provides docs and README guidance for the dev loop, and includes tests and minor supporting updates.

Changes

Isolated Development Runtime with Dynamic Daemon Configuration

Layer / File(s) Summary
Environment variable overrides and path resolution
src/paths.ts, src/paths.test.ts
AIMUX_HOME now overrides the global runtime directory (supports ~/~/...), and tests verify derived daemon log paths and env restore behavior.
CLI entrypoint and package wiring
bin/aimux-dev, package.json
Adds bin/aimux-dev executable that seeds dev env defaults; package.json registers aimux-dev and adds dev:gui/dev:daemon scripts.
Daemon network configuration, spawning, and tests
src/daemon.ts, src/daemon.test.ts
Adds getDaemonHost()/getDaemonPort() and getDaemonBaseUrl(); uses dynamic host/port for routing, health adoption, start/listen binding, and persisted state; switches stdio handling to openSync/closeSync and ensures fds are closed on spawn errors; tests cover env overrides, invalid host rejection, and adoption via /health.
Developer documentation and app integration
README.md, docs/dev-runtime.md, app/package.json
New docs/dev-runtime.md and README section describe the aimux-dev workflow and commands; app/package.json gains dev:local to run Expo against the local dev daemon.
Supporting updates and fixes
src/login-flow.ts, app/eslint.config.mjs, relay/wrangler.toml
Standardizes HTML content-type responses, adds .vercel/ to ESLint ignores, and updates Wrangler config with account_id and new_sqlite_classes.

Sequence Diagram

sequenceDiagram
  participant Client as Client Process
  participant Env as AIMUX_DAEMON_HOST/AIMUX_DAEMON_PORT
  participant Daemon as Daemon Process
  Client->>Env: getDaemonHost()/getDaemonPort()
  Env-->>Client: host & port
  Client->>Daemon: GET /health (probe via getDaemonBaseUrl())
  Daemon-->>Client: {pid, port}
  Client->>Client: ensureDaemonRunning() adopts daemon & persists port
  Client->>Daemon: requestDaemonJson() (dynamic URL)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 In a burrow of code I quietly skulk,
A dev-daemon hums where envs do the talk,
Ports and homes swapped for a sandboxed den,
HMR hops and backend builds, over and then—
🥕 thump, the rabbit nods: “dev loop again.”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 and concisely summarizes the main change: introducing an isolated development runtime for aimux-dev with environment overrides and dedicated tooling.
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 feat/dev-runtime

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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/daemon.ts (1)

90-104: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Close partially opened stdio descriptors on failure.

If Line 92 succeeds and Line 93 throws, the first fd is leaked because the catch path does not close already-opened descriptors.

🧹 Proposed fix
 function loggingChildStdio(path: string): { stdio: StdioOptions; close: () => void } {
   const logging = getLoggingConfig();
   if (!logging.enabled) return { stdio: "ignore", close: () => {} };
+  let stdout: number | null = null;
+  let stderr: number | null = null;
   try {
     ensureParent(path);
-    const stdout = openSync(path, "a");
-    const stderr = openSync(path, "a");
+    stdout = openSync(path, "a");
+    stderr = openSync(path, "a");
     let closed = false;
     const close = () => {
       if (closed) return;
       closed = true;
-      closeSync(stdout);
-      closeSync(stderr);
+      if (stdout !== null) closeSync(stdout);
+      if (stderr !== null) closeSync(stderr);
     };
     return { stdio: ["ignore", stdout, stderr], close };
   } catch {
+    if (stdout !== null) closeSync(stdout);
+    if (stderr !== null) closeSync(stderr);
     return { stdio: "ignore", close: () => {} };
   }
 }
🤖 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/daemon.ts` around lines 90 - 104, The code can leak an open file
descriptor if ensureParent(path) or the second openSync(path, "a") throws;
modify the stdio-opening logic (the block that calls ensureParent, openSync and
defines close) to track each opened fd in local variables (e.g., stdoutFd,
stderrFd), open them sequentially, and if any subsequent step throws ensure you
close any previously opened fd(s) in the catch path before rethrowing or
returning the fallback; also ensure the returned close() (the close variable)
closes both stdoutFd and stderrFd using closeSync when present.
🤖 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 `@src/daemon.ts`:
- Around line 32-35: getDaemonHost currently returns any AIMUX_DAEMON_HOST value
unvalidated, which lets callers (like the daemon bind logic) expose services to
non-loopback interfaces; update getDaemonHost to only accept loopback addresses
(127.0.0.1 or ::1) by default and fall back to DEFAULT_DAEMON_HOST for any other
value, and add an explicit opt-in environment flag (e.g.,
AIMUX_DAEMON_HOST_ALLOW_PUBLIC='1') to permit non-loopback values; implement
validation using Node's net.isIP or equivalent, reference getDaemonHost and any
direct reads of process.env.AIMUX_DAEMON_HOST to ensure they use the new
validated getter.

---

Outside diff comments:
In `@src/daemon.ts`:
- Around line 90-104: The code can leak an open file descriptor if
ensureParent(path) or the second openSync(path, "a") throws; modify the
stdio-opening logic (the block that calls ensureParent, openSync and defines
close) to track each opened fd in local variables (e.g., stdoutFd, stderrFd),
open them sequentially, and if any subsequent step throws ensure you close any
previously opened fd(s) in the catch path before rethrowing or returning the
fallback; also ensure the returned close() (the close variable) closes both
stdoutFd and stderrFd using closeSync when present.
🪄 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 Plus

Run ID: fadd99c4-535d-4c8d-8078-1bc48d22e96a

📥 Commits

Reviewing files that changed from the base of the PR and between 45aa293 and b854b08.

📒 Files selected for processing (12)
  • README.md
  • app/eslint.config.mjs
  • app/package.json
  • bin/aimux-dev
  • docs/dev-runtime.md
  • package.json
  • relay/wrangler.toml
  • src/daemon.test.ts
  • src/daemon.ts
  • src/login-flow.ts
  • src/paths.test.ts
  • src/paths.ts

Comment thread src/daemon.ts
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