Skip to content

Add client state snapshot to chat client stopped events - #1047

Merged
xingsy97 (xingsy97) merged 4 commits into
mainfrom
xingsy97-fix-chat-stopped-user-metadata
Aug 31, 2026
Merged

xingsy97 (xingsy97) merged 4 commits into
mainfrom
xingsy97-fix-chat-stopped-user-metadata

Conversation

@xingsy97

@xingsy97 xingsy97 (xingsy97) commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Include a snapshot of the client’s user ID and joined rooms in the stopped event arguments.

Fixes #902

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2836d2c8-08c4-47da-b9af-b5916c610245
client.on("stopped", () => {
console.log(`chat client for ${userId} stopped`);
client.on("stopped", (event) => {
console.log(`chat client for ${event.userId} stopped`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not directly using client.userId? why userId is the one identify a client?

@xingsy97 xingsy97 (xingsy97) Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.userId is already cleaned in resetState() before this stopped is emitted, so I use this event to preserve the user identity.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds a bit tricky, shall we reserve a client snapshot for this event?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2836d2c8-08c4-47da-b9af-b5916c610245
@xingsy97 xingsy97 (xingsy97) changed the title Add user ID to chat client stopped events Add client state snapshot to chat client stopped events Aug 27, 2026
* `stop()` was called or the underlying connection terminated.
*/
export interface OnStoppedArgs {}
export interface OnStoppedArgs {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about a

export interface ChatClientSnapshot {
  userId: string;
  rooms: RoomInfo[];
}

export interface OnStoppedArgs {
  previousState: ChatClientSnapshot;
}

incase there will be more properties related to stop itself added later, for example stop reason?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2836d2c8-08c4-47da-b9af-b5916c610245
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2836d2c8-08c4-47da-b9af-b5916c610245
@xingsy97
xingsy97 (xingsy97) merged commit a632744 into main Aug 31, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@azure/web-pubsub-chat-client] "stopped" event args missing userId metadata

2 participants