Skip to content

fix(app): strict segment seek + stop-at-end for transcript playback (#4471) - #11170

Merged
kodjima33 merged 4 commits into
BasedHardware:mainfrom
aryanorastar:fix/4471-segment-playback-seek
Aug 6, 2026
Merged

kodjima33 merged 4 commits into
BasedHardware:mainfrom
aryanorastar:fix/4471-segment-playback-seek

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Tapping a transcript segment no longer seeks into a later span and plays to the end of the conversation (Segment playback starts at wrong timestamp and keeps playing  #4471).
  • Root cause: segment taps used scrubber-oriented wallToArtifact gap-snap. After dense MP3 playback collapses gaps >90s, a segment whose wall start sits in that gap (e.g. 11:41) snaps to the next span (e.g. 12:03). macOS already uses strict in-span mapping (CapturePlayback.artifactOffset).
  • Shrink-only: wallToArtifactStrict / wallToArtifactStrictInclusive for segment start/stop; require dense artifact + spans (no per-part fallback for taps); pause via positionStream at segment end. Scrubber keeps gap-snap.

Test plan

  • flutter test test/unit/audio_timeline_mapper_test.dart → 14 passed (incl. reporter-shaped 701→null vs scrubber snap)
  • CI Dart Analyze / Android Compile green
  • Not verified on-device: multi-part CV1 conversation with >90s gap; tap segment before/after gap (needs device). Hermetic tests cover the mapping contract.

Product invariants affected

none

Failure-Class: none

Fixes #4471

Review in cubic

…asedHardware#4471)

Segment taps used scrubber gap-snap (wallToArtifact), so a start in a
collapsed inter-part gap jumped ~20s into the next span and played to the
end. Mirror macOS strict in-span mapping, require the dense artifact, and
pause when position reaches the segment end.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

)

Bump a per-seek generation so a stale segment end-handler cannot pause
playback started by a newer tap or scrub. Format AudioTimelineMapper
constructor to satisfy dart format CI.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Addressed both cubic P2s:

Formatting: dart format restored the six-space initializer indent on AudioTimelineMapper.

Rapid second tap: _segmentSeekGeneration owns the segment end-handler. Scrubber seeks bump it (invalidate). Segment taps bump after seek and only pause/clear when the callback still owns the generation — a late pause from the previous tap cannot stop the new playback.

flutter test test/unit/audio_timeline_mapper_test.dart → 14 passed.

Formatting CI failed: dart format --set-exit-if-changed on the changed
conversation_detail/page.dart (ternary/indent drift).

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Formatting was red on app/lib/pages/conversation_detail/page.dart (not the mapper/bottom_bar files). Ran dart format --line-length 120 on that file and pushed.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Android Compile Smoke — infra flake, not this diff.

Could not resolve androidx.test:runner:1.2+ → GET storage.googleapis.com/download.flutter.io/.../maven-metadata.xml returned 403 Forbidden. No Android/Gradle changes here (Dart mapper + bottom_bar + page format only). Neighboring Mobile App Checks on other branches are green.

Couldn’t gh run rerun (needs admin). Pushed an empty commit to retrigger.

@Git-on-my-level

Copy link
Copy Markdown
Member

Nice work on this — the strict-mapping approach is clean and the generation-guarded stop handler is the right pattern for preventing stale end-handlers from pausing newer taps. The reporter-shaped test case is a good touch.

Two behavior changes I'd want a maintainer to confirm before merge:

  1. Stop-at-end is new UX. Tapping a transcript segment now auto-pauses at the segment boundary instead of continuing through the rest of the conversation. That's a deliberate product direction (matches the PR title), but it changes what users expect from segment playback, so it's worth a product judgment call.

  2. Per-part fallback removed. Segment taps now require _singleArtifact && _timelineMapper != null; conversations without the dense artifact + spans manifest get an audioPlaybackUnavailable error instead of the old imprecise _calculateFilePositionForTimestamp seek. Reasonable for correctness, but it's a regression for those edge-case conversations — worth confirming that's acceptable.

Minor edge case: if wallToArtifactStrictInclusive(segmentEnd) returns null (unmappable end), stopSeconds falls back to filePosition, so the positionStream listener could fire on the first position event and pause immediately. Probably only affects malformed segments, but worth a guard or a comment.

CI is green and the mapper contract is well-tested. Leaving for maintainer review on the two UX/behavior questions above.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Aug 6, 2026

@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.

Strict in-span segment mapping matches the macOS behaviour and stops seeking past the gap; 14 unit tests.

@kodjima33
kodjima33 merged commit a4681f7 into BasedHardware:main Aug 6, 2026
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segment playback starts at wrong timestamp and keeps playing

3 participants