Skip to content

Route teammate work through durable tasks#8

Merged
TraderSamwise merged 11 commits into
masterfrom
fix/teammate-task-workflow
May 22, 2026
Merged

Route teammate work through durable tasks#8
TraderSamwise merged 11 commits into
masterfrom
fix/teammate-task-workflow

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • route task prompt bodies through durable workflow delivery
  • replace raw teammate send/initialPrompt paths with durable teammate tasks and initialTask
  • await tmux prompt submission before marking input operations submitted
  • isolate config default tests from global user config

Verification

  • yarn verify

Summary by CodeRabbit

  • New Features

    • Relay-driven polling mode for live chat/agent output.
  • Documentation

    • Deployment and README updated to use aimux.app relay URLs and Node.js 22+.
    • Teammate API docs updated: use durable teammate tasks endpoint and initialTask (title/body) workflow.
  • Chores

    • Raised Node.js minimum to 22 and updated relay URLs across examples/environments.
    • Added web export script and Vercel config.
  • Refactor

    • Teammate creation/workflow switched to durable task-based delegation (initialTask).

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: d0802fb7-7b34-4f6f-9d13-ba23f567197d

📥 Commits

Reviewing files that changed from the base of the PR and between bd46360 and 424ca99.

📒 Files selected for processing (2)
  • src/metadata-server.test.ts
  • src/metadata-server.ts

📝 Walkthrough

Walkthrough

This PR migrates defaults to aimux.app and raises Node.js requirement to 22, centralizes project HTTP calls via a relay-aware helper, adds chat relay polling, converts teammate delegation to durable tasks (new /agents/teammates/tasks and initialTask), retires the old send route, and refactors tmux prompt submission to await acceptance with updated tests.

Changes

Relay-driven architecture with durable teammate tasks and Node.js 22

Layer / File(s) Summary
Infrastructure: Node.js 22 and aimux.app domain migration
.env.example, app/.env.example, app/app.config.js, app/package.json, app/vercel.json, package.json, scripts/install.sh, relay/wrangler.toml, docs/deployment.md, README.md, src/login-flow.ts, src/main.ts, src/config.ts, src/config.test.ts
Node.js engine requirement raised to >=22; install script and docs updated; default relay/web app domains and example env values migrated to aimux.app/relay.aimux.app; Vercel web export config added.
App API relay routing centralization and chat polling
app/lib/api.ts, app/lib/api.test.ts, app/app/(main)/agent/[sessionId]/chat.tsx
New callProjectJson centralizes project-route requests and forwards via connected relay when available; many API functions now use it. Chat supports relay-driven polling mode that fetches history and live output on an interval. Tests verify routing behaviors.
Teammate lifecycle: migration from initialPrompt to durable task assignment
src/metadata-server.ts, src/metadata-server.test.ts, src/multiplexer/session-actions.ts, src/multiplexer/session-actions.test.ts, src/multiplexer/dashboard-model.ts, src/multiplexer/dashboard-model.test.ts, src/multiplexer/dashboard-tail-methods.ts, src/session-bootstrap.ts, src/session-bootstrap.test.ts, README.md
Introduces TeammateTaskBody, helpers to derive prompt/description, accepts initialTask on create to optionally assign a durable task, implements /agents/teammates/tasks for durable assignment, and retires /agents/teammates/send with HTTP 410. Session/dashboard/bootstrap types and tests updated accordingly.
Tmux submission acceptance and task workflow improvements
src/multiplexer/session-runtime-core.ts, src/multiplexer/session-runtime-core.test.ts, src/task-workflow.ts, src/task-dispatcher.test.ts, src/relay-client.test.ts
Refactor to await tmux prompt submission acceptance before marking submitted (new waitForTmuxAgentSubmit export). Add taskBody helper and use it for initial thread messages and assigned prompts; tests extended to assert prompt construction and submission acceptance/failure paths. RelayClient test added for Node/WebSocket runtime checks.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

"🐰 I hopped through code and changed the streams,
Node twenty-two now powers the dreams,
Relays hum at relay.aimux.app,
Teammates get tasks, no raw-send trap,
Tmux waits — then submits, clean as creams!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.51% 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 across the changeset: routing teammate work through durable tasks instead of raw send/initialPrompt paths.
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 fix/teammate-task-workflow

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

2213-2224: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Validate empty teammateSessionId as a 400 input error.

An empty teammateSessionId currently falls through to the "not attached" 404 path, which is misleading for malformed input.

💡 Suggested fix
 const parentSessionId = body.parentSessionId?.trim() ?? "";
 const teammateSessionId = body.teammateSessionId?.trim() ?? "";
+if (!teammateSessionId) {
+  send(res, 400, { ok: false, error: "teammateSessionId is required" });
+  return;
+}
 const resolved = this.resolveDirectTeammates(parentSessionId);
🤖 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/metadata-server.ts` around lines 2213 - 2224, The code currently treats
an empty teammateSessionId as "not attached" resulting in a 404; add an explicit
validation immediately after computing teammateSessionId (the variable from
body.teammateSessionId?.trim() ?? "") to check for an empty string and call
send(res, 400, { ok: false, error: "missing or empty teammateSessionId" }) (or
similar input-error message) before calling resolveDirectTeammates() / searching
via resolved.teammates in resolveDirectTeammates and before the teammate lookup
so malformed input yields a 400 instead of a 404.
🤖 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/metadata-server.ts`:
- Around line 493-495: The current logic in teammateTaskDescription uses
body.body even when it's only whitespace, causing it to ignore a valid prompt;
update the text selection so that text = typeof body.body === "string" &&
body.body.trim() !== "" ? body.body.trim() : prompt (or equivalent) so that an
empty/whitespace body falls back to prompt before computing firstLine(text) and
slicing to 120 chars.

---

Outside diff comments:
In `@src/metadata-server.ts`:
- Around line 2213-2224: The code currently treats an empty teammateSessionId as
"not attached" resulting in a 404; add an explicit validation immediately after
computing teammateSessionId (the variable from body.teammateSessionId?.trim() ??
"") to check for an empty string and call send(res, 400, { ok: false, error:
"missing or empty teammateSessionId" }) (or similar input-error message) before
calling resolveDirectTeammates() / searching via resolved.teammates in
resolveDirectTeammates and before the teammate lookup so malformed input yields
a 400 instead of a 404.
🪄 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: a2c23bfe-4993-4c4d-a4b4-2aef2179f03f

📥 Commits

Reviewing files that changed from the base of the PR and between 4c00397 and bd46360.

📒 Files selected for processing (31)
  • .env.example
  • README.md
  • app/.env.example
  • app/app.config.js
  • app/app/(main)/agent/[sessionId]/chat.tsx
  • app/lib/api.test.ts
  • app/lib/api.ts
  • app/package.json
  • app/vercel.json
  • docs/deployment.md
  • package.json
  • relay/wrangler.toml
  • scripts/install.sh
  • src/config.test.ts
  • src/config.ts
  • src/login-flow.ts
  • src/main.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/multiplexer/dashboard-model.test.ts
  • src/multiplexer/dashboard-model.ts
  • src/multiplexer/dashboard-tail-methods.ts
  • src/multiplexer/session-actions.test.ts
  • src/multiplexer/session-actions.ts
  • src/multiplexer/session-runtime-core.test.ts
  • src/multiplexer/session-runtime-core.ts
  • src/relay-client.test.ts
  • src/session-bootstrap.test.ts
  • src/session-bootstrap.ts
  • src/task-dispatcher.test.ts
  • src/task-workflow.ts
💤 Files with no reviewable changes (6)
  • src/multiplexer/dashboard-model.test.ts
  • src/multiplexer/dashboard-tail-methods.ts
  • app/app.config.js
  • src/multiplexer/session-actions.test.ts
  • src/multiplexer/dashboard-model.ts
  • src/multiplexer/session-actions.ts

Comment thread src/metadata-server.ts Outdated
@TraderSamwise

Copy link
Copy Markdown
Owner Author

Fixed in 424ca99 - empty teammateSessionId is now rejected as a 400 input error before teammate lookup, and coverage was added for that path.

@TraderSamwise
TraderSamwise merged commit 45aa293 into master May 22, 2026
1 check passed
@TraderSamwise
TraderSamwise deleted the fix/teammate-task-workflow branch May 22, 2026 11:02
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