[AI Chapters] Show indicator until fingerprinting settles#5460
Conversation
geekygecko
left a comment
There was a problem hiding this comment.
Thanks for making this change. I have asked the designers for feedback here p1782174481298809-slack-C05RR9P9RAT
|
Version |
547c986 to
c0d95f5
Compare
|
Claude finished @sztomek's task in 2m 18s —— View job PR Review — AI Chapters fingerprinting indicatorI reviewed the diff, the touched files, and 🟡 Suggestions1. Missing Compose preview (inline) 2. 🔵 Questions / minor
None of these are blockers — (1) and (2) are the ones I'd address before merge. |
| @Composable | ||
| private fun AligningChaptersRow( | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .padding(horizontal = 20.dp, vertical = 8.dp), | ||
| ) { | ||
| CircularProgressIndicator( | ||
| color = LocalChaptersTheme.current.headerTitle, | ||
| strokeWidth = 2.dp, | ||
| modifier = Modifier.size(16.dp), | ||
| ) | ||
| TextP50( | ||
| text = stringResource(LR.string.chapters_aligning), | ||
| color = LocalChaptersTheme.current.headerTitle, | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
Every other composable in this package (ChapterRow, ChaptersHeader) ships a full set of themed @Previews, and the PR checklist claims "Any jetpack compose components I added or changed are covered by compose previews." AligningChaptersRow has none. Since it reads LocalChaptersTheme.current, a preview would also catch the theme wiring. Consider adding one (matching the existing Light/Dark/etc. set) so the indicator is visually verifiable.
| fingerprintTimingManager.stateFlow | ||
| .map { state -> | ||
| state is FingerprintTimingManager.State.Preparing && | ||
| fingerprintTimingManager.activeEpisodeUuid == episodeId | ||
| } | ||
| .distinctUntilChanged() |
There was a problem hiding this comment.
activeEpisodeUuid is a plain @Volatile var, not part of a flow, but it's read inside map on stateFlow. This means the derived boolean only recomputes when stateFlow emits — a change to activeEpisodeUuid alone will not re-trigger it.
This happens to work today because FingerprintTimingManager.prepareForEpisode() sets activeEpisodeUuid = episodeUuid (line 396) before setting _stateFlow.value = State.Preparing (line 422). But it's fragile: if the manager ever switches episodes while remaining in Preparing (e.g. resetState() nulls activeEpisodeUuid without changing the state, then a new prepare sets Preparing again — which MutableStateFlow dedups, emitting nothing), an already-subscribed consumer wouldn't observe the episode change. Worth a comment noting the ordering dependency, or better, deriving the active episode from the flow itself.
Description
This is a follow-up of #5445
Now we show an indicator on the top of the chapters page until fingerprinting settles.
Fixes PCDROID-616 https://linear.app/a8c/issue/PCDROID-616/show-indicator-while-fingerprinting-is-in-progress
Testing Instructions
Screenshots or Screencast
Checklist
./gradlew spotlessApplyto automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xml