Skip to content

Add an estimated local finish time to the player HUD - #1295

Merged
GLinnik21 merged 85 commits into
plxnative:mainfrom
seergi893:feature/hud-end-time
Nov 10, 2026
Merged

GLinnik21 merged 85 commits into
plxnative:mainfrom
seergi893:feature/hud-end-time

Conversation

@seergi893

@seergi893 seergi893 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a per-profile Estimated end time setting under Settings → Video & playback → Player HUD. It is enabled by default.
  • Show the estimated local finish time alongside the remaining duration for movies and episodes. The estimate uses the current playhead and effective playback speed, including normal-speed playback on the URI engine.
  • Keep subsecond precision through the calculation and apply the local time zone at the projected finish. Hide the estimate during previews, pauses, seeks, loading, and scrubbing, or when reliable playback data is unavailable.
  • Draw the remaining duration, a subdued separator dot, and the local finish time using the TV’s clock preference and format locale. Fall back to the remaining duration when the combined run would crowd the elapsed clock.
  • Reserve space for the combined run through playbar.end_time_width. Classic declares 320 px in HUD format 1.1, and installed 1.1 packages can opt in with the same field. The released HUD 1.0 schema is unchanged. The HUD lint checks the reserved space and both hour cycles.
  • Suppress wall-clock estimates during recording and replay so their HUD output stays deterministic.

Validation

  • Added coverage for 12- and 24-hour formatting, locale defaults, daylight-saving transitions in 12-hour mode, the separator’s ink, fallback on narrow layouts, prewarming and the package lane.
  • Local checks passed for module layers, language lists, all 12 catalogs and both Classic archives. The HUD fuzz seed corpus regenerated successfully.
  • All four GitHub Actions workflows passed before the format bump on 7786fb6, including both host unit-test configurations, the ARMv7 cross-build and binary-size budget, the simulator checks, and HUD parser fuzzing. View checks
  • Verified that the HUD 1.0 schema matches the previous published file byte for byte and that both Classic archives declare HUD 1.1. CI for the version bump is tracked in the Checks tab.
  • Verified it on the TV

Localization review

This AI-assisted follow-up removes the translated HUD sentence from all catalogs. The Settings copy carries over from the original change, with a straight apostrophe in the Italian detail. Native review of the retained Settings copy is pending confirmation.

@seergi893

seergi893 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi! This PR is ready for review. All four CI workflows passed on 2495ea4 (unit-test suites, ARMv7 build, and simulator checks).
This is ready to squash and merge after your review. Thanks @GLinnik21 !

@seergi893
seergi893 marked this pull request as ready for review November 9, 2026 12:47
@GLinnik21

Copy link
Copy Markdown
Collaborator

Can you show the screenshots?

@seergi893

Copy link
Copy Markdown
Contributor Author

Can you show the screenshots?

Yes, sorry @GLinnik21 ! attached

HUD:
plxnative-hud

CONFIG:
plxnative-hud-config

Copy link
Copy Markdown
Collaborator

Localization review

Catalogs are complete. All 11 non-English catalogs (be, ca, de, es, fr, hu, it, nl, pl, pt, ru) have player.hud.ends_at, settings.hud_end_time.title and settings.hud_end_time.detail, and every ends_at string keeps the {time} placeholder. The English entries carry value, description and typed args. I read the catalogs from the PR head; I did not run the plx_platform catalog tests myself (CI did).

1. The time itself is not locale-aware

remaining_with_end_time (player_hud/classic.rs) always builds format!("{hour:02}:{minute:02}"), i.e. 24-hour HH:MM, whatever the TV is set to.

LocaleContext already carries the TV's settings: clock() (H12 / H24 / Locale, parsed from the Settings Service's localeInfo.clock) and the format locale (locales.FMT). Today clock() is only written to the boot log; nothing formats with it. So a TV set to 12-hour (e.g. en-US) shows "Ends at 21:45" with no AM/PM, and regional separators are ignored.

Suggested fix: add a shared time-of-day formatter in platform::i18n, next to the existing date/number formatters, that honours clock() and the format locale (Clock::Locale → that locale's default hour cycle), and pass its result into {time}. Things to check:

  • docs/localization.md says the build avoids linking all-locale ICU data; confirm time-formatting data for the shipped locales fits that.
  • local_clock_time is tested only through 24-hour output; add 12-hour cases.
  • The simulator only has PLXNATIVE_FORMAT_LOCALE; I did not find a clock override there (I only searched i18n/mod.rs), so 12-hour may need one to be checkable. Record/replay pins the clock to 24-hour, so it will not exercise this.

The time zone is fine: localtime_r uses the OS zone, including DST.

2. Prepositions for 01:xx (ca / it / pt)

"Acaba a les {time}", "Fine alle {time}" and "Fim às {time}" use the plural-hour form. For 01:00–01:59 the singular is required ("a la", "all'una", "à"). es / de / nl / hu already avoid this by having no preposition ("Fin {time}"); doing the same for ca / it / pt is the simplest fix. This also applies in 12-hour mode once item 1 is done.

3. Belarusian preposition

"Канец у {time}": I'm not certain "у" is the right preposition before a clock time (it may need "а"). A native reviewer should confirm. Per docs/localization.md, AI-drafted translations should say so in the PR and name who reviewed the wording; the PR body doesn't.

4. Nit

The new Italian detail string uses a typographic ’, while neighbouring entries in it/settings.json use '.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator

Follow-up: drop the Ends at {time} sentence, show just a dot and the time

The Belarusian wording is approved, but the maintainer's view is that the label string isn't needed at all, since it is long and messy. Suggestion: draw only a separator dot and the time after the remaining counter (0:42:10 · 21:45), and delete player.hud.ends_at from all 12 catalogs. The settings title and detail strings stay, and the detail already explains the feature.

What this removes:

  • the per-language grammar (the ca/it/pt 01:xx preposition problem and the Belarusian preposition question from my previous comment both disappear);
  • 11 translations to maintain and review, and every future language's translation of this string;
  • most of the width pressure, so the "only when there is room" fallback fires far less often.

What to use for the dot: the app's shared separator is widgets::DottedRun (rust-modules/ui/src/widgets.rs), which draws the middle dot · in theme::TEXT_SEPARATOR ink. Its docs call out that a dot drawn in the same ink as the words joins them instead of punctuating them, and format!("{remaining} · {end}") in a single p.text call can't express that. It also accepts a Measure, so the width is known before drawing. This should go through that component rather than a string concatenation in classic.rs.

What the 12/24-hour point from before still needs: with only the time on screen, the format of that time is the whole feature (21:45 vs 9:45 PM), so honouring LocaleContext::clock() and the format locale matters more, not less.

Overlap check (code reading only)

I read draw_playbar_look at the PR head. I did not run it or look at pixels, and the player HUD is one of the surfaces rust-modules/ui/src/CLAUDE.md lists as having no text-fit test, so nothing automated covers this.

  • Elapsed clock: the combined label is only used when width(label) < (sx + sw - el_r - 20.0), the same condition that already decides whether the remaining clock is drawn (el_r + 20.0 < rem_l). el_r is the union of the drawn elapsed faces, including the grown scrub size, so the label can't reach the elapsed clock; it falls back to the plain remaining counter instead.
  • Transport glyph: room_right is computed from rem_l of the label actually chosen, so the glyph moves to the left of the clock when the right side is crowded, as before.
  • Right edge and custom layouts: the label is right-aligned at the track end and grows leftwards only. For a custom package the width is also capped at the package's own clock_rects.remaining.w.
  • One thing to look at: the old code measured the remaining clock on a '0'-digit template so its extent stayed stable while digits tick; draw_clock still does this for the elapsed clock. The PR measures the real string. That cannot cause an overlap, but near the threshold the label could switch between the full and plain form from one second to the next as digit widths change. Measuring the template of the label, as draw_clock does, would keep it stable. A shorter dot-and-time label makes that threshold rarer.

Generated by Claude Code

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

Requesting changes

The structure is mostly sound. I read the diff and ran the repo's pr-reviewer agent over be8495d5b...5cd3533f5; it found the Sans-IO, ledger, layering and settings-machinery rules clean, and I confirmed the finding below against the code. Details of what was and wasn't checked are at the end. Two earlier comments cover the localization points; this review adds the architectural ones and collects what must change.

Must fix

1. The end-time lane is special-cased by package id, and installed HUD packages can never show the feature.
render.rs:644 passes end_time_width: (!compiled.builtin_classic).then_some(clock_rects.remaining.w), with builtin_classic: package.id == BUILTIN_CLASSIC_ID set in hud_format/compile.rs.

  • For an installed package, clock_rects.remaining.w is exactly the width of the widest remaining clock (hud_format/clocks.rs:73, rects(): remaining_w = width(REMAINING_BOLD, true)). The label "{remaining} · …" is always wider than that, so width(label) < end_width is never true. The setting silently does nothing on every installed HUD, although the PR body says custom layouts show it when there is room. This also holds for the shorter dot-and-time label proposed in my earlier comment: it is still wider than a lane sized to one clock.
  • The built-in builtin:classic instead gets the free track width, so it draws app text outside the remaining-clock rect the compiler emits. The HUD lint invariants (I4 decor z-order, I10 text fit) are judged only against that rect, so the built-in's new label is invisible to them. The renderer now behaves differently per package id, which cuts against D2 "One renderer" in docs/hud-plugins.md (the built-in must be expressible in the same format) and against AGENTS.md's "never write an ad-hoc mechanism when a shared one exists".
  • Suggested fix: make the lane a property the package declares (for example a playbar clocks/end-time field in the schema, compiled into ClockRects), so lint I4/I10 and the parser fuzz cover it, and classic.plxhud declares a wider lane. The id check goes away. This changes the schema, so docs/hud-plugins.md and the hud.format reference need updating with it. If you decide not to extend the schema, state explicitly that the feature is built-in-only and drop the claim about custom layouts, but the id special-case would still need a documented reason.

2. Localization (from my earlier comments, still open): the time is always 24-hour HH:MM and ignores LocaleContext::clock() and the format locale; the player.hud.ends_at string should go in favour of a dot and the time through widgets::DottedRun, which also removes the ca/it/pt 01:xx and Belarusian preposition issues. The remaining label should be measured on a '0'-digit template so the fit decision doesn't flip as digits tick.

Minor

3. Misplaced doc comment. In media/src/route/prefs.rs (about lines 937–945) the new hud_end_time / restore_hud_end_time were inserted between the doc comment "What sits under the focused poster…" and pub fn under_posters. That comment now attaches to hud_end_time, and under_posters has none. Move the new functions above that comment.

Checked and clean

  • Sans-IO: the wall clock and the localtime_r conversion have one production caller, run::hud_model in the app layer, and HudModel.end_time reaches the HUD as frame data, like today. No screen, appkit, ui or data step reads a clock or a global for this. Replay returns None.
  • Ledgers and layering: ci/check-deps.sh, check-ledger-ratchet.py, check-module-layers.py and check-language-lists.py pass on the PR head; the diff touches nothing under ci/ and adds no cfg(test) fork.
  • Settings: the per-profile setting uses the shared row, descriptor, live-cell and choose machinery, the same pattern as TrailerAutoplay.
  • Playback speed and is_movie: the applied rate is a pure read of PlaybackSession (URI is 1x, matching where speed is offered); is_movie is set consistently at every construction site.

Not verified

  • Whether the built-in's wider label can overlap any other classic decor op besides the elapsed clock. The renderer only guards against the elapsed clock (el_r + 20), and no lint covers the rest; this needs the simulator or the TV.
  • Whether simulator or controlled-run HUD captures of live (non-replay) playback now include a real wall-clock time and become nondeterministic.
  • On-device validation is still pending per the PR body.
  • doc-claim-auditor hasn't been run over docs/hud-plugins.md (D2/D3) and the ClockRects contract; the lane change above would make that worthwhile.

Generated by Claude Code

@seergi893
seergi893 requested a review from GLinnik21 November 9, 2026 17:55
@seergi893

seergi893 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review @GLinnik21! I addressed the requested changes in 7786fb6.

  • The HUD now shows the remaining duration, a separator dot drawn by DottedRun, and the estimated finish time. The time follows the TV’s format locale and 12/24-hour preference. I removed player.hud.ends_at from all 12 catalogs and fixed the Italian apostrophe in Settings.
  • The finish-time lane is now declared through playbar.end_time_width. Classic reserves 320 px, and installed HUDs can opt in through the same field. The renderer measures a fixed digit template to keep the fit decision stable as the countdown ticks and falls back to the remaining duration when space is tight. I updated the schema, docs, and lint coverage.
  • I moved the misplaced under_posters doc comment and disabled the wall-clock estimate during recording and replay to keep captures deterministic.

All four GitHub Actions workflows passed, including the ARMv7 binary-size check and HUD parser fuzzing.

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

The follow-up covers everything from the first round, thanks. A few things left before merge:

  1. docs/hud-plugins.md (~line 1264): the Classic listing is missing "end_time_width": 320 in the playbar cell. The table below it already says 320.
  2. docs/localization.md (~line 143): "playback clocks remain durations" isn't quite true any more, since the HUD can now show a finish time of day. Please say so there.
  3. docs/parity-gaps.md (~line 1252): it says there's no "ends at" readout. Mark that half closed.
  4. end_time_width needs to go into HUD format 1.1, not 1.0, because the plugin is already released. That means .at((1, 1)) on the field, 1.1 in SUPPORTED/CURRENT, a new site/hud/schema/hud/1.1.json, Classic moved to 1.1, and the versioning text in docs/hud-plugins.md updated.

Still pending from the PR description: checking it on a TV.


Generated by Claude Code

@GLinnik21

Copy link
Copy Markdown
Collaborator

4. end_time_width needs to go into HUD format 1.1, not 1.0, because the plugin is already released. That means .at((1, 1)) on the field, 1.1 in SUPPORTED/CURRENT, a new site/hud/schema/hud/1.1.json, Classic moved to 1.1, and the versioning text in docs/hud-plugins.md updated.

This is really important since we have https://huds.plxnative.com/

@seergi893
seergi893 requested a review from GLinnik21 November 10, 2026 07:22
@seergi893

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up, @GLinnik21 ! I addressed the remaining review points in the latest revision 5ffa1b2

  • Moved playbar.end_time_width to HUD format 1.1. Classic now declares 1.1 and reserves 320 px. The published 1.0 schema is unchanged byte for byte, and existing 1.0 packages still load.
  • Updated the Classic example, the versioning docs, and the authoring tools to cover both HUD versions.
  • Updated the localization docs to describe the estimated local finish time. The parity notes now mark that readout as implemented and keep the separate current-time clock open.

All four GitHub Actions workflows passed on 5ffa1b2, including both unit-test configurations, the ARMv7 binary-size check, the simulator checks, and HUD parser fuzzing.

@GLinnik21
GLinnik21 merged commit 835114d into plxnative:main Nov 10, 2026
17 checks passed

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

Thanks!

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.

2 participants