From c448abfecc1d4418f2a4531a28424360fb547d53 Mon Sep 17 00:00:00 2001 From: nvms Date: Mon, 21 Apr 2025 11:48:04 -0400 Subject: [PATCH] README --- packages/mesh/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/mesh/README.md b/packages/mesh/README.md index fa1cbe5..ee2d409 100644 --- a/packages/mesh/README.md +++ b/packages/mesh/README.md @@ -456,6 +456,19 @@ const allMetadata = await Promise.all( // [{ userId: "user123", username: "Alice", avatar: "..." }, ...] ``` +> [!NOTE] +> Mesh tracks presence and presence state **per connection**, not per user. +> +> If a user opens multiple browser tabs (or devices), each will be assigned a **separate connection ID** and have an **independent presence state**. +> +> Even if both tabs authenticate with the same user ID and you store these values in connection metadata, Mesh does not merge or deduplicate those connections. +> +> If you want to show a single presence indicator per user (e.g. only one "typing" icon), you should: +> +> 1. Attach a `userId` to each connection's metadata +> 2. Resolve metadata for each `connectionId` client-side +> 3. Deduplicate by `userId` in your UI logic + > [!TIP] > You can expose a `get-user-metadata` command on the server that reads from `connectionManager.getMetadata(...)` to support this.