Skip to content

Conversation

@smian1
Copy link
Collaborator

@smian1 smian1 commented Dec 31, 2025

Summary

When is_user: true, the speaker_name was hardcoded to "User" instead of using the user's actual profile name.

Fix

Fetch the user's name from their profile via get_user_profile(uid) and use it for is_user segments. Falls back to "User" if no name is set.

Files Changed

  • backend/routers/developer.py
  • backend/routers/mcp.py
  • backend/utils/webhooks.py

When is_user is true, fetch the user's actual name from their profile
instead of returning hardcoded 'User'. Falls back to 'User' if no name set.
Copilot AI review requested due to automatic review settings December 31, 2025 05:57
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the _add_speaker_names_to_segments and _add_speaker_names_to_payload functions in backend/routers/developer.py, backend/routers/mcp.py, and backend/utils/webhooks.py. The changes involve fetching the user's name from their profile and using it as the speaker_name for user-identified transcript segments, instead of the previously hardcoded 'User' string. If the user's name is not available in their profile, it defaults back to 'User'. There were no review comments provided.

@mdmohsin7 mdmohsin7 merged commit 25ee36a into BasedHardware:main Dec 31, 2025
4 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the hardcoded "User" speaker name in transcript segments by fetching and using the actual user's profile name. When segments are marked as is_user: true, the system now retrieves the user's name from their profile and uses it, falling back to "User" if no name is set.

Key Changes:

  • Fetches user profile data via get_user_profile(uid) to retrieve the user's actual name
  • Applies the user's name to is_user segments across webhook payloads and API responses
  • Implements consistent fallback logic (or 'User') when no profile name is available

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
backend/utils/webhooks.py Adds user profile name fetching for webhook payloads sent to external integrations
backend/routers/mcp.py Adds user profile name fetching for MCP API conversation endpoint responses
backend/routers/developer.py Adds user profile name fetching for Developer API conversation endpoint responses
Comments suppressed due to low confidence (1)

backend/routers/developer.py:720

  • The function _add_speaker_names_to_segments is duplicated between this file and backend/routers/mcp.py with nearly identical implementations. While the PR correctly adds user profile name fetching to both instances, this duplication creates a maintenance burden. Consider extracting this shared logic into a common utility module (e.g., backend/utils/conversations/speaker_names.py) to avoid having to maintain the same code in multiple places.
def _add_speaker_names_to_segments(uid, conversations: list):
    """Add speaker_name to transcript segments based on person_id mappings."""
    user_profile = users_db.get_user_profile(uid)
    user_name = user_profile.get('name') or 'User'

    all_person_ids = set()
    for conv in conversations:
        for seg in conv.get('transcript_segments', []):
            if seg.get('person_id'):
                all_person_ids.add(seg['person_id'])

    people_map = {}
    if all_person_ids:
        people_data = users_db.get_people_by_ids(uid, list(all_person_ids))
        people_map = {p['id']: p['name'] for p in people_data}

    for conv in conversations:
        for seg in conv.get('transcript_segments', []):
            if seg.get('is_user'):
                seg['speaker_name'] = user_name
            elif seg.get('person_id') and seg['person_id'] in people_map:
                seg['speaker_name'] = people_map[seg['person_id']]
            else:
                seg['speaker_name'] = f"Speaker {seg.get('speaker_id', 0)}"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@smian1 smian1 deleted the fix/speaker-name-user-profile branch January 2, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants