So currently chat input box uses same post status form which blocks all interaction while it's sending, it makes sense for statuses. When chatting you often want to start typing the next message immediately after hitting enter, but this mechanism blocks it, it becomes very clunky.
The challenge is handling posts that fail to send if we unlock the form immediately. they'd have to retry sending a few times and somehow indicate that they haven't been sent.
Designs
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
The challenge is handling posts that fail to send if we unlock the form immediately. they'd have to retry sending a few times and somehow indicate that they haven't been sent.
This can probably be done by introducing optimistic posting (with the help of the idempotency key) and keeping track of each message (e.g., (sending | delivered | error)) and styling them accordingly, I think. But BE would need to broadcast the idempodency key via WS too since sometimes the WS event can arrive earlier than the HTTP response and such event would be taken as a different message.
We could maybe do it simpler without needing extra support, we don't block the entire form but just block send, so that user can start typing the new message before the previous one has sent but just can't post it, I think it would totally eliminate the biggest issue we have with it currently.
this feels like a crutch. Sure we can block send, but what if message errors out, what do we do? Erase new draft and put old one instead? Let errored message go into void? Show error "your message: $MESSAGE was not sent" so that user can copy it?
IMO having chat bubble with "not sent, click to retry", while being an awful situation is still best UX out all known solutions.
Blocking text input while sending is a terrible, terrible UX. People often type message, hit ENTER (or SEND/send shortcut i.e. ctrl-enter) and keep on typing next message. Disabling text field would make it lose focus, which will cost user some keystrokes going into the void (and pray mercy they aren't using VimFX/SakaKey/Vimperator or similar addons), not to mention we will probably need to re-focus it after it becomes enabled which could be pain.
In Soapbox FE we push a fake message into the chat as soon as the user sends, and then it gets overridden with the real message on response. It gives a UUID to this fake message so it can keep track. It feels fast.
A small note. It seems that right now SoapboxFE doesn't sync your own messages when the same chat is opened in different tabs. Since PleromaFE does the sync, the same approach makes duplicate messages being added due to not being able to associate the fake message with the one coming from the WS streaming if it arrives earlier than the HTTP response.
More specifically:
When the user sends a new message,
The fake message is added to the list.
The WS streaming pleroma:chat_update event for that message arrives earlier than the HTTP response. Since it doesn't contain the fake id and can't be associated with the request/response cycle, it can't replace the fake message and so the duplicate message is created.
I think we would need to broadcast something like the idempotency key via the pleroma:chat_update streaming event so that we could associate the fake message with the one coming from the WS streaming event and avoid the duplicates. This way clients can do both the sync and the optimistic posting.