Skip to content

bug: Team-shared users still hit public-link approval queue + Sharing UX conflates identity proof with authorization #446

Closed

Description

@vybe

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):

  1. Owner adds [email protected] to Team Sharing on an agent with require_email=true.
  2. Alice opens the public link, enters her email, verifies the 6-digit code successfully.
  3. On first message, Alice gets the 403 "Your access request is pending approval" response, and a row lands in access_requests for her email.
  4. 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.md
  • docs/memory/feature-flows/unified-channel-access-control.md
  • docs/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 new access_requests row for that (agent, email) pair.
  • Add a backend integration test covering the path: agent_sharing row exists → public chat with verified session_token → gate returns pass, no access_requests insert.
  • Audit the three gate call sites (routers/public.py, adapters/message_router.py, any Slack/Telegram variant) to confirm email_has_agent_access is consulted before upsert_access_request in every path, and that email casing/normalization is consistent end-to-end (store lowercase, compare lowercase).
  • If the bug is a stale/inert access_requests row left over from a pre-share attempt: make sure the pending row does not block chat when agent_sharing now grants access, and consider auto-closing stale pending rows on team-share add.

Bug 2 — UX model collision

  • Restructure SharingPanel.vue headings/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_email without adding anyone to Team Sharing or enabling open_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_session returns the email stored at verification time — confirm casing)

Possible root-cause candidates for Bug 1:

  1. Stale access_requests row from a pre-share attempt masking the team-share add (would not block the gate, but might confuse the UI).
  2. Email-casing mismatch between session storage and agent_sharing lookup — both paths appear to lowercase, but worth re-verifying end-to-end.
  3. Gate order in a variant code path that falls through to upsert_access_request without consulting email_has_agent_access first.
  4. 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-357
  • src/frontend/src/views/PublicChat.vue (error copy on 403)

Related tracking:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p1theme-channelstype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions