Skip to content

composer: restore typed text when thread:send fails - #73

Closed
Yash990-bit wants to merge 1 commit into
TypeSafeAI:mainfrom
Yash990-bit:composer-restore
Closed

Yash990-bit wants to merge 1 commit into
TypeSafeAI:mainfrom
Yash990-bit:composer-restore

Conversation

@Yash990-bit

Copy link
Copy Markdown
Contributor

Summary

In Composer.tsx, hitting Enter or clicking Send immediately called setText("") before awaiting the send operation. When thread:send fails (e.g. runner is busy, working directory was removed, or an IPC error occurs), an error toast is surfaced to the user, but their typed message had already been wiped from the composer box.

This PR ensures that Composer preserves the typed message and restores it if onSend resolves to false (or rejects), while also keeping the unsent text state in App.tsx synchronized so the message is not lost across thread re-renders.

What Changed

  1. Composer.tsx:

    • Updated Props.onSend to accept Promise<boolean | void> | boolean | void.
    • submit() clears the box for immediate perceived responsiveness, but stores the typed text and restores it with focus if onSend returns false or throws.
    • Added a submittingRef guard to prevent accidental duplicate submissions during an in-flight send.
  2. App.tsx:

    • send() and sendDraft() now return Promise<boolean> (true on { ok: true }, false on failure).
    • On send failure, setUnsentFor() saves the text for the thread (or newly created thread from draft) so switching or re-renders keep the user's input intact.
  3. ThreadView.tsx & DraftView.tsx:

    • Updated onSend prop signature to match.
  4. e2e/app.spec.ts:

    • Added an end-to-end test asserting that when thread:send fails (tested via missing worktree cwd), the error toast is surfaced and the composer restores the exact typed message.

Testing

  • npm run build: built cleanly with no TypeScript or bundling errors.
  • npm test: all 180 unit and engine tests pass.
  • npx playwright test e2e/app.spec.ts: all 14 end-to-end browser tests pass.
  • Commits are cryptographically signed with SSH per repository rules.

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