You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Widget: setUser({ token }) should take a token function, like userToken #482
Follow-up to #476. userToken in the widget config can now be a function the widget calls for a fresh token each time it asks for a session (UserToken in packages/widget/src/api/client.ts:6). ChatCops.setUser({ token }) still takes only a string (packages/widget/src/widget.ts:501, and the same signature in packages/widget/src/index.ts and ChatCopsLoader in packages/widget/src/loader/loader.ts). So a site that signs the visitor in after the page loads, which is what setUser is for, can't hand over a function.
What to do
Widen token in setUser to UserToken in all three places, and pass it through to client.setUserToken as it is.
setUser compares the new token with the old one to decide whether the visitor changed and the chat should be cleared (widget.ts:502-504). Two different functions are always different, so define what counts as the same visitor: the simplest rule is that passing the same function again doesn't clear the chat, and anything else does. Document it.
Acceptance criteria
Unit tests: setUser with a function, the function is called when a session is requested, the same function again doesn't clear the chat, and a different token or null does
Type tests in packages/widget/tests/api.test-d.ts for both builds
website/src/content/docs/widget/api.mdx (the setUser section) says it takes a function
A patch changeset for @chatcops/widget; pnpm test:coverage, pnpm lint and pnpm size pass
Thanks @Sreehita-here, but this one is the follow-up @Saifjafri212213 asked for on #73 before I opened it, so it's his. I've just opened 485, a small one in the same area (the widget's CSP nonce). Comment there and it's yours.
Thanks @anurag629, I'd like to take this one. I have no open PRs or assigned issues in chatcops, so I have a free slot. Could you assign it to me? I'll start once it shows as assigned.
Activity
Sreehita-here commentedon Oct 30, 2026
Hey @anurag629 id like to work on this
anurag629 commentedon Oct 30, 2026
Thanks @Sreehita-here, but this one is the follow-up @Saifjafri212213 asked for on #73 before I opened it, so it's his. I've just opened 485, a small one in the same area (the widget's CSP nonce). Comment there and it's yours.
Saifjafri212213 commentedon Oct 30, 2026
Thanks @anurag629, I'd like to take this one. I have no open PRs or assigned issues in chatcops, so I have a free slot. Could you assign it to me? I'll start once it shows as assigned.
anurag629 commentedon Oct 30, 2026
Assigned, @Saifjafri212213.