Skip to content

All accounts share one cache database #17

Closed

Description

@neoromantic

src/db/index.ts opens one cache.db for every account, and none of the cache, sync-state or job tables has an account column. The architecture rule in AGENTS.md says "one database per account".

With two accounts:

  • chats list, contacts list, messages search and tg sql mix both accounts' data;
  • the daemon runs a job on the first connected account's client (selectAvailableWorker in src/daemon/daemon-scheduler.ts), with access hashes from the other account;
  • message IDs of private chats and basic groups collide across accounts, which also breaks Delete events without chat context can skip valid deletions #7.

Fix: one cache.db per account (for example accounts/<id>/cache.db) and a migration that keeps a single-account cache as account 1. The CLI picks the database from --account or the active account, and each sync worker uses its own account's database.

Done when an e2e test with two seeded accounts shows separate results for each --account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions