[Bugfix #584] Pace multi-line afx send messages to prevent paste detection#657
Merged
waleedkadous merged 4 commits intomainfrom Apr 5, 2026
Merged
Conversation
…tection When afx send delivers messages >3 lines, write line-by-line with 10ms delays instead of a single write() call. This prevents the receiving terminal from classifying the input as a paste and swallowing the final Enter.
When multiple multi-line messages are buffered for the same session, writeMessageToSession now accepts a delayOffset and returns the end time so SendBuffer.flush() can chain messages without interleaving.
Move pacing logic to message-write.ts to avoid circular dependency between tower-routes.ts and tower-cron.ts. Also fix tower-cron.ts cron message delivery to use the same pacing.
Contributor
Author
Architect ReviewClean fix. Good extraction of Go ahead and merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #584
Root Cause
When
afx senddelivers a message longer than 3 lines, the entire formatted text is written to the PTY in a singlesession.write()call. The receiving terminal (Claude Code) classifies the rapid multi-line input as a "paste" operation, which causes the final\r(Enter) — sent 50ms later — to be swallowed. The message appears on screen but never gets submitted.Fix
Extracted a
writeMessageToSession()helper inmessage-write.tsthat paces multi-line output:write()+ 50ms delayed Enter (existing behavior, works fine)All three delivery paths now use this helper:
handleSend()(tower-routes.ts)deliverBufferedMessage()(tower-routes.ts)tower-cron.tsThe helper also supports a
delayOffsetparameter and returns the end time, enablingSendBuffer.flush()to serialize multiple buffered messages without interleaving.Test Plan
CMAP Review
delayOffsetparameter and return value to serialize writes.tower-cron.tsand suggested extracting to shared module. Fixed by creatingmessage-write.tsand updating tower-cron.ts.