Skip to content

fix: move MCP message injection into send_message()#12

Merged
fraction12 merged 3 commits into
masterfrom
fix/mcp-message-injection
Mar 31, 2026
Merged

fix: move MCP message injection into send_message()#12
fraction12 merged 3 commits into
masterfrom
fix/mcp-message-injection

Conversation

@fraction12

Copy link
Copy Markdown
Owner

Problem

The structured messaging migration (PR #8) changed potato_send_message args from {message} to {type, subject, body}, but bridge.rs::build_inject_request() still called args.get("message"), which returned None for every structured message. Push delivery was silently dead — agents only saw messages when they polled get_messages().

Fix

Move injection into InterSessionState::send_message() where all the context already lives (from_pane, to_pane, content, roles). Remove the bridge's post-hoc RPC arg parsing (is_send_message_call, build_inject_request).

Any code path calling send_message() now automatically triggers PTY injection. One source of truth, no schema coupling.

Changes

  • state.rs: Added inject_tx: Option<UnboundedSender<InjectRequest>> to InterSessionState. send_message() fires injection request before enqueueing.
  • bridge.rs: Removed is_send_message_call(), build_inject_request(), and all post-dispatch injection logic.
  • main.rs: Clone inject_tx into state before bridge startup.

Tests

799 passed, 0 failed. Clippy clean.

fraction12 and others added 3 commits March 31, 2026 13:46
T-858: Log rotation detection — reset offset when file shrinks
T-862: inject_into_pane accepts pane_id (u64) instead of index (usize)
T-863: Remove duplicate raw-mode setup from TerminalGuard (ratatui owns it)
T-864: Wire dirty_rx into event loop for immediate PTY redraws
T-874: TextDone matches correct turn via turn_seq instead of blind last_mut
T-875: rename_session migrates orphaned UUID rows on SessionBound

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sh delivery

The structured messaging migration (PR #8) changed potato_send_message
args from {message} to {type, subject, body}, but the bridge's
build_inject_request() still looked for args.get("message"), which
silently returned None for every structured message. Agents only saw
messages when they polled get_messages() — push notifications were dead.

Root cause: the bridge was reconstructing injection intent by post-hoc
parsing of raw RPC args, duplicating knowledge that send_message()
already had.

Fix: InterSessionState::send_message() now owns injection. It has
from_pane, to_pane, content, and roles — everything needed. The bridge's
build_inject_request() and is_send_message_call() are removed entirely.

Any code path that calls send_message() now automatically triggers PTY
injection. No duplication, no schema drift, one source of truth.
@fraction12
fraction12 merged commit 617880d into master Mar 31, 2026
9 checks passed
@fraction12
fraction12 deleted the fix/mcp-message-injection branch March 31, 2026 18:33
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