Skip to content

Conversation

@mahibi
Copy link
Collaborator

@mahibi mahibi commented Dec 10, 2025

WIP

This PR will

  • Use signaling to receive chat messages instead of long polling when hpb is used

  • Introduce a regular insurance request if somehow a signaling messages did not make it through

  • Change the chat architecture from an event based message handling to a state based messages handling. This change was done in this PR because adding two more ways how messages can be received (signaling and insurance request) would have made the event based messages Handling even more complex.

    • Before:
      messages were passed to ui directly from responses (as well to DB). This was necessary as the chatkit library required different processing depending on if messages from the past or future were received

    • Now:
      Received messages are just written to database no matter where they come from (initial request / request for scrolling into past /long polling / signaling / insurance request).
      Messages are observed on database to be shown in UI via flows.
      The database is the single source of truth, so no events are needed to update the ui.
      To avoid messages gaps in UI, the chat block handling is used: the flow is implemented so that always the messages from the newest chat block are emitted. For this, the database is observed for the newest chat block and whenever it changes, the messages of it are emitted.

  • Implement a workaround so that chatkit library can handle the messages flow instead of the former events. For this, the adapter is cleared and all messages are added again. This may come with a minor performance loss on some devices, but as a temporary solution to migrate to Jetpack Compose + flow handling, this is the best way to go.

  • Refactor and improve the Jetpack Compose code for messages that was used for the message search window to be able to handle flows. (for now it was only able to handle a single response with a chat message list)

  • Add a switch for developers to use Jetpack Compose instead of chatkit. We can continue to maintain the chatkit based solution while being able to further improve the new compose solution until it's ready to replace chatkit.
    To use the compose solution for developing, just change the value of useJetpackCompose in onCreate in the ChatActvity.

  • Add a new solution to automatically mark messages as read.

    • Before:
      messages were marked as read as soon as they were received.
    • Now:
      messages are marked as read until the newest message that was shown on the screen. This is transmitted whenever the user manually scrolls or when the chat is closed/brought to background.
      This change was planned for ages and it was now necessary because of the signaling handling.
  • improve scope handling of the flows from database

TODO

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

@mahibi mahibi added this to the 23.0.0 milestone Dec 10, 2025
@mahibi mahibi self-assigned this Dec 10, 2025
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 2 times, most recently from 074dc73 to 2d34ff3 Compare December 15, 2025 16:57
@mahibi mahibi modified the milestones: 22.1.0, 23.0.0 Dec 18, 2025
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 2 times, most recently from ab134d2 to 3127450 Compare December 19, 2025 20:32
@mahibi mahibi added the 2. developing Work in progress label Dec 19, 2025
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from 3127450 to f50377e Compare January 5, 2026 10:37
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 3 times, most recently from 23b18fc to 05b9a26 Compare January 23, 2026 10:31
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 3 times, most recently from 8a479c6 to acbc95d Compare January 28, 2026 07:40
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from deb4c0e to e21d4e5 Compare January 28, 2026 18:14
@mahibi mahibi modified the milestones: 23.0.0, 23.1.0 Jan 28, 2026
@mahibi mahibi changed the title WIP receive chat message from HPB New chat architecture + chat relay Jan 28, 2026
@github-actions
Copy link
Contributor

Codacy

Lint

TypemasterPR
Warnings99104
Errors02

SpotBugs

CategoryBaseNew
Bad practice66
Correctness1010
Dodgy code5456
Internationalization33
Malicious code vulnerability33
Performance44
Security11
Total8183

Lint increased!

SpotBugs increased!

@mahibi mahibi mentioned this pull request Jan 29, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat relay via High-performance backend

2 participants