Skip to content

New chat architecture + chat relay#5635

Draft
mahibi wants to merge 1 commit intomasterfrom
feature/5633/chatRelay
Draft

New chat architecture + chat relay#5635
mahibi wants to merge 1 commit intomasterfrom
feature/5633/chatRelay

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.

  • 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 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

  • avatars
  • determinePreviousMessageIds + handleExpandableSystemMessages + collapseSystemMessages()
  • quoted messages
  • chat relay
  • special system messages handling regarding signaling?
  • implement new mark as read handling
    • handle actually shown newest messages on screen
  • last read handling
  • show unread chat item. Add in viewmodel
  • message context menu
    • add temporary solution to get ChatMessage for this
  • show play button for audio/video with preview
  • reactions
  • implement all message types
    • media files
    • voice message playback
    • location
    • deck
    • link preview
    • poll
  • temp messages
  • check New features. Scheduled messaages / fixed messages
  • threads handling
  • reply handling
    • get single message from offline stored messages
    • get single message from server if ot stored offline
    • scroll to message when clicked
  • bugfix: sometimes jumping to newest message when scrolling up?!
    • empty list passed??
    • ViewCompositionStrategy ??
  • move all logic from UI to viewModel or to domain->uiModel mapper
  • make new ui model for chat message immutable to work better with Compose
  • rewrite handling of message parameters / rich object type handling / "selectedIndividualHashMap"?
    • reimplement mention chips
  • send chat-relay feature offer to HPB
  • handle chat-relay feature response from HPB
  • migrate database for unique reference id's
  • partly reimplement message editing
  • add theming to chatComponents by CompositionLocalProvider
  • implement own stickyHeader for reversed list
    • Compose only offers stickyHeader when the list is not reverted. But i use "reverseLayout = true" as it fits best for a chatapp. To have a stickyHeader anyway i implemented a stickyHeader for reversed lists
    • do never show it when chat is scrolled to bottom
  • reimplement temorary messages
    • change ChatMessages database table: make referenceIds unique
  • reimplement message read indicator
  • reimplement message status icon handling
  • introduce MessageTypeContent for type-safe rendering
  • reimplement parent message handling
    • load parent messages from same flow that are already contained in latest chat block
      • load missing parent messages from api or older chatBlocks
  • reimplement markdown
    • improve it
  • reimplement links handling
  • reimplement unread message marker between chat messages
  • reimplement unread messages bubble
    • use latestKnownMessageIdFromSync ? -> move to viewmodel
  • Set Read marker
  • add message counter for unread messages bubble
  • comment in openHelperFactory again
  • reimplement search feature
  • delete old chatkit stuff

might be done in followup PRs

  • swipe to answer..
  • reimplement/fix lobby
  • Performance optimizations
    • pagination /Paging3
  • Grouping of bubbles
    • bubble design
    • show only one avatar per bubble-group
  • playback voice messages in service. Playback in ConversationList was removed. There mst be an overall solution to play voice messages in OS notification panel.
  • reimplement GIF autoplay (GIF animations autoplay in chat messages #5969 was merged for legacy code)

🏁 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 4 times, most recently 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
@mahibi mahibi mentioned this pull request Jan 29, 2026
5 tasks
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from e21d4e5 to ceef454 Compare February 4, 2026 10:04
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from ceef454 to 425ed1c Compare February 5, 2026 18:32
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 5 times, most recently from 37d84db to 538c7db Compare February 11, 2026 08:36
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from bb55cef to b308d27 Compare February 13, 2026 08:03
@mahibi mahibi mentioned this pull request Feb 13, 2026
12 tasks
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 4 times, most recently from 1a75ca3 to 8d84236 Compare February 19, 2026 13:51
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 3 times, most recently from 78a8ed7 to 552b889 Compare February 24, 2026 13:22
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 3 times, most recently from 190c889 to f99a164 Compare March 5, 2026 14:35
This was referenced Mar 12, 2026
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from 5d65918 to f07cdff Compare March 12, 2026 15:40
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from f07cdff to bf07a78 Compare March 19, 2026 18:12
@mahibi mahibi force-pushed the feature/5633/chatRelay branch 4 times, most recently from 01621e4 to 31f752c Compare March 24, 2026 13:02
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi mahibi force-pushed the feature/5633/chatRelay branch from 31f752c to f67a329 Compare March 24, 2026 18:08
@github-actions
Copy link
Contributor

Codacy

Lint

TypemasterPR
Warnings9393
Errors00

SpotBugs

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

SpotBugs increased!

@github-actions
Copy link
Contributor

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/5635.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

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 get rid of forked ChatKit

1 participant