cmux NEXT composer: a failed upload tries again on the next key or click, never refused for lack of one
Leo: "idk what's going on with video attachments"
A screen recording's tile showed "The app refused the agent connection." with Retry.
Cause
The host starts a chat upload only with the person's fresh key or click: AgentPaneModel uploadStage spends that gesture at chat.upload.begin and answers gestureRequired (shown as "The app refused the agent connection.") without one. After a failed upload, the composer's first automatic retry (#30572) went out on a 1 s timer with no gesture. The gesture was already spent by the first begin, so the host always refused that retry. With no key or click in the next 15 s, the tile then showed the refusal and lost the upload's own error (for example "The upload timed out: the app did not answer.").
Fix
composer/uploadRetry.ts: every automatic retry now waits for the person's next key or click in the page (never Return, which keeps its gesture for the send), as the last retry already did. Where no document exists (a test host), the 1 s timer stays.
Test
cd webviews && bun test test/composer-upload-first-send.test.tsx
- Red on base (6aaa616327e, test only):
a failed upload never tries again without the person's gesture, and keeps its own wordsfails withrefused = [2]. The 1 s retry went out with no gesture. - Green on head: 9 pass. The existing retry tests now drive the retry with the person's key.
Observed / Not run
- Ran: the suite above, red then green;
scripts/web-lint.sh(format and fast lints; this host leaves the type-aware lint to CI);prepush-gate.py;tsc, which reports no errors in the changed files. - Not run: a capture of the real app sending a recording.
Changelog
Fixed: a failed attachment upload tries again on your next key or click instead of showing "The app refused the agent connection."
No capture: no UI layout changes, only when a retry starts.
Agent session: agent session
š¤ Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes failed attachment uploads so automatic retries wait for the person's next key or click instead of firing on a 1-second timer. The timer-based retry was always refused by the host ("The app refused the agent connection."), and that refusal replaced the upload's own error on its tile.
- Every retry now waits for the person's next key or click in the page. Return and lone modifier keys (Shift, Control, Alt, Meta, CapsLock, Fn) never count, since the host records no gesture for them.
- The 1-second timer remains only where no page exists (a test host).
- Tests now restore their patched document listener on every path, including failures.