Skip to content

vector-sdk: Channel::history is empty after a bot restart #115

Backlog

Description

@TheSeydiCharyyev

After a bot restarts, Channel::history and Channel::history_before return nothing for a Community channel, even when the bot's database holds the messages. Channel::sync does not bring them back.

Why

  • Channel::history calls VectorCore::get_messages_before, and it reads only STATE (vector-core/src/lib.rs).
  • A new process starts with an empty STATE, and the SDK does not load stored messages into it.
  • Ingest skips a message whose id is already stored (apply_chat_to_state_in in community/v2/inbound.rs: "in-memory STATE holds only a window"). So a sync page with old messages gives 0 new and adds nothing to STATE.
  • The walk loop in the Channel::sync_before doc then stops at once: history is empty and sync returns 0, so the bot thinks it is at the start of history.

The Channel::history doc says it "answers from the bot's own store". The SDK CHANGELOG says "What was sent before the bot began listening is history, as before: channel.history()". The desktop app reads its pages from the database (get_message_views).

Repro (test on master at 4c865db)

In community/v2/service.rs with TestBed: ingest channel messages with v2_ingest_chat_page, then swap_to the same actor again. This opens the same database in a new session, so STATE is empty, like a new process. get_message still finds the rows, but get_messages_before(channel, None, 10) returns []. Ingesting the same page again gives 0 new, and history stays [].

I'll open a PR for this: VectorCore::get_messages_before reads the store too, with a cursor query in db/events.rs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions