Skip to content

tvOS: focus & navigation polish across the SiloTV surface - #1

Merged
Quick104 merged 3 commits into
mainfrom
tvos-focus-navigation-polish
Jun 9, 2026
Merged

Quick104 merged 3 commits into
mainfrom
tvos-focus-navigation-polish

Conversation

@Quick104

@Quick104 Quick104 commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A focus & navigation pass across the tvOS (SiloTV) surface, from a structured review plus follow-up fixes. Goal: focus priority feels natural when moving between every component, with consistent focus visuals.

What changed

Shell & menu↔content hand-off

  • One contentFocusRequest token drives the hand-off, so selecting Home/Libraries/For You actively pushes focus into the freshly-mounted content (previously only Home did — Libraries/For You could land on nothing).
  • returnToHomeInMenu un-suppresses the menu before requesting focus.

Default / d-pad-entry focus

  • Deterministic default focus on Movie-detail Play, Library landing, Profile selection, Login, Server Setup (.defaultFocus(priority: .userInitiated)).
  • Libraries first content row default-focuses its first item on d-pad entry, matching Home; the hero still owns initial focus via its focusRequest kick.
  • Recommended / “More Like This” rail now lands d-pad entry on the first card (was landing mid-rail) and uses the white-ring focus treatment matching the episode/cast rails.

Detail sections

  • Info / About are readable focus stops again via a new readableFocusSection() (visible fill + border; doesn’t steal initial focus from Play) — fixes both the earlier invisible dead-stop and the later “focus skips them” regression.
  • Season chip centers on first appearance; episode-row title no longer reserves a phantom 2nd line (tighter title↔description spacing).

Settings

  • Every focusable row now flips to the dark platter color on focus (FocusAwareValueRow for pickers, FocusAwareRowLabel for toggles + Reset) — fixes inconsistent, washed-out focus contrast on the white platter. focusSection on both card-overlay panes.

Other

  • Primary auth buttons stay focusable while submitting (no focus bounce); intro-skip vs idle player focus made deterministic + grouped; player Info pane scrollable; OverlayPositionGrid dots get a real focus visual; Reduce Motion guard on the shared focus scale; CreateProfile column scrolls.
  • Removed dead code: TVLibraryFilterSheet, TVFilterLandingRail, and the unreferenced inline browse view (~380 lines).

Notes

  • Excludes the unrelated CoreMedia player changes that were already in the working tree.
  • New file ReadableFocusSection.swift added (project regenerated via XcodeGen).

Testing

  • Builds clean on the SiloTV scheme (tvOS simulator, CODE_SIGNING_ALLOWED=NO).
  • Findings/fixes were adversarially verified against source. Focus feel (especially the menu hand-off and player items) should still be confirmed on a physical Apple TV.

🤖 Generated with Claude Code


Note

Medium Risk
Broad tvOS UX changes across auth, shell, player, and playback HTTP options; low security impact but regressions in focus or streaming are likely without device testing.

Overview
This PR is a tvOS focus and navigation polish pass across SiloTV: menu↔content hand-offs, predictable default focus, visible focus cues, and removal of dead library-browse UI.

Shell & roots — TVMainTabView replaces per-tab home tokens with a single contentFocusRequest so Home, Libraries, and For You all imperatively push focus into freshly mounted content (fixing dead remotes after tab switches). returnToHomeInMenu un-suppresses the top menu before requesting focus.

Default / d-pad entry — .defaultFocus(..., priority: .userInitiated) on login, server setup, movie-detail Play, profile tiles, and PIN pad 1. Library landing mirrors Home: first row’s first item on d-pad down; hero still wins initial focus via focusRequest. For You shortcuts and Similar rail land on the first focusable item; TVMediaCard adds .ring focus treatment and parent rail bindings for detail recommendation rows.

Detail & settings — New readableFocusSection() makes Info/About readable, visible focus stops without stealing Play. Season chips scroll to selection on appear; episode titles drop phantom second-line reserve. Settings rows use FocusAwareValueRow / FocusAwareRowLabel so labels read on the white focus platter; overlay settings split focusSection for preview vs controls.

Player & overlays — tvOS controls: intro-skip vs scrubber focus race, auto-hide rearm on transport focus moves, Info pane scroll anchors. OverlayPositionGrid uses per-corner hit targets and a custom dot style for focus. Primary buttons respect Reduce Motion; auth/create buttons stay focusable while loading (guard + spinner, no .disabled bounce).

Cleanup — Deletes TVLibraryFilterSheet, TVFilterLandingRail, and the unused inline library browse block (~380 lines). PlayerCore / PlayerViewModel add HTTP reconnect/seek sizing and skip source proxy for playerCoreDirect (playback path; verify separately from UI QA).

Reviewed by Cursor Bugbot for commit 60c50ea. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Improved tvOS focus controls: readable focus sections, focus scoping, and a new ring-style focus treatment for media cards.
    • Explicit focus targets for login, server setup, PIN entry, profiles, and recommendation shortcuts.
  • Bug Fixes

    • Prevented duplicate submissions from buttons while keeping them focusable.
    • Improved stream reconnection handling for more reliable playback.
  • UI/UX Improvements

    • Clearer focus visuals (corner dots, HUD rows, player controls) and better scrolling/focus for long content.

Quick104 and others added 2 commits May 27, 2026 21:38
Implements the verified findings from a tvOS focus/navigation review plus
follow-up fixes for Libraries initial focus, episode-row spacing, settings
focus contrast, and the detail-page Recommended rail.

Shell & menu↔content hand-off
- Unify the hand-off behind one contentFocusRequest token so selecting
  Home/Libraries/For You actively pushes focus into the freshly-mounted
  content instead of leaving the remote dead.
- returnToHomeInMenu un-suppresses the menu before requesting focus.

Default focus
- Deterministic default focus on Movie detail Play, Library landing,
  Profile selection, Login, and Server Setup via
  .defaultFocus(priority: .userInitiated).
- Libraries first content row default-focuses its first item on d-pad entry,
  matching Home (hero still owns initial focus via its focusRequest kick).

Rails & detail sections
- Recommended/"More Like This" rail (TVSimilarRail) lands d-pad entry on the
  first card and uses the white-ring focus treatment matching the
  episode/cast rails (TVMediaCard gains an opt-in .ring treatment + an
  inner-button focus binding).
- Info/About detail sections are readable focus stops again via a new
  readableFocusSection() modifier (visible fill+border, no initial-focus
  steal), replacing the earlier invisible dead-stop / skip behavior.
- Season chip centers on first appearance; episode-row title no longer
  reserves a phantom second line.

Settings
- All focusable rows flip to the dark platter color on focus
  (FocusAwareValueRow for pickers, FocusAwareRowLabel for toggles + Reset),
  fixing washed-out contrast against the white focus platter.
- focusSection on both card-overlay panes.

Other
- Primary auth buttons stay focusable while submitting; intro-skip vs idle
  player focus grouped + deterministic; Info pane scrollable; OverlayPositionGrid
  dots get a real focus visual; Reduce Motion guard on the shared focus scale;
  CreateProfile column scrolls.
- Delete dead TVLibraryFilterSheet + TVFilterLandingRail + the inline browse view.

Builds clean on the SiloTV scheme. Behaviors are static-analysis-verified;
on-device focus confirmation still recommended.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR centralizes tvOS focus behavior: accessibility-aware button animations, new focus primitives (readable focus sections, focus-aware rows), namespace-scoped default focus, programmatic focus tokens, player focus coordination, and library/collection focus reseeding.

Changes

tvOS Focus Management & Navigation

Layer / File(s) Summary
Accessibility & Button Styling
iosApp/iosApp/Extensions/ViewExtensions.swift
Continuum primary and secondary button styles now respect reduce-motion by gating focused-state scale effects; adds applyDefaultFocusIfNeeded(_:namespace:) for conditional default focus.
Focus Primitives & Detail Helpers
iosApp/iosApp/tvOS/Screens/Detail/ReadableFocusSection.swift, iosApp/iosApp/tvOS/Screens/Settings/TVSettingsView.swift, iosApp/iosApp/Overlays/OverlayPositionGrid.swift
Adds ReadableFocusSection modifier, focus-aware row primitives for settings, and OverlayCornerDotStyle/OverlayCornerDot for explicit corner-dot focus visuals.
Auth Views Focus Management
iosApp/iosApp/Screens/Auth/TVLoginView.swift, iosApp/iosApp/Screens/Auth/TVServerSetupView.swift
Sign-in/Connect actions guard against duplicate submissions via early-return rather than disabling, and set initial default focus to username/host fields.
Profile Selection, PIN Pad & Create Profile
iosApp/iosApp/Screens/Profiles/ProfileSelectionView.swift, iosApp/iosApp/Screens/Profiles/ProfileTile.swift, iosApp/iosApp/Screens/Profiles/PINEntryView.swift, iosApp/iosApp/Screens/Profiles/CreateProfileView.swift
Profile grid and tiles accept default-focus parameters and namespaces; PIN pad scopes focus via Namespace and marks “1” as default-focus; create-profile layout scrolls to make controls reachable and guards submit while loading.
Home & Featured Carousel
iosApp/iosApp/Screens/Home/FeaturedCarousel.swift, iosApp/iosApp/Screens/Home/SectionRow.swift
Hero cards gain accessibility labels; SectionRow adds focusRequest for programmatic focus routing.
Media Card & Rail Focus Treatments
iosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swift, iosApp/iosApp/tvOS/Screens/Detail/TVSimilarRail.swift
TVMediaCard supports .nativeCard and .ring focus treatments with optional rail routing; TVSimilarRail tracks focused card via @FocusState and applies a default-focus to the first item.
Detail Views Focus Management
iosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swift, iosApp/iosApp/tvOS/Screens/Detail/TVSeasonDetailView.swift, iosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift, iosApp/iosApp/tvOS/Screens/Detail/TVSeasonChip.swift, iosApp/iosApp/tvOS/Screens/Detail/TVEpisodeRail.swift
Detail screens adopt readableFocusSection() for long text blocks, add focus namespaces, adjust episode title layout, and auto-center selected season chips on appear.
Player Controls & HUD Focus Coordination
iosApp/iosApp/Screens/Player/tvOS/TVPlayerControls.swift, iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Player controls deterministically manage intro-skip focus hand-off, restore scrubber focus when appropriate, re-arm auto-hide on focus moves, and Info HUD adds top/bottom scroll anchors and updated track-row focus visuals.
Recommendations & Shortcuts Focus
iosApp/iosApp/Screens/Recommendations/RecommendationsView.swift
Adds focusRequest and makes SavedShortcutsRow imperatively apply focus to the watchlist shortcut when requested.
Main Tab Navigation & Root Switching
iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
Replaces Home-only focus token with shared contentFocusRequest and increments it on root swaps so all root content can claim focus consistently; unsuppresses top-menu focus before returning to Home.
Libraries Landing & Collection Focus
iosApp/iosApp/tvOS/Screens/Libraries/TVLibrariesTabView.swift, iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryLandingView.swift
Adds focusRequest plumbing, introduces focusKickNonce/landingFocusRequest, reseeds focus on mode/content changes, wires focus into hero/recommended/collection cards, and implements conditional Up-command handling on collection cards; obsolete filter sheet/chip rail UI removed.
Playback Engine & Source Proxy Configuration
iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift, iosApp/iosApp/Screens/Player/PlayerViewModel.swift
FFmpeg HTTP options updated with reconnect and bounded-request parameters; PlayerViewModel avoids proxy creation for playerCoreDirect and treats PlayerCore direct HTTP 404 as likely expired session.
Settings & Overlay Focus Grouping
iosApp/iosApp/tvOS/Screens/Settings/TVCardOverlaySettingsView.swift
Applies focusSection() to preview and controls panes for explicit focus grouping.

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main focus of the PR: tvOS-specific focus and navigation improvements across the entire application surface (Home, Libraries, For You screens, details, settings, etc.).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tvos-focus-navigation-polish

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 60c50ea. Configure here.

}
}
}
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicate identical ViewModifier structs across two files

Low Severity

ProfileTileDefaultFocus and NumberPadDefaultFocus are structurally identical ViewModifiers added in this PR — same properties (prefers: Bool, namespace: Namespace.ID?), same body logic. A shared internal modifier (similar to the existing applyDefaultFocusIfNeeded extension on View in TVMediaCard.swift) would avoid the duplication and the risk of future divergence if the focus-application logic changes.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 60c50ea. Configure here.

