Skip to content

Audiobooks: first-party playback over the standard API, PlexAmp-style player, tvOS polish - #3

Merged
Quick104 merged 6 commits into
mainfrom
audiobook-playback-and-player
Jun 10, 2026
Merged

Quick104 merged 6 commits into
mainfrom
audiobook-playback-and-player

Conversation

@Quick104

@Quick104 Quick104 commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Playback over the standard API

First-party audiobook support for iOS, tvOS, and macOS. The original client work targeted the dedicated /api/v1/audio/* surface from server PR Silo-Server/silo-server#97, which was closed without merging — so every playback start 404'd in production. The client now ships against what main actually serves (mirroring the web player):

  • AudiobookPlaybackContext builds the whole-book timeline (parts, global chapter offsets, resume point) from GET /items/{id}
  • One direct POST /playback/start session per file with disable_progress_persistence: true; parts are stitched at boundaries by stopping/starting sessions
  • File-local progress goes to POST /playback/{id}/progress (admin activity/keepalive); book-level resume persists through POST /sync/progress with force_overwrite
  • Bookmarks are omitted — main has no first-party bookmark endpoint (only the ABS-compat surface with separate auth)

Also fixes a fatal crash in the audio error path: both tab shells applied .environment(router) inside the presentation modifiers, so fullScreenCover content never inherited AppRouter and ErrorView trapped on first render.

PlexAmp-style player

  • Cover-sampled palette (CoreImage quadrant averages) drives a slow-drifting MeshGradient backdrop and an accent tint for controls
  • Slim chapter-ticked scrubber with drag-to-scrub, oversized artwork that breathes with play state, circular accent play button, speed/sleep/chapter chips, chapter sheet that opens at the current chapter
  • tvOS side-by-side layout (remote Back minimizes); Reduce Motion pauses the drift and artwork scaling; scrubber is VoiceOver-adjustable

tvOS detail + home polish

  • Detail action pills now use the shared TVPrimaryPillButton/TVSecondaryPillButton (system bordered styles rendered white-on-white under the shell's continuumOnSurface tint)
  • Chapter rows use native list-row focus inversion instead of the plain-button blowup, with 10-foot typography
  • All-audiobook rows (Continue Listening, audiobook rails) render square 1:1 tiles instead of stretching covers into 2:3 posters

Infrastructure

  • Vendored mpvkit/ffmpeg-build as a local Swift package — upstream is archived and its pinned Libuavs3d release asset was re-published with a new checksum, so remote manifest resolution can never succeed again
  • PlayerCore: generation-tokened post-discontinuity preroll waiters, buffer-gated restart, centralized format-context seeking

Review notes

  • The playback flow is intentionally a port of web/src/pages/audiobooks/player/useAudiobookPlayback.ts — divergences from it are bugs
  • Vendor/ffmpeg-build adds only the package manifest/shims (~90 KB); .build/.swiftpm are ignored
  • Verified: all three schemes build; standalone DetailVersionSelectionTests pass; playback, resume, and the detail page exercised on a physical Apple TV against the production server

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added audiobook playback support with full-screen player, mini player, and chapter navigation
    • Introduced square media tile layout alongside poster layout
    • Enhanced library type detection with dedicated audiobook and series labels
    • Added audiobook detail screen with metadata and playback controls
  • Bug Fixes

    • Improved video player seeking and decoder reset behavior for optimal playback quality
  • Tests

    • Added comprehensive audiobook playback and timeline mapping test coverage
  • Chores

    • Vendored FFmpeg dependency locally for improved build reliability

Quick104 and others added 6 commits June 9, 2026 18:26
Upstream is archived and the Libuavs3d 1.2.1 release asset it pins was
re-published with a new checksum on 2026-04-23, so remote resolution of
the manifest can never succeed again. Vendor the package at commit
b38afaff with only the Libuavs3d checksum corrected, and point
project.yml at the local path. Ignore .swiftpm/ so SPM workspace state
stays out of the repo.

Co-Authored-By: Claude Fable 5 <[email protected]>
Generation-token the post-discontinuity preroll waiters so a newer seek
or track switch cancels stale ones instead of racing them, gate restart
on minimum decoded audio/video buffer, and centralize format-context
seeking with stream-appropriate timestamps.

Co-Authored-By: Claude Fable 5 <[email protected]>
First-party audiobook support for iOS, tvOS, and macOS: a persistent
audio player (mini player + full-screen Now Playing), audiobook detail
content with parts/chapters, audiobook library surfaces in Home,
Browse, and the tvOS library tabs, and spoken-audio Now Playing
integration with adjustable skip intervals and playback rate.

Playback uses the standard per-file session API that the web client
ships against — the dedicated /api/v1/audio surface from the closed
server PR #97 never reached main, which 404'd every audiobook start.
The client now builds the whole-book timeline from item detail
(AudiobookPlaybackContext), starts one direct /playback/start session
per part with disable_progress_persistence, stitches parts at
boundaries, and reports file-local progress to the session while
persisting book-level resume through /sync/progress. Bookmarks are
omitted: main has no first-party bookmark endpoint.

Also fix a startup crash in the audio error path: both tab shells
applied .environment(router) inside the presentation modifiers, so
fullScreenCover content (the audio player) never inherited AppRouter
and ErrorView trapped on first render.

Co-Authored-By: Claude Fable 5 <[email protected]>
PlexAmp-inspired Now Playing surface: quadrant colors sampled from the
book cover (CIAreaAverage over a Nuke-downsampled thumb) drive a
slow-drifting MeshGradient backdrop and an accent tint for the
controls. The full player gets oversized artwork that breathes with
play state, a slim chapter-ticked scrubber with drag-to-scrub, a
circular accent play button, capsule chips for speed/sleep/chapters,
and a chapter sheet that opens scrolled to the current chapter. tvOS
uses a side-by-side layout with remote Back to minimize; the mini
player picks up the accent progress hairline and current chapter line.

Drift and artwork scaling pause under Reduce Motion, and the scrubber
exposes a VoiceOver-adjustable element. AudioPlayerViews.swift is
split into focused per-view files.

Co-Authored-By: Claude Fable 5 <[email protected]>
The detail action row rendered white-on-white until focused because
the tvOS shell tints controls with continuumOnSurface — swap the
system bordered styles for the hero pill buttons the video detail
already uses. Chapter rows were .plain buttons, so tvOS focus blew
them up into full-width slabs; they now use the native list-row
inversion (faint resting fill, white/black on focus, gentle scale)
with 10-foot typography.

Audiobook covers are square, so rows made entirely of audiobooks
(Continue Listening, audiobook rails) now render 1:1 tiles via a new
MediaRow/MediaCard square aspect instead of stretching covers into
2:3 posters — same treatment for the detail page's related rails.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 89bf1bcc-3c89-4630-bfe4-debdecd9720e

📥 Commits

Reviewing files that changed from the base of the PR and between b03b653 and ba6cead.

⛔ Files ignored due to path filters (5)
  • docs/mockups/media-integration/01-unified-home-feed-iphone.png is excluded by !**/*.png
  • docs/mockups/media-integration/02-library-first-switcher-iphone.png is excluded by !**/*.png
  • docs/mockups/media-integration/03-for-you-intent-hub-iphone.png is excluded by !**/*.png
  • docs/mockups/media-integration/04-ipad-sidebar-all-media.png is excluded by !**/*.png
  • docs/mockups/media-integration/05-tvos-unified-dashboard.png is excluded by !**/*.png
