Skip to content

feat(knowledge): Share KB facts when sharing conversations #689

Closed

Description

@mrveiss

Summary

When sharing a conversation with another user, provide option to include associated knowledge base facts.

Problem

Currently, sharing a conversation only shares the messages. Any KB facts created during that conversation remain private to the original owner, making the shared context incomplete.

Proposed Solution

UI Changes

  1. Chat Sharing Dialog - Add checkbox: "Include knowledge created in this conversation"
  2. Preview - Show list of KB facts that would be shared
  3. Granular Control - Allow selecting specific facts to share vs share all

Backend Changes

  1. Add shared_via_session field to fact metadata when sharing
  2. Update fact visibility to "shared"
  3. Add shared user IDs to shared_with array
  4. Create Redis index entries for shared user

API Endpoint

POST /api/chat/sessions/{session_id}/share
{
    "share_with": ["user_id"],
    "include_knowledge": true,
    "knowledge_facts": ["fact_id1", "fact_id2"]  // Optional: specific facts
}

Acceptance Criteria

  • Sharing dialog shows option to include KB facts
  • User can preview which facts would be shared
  • Shared facts appear in recipient's "Shared with me" KB view
  • Original owner retains full ownership
  • Recipient can view but not modify shared facts

Related Issues

Technical Notes

  • Frontend: ChatSidebar.vue - Update sharing dialog
  • Backend: chat_sessions.py - Add sharing endpoint
  • Backend: facts.py - Update sharing logic

Activity

  1. mrveiss commented on Feb 11, 2026

    @mrveiss
    OwnerAuthor

    Implementation Complete

    Backend Changes (3 files, +389 lines)

    autobot-user-backend/knowledge/facts.py - Fact ownership & sharing

    • Added user_id tracking in _store_fact_in_redis() → user:facts:{user_id} Redis set (feat(knowledge): User ownership model for chat-derived knowledge #688 minimal)
    • share_facts() - Share specific facts with users, updates metadata with shared_with array
    • _share_single_fact() - Per-fact sharing helper, creates user:shared_facts:{user_id} indices
    • get_shared_facts() - Retrieve all facts shared with a user

    autobot-user-backend/security/session_ownership.py - Session sharing

    • share_session() - Share session via session:shared_with:{id} and user:shared_sessions:{id} Redis sets
    • is_shared_with_user() - Check if session is shared with user
    • get_shared_sessions() - List all sessions shared with a user
    • Updated _check_ownership_mismatch() - shared_access bypass (after owner/org_admin checks)

    autobot-user-backend/api/chat_sessions.py - API endpoints

    • POST /chat/sessions/{id}/share - Share conversation with optional KB fact inclusion
    • GET /chat/sessions/{id}/share/preview - Preview KB facts before sharing
    • scope=shared on GET /chat/sessions - List sessions shared with authenticated user
    • SessionShareRequest Pydantic model with share_with, include_knowledge, knowledge_facts

    Frontend Changes (2 files, +281 lines)

    ShareConversationDialog.vue (new) - Sharing modal

    • Recipient input with tag-style chips
    • "Include knowledge" toggle with granular fact selection
    • Fact preview with select all/deselect all
    • Loading states and error handling

    ChatSidebar.vue - Share button

    • Share icon (fa-share-alt) added to session hover actions
    • Share dialog state management and toast notifications

    Redis Key Schema (Issue #689)

    session:shared_with:{session_id}   → Set of recipient user IDs
    user:shared_sessions:{user_id}     → Set of session IDs shared with user
    user:shared_facts:{user_id}        → Set of fact IDs shared with user
    user:facts:{user_id}               → Set of fact IDs owned by user (#688)
    

    Acceptance Criteria

    • Sharing dialog shows option to include KB facts
    • User can preview which facts would be shared
    • Shared facts appear in recipient's shared_facts index (retrievable via get_shared_facts)
    • Original owner retains full ownership
    • Recipient can view but not modify shared facts (read-only via shared_access)

    Commit: f1f3e6e

  2. added a commit that references this issue on Feb 11, 2026
  3. added 2 commits that reference this issue on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions