Skip to content

Restore agent chat composer#52

Merged
TraderSamwise merged 3 commits into
masterfrom
work/next-ui
May 30, 2026
Merged

Restore agent chat composer#52
TraderSamwise merged 3 commits into
masterfrom
work/next-ui

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • restore the agent chat composer and metadata endpoint send path
  • send multiline input through tmux as text followed by enter
  • keep the composer visible in native terminal mode

Verification

  • yarn typecheck
  • yarn build
  • yarn test src/metadata-server.test.ts
  • yarn --cwd app typecheck
  • yarn --cwd app test lib/api.test.ts
  • yarn lint
  • yarn --cwd app lint (pre-existing warnings only)
  • iOS simulator screenshot check for native composer layout

Summary by CodeRabbit

  • New Features

    • Send text messages to running agents via the chat interface with a composer and send button.
    • UI shows loading and error states while messages are submitted.
  • Backend/API

    • Added server endpoint and runtime support to accept and forward agent input.
  • Tests

    • Added HTTP and routing tests covering agent-input submission and validation.

Review Change Stack

@vercel

vercel Bot commented May 30, 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 May 30, 2026 2:57pm

@coderabbitai

coderabbitai Bot commented May 30, 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: 1fbcf138-7501-4a26-b907-3ff02618a7b2

📥 Commits

Reviewing files that changed from the base of the PR and between c14cba4 and 5d16b9a.

📒 Files selected for processing (2)
  • src/metadata-server.test.ts
  • src/metadata-server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/metadata-server.ts

📝 Walkthrough

Walkthrough

This PR adds agent input messaging: client UI composes and sends text via a new sendAgentInput API to POST /agents/input, which validates and dispatches to an optional lifecycle handler, triggers onChange, and ultimately writes the text to running session transports via session runtime wiring.

Changes

Agent Input Messaging

Layer / File(s) Summary
Client UI and API contract
app/components/screens/AgentChatScreen.tsx, app/lib/api.ts, app/lib/api.test.ts
AgentChatScreen adds state (draft, sendBusy, sendError), handlers (handleSendMessage, handleComposerKeyPress), KeyboardAvoidingView layout, and composer wiring. Client API adds SendAgentInputResponse and sendAgentInput. Relay routing tests include the new API call and proxy expectation.
Server endpoint and validation
src/metadata-server.ts, src/metadata-server.test.ts
MetadataServer adds optional lifecycle.sendAgentInput and implements POST /agents/input with validation (sessionId required, non-blank text), returns 400/501 when appropriate, invokes the lifecycle hook, triggers onChange(), and returns the hook result. Tests cover successful dispatch and blank-text rejection.
Session runtime and multiplexer integration
src/multiplexer/session-runtime-core.ts, src/multiplexer/agent-io-methods.ts, src/multiplexer/dashboard-model.ts
Session runtime exports sendAgentInput to write text+CR to sessions (retargeting tmux when needed). agentIoMethods exposes the method and dashboard-model wires lifecycle actions to host.sendAgentInput, completing the flow from HTTP to session I/O.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TraderSamwise/aimux#21: Both PRs modify the POST /agents/input endpoint in src/metadata-server.ts to route agent input through the service lifecycle, overlapping in the same request/handler path.

Poem

🐰 I typed a note, a carrot for the bot,
From composer to server it hopped a lot.
Validated, relayed, then sent with care —
Through tmux or transport, the text was there.
Hop! The agent answers — coding bliss in the air.

🚥 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 'Restore agent chat composer' is directly relevant to the changeset, which adds agent input submission functionality including the composer UI, API endpoints, and message sending.
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 work/next-ui

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

🧹 Nitpick comments (1)
src/metadata-server.test.ts (1)

1348-1375: ⚡ Quick win

Add negative-path coverage for /agents/input.

Line 1348 covers success only. Please add explicit cases for missing sessionId, empty/whitespace text, and unsupported lifecycle hook (501) so this endpoint contract stays locked.

🤖 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.test.ts` around lines 1348 - 1375, Add negative-path
tests for the /agents/input handler in the metadata-server.test.ts suite: create
cases that call POST /agents/input with (1) a missing sessionId (omit sessionId
from body) and assert a non-2xx response and an error payload, (2) empty or
whitespace-only text values (e.g., "" and "   ") and assert validation errors,
and (3) configure MetadataServer without a lifecycle.sendAgentInput (or with a
lifecycle that returns a 501-like unsupported response) and assert the endpoint
responds with 501 and an appropriate error body; use the same server start/stop
pattern and the server.getAddress() base, and reference MetadataServer and
lifecycle.sendAgentInput to locate where to change the test setup.
🤖 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 2656-2659: The request validation currently accepts strings
containing only whitespace because it checks body.text length without trimming;
update the check in the handler that examines body.text so it rejects inputs
where body.text.trim().length === 0 (call send(res, 400, { ok: false, error:
"text is required" }) and return) instead of only checking raw length, ensuring
whitespace-only submissions are treated as empty.

---

Nitpick comments:
In `@src/metadata-server.test.ts`:
- Around line 1348-1375: Add negative-path tests for the /agents/input handler
in the metadata-server.test.ts suite: create cases that call POST /agents/input
with (1) a missing sessionId (omit sessionId from body) and assert a non-2xx
response and an error payload, (2) empty or whitespace-only text values (e.g.,
"" and "   ") and assert validation errors, and (3) configure MetadataServer
without a lifecycle.sendAgentInput (or with a lifecycle that returns a 501-like
unsupported response) and assert the endpoint responds with 501 and an
appropriate error body; use the same server start/stop pattern and the
server.getAddress() base, and reference MetadataServer and
lifecycle.sendAgentInput to locate where to change the test setup.
🪄 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: 1aed76ad-2425-48e9-81ad-6bdea18c023d

📥 Commits

Reviewing files that changed from the base of the PR and between 3cba828 and c14cba4.

📒 Files selected for processing (8)
  • app/components/screens/AgentChatScreen.tsx
  • app/lib/api.test.ts
  • app/lib/api.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/multiplexer/agent-io-methods.ts
  • src/multiplexer/dashboard-model.ts
  • src/multiplexer/session-runtime-core.ts

Comment thread src/metadata-server.ts Outdated
@TraderSamwise
TraderSamwise merged commit a30b82b into master May 30, 2026
3 checks passed
@TraderSamwise
TraderSamwise deleted the work/next-ui branch May 30, 2026 15:01
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