Playing Is Not the Same as Having Watched
In LoverCast, hitting play on one episode was enough for the entire series to show up as watched on every device. It wasn't an Android bug: it was a domain model that had fused two similar-sounding ideas into one.
You start a series on your phone. You watch ten minutes of the first episode, leave it, and that night you turn on the TV. The series is in "Watched", with its completed badge on it.
You haven't watched it. You watched ten minutes. And the worst part isn't the label: it's that, sitting there as "watched", the series stops behaving like something you have half-finished.
The bug had a one-line cause and a much longer origin. The line was fixed in a commit. The interesting part is why that line looked reasonable when it was written.
What the player was doing
In the phone player there was an effect that fired when playback started. If it was a movie, it saved it to the watched list; if it was an episode, it saved its series:
LaunchedEffect(contentId, contentType, title, posterUrl, streamUrl, seriesId, seriesName) {
if (contentId.isBlank()) return@LaunchedEffect
when (contentType) {
WatchType.MOVIE -> watchedContentRepository.saveMovie(Movie(id = contentId, ...))
WatchType.SERIES -> {
val id = seriesId ?: return@LaunchedEffect
watchedContentRepository.saveSeries(Series(id = id, ...))
}
}
}
The effect landed in the same commit that added the catalog history and the watched-content screen. Read in that context it makes perfect sense: "if they play it, they've watched it." It's the intuition everyone has, and for a ninety-minute movie that someone puts on and finishes, it's almost always right.
The problem is that saveSeries wasn't writing to an innocent list.
The cascade
saveSeries put the series into watched_series, the column that feeds "Watched". That column syncs to the cloud like the rest of the user's state. And on the other side, when a device pulls the row down, the repository that applies it does this:
private fun mergeSeries(remote: List<Series>?) {
// null = column never synced → leave local alone.
// [] = list actually emptied → propagate the deletion (align local with remote).
if (remote == null) return
// …drop whatever is no longer in remote…
remote.filter { it.id !in currentIds }.forEach {
local.saveSeries(it)
seriesCompleted.markCompleted(it.id)
}
}
Every series that shows up in watched_series also gets marked in series_completed, which is the "series completed" badge. On their own, both pieces were correct: if a series is in "Watched", it's consistent to paint it as completed. Together, hitting play on the phone ended up, shortly after, with the series in "Watched" on every platform and marked as finished on the TV.
Neither piece had a bug that a unit test was going to catch. The player saved what it meant to save. The merge applied what it pulled down. The bug was in what the column meant, and nobody checks that.
Two ideas that look a lot alike
If you look at it calmly, the app carries four things that in a normal conversation you'd call "watched":
- Per-episode or per-movie progress (
episode_progress,movie_progress): how far in you are, for the bar and for resuming. - Continue watching (
watch_progress): the last thing you have half-finished. - Watched (
watched_movies,watched_series): a list the user consults. - Series completed (
series_completed): the badge.
The first two are facts. They happen on their own while you play, and the user doesn't have to say anything. The last two are opinions: "I'm done with this, get it out of my way." And only the user can give an opinion.
The bug was treating a fact as if it were an opinion. Playing is a fact. Having watched is a claim about you, and the app was making it on your behalf.
The 95%
There was a second version of the same mistake, more discreet. Episode progress has this definition of completed:
val isCompleted: Boolean
get() = manuallyCompleted || (durationMs > 0L && fraction >= 0.95f)
Reaching 95% counts as completed, which is reasonable: nobody watches the end credits. But the series detail screen used that same isCompleted to decide whether all episodes were watched, and if they were, it marked the whole series. With single-episode series the shortcut was direct: playing to the end amounted to declaring the series finished.
Here the boundary is finer than in the play case, which is exactly why it's worth a closer look. An episode counting as completed at 95% is a decision about progress. That promoting the series to "watched" is a decision about the user's opinion. The same property was serving both.
What got written down
The fix is more about deleting than adding. The player effect disappeared entirely, and in its place a comment explaining why it isn't there:
// NOTE: content is NOT marked "watched" here. Playing only saves progress
// (continue watching + movie/episode progress). The "Watched" state is ONLY
// set by manual marking (eye on the series/episodes).
And the detail screen started separating the two readings of the same datum:
// "Series watched" ONLY by manual marking, NEVER by hitting 95% playback.
val allEpisodesCompleted = remember(allEpisodes, episodeProgressMap) {
allEpisodes.isNotEmpty() && allEpisodes.all { episodeProgressMap[it.id]?.manuallyCompleted == true }
}
// Progress ring: counts what was actually watched (isCompleted, includes 95%).
val completedEpisodes = remember(allEpisodes, episodeProgressMap) {
allEpisodes.count { episodeProgressMap[it.id]?.isCompleted == true }
}
The progress ring still counts what you've played, because that's a fact and that's what it's for. The watched-series badge only lights up if you've marked the episodes by hand or pressed the series' eye.
The important part is where the rule got written down besides the code. In SYNC.md, the docs for synced state, there's an invariants section, and two of them are exactly this: "series watched" is manual marking only, and playing never marks watched. The same commit changed the TV app to do the same: it stopped bulk-marking a series' episodes just because it was in series_completed, and it now unmarks a series whose episodes aren't completed by hand. That way, an old flag the bug had left behind fixes itself the next time you open that series.
The cost of the rule
Separating the two ideas has a price, and it's worth saying so. Now, if you watch a whole series start to finish, the app doesn't move it to "Watched" on its own. You have to press the eye. For someone who expected the app to notice, that's one extra step.
We chose it that way because the two mistakes don't cost the same. If the app doesn't mark something you did watch, you're missing a mark and you add it with one tap. If it marks something you didn't watch, it hides a series you have half-finished, on every device you own, and you don't know why. The first is an annoyance. The second is the app making decisions about your state without asking you.
What we took away
If two concepts share a name in conversation, that doesn't make them the same in the model. "Watched" was four things. As long as the code called them by the same word, any place that wrote to one ended up writing to another.
Facts and opinions travel different roads. What happens on its own (progress, playback) can be recorded by the system. What asserts something about the user (finished, dropped, favorite) only the user can write. When a fact gets promoted to an opinion without anyone pressing anything, there's a bug waiting for someone to see it.
Who decides the damage of a side effect is the reader, not the writer. The player wasn't doing anything weird: it saved a series to a list. What turned that into "series completed on three devices" was in another file, in another data repository, and in another screen's pull. Before writing to a synced column, the useful question is who else reads it and what they do with it.
A rule is worth more written in the docs than only in the code. The comment in the player explains why there's no effect there. The invariant in SYNC.md is what stops the next person from putting it back thinking it's missing.
LoverCast is in production and you can download it. If your product has a "watched", "read" or "finished" state that the system sets on its own, drop me a line: it's usually worth a look at who reads it.