av_dict_set(&options, "reconnect", "1", 0)
av_dict_set(&options, "reconnect_streamed", "1", 0)
av_dict_set(&options, "reconnect_on_network_error", "1", 0)
av_dict_set(&options, "reconnect_at_eof", "1", 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VOD playback may hang with reconnect_at_eof enabled

Medium Severity

Setting reconnect_at_eof to "1" unconditionally tells ffmpeg to reconnect when the HTTP source returns EOF. For VOD/file-based playback (the primary use case of this media player), a natural EOF means the movie or episode has ended. With this flag, the demuxer may attempt to reconnect instead of signaling completion, potentially causing playback to hang or loop at the end of content rather than advancing to the next episode or returning to the UI.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 60c50ea. Configure here.

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift`:
- Around line 2342-2353: The AVDictionary "options" passed to
avformat_open_input is being freed immediately, which can silently discard
unrecognized/unapplied FFmpeg HTTP options; after calling avformat_open_input
(in PlayerCore.swift where options is set and passed), iterate/check the
returned "options" for leftover entries (using av_dict_get or equivalent) and if
any remain log an error/warning or fail early so misconfigured keys (e.g.,
"reconnect_on_network_error", "reconnect_at_eof", "reconnect_on_http_error",
"initial_request_size", "request_size", "short_seek_size", "seekable",
"multiple_requests") are visible to developers; only free the dictionary after
this check.

In `@iosApp/iosApp/Screens/Player/tvOS/TVPlayerControls.swift`:
- Around line 79-81: The assignment to focusedIntroAction inside the block that
checks visible can steal focus when the HUD is open; update the conditional to
only set focusedIntroAction = .skip when visible is true AND the HUD is not
presented (e.g. visible && !isHUDPresented). Locate the visible check and modify
it to include the HUD state guard (or early return/guard statement) so
focusedIntroAction is only changed when the HUD is closed.

In `@iosApp/iosApp/Screens/Profiles/CreateProfileView.swift`:
- Around line 231-233: The guard check uses isLoading but createProfile() sets
isLoading asynchronously, allowing multiple Tasks to be queued; fix by setting
isLoading = true immediately before launching the Task (so the UI/state prevents
additional presses), then call await createProfile() (which should no longer set
isLoading true again) and ensure createProfile() still clears isLoading on
completion/error; apply the same change for the other buttons referencing
isLoading (the Button blocks that call createProfile() at the other occurrences
mentioned) and keep createProfile() responsible only for teardown/reset of
isLoading.

In `@iosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swift`:
- Around line 181-199: Add an accessibilityReduceMotion environment check and
skip the focus/press scaling and animations when it's true: add
`@Environment`(\.accessibilityReduceMotion) private var reduceMotion, then in body
only apply .scaleEffect(scale) and .animation(...) when reduceMotion is false
(or use conditional modifiers), and adjust the private var scale to return 1.0
when reduceMotion is true so that TVMediaCard's focus/press transforms (and
shadow animation) are disabled when Reduce Motion is enabled; reference the
existing isFocused, configuration.isPressed, body, and scale symbols to
implement the conditional behavior.

In `@iosApp/iosApp/tvOS/Screens/Settings/TVCardOverlaySettingsView.swift`:
- Around line 20-25: Keep the separate .focusSection() modifiers on previewPane
and controlsPane, but guard their usage for tvOS 15+ by wrapping/applying them
behind an availability check (if `#available`(tvOS 15.0, *)) or by ensuring the
project minimum tvOS deployment target is >= 15.0; update the HStack so
previewPane.focusSection() and controlsPane.focusSection() are only invoked when
available, referencing the previewPane and controlsPane symbols and the
.focusSection() modifier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e250c4c-161d-4cfd-be42-8abf2120a6ab

📥 Commits

Reviewing files that changed from the base of the PR and between 80dc9c5 and 60c50ea.

📒 Files selected for processing (30)
  • iosApp/iosApp/Extensions/ViewExtensions.swift
  • iosApp/iosApp/Overlays/OverlayPositionGrid.swift
  • iosApp/iosApp/Screens/Auth/TVLoginView.swift
  • iosApp/iosApp/Screens/Auth/TVServerSetupView.swift
  • iosApp/iosApp/Screens/Home/FeaturedCarousel.swift
  • iosApp/iosApp/Screens/Home/SectionRow.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift
  • iosApp/iosApp/Screens/Player/PlayerViewModel.swift
  • iosApp/iosApp/Screens/Player/tvOS/TVPlayerControls.swift
  • iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
  • iosApp/iosApp/Screens/Profiles/CreateProfileView.swift
  • iosApp/iosApp/Screens/Profiles/PINEntryView.swift
  • iosApp/iosApp/Screens/Profiles/ProfileSelectionView.swift
  • iosApp/iosApp/Screens/Profiles/ProfileTile.swift
  • iosApp/iosApp/Screens/Recommendations/RecommendationsView.swift
  • iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
  • iosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swift
  • iosApp/iosApp/tvOS/Screens/Detail/ReadableFocusSection.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVEpisodeRail.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVSeasonChip.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVSeasonDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVSimilarRail.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVFilterLandingRail.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibrariesTabView.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryFilterSheet.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryLandingView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVCardOverlaySettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsView.swift
💤 Files with no reviewable changes (2)
  • iosApp/iosApp/tvOS/Screens/Libraries/TVFilterLandingRail.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryFilterSheet.swift

Comment on lines +2342 to +2353
av_dict_set(&options, "reconnect_on_network_error", "1", 0)
av_dict_set(&options, "reconnect_at_eof", "1", 0)
av_dict_set(&options, "reconnect_on_http_error", "5xx", 0)
av_dict_set(&options, "reconnect_delay_max", "5", 0)
// Matroska over HTTP needs frequent small seeks during probing and
// startup. Keep requests bounded so CDN/proxy TLS connections are not
// held as one large open-ended range while the demuxer seeks around.
av_dict_set(&options, "seekable", "1", 0)
av_dict_set(&options, "multiple_requests", "1", 0)
av_dict_set(&options, "initial_request_size", "2097152", 0)
av_dict_set(&options, "request_size", "2097152", 0)
av_dict_set(&options, "short_seek_size", "2097152", 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

`For the FFmpeg version used by this project, confirm:

  1. whether avformat_open_input leaves unrecognized AVDictionary options unconsumed;
  2. whether these HTTP options are valid and supported: reconnect_on_network_error, reconnect_at_eof, reconnect_on_http_error, seekable, multiple_requests, initial_request_size, request_size, short_seek_size.`

💡 Result:

Regarding your questions about FFmpeg's avformat_open_input and HTTP options: 1) Does avformat_open_input leave unrecognized AVDictionary options unconsumed? Yes. When avformat_open_input is called with an AVDictionary pointer, it attempts to apply relevant options to the format context or the demuxer [1][2][3]. If an option is recognized and successfully applied, it is consumed (removed from the dictionary) [1][2][3]. Any options that are not recognized by the demuxer or the format context are left in the dictionary [1][2][3]. Upon return, the options parameter is updated to contain only those remaining, unrecognized options, allowing the calling code to inspect them [2][3]. 2) Are the specified HTTP options valid and supported? Yes, all of the HTTP options you listed are valid and supported in FFmpeg [4][5]. They are specifically implemented for the HTTP protocol and are used to control connection behavior, retries, and request sizes [4][5]. The supported options are: - reconnect_on_network_error: Automatically reconnect in case of TCP/TLS errors during connection [4][5]. - reconnect_at_eof: Treats end-of-file as an error, useful for live or endless streams [4][5]. - reconnect_on_http_error: A comma-separated list of HTTP status codes (or '4xx'/'5xx') that trigger a reconnection [4][5]. - seekable: Controls seekability of the stream (though its implementation/support can vary by context) [6]. - multiple_requests: Enables the use of persistent HTTP connections [4][5]. - initial_request_size: Limits the size of requests made specifically during initial format probing [4][5]. - request_size: Limits the size of HTTP requests made [4][5]. - short_seek_size: Sets the byte threshold for favoring readahead over performing a new seek request [4][5]. Note: Because these are protocol-level options, they are typically applied when opening a URL with an HTTP protocol handler [4]. When passing these via avformat_open_input, ensure they are included in the AVDictionary [1][2]. In some cases, if you are using a custom AVIOContext, these options might need to be set directly on the AVIOContext or the underlying protocol depending on your specific implementation architecture [7].

Citations:


Ensure FFmpeg-consumed HTTP options aren’t silently ignored
avformat_open_input consumes recognized AVDictionary options and leaves unrecognized/unapplied ones in the dictionary; freeing options immediately can therefore discard misconfigurations without any signal, even though the listed HTTP keys are valid FFmpeg options.

Proposed fix
-        let openResult = avformat_open_input(&optCtx, urlC, nil, &options)
-        av_dict_free(&options)
+        var openOptions = options
+        let openResult = avformat_open_input(&optCtx, urlC, nil, &openOptions)
+        if let openOptions {
+            var leftovers: [String] = []
+            var entry: UnsafeMutablePointer<AVDictionaryEntry>?
+            while true {
+                entry = av_dict_get(openOptions, "", entry, AV_DICT_IGNORE_SUFFIX)
+                guard let entry, let key = entry.pointee.key else { break }
+                leftovers.append(String(cString: key))
+            }
+            if !leftovers.isEmpty {
+                Self.logger.warning("Unused FFmpeg open options: \(leftovers.joined(separator: ","), privacy: .public)")
+            }
+        }
+        av_dict_free(&openOptions)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift` around lines 2342 -
2353, The AVDictionary "options" passed to avformat_open_input is being freed
immediately, which can silently discard unrecognized/unapplied FFmpeg HTTP
options; after calling avformat_open_input (in PlayerCore.swift where options is
set and passed), iterate/check the returned "options" for leftover entries
(using av_dict_get or equivalent) and if any remain log an error/warning or fail
early so misconfigured keys (e.g., "reconnect_on_network_error",
"reconnect_at_eof", "reconnect_on_http_error", "initial_request_size",
"request_size", "short_seek_size", "seekable", "multiple_requests") are visible
to developers; only free the dictionary after this check.

Comment on lines 231 to 233
Button("Create Profile") {
guard !isLoading else { return }
Task { await createProfile() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Prevent duplicate profile-create requests from rapid re-presses.

isLoading is set inside createProfile(), so two fast presses can queue multiple Tasks before the flag flips, causing duplicate create calls.

Suggested fix
-    private func createProfile() async {
+    `@MainActor`
+    private func createProfile() async {
+        guard !isLoading else { return }
         guard !name.trimmingCharacters(in: .whitespaces).isEmpty else {
             formError = FormError(title: "Name Required", message: "Please enter a name.")
             return
         }

         isLoading = true
         formError = nil
         defer { isLoading = false }

Also applies to: 236-239, 473-481

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@iosApp/iosApp/Screens/Profiles/CreateProfileView.swift` around lines 231 -
233, The guard check uses isLoading but createProfile() sets isLoading
asynchronously, allowing multiple Tasks to be queued; fix by setting isLoading =
true immediately before launching the Task (so the UI/state prevents additional
presses), then call await createProfile() (which should no longer set isLoading
true again) and ensure createProfile() still clears isLoading on
completion/error; apply the same change for the other buttons referencing
isLoading (the Button blocks that call createProfile() at the other occurrences
mentioned) and keep createProfile() responsible only for teardown/reset of
isLoading.

Comment on lines +181 to +199
@Environment(\.isFocused) private var isFocused

var body: some View {
configuration.label
.scaleEffect(scale)
.shadow(
color: .black.opacity(isFocused ? 0.45 : 0.0),
radius: isFocused ? 18 : 0,
y: isFocused ? 8 : 0
)
.focusEffectDisabled()
.animation(.easeOut(duration: ContinuumTheme.fastDuration), value: isFocused)
.animation(.easeOut(duration: ContinuumTheme.fastDuration), value: configuration.isPressed)
}

private var scale: CGFloat {
let base: CGFloat = isFocused ? 1.05 : 1.0
return configuration.isPressed ? base * 0.97 : base
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Respect Reduce Motion in TVPosterRingButtonStyle.

The ring button style still applies focus scale/animation even when Reduce Motion is enabled, which can violate the user’s accessibility preference.

Proposed fix
 private struct TVPosterRingButtonBody: View {
     let configuration: ButtonStyleConfiguration

     `@Environment`(\.isFocused) private var isFocused
+    `@Environment`(\.accessibilityReduceMotion) private var reduceMotion

     var body: some View {
         configuration.label
-            .scaleEffect(scale)
+            .scaleEffect(reduceMotion ? 1.0 : scale)
             .shadow(
                 color: .black.opacity(isFocused ? 0.45 : 0.0),
                 radius: isFocused ? 18 : 0,
                 y: isFocused ? 8 : 0
             )
             .focusEffectDisabled()
-            .animation(.easeOut(duration: ContinuumTheme.fastDuration), value: isFocused)
-            .animation(.easeOut(duration: ContinuumTheme.fastDuration), value: configuration.isPressed)
+            .animation(reduceMotion ? nil : .easeOut(duration: ContinuumTheme.fastDuration), value: isFocused)
+            .animation(reduceMotion ? nil : .easeOut(duration: ContinuumTheme.fastDuration), value: configuration.isPressed)
     }

Also applies to: 192-193

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@iosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swift` around lines 181 -
199, Add an accessibilityReduceMotion environment check and skip the focus/press
scaling and animations when it's true: add
`@Environment`(\.accessibilityReduceMotion) private var reduceMotion, then in body
only apply .scaleEffect(scale) and .animation(...) when reduceMotion is false
(or use conditional modifiers), and adjust the private var scale to return 1.0
when reduceMotion is true so that TVMediaCard's focus/press transforms (and
shadow animation) are disabled when Reduce Motion is enabled; reference the
existing isFocused, configuration.isPressed, body, and scale symbols to
implement the conditional behavior.

Comment on lines 20 to 25
HStack(alignment: .top, spacing: 60) {
previewPane
.focusSection()
controlsPane
.focusSection()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

SwiftUI focusSection modifier tvOS availability and version requirements

💡 Result:

SwiftUI’s focusSection modifier is available on tvOS (and also macOS), and it requires tvOS 15.0 or later. Evidence: The official focusSection API documentation describes its behavior in the context of tvOS focus sections [1]. Apple’s WWDC21 “Direct and reflect focus in SwiftUI” session explains using FocusSections on tvOS by adding focusSection to containers to control Siri Remote focus movement [2]. A code example in the wild demonstrates availability checking with #available(tvOS 15.0, *) around focusSection, implying the API’s tvOS minimum deployment target is 15.0 [3].

Citations:


Keep the .focusSection() boundaries, but enforce the tvOS 15+ requirement.

The SwiftUI .focusSection() modifier is a standard API on tvOS and requires tvOS 15.0+. Applying it separately to previewPane and controlsPane is appropriate for remote focus navigation between the two regions. Ensure your minimum tvOS deployment target is >= 15.0 (or guard with if #available(tvOS 15.0, *)). Also, if the PR summary is about “contrast issues,” consider aligning the description since focus sections affect focus navigation, not styling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@iosApp/iosApp/tvOS/Screens/Settings/TVCardOverlaySettingsView.swift` around
lines 20 - 25, Keep the separate .focusSection() modifiers on previewPane and
controlsPane, but guard their usage for tvOS 15+ by wrapping/applying them
behind an availability check (if `#available`(tvOS 15.0, *)) or by ensuring the
project minimum tvOS deployment target is >= 15.0; update the HStack so
previewPane.focusSection() and controlsPane.focusSection() are only invoked when
available, referencing the previewPane and controlsPane symbols and the
.focusSection() modifier.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60c50ea7f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// the remote sits in the top-menu slider) and when content first
// arrives (rows/cards mount after the async load, so the initial token
// would otherwise land before there is anything to focus).
.onChange(of: selectedMode) { _, _ in focusKickNonce += 1 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate content focus kicks to menu hand-off

This reseed also runs when the library-mode slider changes selectedMode while focus is still in TVTopMenuBar—that slider selects modes on focus in segmentButton via onChange(of: isFocused). As a result, simply d-padding between Recommended and Collections in the top menu can make the landing page imperatively focus the hero/first collection card and pull focus out of the menu, making the slider hard to use. Only issue the content focus kick when the menu is actually handing focus down, not for every mode focus change.

Useful? React with 👍 / 👎.

) async throws -> SourceProxyPreparation {
guard plan.delivery == .direct,
plan.engine != .avPlayerHLS,
plan.engine != .playerCoreDirect,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep playerCoreDirect on the source proxy for 404 recovery

When a direct playerCoreDirect stream hits an expired/missing playback session, this guard now skips PlaybackSourceProxy, but the proxy setup below is the only path that calls attemptStaleSessionRenewal via onPlaybackSessionMissing when the origin returns the server's playback_session_not_found 404. In that scenario PlayerCore will read the origin URL directly and surface a terminal playback error instead of renewing the session and resuming, so direct CoreMedia playback loses the stale-session recovery that still exists for proxied direct routes.

Useful? React with 👍 / 👎.

av_dict_set(&options, "reconnect", "1", 0)
av_dict_set(&options, "reconnect_streamed", "1", 0)
av_dict_set(&options, "reconnect_on_network_error", "1", 0)
av_dict_set(&options, "reconnect_at_eof", "1", 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don’t reconnect at real EOF for finite files

For normal finite movie/episode HTTP streams, setting reconnect_at_eof makes FFmpeg treat a legitimate end-of-file as another reconnect condition (the official HTTP protocol docs describe it as useful for live/endless streams). That can keep the demuxer retrying or delay/skip the normal end-of-playback path when the user reaches the end of a file; leave this off for VOD and rely on the existing disconnect/network-error reconnect options instead.

Useful? React with 👍 / 👎.

- PlayerCore: drop reconnect_at_eof — FFmpeg documents it for live/endless
  streams; on finite VOD files it turns a natural EOF into a reconnect,
  delaying or breaking end-of-playback.
- PlayerViewModel: restore stale-session renewal for playerCoreDirect now
  that it bypasses the source proxy. A bare HTTP 404 from FFmpeg on that
  route is treated as playback_session_not_found (the proxy used to parse
  the response body; FFmpeg error strings never carry it).
- TVLibraryLandingView: gate the focus kicks on the top menu not holding
  focus — the mode slider selects on focus, so ungated kicks yanked focus
  out of the menu while sliding between Recommended/Collections.
- SavedShortcutsRow / TVCollectionCard: make the focus hand-down one-shot
  per token. Both live in lazy containers, so onAppear re-fired on scroll
  recycle and teleported focus back to the first item.
- TVPlayerControls: don't claim intro-skip focus while the HUD is open
  (the skip layer renders beneath it).
- TVPosterRingButtonStyle / OverlayCornerDot: respect Reduce Motion on the
  focus scale, matching the primary/secondary button styles.
- Consolidate five copies of the conditional prefersDefaultFocus helper
  into a shared View.applyDefaultFocusIfNeeded extension.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Quick104
Quick104 merged commit b03b653 into main Jun 9, 2026
1 check was pending
@Quick104
Quick104 deleted the tvos-focus-navigation-polish branch June 9, 2026 21:36
Quick104 added a commit that referenced this pull request Jun 15, 2026
…ation

- Remove the Face ID / biometric gate (spec §1/§5/§6). Authorization is the
  user's confirmation tap on a phone already signed in to the server — the
  signed-in phone is the authority. Resolves the spec/plan inconsistency
  (HIGH #1) by dropping the unimplemented gate rather than adding it.
- Make the Receiver poll loop cancellable (plan Task 8): the stream reader
  no longer blocks on polling; each server's start+poll is a separate
  cancellable Task, so a peer Cancel or dropped connection aborts the
  attempt immediately and frees the advertiser (HIGH #3).
- Confirm-once multi-server CRITICAL re-affirmed as the previously-accepted
  v1 risk (no change).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Quick104 added a commit that referenced this pull request Jul 21, 2026
- Clear cached/persisted status and breadcrumb consent context when purging
  a signed-out binding, so a later capture can't recreate default-Ask consent
  and resume diagnostics for the old account (#1)
- Gate persistent capture on server availability, not just consent != Never,
  so a disabled/storage-unavailable server never stores crash reports (#2)
- Persist the binding (and profile) in abnormal-exit markers and attribute the
  report to it; drop markers whose account no longer matches, keeping legacy
  markers' best-effort behavior (#3)
- Default breadcrumb capture to disabled until stored consent loads, bootstrapping
  from the last-known status so a Never account's fresh launch writes nothing (#4)
- Treat a status-refresh failure during upload as retryable instead of a
  destination mismatch (wrong message + 24h retry suppression) (#5)
- Suppress declined prompts for the report's lifetime via a per-report flag;
  declined reports stay manually sendable but never re-prompt or auto-upload (#6)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh
Quick104 added a commit that referenced this pull request Jul 21, 2026
…sent, and upload (#96)

* feat(diagnostics): Apple client diagnostics slice (iOS + tvOS)

Implements the Apple slice of the client-diagnostics spec (silo-server
docs/design/2026-07-19-client-diagnostics.md): vendored contract models
with fixture tests, DiagLog safe-logging facade with collection-time
redaction and an always-on memory ring, breadcrumb journal, tar.gz bundle
builder + multipart upload via DiagnosticsAPI, MetricKit crash/hang capture
(iOS), abnormal-exit sentinel (tvOS) with consent gating, server+account-
bound consent and pending-report stores with sign-out purge, device
snapshot with hashed route identifiers, Diagnostics settings + consent
prompts on both platforms, and a curated cmpLog tee into the ring.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XppCCycoaskCsW7ja1fZct

* feat(diagnostics): consent prompts, pending-report review, and settings UX (iOS + tvOS)

Adds the user-facing layer over the diagnostics slice: the crash/hang
pending-report prompt flow with a review sheet before anything uploads,
per-fingerprint suppression and child-profile gating via
DiagnosticsPromptPolicy, an automatic upload path for always-on consent,
report summary and detail screens, Diagnostics settings panes on both
platforms, and pending-report notifications posted from MetricKit
capture so an active session can surface the prompt.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* feat(debug): auto-login launch arguments for simulator E2E runs

-debugServer/-debugUsername/-debugPassword sign in through the real
checkServer -> login -> selectProfile flow and land on Home, so
simulator-driven end-to-end runs (paired with -debugPlayFirst) need no
UI input. DEBUG builds only.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): redact server hosts, emails, and identity key-values in logs

A captured report leaked the server domain three ways: HTTPClient error
lines with full URLs, wss:// URLs inside NSError descriptions (the URL
regex only matched http/https), and the potential for bare hostnames
outside URL syntax. Now:

- URL normalization hashes the host to a stable [host:<sha256-12>]
  token (ws/wss included), keeping lines correlatable without exposing
  the domain; loopback hosts stay literal for playback debugging.
- Every remembered server hostname from ServerRegistry is registered
  with the redactor and replaced even when it appears as bare text —
  known-string matching avoids the false positives a generic domain
  regex would hit (bundle ids, file names).
- Email addresses are redacted, and username/login/email key-values
  join the token key-value redaction (= and : separators).

Verified on a live report: zero domain occurrences in the bundle,
hashed tokens in place, loopback URLs intact.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address PR #96 review findings

- Move DiagnosticsSHA256 into its own file so the SiloTVTopShelf target
  (which compiles the logging/redaction slice) links DiagLog.hostToken
- Refresh the stored manifest consent notice_version at upload time so a
  report captured under an older notice isn't rejected as stale_consent forever
- Classify too_large uploads as a permanent local failure (new report state)
  instead of retrying the same oversized bundle indefinitely
- Preserve crash capture when the status refresh is offline by falling back to
  the last-known-good status/binding (in-memory, then persisted per server)
- Gate persistent capture for child profiles, mirroring the prompt policy
- Filter breadcrumbs.jsonl to the crashed run's lines for abnormal-exit reports
- Snapshot logs at capture time and prefer the frozen snapshot when building an
  old crash/hang/abnormal-exit bundle (manual reports still use the live ring)
- Distinguish a token rotation from a real identity change by comparing the
  server id + account id rather than raw access-token fingerprints
- Skip reports marked needsServerUpdate/tooLarge in auto-upload and prompting
- Scope recorded playback session IDs to the active binding so another
  server/account's sessions can't leak into a report bound elsewhere
- Truncate MetricKit stack_excerpt by UTF-8 bytes, not characters
- Drop the redundant named-keys frame traversal that duplicated stack frames
- Note the MetricKit delivery-time binding limitation at the capture site
- Hold BreadcrumbJournal's lock across readAll() so reads can't race rotation
- Disable decline/delete buttons while the view model isWorking (iOS + tvOS)
- Register the legacy host for redaction during ServerRegistry migration
- Serialize ExitSentinel.captureEnabled writes with its lock via setCaptureEnabled
- Coalesce overlapping foreground refreshes in DiagnosticsViewModel
- Gate verbose 1 Hz [CMP-DIAG] player traces behind the Debug Logging toggle
- Tests: use failable String(bytes:encoding:) and XCTUnwrap in redaction tests;
  add focused tests for consent refresh, permanent-failure state, session
  scoping, and byte-safe stack truncation

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-2 review findings on PR #96

- Clear cached/persisted status and breadcrumb consent context when purging
  a signed-out binding, so a later capture can't recreate default-Ask consent
  and resume diagnostics for the old account (#1)
- Gate persistent capture on server availability, not just consent != Never,
  so a disabled/storage-unavailable server never stores crash reports (#2)
- Persist the binding (and profile) in abnormal-exit markers and attribute the
  report to it; drop markers whose account no longer matches, keeping legacy
  markers' best-effort behavior (#3)
- Default breadcrumb capture to disabled until stored consent loads, bootstrapping
  from the last-known status so a Never account's fresh launch writes nothing (#4)
- Treat a status-refresh failure during upload as retryable instead of a
  destination mismatch (wrong message + 24h retry suppression) (#5)
- Suppress declined prompts for the report's lifetime via a per-report flag;
  declined reports stay manually sendable but never re-prompt or auto-upload (#6)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-3 review findings on PR #96

- DiagnosticsCoordinator: drop abnormal-exit markers captured under a
  child profile by re-checking the marker's own profile at capture, not
  just the profile active now (an unknown status keeps the marker for a
  later retry).
- DiagnosticsCoordinator: rotate the breadcrumb journal when the active
  server/account binding changes mid-run so a new binding can't bundle
  the previous one's breadcrumbs; the first establish of a launch still
  keeps the prior run's trail for abnormal-exit capture.
- DiagnosticsCoordinator: restrict the last-known-status offline fallback
  to genuine network/status failures; identityChanged (signed out / no
  token) and missing-account no longer capture against a stale binding.
- DiagnosticsCoordinator: gate breadcrumb capture on server availability
  so disabled/storage_unavailable status no longer arms capture,
  consistent with the persistent-capture gate.
- DiagnosticsCoordinator: fail closed when the active profile's child
  status can't be resolved during persistent capture (getProfiles()
  failed offline) instead of proceeding.
- PendingReportStore: refresh consent.mode as well as notice_version from
  the current consent record at upload so a demoted Always->Ask report
  can't still claim mode=always (manual reports stay manual).
- MetricKitCapture: cap crash.summary to 8192 UTF-8 bytes after prefixing
  the first frame, reusing the byte-safe truncation.
- DiagLog: redact HTTPClient's camelCase/wrapper header forms harvested
  from OSLog (profileId=, auth(...), profileToken(...), accessToken /
  refreshToken key-values).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-4 review findings on PR #96

- Restrict the offline capture fallback to genuinely transient failures:
  only network/offline errors and 5xx server errors fall back to the
  last-known snapshot; auth/permission (401/403), missing endpoint (404),
  other 4xx, malformed responses, and identity-level errors now fail closed
  so a capture is never queued against a signed-out or unavailable binding.
- Back-fill the tvOS exit-sentinel marker binding the moment diagnostics
  first resolves it (coordinator refresh completion), not only on a later
  foreground, so a first-run crash before any status refresh is still
  attributed to the right account instead of a legacy/unbound marker.
- Re-verify the active destination immediately before posting a diagnostics
  bundle; the bundle build (OSLog harvest + gzip) can outlast an account
  switch, and a same-server switch keeps server_instance_id, so keep the
  report retryable rather than upload it to the newly active account.
- Drop the access-token fingerprint from the view model's RuntimeIdentity so
  a transparent token refresh during load() is no longer misread as an
  identity change and reset(); the stable identity is server registry id plus
  profile id, with sign-out still detected via token presence and generation.
- Always run the registry-wide diagnostics purge on sign-out (it clears
  reports/consent under older server_instance_ids for the same URL); the
  current-binding purge only skips its own duplicate work, never the
  registry-wide purge.
- Gate uploads on the captured profile: the server rejects an upload whose
  X-Profile-Id header (the currently active profile) disagrees with the
  manifest's report.profile_id (HTTP 400 profile_mismatch). Hold a report
  captured under another profile as retryable — before the bundle build and
  again right before the POST — so it uploads next time the capturing profile
  is active, mirroring the server's resolveProfileID trim-and-compare rule.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-5 review findings on PR #96

- DiagnosticsCoordinator: verify a *stable* destination identity (server
  registry id + selected profile, plus a token-presence sign-out check)
  before posting a bundle, not the access-token value. A transparent token
  refresh during buildBundle no longer trips the pre-POST check and defers
  the Always-path auto-upload for 24h; a genuine same-server account switch
  still fails closed (it clears the token and lands on a different profile).
- DiagLog/LogRing: clear the process-wide log ring when the active
  diagnostics binding changes, mirroring the breadcrumb-journal purge at the
  same trigger, so a new binding's manual report or crash snapshot can't
  include the previous binding's CMP/playback log lines. Adds LogRing.clear().
- DiagnosticsCoordinator: re-evaluate the breadcrumb gate on profile change
  (and status refresh) so an adult->child profile switch disarms breadcrumb
  and exit-sentinel capture, consistent with the persistent-capture child
  gate; fails closed immediately on switch until the async child check lands.
- PlaybackSessionBridge: gate RecentSessionTracker recording on the same
  capture-enabled signal (isDiagnosticsCaptureEnabled) as breadcrumbs, so
  session IDs aren't accumulated while collection is off (Never / disabled /
  storage-unavailable) and later surfaced in a report after re-enable.
- DiagLog.replaceKnownHosts: rewrite as a single forward pass that never
  rescans replaced output, fixing an infinite loop when a registered host is
  a substring of its replacement token (e.g. "host" vs "[host:...]"). Adds a
  pathological-host regression test plus a LogRing.clear() test.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Quick104 added a commit that referenced this pull request Jul 22, 2026
…98)

* feat(diagnostics): Apple client diagnostics slice (iOS + tvOS)

Implements the Apple slice of the client-diagnostics spec (silo-server
docs/design/2026-07-19-client-diagnostics.md): vendored contract models
with fixture tests, DiagLog safe-logging facade with collection-time
redaction and an always-on memory ring, breadcrumb journal, tar.gz bundle
builder + multipart upload via DiagnosticsAPI, MetricKit crash/hang capture
(iOS), abnormal-exit sentinel (tvOS) with consent gating, server+account-
bound consent and pending-report stores with sign-out purge, device
snapshot with hashed route identifiers, Diagnostics settings + consent
prompts on both platforms, and a curated cmpLog tee into the ring.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XppCCycoaskCsW7ja1fZct

* feat(diagnostics): consent prompts, pending-report review, and settings UX (iOS + tvOS)

Adds the user-facing layer over the diagnostics slice: the crash/hang
pending-report prompt flow with a review sheet before anything uploads,
per-fingerprint suppression and child-profile gating via
DiagnosticsPromptPolicy, an automatic upload path for always-on consent,
report summary and detail screens, Diagnostics settings panes on both
platforms, and pending-report notifications posted from MetricKit
capture so an active session can surface the prompt.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* feat(debug): auto-login launch arguments for simulator E2E runs

-debugServer/-debugUsername/-debugPassword sign in through the real
checkServer -> login -> selectProfile flow and land on Home, so
simulator-driven end-to-end runs (paired with -debugPlayFirst) need no
UI input. DEBUG builds only.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): redact server hosts, emails, and identity key-values in logs

A captured report leaked the server domain three ways: HTTPClient error
lines with full URLs, wss:// URLs inside NSError descriptions (the URL
regex only matched http/https), and the potential for bare hostnames
outside URL syntax. Now:

- URL normalization hashes the host to a stable [host:<sha256-12>]
  token (ws/wss included), keeping lines correlatable without exposing
  the domain; loopback hosts stay literal for playback debugging.
- Every remembered server hostname from ServerRegistry is registered
  with the redactor and replaced even when it appears as bare text —
  known-string matching avoids the false positives a generic domain
  regex would hit (bundle ids, file names).
- Email addresses are redacted, and username/login/email key-values
  join the token key-value redaction (= and : separators).

Verified on a live report: zero domain occurrences in the bundle,
hashed tokens in place, loopback URLs intact.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address PR #96 review findings

- Move DiagnosticsSHA256 into its own file so the SiloTVTopShelf target
  (which compiles the logging/redaction slice) links DiagLog.hostToken
- Refresh the stored manifest consent notice_version at upload time so a
  report captured under an older notice isn't rejected as stale_consent forever
- Classify too_large uploads as a permanent local failure (new report state)
  instead of retrying the same oversized bundle indefinitely
- Preserve crash capture when the status refresh is offline by falling back to
  the last-known-good status/binding (in-memory, then persisted per server)
- Gate persistent capture for child profiles, mirroring the prompt policy
- Filter breadcrumbs.jsonl to the crashed run's lines for abnormal-exit reports
- Snapshot logs at capture time and prefer the frozen snapshot when building an
  old crash/hang/abnormal-exit bundle (manual reports still use the live ring)
- Distinguish a token rotation from a real identity change by comparing the
  server id + account id rather than raw access-token fingerprints
- Skip reports marked needsServerUpdate/tooLarge in auto-upload and prompting
- Scope recorded playback session IDs to the active binding so another
  server/account's sessions can't leak into a report bound elsewhere
- Truncate MetricKit stack_excerpt by UTF-8 bytes, not characters
- Drop the redundant named-keys frame traversal that duplicated stack frames
- Note the MetricKit delivery-time binding limitation at the capture site
- Hold BreadcrumbJournal's lock across readAll() so reads can't race rotation
- Disable decline/delete buttons while the view model isWorking (iOS + tvOS)
- Register the legacy host for redaction during ServerRegistry migration
- Serialize ExitSentinel.captureEnabled writes with its lock via setCaptureEnabled
- Coalesce overlapping foreground refreshes in DiagnosticsViewModel
- Gate verbose 1 Hz [CMP-DIAG] player traces behind the Debug Logging toggle
- Tests: use failable String(bytes:encoding:) and XCTUnwrap in redaction tests;
  add focused tests for consent refresh, permanent-failure state, session
  scoping, and byte-safe stack truncation

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-2 review findings on PR #96

- Clear cached/persisted status and breadcrumb consent context when purging
  a signed-out binding, so a later capture can't recreate default-Ask consent
  and resume diagnostics for the old account (#1)
- Gate persistent capture on server availability, not just consent != Never,
  so a disabled/storage-unavailable server never stores crash reports (#2)
- Persist the binding (and profile) in abnormal-exit markers and attribute the
  report to it; drop markers whose account no longer matches, keeping legacy
  markers' best-effort behavior (#3)
- Default breadcrumb capture to disabled until stored consent loads, bootstrapping
  from the last-known status so a Never account's fresh launch writes nothing (#4)
- Treat a status-refresh failure during upload as retryable instead of a
  destination mismatch (wrong message + 24h retry suppression) (#5)
- Suppress declined prompts for the report's lifetime via a per-report flag;
  declined reports stay manually sendable but never re-prompt or auto-upload (#6)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-3 review findings on PR #96

- DiagnosticsCoordinator: drop abnormal-exit markers captured under a
  child profile by re-checking the marker's own profile at capture, not
  just the profile active now (an unknown status keeps the marker for a
  later retry).
- DiagnosticsCoordinator: rotate the breadcrumb journal when the active
  server/account binding changes mid-run so a new binding can't bundle
  the previous one's breadcrumbs; the first establish of a launch still
  keeps the prior run's trail for abnormal-exit capture.
- DiagnosticsCoordinator: restrict the last-known-status offline fallback
  to genuine network/status failures; identityChanged (signed out / no
  token) and missing-account no longer capture against a stale binding.
- DiagnosticsCoordinator: gate breadcrumb capture on server availability
  so disabled/storage_unavailable status no longer arms capture,
  consistent with the persistent-capture gate.
- DiagnosticsCoordinator: fail closed when the active profile's child
  status can't be resolved during persistent capture (getProfiles()
  failed offline) instead of proceeding.
- PendingReportStore: refresh consent.mode as well as notice_version from
  the current consent record at upload so a demoted Always->Ask report
  can't still claim mode=always (manual reports stay manual).
- MetricKitCapture: cap crash.summary to 8192 UTF-8 bytes after prefixing
  the first frame, reusing the byte-safe truncation.
- DiagLog: redact HTTPClient's camelCase/wrapper header forms harvested
  from OSLog (profileId=, auth(...), profileToken(...), accessToken /
  refreshToken key-values).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-4 review findings on PR #96

- Restrict the offline capture fallback to genuinely transient failures:
  only network/offline errors and 5xx server errors fall back to the
  last-known snapshot; auth/permission (401/403), missing endpoint (404),
  other 4xx, malformed responses, and identity-level errors now fail closed
  so a capture is never queued against a signed-out or unavailable binding.
- Back-fill the tvOS exit-sentinel marker binding the moment diagnostics
  first resolves it (coordinator refresh completion), not only on a later
  foreground, so a first-run crash before any status refresh is still
  attributed to the right account instead of a legacy/unbound marker.
- Re-verify the active destination immediately before posting a diagnostics
  bundle; the bundle build (OSLog harvest + gzip) can outlast an account
  switch, and a same-server switch keeps server_instance_id, so keep the
  report retryable rather than upload it to the newly active account.
- Drop the access-token fingerprint from the view model's RuntimeIdentity so
  a transparent token refresh during load() is no longer misread as an
  identity change and reset(); the stable identity is server registry id plus
  profile id, with sign-out still detected via token presence and generation.
- Always run the registry-wide diagnostics purge on sign-out (it clears
  reports/consent under older server_instance_ids for the same URL); the
  current-binding purge only skips its own duplicate work, never the
  registry-wide purge.
- Gate uploads on the captured profile: the server rejects an upload whose
  X-Profile-Id header (the currently active profile) disagrees with the
  manifest's report.profile_id (HTTP 400 profile_mismatch). Hold a report
  captured under another profile as retryable — before the bundle build and
  again right before the POST — so it uploads next time the capturing profile
  is active, mirroring the server's resolveProfileID trim-and-compare rule.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-5 review findings on PR #96

- DiagnosticsCoordinator: verify a *stable* destination identity (server
  registry id + selected profile, plus a token-presence sign-out check)
  before posting a bundle, not the access-token value. A transparent token
  refresh during buildBundle no longer trips the pre-POST check and defers
  the Always-path auto-upload for 24h; a genuine same-server account switch
  still fails closed (it clears the token and lands on a different profile).
- DiagLog/LogRing: clear the process-wide log ring when the active
  diagnostics binding changes, mirroring the breadcrumb-journal purge at the
  same trigger, so a new binding's manual report or crash snapshot can't
  include the previous binding's CMP/playback log lines. Adds LogRing.clear().
- DiagnosticsCoordinator: re-evaluate the breadcrumb gate on profile change
  (and status refresh) so an adult->child profile switch disarms breadcrumb
  and exit-sentinel capture, consistent with the persistent-capture child
  gate; fails closed immediately on switch until the async child check lands.
- PlaybackSessionBridge: gate RecentSessionTracker recording on the same
  capture-enabled signal (isDiagnosticsCaptureEnabled) as breadcrumbs, so
  session IDs aren't accumulated while collection is off (Never / disabled /
  storage-unavailable) and later surfaced in a report after re-enable.
- DiagLog.replaceKnownHosts: rewrite as a single forward pass that never
  rescans replaced output, fixing an infinite loop when a registered host is
  a substring of its replacement token (e.g. "host" vs "[host:...]"). Adds a
  pathological-host regression test plus a LogRing.clear() test.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address round-6 review findings on PR #96

- AuthService: move diagnostics profile invalidation into the profileId
  setter (and the ServerRegistry switchTo/remove profile-restore paths) so
  every active-profile change fails the breadcrumb/session/exit-sentinel gate
  closed, not just the selectProfile path.
- DiagnosticsConsentStore: purge the tvOS ExitSentinel marker when Crash
  Reports is set to Never, so an armed marker can't later surface as an
  abnormal-exit report after collection was turned off.
- ExitSentinel: preserve an unclean previous run's marker in a distinct
  leftover slot before arming the current run, so a crash marker survives a
  failed captureLeftoverIfNeeded and a subsequent background/terminate;
  decode stays backward-compatible. Extracted ExitSentinelMarkerStore for
  the (now unit-tested) slot bookkeeping.
- MetricKitCapture: filter attached breadcrumbs to the payload's reporting
  window (with margin) so post-incident/relaunch and older-segment lines
  don't ride along with a crash/hang report.
- Tests: leftover-preservation round-trip and breadcrumb-window filtering.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e3QjbPo96ed9Mn2qRiUkh

* fix(diagnostics): address PR review feedback

* fix(diagnostics): address automated review follow-ups

* fix(diagnostics): close evidence isolation gaps

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Quick104 added a commit that referenced this pull request Aug 21, 2026
… it clobber the newer load

Finding control-plane/1 (P1 #1).

`send`/`ingest` commit the reduced state and then `await run(effects)`, and a
Swift actor is re-entrant at every `await`. `beginLoad` orders three suspending
effects — `.cancelTimer(.sourceOutageRideThrough)` (clearOutageNoticeLatch),
`.publish` (applyPresentation) and `.disposeEngine` (teardownEngine) — before
`.startSession`, and `.load` is accepted from `.preparing`. A second load that
committed and ran while the first batch was parked was then overwritten by it:
the parked batch published its stale surface, and its `.startSession` cancelled
the newer load's fresh-load task and installed its own — whose `.prepared`
answer the reducer refused, leaving the player in `.preparing` behind the
loading overlay with nothing left to finish it.

One mechanism: a monotonic `transitionEpoch` owned by the actor, bumped by
`commit` on every transition that binds the state to a different load or moves
it to a different phase, captured at the commit and checked before every effect
in `run`/`perform`. A stale batch stops where it is and undoes nothing.
`startSession` additionally guards `loadID == state.loadID`, which is what keeps
its `tasks[.freshLoad]?.cancel()` from ever retiring a newer load's task; the
registry key stays a plain enum because the guard, not the key, is the gate.

Also introduces `PlaybackControlPlaneShell`, the seam the lifecycle tests need
to hold a shell call open across a second transition. `PlayerViewModel` is the
one production conformer (retroactive conformance here; that file is untouched)
and every requirement is `async`, which its synchronous `@MainActor` methods
satisfy unchanged. No runtime behaviour rides on the protocol itself.

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

1 participant