Automattic / Automattic/frontend-agent-chat
Support scoped session bootstrap for product/project-bound chats
- Dominant language
- PHP
- Stars
- 3
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
`frontend-agent-chat` can forward generic `chatContext` with each POST, but session bootstrap and session selection are still global for the current owner/agent. Product integrations that mount the widget inside a project/site workspace need the visible transcript to follow the active product scope.
For WordPress Build, the desired behavior is: conversation about site X belongs to site X; switching to site Y switches the visible transcript; returning to site X restores site X's chat.
## Evidence
- `src/AgentChat.tsx:652-696` merges static `chatContext` into POST `client_context`, so per-message context exists.
- `src/AgentChat.tsx:1721-1725` creates the generic Agents API chat adapter without a session scope key.
- `src/AgentChat.tsx:1960-1994` bootstraps logged-in users by loading the most recent session from `chat.sessions`, with no product/session-scope filter.
- `inc/enqueue.php:275-278` localizes `chatContext` from config, but this is static config context rather than an active-session selector.
## Needed Primitive
Add a product-neutral scoped-session option to the widget/adapter, once Agents API exposes the storage primitive in Automattic/agents-api#407.
Possible shape:
- config accepts `sessionScope` or a callback/event-backed scope provider.
- session create/list/load calls include that opaque scope.
- when the scope changes, the widget reloads sessions for that scope and bootstraps the latest matching session or starts a new one.
## Acceptance Criteria
- A host can provide an opaque current scope such as `wp-build-project:123` without frontend-agent-chat knowing product semantics.
- Session controls list only sessions for the active scope.
- Changing scope swaps/restores the active transcript without leaking prior-scope messages into the current conversation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Read the cited ranges in src/AgentChat.tsx and inc/enqueue.php, then review Automattic/agents-api#407 for the storage primitive this depends on. Trace the existing session bootstrap, selection, and chatContext flow before defining the scope input. Done means hosts can provide an opaque scope, session controls filter by it, and changing scope swaps or restores the matching transcript without leakage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, typescript, wordpress
- Domain
- api, backend, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100