Skip to content

fix(app): compute conversation duration from transcript speech span #18520 - #18619

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
TheRWX:fix/conversation-duration-inflation-18520
Sep 24, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
TheRWX:fix/conversation-duration-inflation-18520

Conversation

@TheRWX

@TheRWX TheRWX commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #18520: Conversation duration shown inflated in app when speech occurs late in a continuous streaming session.

Problem & Root Cause

In app/lib/backend/schema/conversation.dart:693-705, _getDurationInSecondsByTranscripts() calculated duration solely as lastEndTime = segment.end.

When speech occurs 38 minutes into a 40-minute continuous streaming session, the STT segments have timestamps reflecting stream offsets (e.g. start: 2299.0, end: 2431.0). _getDurationInSecondsByTranscripts() took lastEndTime (2431s = 40m 31s), causing the conversation header to display 40+ minutes even though the audio recording was only 2:12 (132s = 2431 - 2299).

PR #7528 intended to compute phone-app duration from the transcript instead of the session timestamp delta, but all of its tests initialized segments with start: 0.0, missing streaming session offsets entirely.

Fix

Compute the transcript speech span as lastEndTime - firstStartTime (with non-negative clamping) across the conversation's transcript segments. When speech starts at 0, existing behavior is preserved (lastEndTime - 0 = lastEndTime). When speech starts at an offset into the stream, the duration accurately reflects the speech duration (lastEndTime - firstStartTime), matching the audio player.

Failure Class

Failure-Class: FC-capture-session-window-read-as-content-duration

Verification

  • Added unit test in app/test/unit/conversation_duration_test.dart reproducing the reported defect with offset segments (start: 2299.0, end: 2431.0).
  • Verified failure on unpatched baseline: returned 2431 instead of 132.
  • Verified all 7 unit tests pass after fix (flutter test test/unit/conversation_duration_test.dart).
  • Verified all 55 parity contract tests and detail UX widget tests pass (flutter test test/parity/parity_contracts_test.dart test/widgets/conversation_detail_ux_test.dart).
  • Verified zero errors on touched files with flutter analyze.

PayPal: [email protected]

Review in cubic

…asedHardware#18520

In app/lib/backend/schema/conversation.dart, _getDurationInSecondsByTranscripts()
took the largest segment end timestamp without subtracting the first segment
start timestamp. When speech occurred late in a continuous streaming session
(e.g. 38 minutes in), the transcript segments carry session-offset timestamps,
causing the conversation header to report 40+ minutes for a 2-minute recording.

Compute the conversation duration from the speech span (lastEndTime - firstStartTime)
with non-negative clamping, preserving zero-offset segment behavior while accurately
reporting conversation length for session-offset speech.

Failure-Class: FC-capture-session-window-read-as-content-duration

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bug fix: duration calc used only transcript end-time, over-counting when speech starts late in a long streaming session (fixes #18520). Root cause stated, scoped diff (34 lines), test added, CI green, confirmed still broken on main. 5/5.

@kodjima33
kodjima33 merged commit dd31649 into BasedHardware:main Sep 24, 2026
36 checks passed
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.

Conversation duration shown inflated in app

2 participants