-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Use user profile name instead of hardcoded 'User' for speaker_name #3993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Use user profile name instead of hardcoded 'User' for speaker_name #3993
Conversation
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.
There was a problem hiding this 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.
There was a problem hiding this 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_usersegments 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_segmentsis duplicated between this file andbackend/routers/mcp.pywith 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.
|
where's the test? how did you guys become confident that this PR works and helps fix things? |
Summary
When
is_user: true, thespeaker_namewas 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 foris_usersegments. Falls back to"User"if no name is set.Files Changed
backend/routers/developer.pybackend/routers/mcp.pybackend/utils/webhooks.py