Skip to content

Conversation

@goestav
Copy link

@goestav goestav commented Nov 7, 2025

This pull request marks videos as watched after watching them for a given amount of time and also indirectly fixes a bug that prevents YouTube/Invidious links from updating when seeking backwards for the video.

Closes #3794

Todo

  • Mark as watched after watching for at least 30 seconds or fully watching
  • Add preference for this feature
    • Default to false to avoid confusion for existing users
    • Store value in browser's local storage
  • Remove server side logic that marks a video as watched when navigating to a video

@goestav goestav marked this pull request as ready for review November 7, 2025 19:24
@goestav goestav requested a review from SamantazFox as a code owner November 7, 2025 19:24
@unixfox unixfox requested a review from Copilot November 13, 2025 16:49
Copilot finished reviewing on behalf of unixfox November 13, 2025 16:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a feature to automatically mark videos as watched after the user has watched them for at least 30 seconds (or fully for videos shorter than 30 seconds). The feature is opt-in via a new user preference and uses client-side tracking to determine when to mark videos as watched. It also removes the previous server-side logic that marked videos as watched upon navigation to a video page, and fixes a bug preventing YouTube/Invidious link updates when seeking backwards.

Key changes:

  • Added mark_watched_after_duration preference with default value of false to avoid confusion for existing users
  • Implemented client-side tracking in player.js to monitor watch time and trigger mark-as-watched after thresholds are met
  • Removed automatic server-side marking of videos as watched on page load

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/invidious/config.cr Added mark_watched_after_duration property to default preferences config
src/invidious/user/preferences.cr Added mark_watched_after_duration property to user preferences struct
src/invidious/videos/video_preferences.cr Added processing and handling of mark_watched_after_duration parameter in video preferences
src/invidious/routes/preferences.cr Added route handling to save the mark_watched_after_duration preference from form submission
src/invidious/routes/watch.cr Removed server-side logic that automatically marked videos as watched on page navigation
src/invidious/views/user/preferences.ecr Added checkbox UI for the new preference in the preferences page
src/invidious/views/template.ecr Added hidden span to expose the preference value to client-side JavaScript (only for logged-in users)
locales/en-US.json Added English translation for the preference label
assets/js/player.js Implemented client-side watch time tracking and auto-mark-as-watched logic, also fixed backward seeking bug
Comments suppressed due to low confidence (1)

assets/js/player.js:210

  • Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
    time_watched += 1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unixfox
Copy link
Member

unixfox commented Nov 13, 2025

It also removes the previous server-side logic that marked videos as watched upon navigation to a video page

I don't think that's a good thing because we still want to support non js users as long as possible.

@goestav
Copy link
Author

goestav commented Nov 13, 2025

Apologies, that was supposed to be ignored only if this feature is enabled.

- if watched && preferences.watch_history
+ if watched && preferences.watch_history && !preferences.mark_watched_after_duration
  Invidious::Database::Users.mark_watched(user.as(User), id)
end

It should probably be mentioned under the checkbox in the preference page that the feature requires JavaScript though.
What do you think?

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.

[Enhancement] Mark as watched after certain amount of time

2 participants