fix: composer send attempt while signed out reopens login instead of dead-ending
What
On chat.recoupable.dev, a signed-out visitor who dismisses the Privy login modal can type in the composer but can never send: the workspace never provisions without auth, so the send button stays permanently disabled and Enter is a silent no-op (form.requestSubmit() bails when the default submit button is disabled). This PR turns that dead end into a login reprompt: any send attempt (button click or Enter) while unauthenticated reopens the Privy login modal via usePrivy().login().
Part of recoupable/chat#1902 (item C4).
How
- New
lib/chat/getComposerSubmitAction.ts: pure decision function returning"send" | "prompt-login" | "disabled". Auth is checked before workspace blockers, because the workspace never provisions for anonymous visitors; without that ordering the signed-out state is permanently "disabled". components/VercelChat/ChatInput.tsx: computes the action fromusePrivy()(ready,authenticated,login) plus the existing context flags. When the action isprompt-loginthe send button stays enabled and the submit handler callslogin()instead ofhandleSendMessage. Signed-in behavior (workspace gating, stop-while-generating, empty-input no-op) is unchanged. The button also gains a state-accuratearia-label("Sign in to send" / "Send message" / "Stop response").login()is never called before Privy finishes initializing (readygate in the decision function).
Draft persistence: the composer draft is React state (useState("") in hooks/useVercelChat.ts) inside the <Chat> instance, which NewChatBootstrap keeps mounted with a stable ref-based id across the provisioning transition. The Privy modal is an overlay, so nothing unmounts: the drafted text survives dismissing and reopening the modal and the full auth flow, and sends normally once the workspace provisions after login.
How to test
- Open the preview signed out and dismiss the auto-opened Privy login modal.
- Type a message in the composer. The send button is now enabled (previously stuck disabled).
- Click send or press Enter: the Privy login modal reopens and the typed text stays in the composer.
- Dismiss again, press Enter again: modal reopens again (repeatable, no dead end).
- Complete login: the draft is still in the composer; once the workspace dot turns green, send works normally.
- Signed in: empty-input Enter still does nothing, sends still gate on workspace readiness, and the stop button still works mid-response.
Tests: pnpm exec vitest run (282 passed, incl. 6 new for getComposerSubmitAction); pnpm exec tsc --noEmit clean for the changed files.
Preview verification to follow in a PR comment.
🤖 Generated with Claude Code
Summary by cubic
Fixes the signed-out composer dead end: pressing Send or Enter now reopens the Privy login modal and preserves the draft. Addresses recoupable/chat#1902 (C4).
- Bug Fixes
- Added
getComposerSubmitActionto decide between "send" | "prompt-login" | "disabled", checking auth before workspace blockers. - Updated
VercelChat/ChatInputto callusePrivy().login()from@privy-io/react-authon unauthenticated send, keep Send enabled with correct aria-labels, and guard until Privy is ready; drafts persist and signed-in behavior is unchanged.
- Added