Menu

#110 feat: Implement optimistic-send UI for chat messages + misc fixes

closed
nobody
None
2025-08-20
2025-08-18
Anonymous
No

Originally created by: HaysonC

Implement optimistic-send UI for chat messages + misc fixes

  • UX: optimistic-send
  • Show outgoing messages instantly (optimistic UI) with a temporary MessageInfo (id tmp:<uuid>, pending=True) appended under refresh_lock.
  • Display "Sending..." in the status bar while the send runs in a background daemon thread.
  • On success: fetch authoritative server messages and replace the local list so the optimistic entry is replaced by server-provided data.
  • On failure: remove the optimistic message and clear status.
  • All mutations to chat_window.messages are protected by refresh_lock and the lock is never held during blocking network I/O.

  • Data / rendering

  • Add pending and failed flags to MessageInfo.
  • Render pending/failed markers in ChatWindow (e.g. " (sending...)", " (FAILED)").

  • Code style / safety

  • Ensure optimistic send thread replaces messages safely and always releases locks.
  • Use UUID-based temporary IDs to avoid collisions.

  • Utilities / API changes

  • Convert copied class-methods to standalone module functions in utils.py (moved logic out of class methods).
  • Replace incorrect parameter names and update internal references accordingly.
  • Update docstrings to document the renamed parameter (selfclient) for the converted functions.

  • CLI

  • Added -h flag as an alias for --help.

Files touched (high level)

  • direct_messages.py — add pending/failed to MessageInfo.
  • chat_interface.py — optimistic append, background send, server-replace logic (uses refresh_lock).
  • chat_window.py — show pending/failed markers.
  • status_bar.py — spinner support/status update integration.
  • utils.py — convert class-methods → standalone functions, fix parameter names & docstrings.
  • cli.py — add -h flag alias for --help.

Notes / next steps

  • Consider marking failed messages instead of removing to allow retries.
  • If the send API can return the sent message object, consider replacing only the optimistic message rather than the whole list to reduce UI churn.
  • Add tests and manual checks for success/failure flows, rapid sends, and race conditions.

Related

Tickets: #115

Discussion

  • Anonymous

    Anonymous - 2025-08-18

    Originally posted by: HaysonC

    will test more tmr and make sure linting and coding convention follow. i will go to sleep now

     
  • Anonymous

    Anonymous - 2025-08-19

    Originally posted by: supreme-gg-gg

    When running seems like the message disappears for a few seconds after the placeholder and before being updated when the server responds, might have to do with fetching stale messages from backend and refreshing those?

    EDIT: shoudl be fixed by the latest commit since we now also manage a local list of pending messages and merge them with stale server messages and expire them when failed / done

     
  • Anonymous

    Anonymous - 2025-08-19

    Originally posted by: HaysonC

    lgtm, thanks for the feature @HaysonC, you might need to run linter again tho

    linter passed for me, see if the GitHub workflow ones had any errors

     
  • Anonymous

    Anonymous - 2025-08-19

    Originally posted by: supreme-gg-gg

    lgtm, thanks for the feature @HaysonC, you might need to run linter again tho

    linter passed for me, see if the GitHub workflow ones had any errors

    Sorry I meant formatter, we don't have a precommit hook for ruff yet because it conflicts with prettier one, so you need to do it manually or format on save unfortunately 😭

     
  • Anonymous

    Anonymous - 2025-08-19

    Originally posted by: HaysonC

    lgtm, thanks for the feature @HaysonC, you might need to run linter again tho

    linter passed for me, see if the GitHub workflow ones had any errors

    Sorry I meant formatter, we don't have a precommit hook for ruff yet because it conflicts with prettier one, so you need to do it manually or format on save unfortunately 😭

    ok, mb, did ruff format .

     
  • Anonymous

    Anonymous - 2025-08-20

    Ticket changed by: supreme-gg-gg

    • status: open --> closed
     

Log in to post a comment.

Auth0 Logo