fix: pass user's configured name to transcript formatter for summary …#5369
fix: pass user's configured name to transcript formatter for summary …#5369bzanghi wants to merge 2 commits intoBasedHardware:mainfrom
Conversation
…generation When generating conversation summaries, the transcript passed to the LLM was using the generic 'User' placeholder instead of the user's actual configured name (e.g. 'Stephen' instead of 'User'). Root cause: TranscriptSegment.segments_as_string() accepts a user_name parameter but get_transcript() never forwarded it, so it always defaulted to 'User'. Fix: - Add user_name param to Conversation.get_transcript() and CreateConversation.get_transcript() and pass it through to segments_as_string() - In _get_structured() and _trigger_apps(), fetch the user's display name via get_user_name(uid) (Redis-cached, fast) and pass it to get_transcript() Result: summaries now say 'Stephen: ...' instead of 'User: ...' when the user has configured their name in app settings. Fixes BasedHardware#5319
Greptile SummaryThis PR fixes a UX gap where AI-generated conversation summaries displayed the generic Key concerns:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller
participant GS as _get_structured()
participant TA as _trigger_apps()
participant GA as get_user_name()<br/>(database/auth.py)
participant FB as Firebase Auth
participant FS as Firestore
participant TR as get_transcript()<br/>(Conversation model)
participant SS as segments_as_string()
C->>GS: uid, conversation, people
GS->>GA: get_user_name(uid, use_default=False)
GA->>FB: auth.get_user(uid) [uncached - Redis read disabled]
FB-->>GA: user or error
alt no display_name
GA->>FS: db.collection('users').document(uid).get()
FS-->>GA: Firestore doc
end
GA-->>GS: user_name (or None)
GS->>TR: get_transcript(False, people, user_name)
TR->>SS: segments_as_string(segments, user_name=user_name)
SS-->>TR: "Stephen: Hello..."
TR-->>GS: transcript_text
GS-->>C: Structured, discarded
C->>TA: uid, conversation, people
TA->>GA: get_user_name(uid, use_default=False)
Note over GA,FB: Second uncached Firebase call<br/>(same uid, same result)
GA->>FB: auth.get_user(uid)
FB-->>GA: user
GA-->>TA: user_name
TA->>TR: get_transcript(False, people, user_name)
TR->>SS: segments_as_string(segments, user_name=user_name)
SS-->>TR: "Stephen: Hello..."
TR-->>TA: transcript_text
Last reviewed commit: 187daa1 |
|
|
||
| # Fetch the user's configured display name so transcripts use real names | ||
| # instead of the generic "User" placeholder during summary generation. | ||
| user_name = get_user_name(uid, use_default=False) |
There was a problem hiding this comment.
Redis cache is disabled — uncached Firebase Auth call on every conversation
The PR description states get_user_name() is "Redis-cached, fast", but the cache-read line in database/auth.py is commented out:
def get_user_name(uid: str, use_default: bool = True):
# if cached_name := get_cached_user_name(uid): ← disabled
# return cached_name
user = get_user_from_uid(uid) # always hits Firebase AuthThis means every invocation of get_user_name makes a live synchronous Firebase Auth network call (and a potential Firestore fallback call). This PR adds two such calls per conversation — one here in _get_structured and a second one in _trigger_apps (line 299) — where there were none before. These calls happen on the critical path of conversation processing and will add measurable latency.
The fix should either:
- Re-enable the Redis cache read in
get_user_name, or - Fetch
user_nameonce (e.g. pass it into both functions from the caller) rather than callingget_user_nameindependently in each function.
| @@ -139,7 +144,7 @@ def _get_structured( | |||
| # not supported conversation source | |||
| raise HTTPException(status_code=400, detail=f'Invalid conversation source: {conversation.text_source}') | |||
|
|
|||
| transcript_text = conversation.get_transcript(False, people=people) | |||
| transcript_text = conversation.get_transcript(False, people=people, user_name=user_name) | |||
There was a problem hiding this comment.
user_name fetched but unused for workflow/external-integration sources
get_user_name is called unconditionally at line 91, but for workflow and external_integration conversation sources the function returns early (lines 112–145) before ever reaching conversation.get_transcript(…, user_name=user_name) at line 147. The Firebase Auth call is wasted for those code paths.
Moving the fetch to just before where it is used (after the early-return block) avoids the unnecessary network call for external/workflow sources:
# After the early-return block for workflow / external_integration:
transcript_text = conversation.get_transcript(False, people=people, user_name=get_user_name(uid, use_default=False))Or alternatively, guard the fetch:
user_name = None
if conversation.source not in (ConversationSource.workflow, ConversationSource.external_integration):
user_name = get_user_name(uid, use_default=False)…avoid duplicate calls Address Greptile review feedback: - Move get_user_name() call from _get_structured() and _trigger_apps() up to process_conversation(), so it's fetched once per conversation and passed down as a parameter to both functions - This eliminates the duplicate Firebase Auth call that was made separately in each function for the same uid - _get_structured() no longer calls get_user_name() unconditionally before early-return paths for workflow/external-integration sources; the call now sits at the process_conversation() level, which only handles omi/ble source conversations on this code path - Both _get_structured() and _trigger_apps() accept user_name as an optional parameter (default None), maintaining backward compatibility
…generation
When generating conversation summaries, the transcript passed to the LLM was using the generic 'User' placeholder instead of the user's actual configured name (e.g. 'Stephen' instead of 'User').
Root cause: TranscriptSegment.segments_as_string() accepts a user_name parameter but get_transcript() never forwarded it, so it always defaulted to 'User'.
Fix:
Result: summaries now say 'Stephen: ...' instead of 'User: ...' when the user has configured their name in app settings.
Fixes #5319