📒 Files selected for processing (52)
  • .gitignore
  • iosApp/Tests/DetailVersionSelectionTests.swift
  • iosApp/Vendor/ffmpeg-build/LICENSE
  • iosApp/Vendor/ffmpeg-build/Package.swift
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/dummy.c
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/avcodec_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/avdevice_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/avfilter_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/avformat_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/avutil_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/swresample_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/swscale_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/dummy.c
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/avcodec_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/avdevice_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/avfilter_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/avformat_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/avutil_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/swresample_shim.h
  • iosApp/Vendor/ffmpeg-build/Sources/FFmpeg/include/swscale_shim.h
  • iosApp/iosApp/Components/MediaCard.swift
  • iosApp/iosApp/Components/MediaRow.swift
  • iosApp/iosApp/ContentView.swift
  • iosApp/iosApp/Networking/Models.swift
  • iosApp/iosApp/Screens/Audio/AudioChaptersSheet.swift
  • iosApp/iosApp/Screens/Audio/AudioCoverArtView.swift
  • iosApp/iosApp/Screens/Audio/AudioCoverPalette.swift
  • iosApp/iosApp/Screens/Audio/AudioFullPlayerView.swift
  • iosApp/iosApp/Screens/Audio/AudioMiniPlayerView.swift
  • iosApp/iosApp/Screens/Audio/AudioPlaybackStore.swift
  • iosApp/iosApp/Screens/Audio/AudioPlaybackTimeline.swift
  • iosApp/iosApp/Screens/Audio/AudioPlayerBackground.swift
  • iosApp/iosApp/Screens/Audio/AudioPlayerEngine.swift
  • iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift
  • iosApp/iosApp/Screens/Audio/AudiobookPlaybackContext.swift
  • iosApp/iosApp/Screens/Browse/BrowseView.swift
  • iosApp/iosApp/Screens/Browse/LibrariesTabView.swift
  • iosApp/iosApp/Screens/Detail/AudiobookDetailContent.swift
  • iosApp/iosApp/Screens/Detail/ItemDetailView.swift
  • iosApp/iosApp/Screens/Detail/ItemDetailViewModel.swift
  • iosApp/iosApp/Screens/Home/FeaturedCarousel.swift
  • iosApp/iosApp/Screens/Home/HomeView.swift
  • iosApp/iosApp/Screens/Home/SectionRow.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/CompressedVideoPipeline.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift
  • iosApp/iosApp/Screens/Player/NowPlayingController.swift
  • iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibrariesTabView.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridView.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryLandingView.swift
  • iosApp/project.yml

📝 Walkthrough

Walkthrough

This PR introduces comprehensive audiobook playback support to the iOS/tvOS app while transitioning FFmpeg binary dependencies from a remote Git source to a locally vendored package. The feature includes a complete playback engine, multi-part timeline management, full-screen and mini-player UI, detail screen rendering, and integration across browse, library, and home navigation. Video player discontinuity handling is improved to gate playback resumption after seek/track-switch operations.

Changes

FFmpeg vendoring and binary dependencies

Layer / File(s) Summary
FFmpeg dependency vendoring
.gitignore, iosApp/project.yml, iosApp/Vendor/ffmpeg-build/LICENSE, iosApp/Vendor/ffmpeg-build/Package.swift, iosApp/Vendor/ffmpeg-build/Sources/FFmpeg*/include/*_shim.h, iosApp/Vendor/ffmpeg-build/Sources/FFmpeg-GPL/include/*_shim.h
.gitignore excludes .swiftpm/ cache. project.yml switches FFmpeg from remote Git URL/revision to local Vendor/ffmpeg-build path. A new SwiftPM manifest declares two library products (FFmpeg, FFmpeg-GPL) and targets with explicit binary dependencies pinned to upstream artifact URLs and checksums. LGPL v3 license is added. Shim headers are created for both products, providing include guards and forwarding includes to FFmpeg libraries, with avutil_shim.h variants also exposing Swift-friendly constant/function wrappers.

Audiobook playback feature

Layer / File(s) Summary
Audiobook models and data infrastructure
iosApp/iosApp/Networking/Models.swift, iosApp/iosApp/Screens/Audio/AudiobookPlaybackContext.swift, iosApp/iosApp/Screens/Audio/AudioPlaybackTimeline.swift
Models.swift adds SiloMediaType classification, extends ItemDetail with optional audiobook field and corresponding Codable types, adds presentation metadata to FileVersion, and updates Library/LibrariesResponse to support audiobook/series detection and flexible response decoding. AudiobookPlaybackContext.swift defines AudioPlaybackTrack and AudioPlaybackChapter structures representing a stitched timeline and provides initialization from ItemDetail.versions. AudioPlaybackTimeline.swift provides utilities for converting between global and local track time.
Audio playback engine and observable store
iosApp/iosApp/Screens/Audio/AudioPlayerEngine.swift, iosApp/iosApp/Screens/Audio/AudioPlaybackStore.swift
AudioPlayerEngine.swift wraps AVPlayer with lifecycle management, time observation, end-of-playback notifications, and methods for load/play/pause/seek/stop. AudioPlaybackStore.swift provides an @MainActor observable store managing playback requests, full-player presentation, and async playback start via AudioPlayerViewModel.
Audio player view model and now playing integration
iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift, iosApp/iosApp/Screens/Player/NowPlayingController.swift
AudioPlayerViewModel.swift orchestrates playback, session lifecycle, track loading, stream URL resolution, now-playing metadata, progress sync, and chapter navigation. NowPlayingController.swift is extended to support configurable skip intervals, media kind classification, and enriched metadata (artist, album, playback rate).
Audio player UI components
iosApp/iosApp/Screens/Audio/AudioCoverArtView.swift, iosApp/iosApp/Screens/Audio/AudioCoverPalette.swift, iosApp/iosApp/Screens/Audio/AudioPlayerBackground.swift, iosApp/iosApp/Screens/Audio/AudioMiniPlayerView.swift, iosApp/iosApp/Screens/Audio/AudioFullPlayerView.swift, iosApp/iosApp/Screens/Audio/AudioChaptersSheet.swift
Cover art display with async loading, color palette sampling from cover art using CoreImage, animated mesh-gradient background with phase animation, bottom mini player with progress hairline, full-screen player with platform-specific layouts and scrubber with chapter tick marks, and chapters list sheet with auto-scroll and tap-to-jump.
Audiobook detail screen rendering
iosApp/iosApp/Screens/Detail/AudiobookDetailContent.swift, iosApp/iosApp/Screens/Detail/ItemDetailView.swift, iosApp/iosApp/Screens/Detail/ItemDetailViewModel.swift, iosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swift
AudiobookDetailContent.swift renders audiobook detail with overview, parts, chapters, series/related rails, and alternate narrations sections, with responsive headers and action buttons. Integration files route audiobook content through this view on both iOS and tvOS.
Audiobook routing and navigation integration
iosApp/iosApp/Screens/Home/FeaturedCarousel.swift, iosApp/iosApp/Screens/Home/HomeView.swift, iosApp/iosApp/Screens/Browse/BrowseView.swift, iosApp/iosApp/Screens/Home/SectionRow.swift, iosApp/iosApp/Screens/Browse/LibrariesTabView.swift, iosApp/iosApp/Components/MediaCard.swift, iosApp/iosApp/Components/MediaRow.swift, iosApp/iosApp/tvOS/Screens/Libraries/TVLibrariesTabView.swift, iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridView.swift, iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryLandingView.swift
Featured carousel callback updated to pass full SectionItem. HomeView and BrowseView route audiobooks via audioStore.play() while non-audiobooks navigate to video player. SectionRow detects all-audiobook sections and applies square layout. Library UI files update classification using isAudiobookLibrary/isSeriesLibrary helpers for icons and labels. MediaCard adds aspect-ratio support and MediaRow treats square layout like poster while setting card aspect conditionally.
Root app and top-level navigation
iosApp/iosApp/ContentView.swift, iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
ContentView.swift adds AudioPlaybackStore state, injects it into environment, closes player on session expiration, and updates continuum://play/ deep-link handling to route audiobooks through store while non-audiobooks use video player. MainTabView renders mini player and full-screen player presentation. Router environment is moved outside presentation modifiers for accessibility. TVMainTabView.swift integrates audio store for tvOS with full-screen cover presentation and router availability.
Video player discontinuity and decoder improvements
iosApp/iosApp/Screens/Player/CoreMedia/CompressedVideoPipeline.swift, iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift
CompressedVideoPipeline.swift adds conditional decoder-reset behavior via requiresRandomAccessForDecoderReset parameter and exposes decoderResetApplied in outcome. PlayerCore.swift introduces playback restart generation tracking, beginPlaybackAfterDiscontinuityWhenPrimed() for gating resumption after seek/track-switch, generalized seek helpers, and updates discontinuity workflows to use the new preroll-and-generation flow.
Audiobook and timeline tests
iosApp/Tests/DetailVersionSelectionTests.swift
Four new test cases verify audiobook ItemDetail decoding, SiloMediaType classification, LibrariesResponse bare-array decoding, and AudioPlaybackTimeline track/time conversion helpers.

🎯 4 (Complex) | ⏱️ ~75 minutes

✨ 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 audiobook-playback-and-player

@Quick104
Quick104 merged commit 8cd4623 into main Jun 10, 2026
1 check was pending
@Quick104
Quick104 deleted the audiobook-playback-and-player branch June 10, 2026 00:01

@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: ba6cead181

ℹ️ 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".

Comment on lines +26 to +31
Task {
await player.start(
contentId: lastRequest.contentId,
restart: lastRequest.restart,
startPosition: lastRequest.startPosition
)

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 Ignore stale audiobook start tasks

When a user starts two audiobooks in quick succession (or retries/taps another title while the first /itemDetail or /playback/start call is still in flight), each untracked Task can complete out of order and still call player.start. Since AudioPlayerViewModel.start only checks the existing context before its first await, an older request can overwrite the newer context or reuse the newer session/track index, leaving playback pointed at the wrong book/session. Track and cancel the previous start task or pass a request generation through start so stale completions are ignored.

Useful? React with 👍 / 👎.

Comment on lines +436 to +440
.fullScreenCover(isPresented: Binding(
get: { audioStore.isShowingFullPlayer },
set: { if !$0 { audioStore.dismissFullPlayer() } }
)) {
AudioFullPlayerView()

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 Present audio controls on macOS

These new audio presentation modifiers are compiled only for !os(macOS), but the shared non-tvOS detail UI still renders AudiobookDetailContent play buttons on macOS and calls audioStore.play. On macOS, pressing Play can therefore start the AVPlayer-backed audiobook in the background with no mini player/full player and no in-app way to pause or stop it. Either present a macOS audio player/control surface or hide/route the audiobook play actions for macOS.

Useful? React with 👍 / 👎.

Comment on lines +172 to +175
audioStore.play(
contentId: detail.contentId,
restart: false,
startPosition: resumePosition

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 Start non-resumable Play actions from zero

When the stored audiobook position is intentionally not resumable (for example resumePosition is nil because progress is under 30 seconds or within 5 seconds of the end), this primary button still sends restart: false; AudioPlayerViewModel.start then falls back to context.resumePositionSeconds, so a button labeled “Play” can jump to the near-end saved position instead of starting over. Pass restart: true (or an explicit startPosition: 0) when resumePosition is nil so the label and behavior match.

Useful? React with 👍 / 👎.

Comment on lines +84 to +85
} catch {
self.error = ErrorState(error)

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 Clear partial audio state after failed starts

If loadTrack fails after the context has been assigned (for example /playback/start fails or returns an unusable stream URL), the catch only records the error and leaves context, duration, Now Playing, and hasActiveSession populated. Dismissing the error then leaves the mini player visible for an item that never loaded, and its controls operate on an empty AVPlayer. Clean up the partially-created session state in this failure path before exposing the error.

Useful? React with 👍 / 👎.

Comment on lines +436 to +440
.fullScreenCover(isPresented: Binding(
get: { audioStore.isShowingFullPlayer },
set: { if !$0 { audioStore.dismissFullPlayer() } }
)) {
AudioFullPlayerView()

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 Stop audiobooks before opening videos

With the new persistent audiobook player, the audio full-screen cover is independent from the existing video PlayerView cover below it. If an audiobook is playing and the user starts a movie/episode, nothing pauses or closes audioStore.player, so the audiobook can keep playing underneath the video and both players can register Now Playing remote commands. Close or pause the audio session before presenting video playback.

Useful? React with 👍 / 👎.

Comment on lines 97 to 99
.onReceive(NotificationCenter.default.publisher(for: .continuumSessionExpired)) { _ in
Task { await audioStore.player.close() }
router.expiredSession()

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 Close audio on manual sign-out

This only stops audiobook playback when the session-expired notification fires. Manual sign-out paths call router.signOutAndReset() directly and do not post .continuumSessionExpired, so an audiobook can continue playing after tokens/profile state have been cleared and the UI has returned to login/server setup with no mini player controls. Also close audioStore.player when auth state leaves .authenticated or when sign-out is requested.

Useful? React with 👍 / 👎.

Comment on lines +18 to +21
#if os(tvOS)
.onExitCommand {
minimize()
}

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 orphan tvOS playback on Exit

On tvOS, pressing Menu/Back while the audiobook player is open calls minimize(), which dismisses the only audio UI while leaving playback active. Unlike iOS, tvOS does not install AudioMiniPlayerView, so after this path the user has no visible way to reopen, pause, or stop the audiobook except by starting another book or relying on system controls. Either treat Exit as stop/pause or provide a tvOS mini/reopen affordance before dismissing.

Useful? React with 👍 / 👎.

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]>
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