Repository navigation
Description
Summary
When an owner adds a user to Team Sharing on an agent's Sharing tab, that user is expected to be able to chat with the agent through the public link without hitting the access-request approval queue. In practice, team-shared users are still being placed into the pending-approval list when they send a message via the public link — effectively gating them twice (email verification + owner approval) despite being pre-authorized.
There are two linked issues here: one is a genuine gate defect, the other is a UX model collision that makes the intent of the panel unclear.
Context
Reported behavior (confirmed by owner):
- Owner adds
[email protected]to Team Sharing on an agent withrequire_email=true. - Alice opens the public link, enters her email, verifies the 6-digit code successfully.
- On first message, Alice gets the 403 "Your access request is pending approval" response, and a row lands in
access_requestsfor her email. - Owner has to also approve her from the Pending Access Requests list for her to chat — even though she's already in
agent_sharing.
This contradicts the unified gate in src/backend/routers/public.py:440-455 and src/backend/adapters/message_router.py:210-264, which both consult db.email_has_agent_access(agent_name, verified_email) (owner/admin/agent_sharing) before falling through to upsert_access_request. Per db/agent_settings/sharing.py:136-151, a user present in agent_sharing for that agent should pass the gate immediately.
Separately, the Sharing panel's mental model is muddled — it stacks Channel Access Policy (require_email, open_access), Team Sharing (allow-list), Pending Access Requests, Slack/Telegram bindings, and Public Links in one view. Owners read "Team Sharing" as "pre-authorize these users for the public link" and expect zero friction. The panel doesn't make it clear that require_email is identity proof (always enforced for everyone) and Team Sharing only short-circuits the approval step.
See also the reference flows:
docs/memory/feature-flows/agent-sharing.mddocs/memory/feature-flows/unified-channel-access-control.mddocs/memory/feature-flows/public-agent-links.md
Acceptance Criteria
Bug 1 — Gate defect
- Reproduce: owner adds
[email protected]to Team Sharing;[email protected]email-verifies via public link and sends a message. Assert 200 response, no newaccess_requestsrow for that (agent, email) pair. - Add a backend integration test covering the path:
agent_sharingrow exists → public chat with verified session_token → gate returns pass, noaccess_requestsinsert. - Audit the three gate call sites (
routers/public.py,adapters/message_router.py, any Slack/Telegram variant) to confirmemail_has_agent_accessis consulted beforeupsert_access_requestin every path, and that email casing/normalization is consistent end-to-end (store lowercase, compare lowercase). - If the bug is a stale/inert
access_requestsrow left over from a pre-share attempt: make sure the pending row does not block chat whenagent_sharingnow grants access, and consider auto-closing stale pending rows on team-share add.
Bug 2 — UX model collision
- Restructure
SharingPanel.vueheadings/copy so the distinction is obvious:- "Require verified email" is framed as identity proof ("prove who they are"), not authorization.
- "Team Sharing" is framed as the allow-list that skips owner approval, applied across web / Slack / Telegram uniformly.
- "Pending access requests" is only populated for users who are not in Team Sharing and not covered by
open_access.
- Add an inline note on the Team Sharing section: "These users still verify their email on first chat (proof of identity), but they won't need your approval."
- Consider surfacing a warning when the owner turns on
require_emailwithout adding anyone to Team Sharing or enablingopen_access, since that locks out everyone until the owner approves each request manually.
Technical Notes
Gate code paths to audit:
src/backend/routers/public.py:420-455(web public link gate)src/backend/adapters/message_router.py:210-264(Slack/Telegram gate)src/backend/db/agent_settings/sharing.py:124-151(is_agent_shared_with_email,email_has_agent_access)src/backend/db/public_links.py:298-320(validate_sessionreturns the email stored at verification time — confirm casing)
Possible root-cause candidates for Bug 1:
- Stale
access_requestsrow from a pre-share attempt masking the team-share add (would not block the gate, but might confuse the UI). - Email-casing mismatch between session storage and
agent_sharinglookup — both paths appear to lowercase, but worth re-verifying end-to-end. - Gate order in a variant code path that falls through to
upsert_access_requestwithout consultingemail_has_agent_accessfirst. - Race condition: team-share row committed after the gate read. Unlikely but cheap to rule out.
UI files for Bug 2:
src/frontend/src/components/SharingPanel.vue:1-357src/frontend/src/views/PublicChat.vue(error copy on 403)
Related tracking:
- feat: Unified channel access control — verified-email identity, per-agent allow-list, access requests (web / Telegram / Slack) #311 (unified cross-channel access control) — the primitive this bug sits on.
Activity
docs(test-runner): catalog team-share gate unit tests (#446)
fix(sharing): clear stale pending access_request on team share + Shar…