feat: use external_user_id in embed to save conversation#9304
Conversation
begelundmuller
left a comment
There was a problem hiding this comment.
Backend looks good
ericpgreen2
left a comment
There was a problem hiding this comment.
Don't put externalUserId on RuntimeClient
RuntimeClient is our connection/transport abstraction: host, instanceId, JWT, transport, request queue. After this PR it also carries an embed-only string that nothing on the runtime side reads — it's stored in the constructor and consumed in exactly one place (BrowserStorageConversationSelector) to namespace a sessionStorage key.
Suggest passing the user id directly into the selector instead. In ConversationManager, construct BrowserStorageConversationSelector({ userId: EmbedStore.getInstance()?.externalUserId }). The selector no longer depends on RuntimeClient, and RuntimeClient, RuntimeProvider, and getRuntimeClient revert to their pre-PR shape.
Developed in collaboration with Claude Code
40656a7 to
8d9b13b
Compare
ericpgreen2
left a comment
There was a problem hiding this comment.
Rename the param to signal intent
userId: string | null reads as too generic at the call site — a reader sees new BrowserStorageConversationSelector(EmbedStore.getInstance()?.externalUserId ?? null) and reasonably asks "why does conversation selection know about users?" The selector isn't really using a user id in any general sense; it's using an optional namespace for the sessionStorage key that happens to be filled with the embed external user id today. A name like scopeId (or userScopeId) honors what the parameter actually does without overcommitting to embed semantics.
Add a constructor JSDoc
One sentence explaining when callers should pass it. For example:
/**
* @param scopeId Optional namespace for the sessionStorage key. Pass when the
* same browser tab may serve multiple users (e.g. embed with `external_user_id`)
* so conversation selection doesn't leak between them.
*/
constructor(scopeId: string | null) {The class-level docstring's "Selection is scoped per project" line should also pick up "...optionally per user."
Developed in collaboration with Claude Code
* feat: use external_user_id in embed to save conversation * Do not pass through runtime client * Improve var name and add doc string
We recently added support for
external_user_idto scope conversations in embed context. This PR adds support for it in the app by saving the recently open conversation byexternal_user_id.Checklist: