Skip to content

Sweep dead code, redundant tests and superseded docs - #365

Merged
jlipworth merged 12 commits into
mainfrom
chore/cruft-dead-code-sweep
Oct 17, 2026
Merged

jlipworth merged 12 commits into
mainfrom
chore/cruft-dead-code-sweep

Conversation

@jlipworth

@jlipworth jlipworth commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Speculative cleanup sweep. 12 partitions were swept by Sonnet and Haiku agents (148 candidates), then an Opus verifier per partition tried to refute each one, which left about 55. Every change is a pure deletion or an equivalent dedup with no intended behaviour change. The net diff is about −11k lines, mostly archived docs.

Commits

  1. PMSKit dead APIs. Removes PlaybackSeekControl, HomeRailsLoad, EpisodeResolver, directPlayStartM3U8Request(), uniqueExactIndex, LibraryVisibility.isHidden, unused enum cases (stallWatchdog, ambiguousCandidateCount), test-only SharePlay helpers, the duplicate quote wrappers and the test-only typealiases. Two members that only their own file used are now private. X-Plex-Client-Profile-Name=Generic is untouched.
  2. Persistence durability tier. Drops PersistenceDurabilityTier. Every caller passed .bestEffort, so AppDiagnostics.flush() and append(_:) lose the parameter.
  3. Dead player/debug code. Removes the #if DEBUG logDirectPlayDecision, the unused musicArtwork callback kind, the unused debug-probe helpers, the unused Cinema geometry members and the unreferenced LabstreamLogo.imageset.
  4. Music/UI dedup. Adds RepeatMode.symbolName and has search use formatTrackDuration.
  5. Test dedup. Moves waitForObservedState, TestCounter and the gate helpers into TestSupport.swift, adds a TV UI-test screenshot helper, and collapses the auth test gates into one held continuation.
  6. Docs pruning. Deletes superseded docs/archive/{plans,reviews,macos,proposals,first-public-cleanup}, most of docs/archive/research and docs/evidence/profiling, and the stray .claude copy of the openai.yaml agent metadata. It also repairs the links to them, de-duplicates the doc-lane taxonomy in README/index, and fixes small stale passages in DEVELOPMENT/CODE-MAP.
  7. Scripts. Removes loc.sh, de-duplicates the _sha256 helpers into contract.sha256_file, and adds a shared _script_loader for 8 tooling tests.
  8. PlexInsecureLANTrustDelegate removed (maintainer decision): it was never installed.
  9. PMSKit fallback version removed: PMSKit.swift, SanityTests, the bump-version skill's toolkit scope and pmskit-v tags, and the matching RELEASES.md lines.
  10. visionOS synthetic-click scenario removed: simclick.swift, click-login-jellyfin-tab in agent-sim-run.sh, the sim-driving skill and CLAUDE.md.
  11. RELEASES.md refreshed: the Cold launch without connectivity blocks completed offline downloads #259/iOS player chrome changes size or position between video aspect ratios #258 notes now say their fixes (Gate offline launch on a typed session-restore outcome (#259) #355/Keep iOS player chrome in one stable safe-area envelope (#258) #356) are on main with physical acceptance still open, and the outdated validation narrative is condensed.
  12. Watch Together start now goes through SharePlayReadinessSummary.canStart, so the tested policy is the one that runs. This doesn't change behaviour: the local participant is always .ready once resolvedItem is set.

Verification (local)

  • Hermetic PMSKit tests: 1514 passed after the rebase onto main.
  • PATH=/usr/bin:$PATH scripts/ci-hygiene.sh: ok (strict MkDocs, links, mermaid, tooling tests).
  • Clean builds of Labstream (visionOS), LabstreamMobile, LabstreamTV (build-for-testing) and LabstreamMac: all exit 0.
  • native-test-matrix.py affected lanes:
    • macOS hosted: 636 Swift Testing tests passed after the rebase.
    • mobile hosted: 622 passed.
    • mobile UI smoke: passed.
    • tvOS hosted: 370 passed.
    • tvOS UI smoke: 2 passed.
  • The full set was rerun after the rebase and commits 8–12: hygiene, clean builds of all four targets, macOS hosted, and a clean visionOS rebuild plus smoke.
  • visionOS smoke on this worktree's sim: the installed app's UUID matches the build, the app launches to the signed-in Plex Home with no crash, and the log has no fatal errors.

Deliberately not changed

  • The live-probe .env loader dedup across scripts/live-*.sh partly touches the download probes.

Report-only (overlaps with active threads)

  • Downloads: DownloadStore.createSeasonPlanned has no callers, setPosterRelativePath is test-only, there are testing hooks in production sources, there is a stale "NOT live-verified" banner in the Plex optimize code, and the BackgroundQueue.first* accessors are test/probe-only. The Local* trickplay/chapter providers also duplicate boilerplate.
  • Larger refactors left alone: the duplicated Emby/Jellyfin request builders and media-source models.

@jlipworth
jlipworth force-pushed the chore/cruft-dead-code-sweep branch from d197130 to 64c1b7f Compare October 17, 2026 02:25
@jlipworth
jlipworth merged commit 6aa92bd into main Oct 17, 2026
5 checks passed
@jlipworth
jlipworth deleted the chore/cruft-dead-code-sweep branch October 17, 2026 02:42
jlipworth added a commit that referenced this pull request Oct 17, 2026
#365 added a shared `XCTestCase.attachScreen(named:app:)` extension in
`LabstreamTVUITests/XCTestCase+Screenshot.swift`; #367 kept an identical
private copy in `LabstreamTVStatsTests.swift`. Together they break
`LabstreamTVUITests` compilation on main ("overriding declaration
requires an 'override' keyword"), which fails the
`native-test-matrix.py` `tvos-build` lane (build-for-testing). CI does
not currently build the tvOS UI-test target, so this merged green.

Fix: delete the private duplicate; the shared extension is byte-for-byte
the same body.

Verification: `scripts/native-test-matrix.py affected --run --lane
tvos-build` → TEST BUILD SUCCEEDED (run from the downloads-overhaul
branch carrying the same one-file change).
jlipworth added a commit that referenced this pull request Oct 17, 2026
Second PR of the performance pass (UI and artwork). It stops off-screen
browse work from fetching, decoding and animating.

## Changes
- **Grid prefetch is tied to the placeholder's `.task`**
(`LibraryGridView`, `MusicPagedGrid`, `ContainerBrowserView`). A fling
now cancels the page prefetches for placeholders it scrolls past,
instead of starting an unowned `Task` for every one.
- **Lazy playlist rows:** the playlist track list and the music playlist
list use `LazyVStack`.
- **Skeleton shimmer:**
- Skeletons lease the shared 60 Hz clock only after 300 ms, so cache
hits and fast loads never start it.
- Skeletons that don't hold a lease don't read the clock's phase, so
they aren't invalidated on every tick.
- The blurred backdrop washes in Detail and the music views show no
shimmer.
  - `DEBUG || PERFORMANCE_AUDIT` counters emit `perf.shimmer_session`.
- **Now Playing and mini bar:** the playhead tick now invalidates only
the extracted scrubber and progress-hairline views, not the whole view.
The Now Playing queue deliberately stays a `VStack` because its
`scrollPosition` anchoring depends on it.
- **Artwork memory pressure:** on a warning or critical memory-pressure
event, the decoded-bitmap cache is emptied. Compressed bytes are kept,
so the next read of an image whose bytes are still cached decodes
locally with no network fetch. There is no epoch bump, so in-flight
loads are unaffected.
- **Docs:** `ARCHITECTURE.md` and `CODE-MAP.md` describe the trim, the
delayed lease and the backdrop exemption.

## Measurements (visionOS worktree sim, Plex golden clone, 3 interleaved
cold-launch pairs; full raw evidence kept privately)
| `perf.shimmer_session` on Home | Baseline | After |
|---|---|---|
| Clock running | 788–804 ms | 77–109 ms |
| 60 Hz ticks | 24 | 4–5 |
| Leases | 38 | 7 |
| Peak subscribers | 19 | 7 |

`home.first_content` was unchanged (59–115 ms in both arms).

The grid-prefetch cancellation, the lazy playlist rows and the Now
Playing invalidation split are structural and were not timed in this
pass. The memory-pressure trim is covered by a new
`ArtworkPipelineTests` case: the read after a trim takes the
compressed-cache decode path with no second network fetch.

## Verification
- `ci-hygiene.sh`.
- Hermetic PMSKit tests.
- Clean builds: visionOS, iOS and macOS. tvOS is blocked by `main` (see
below).
- macOS hosted app tests.
- visionOS worktree-sim smoke: install matches build, the app stays
alive, and Home renders.

## Open gates
- **Interactive checks:** fling, scrub and playlist scroll behaviour,
and the music views on iPhone, iPad, tvOS and macOS, were not driven
interactively. This is the user's half.
- **Jellyfin/Emby:** blocked (no credentials). The changes are
backend-agnostic UI code.
- Physical-device performance and energy acceptance remain the
maintainer's.
- **tvOS build (pre-existing on `main`):** `tvos-build` fails on
`origin/main` itself. Two PRs that merged close together collided: #365
added a shared `XCTestCase.attachScreen(named:app:)`, and #367 added a
`private func attachScreen` in
`LabstreamTVUITests/LabstreamTVStatsTests.swift`. This PR touches no
tvOS file; the main app target compiles in the other three lanes.
jlipworth added a commit that referenced this pull request Oct 17, 2026
…#372)

First PR of a bottom-up performance pass (networking/PMSKit). Static
audit first, then before/after measurement where a harness exists.
Results are unchanged; latency and the request pattern change. Probes
now overlap, and discovery may contact up to four candidate servers at
once where the serial walk contacted one.

## Changes
- **Plex connection selection** (`PreferredProbe` in PMSKit, used by
`AuthManager.firstReachable` and `discoverPlexSession`): probes still
run concurrently, but the most-preferred reachable connection is
returned as soon as every more-preferred one has failed, and the
remaining probes are cancelled. Before, one dead LAN/IPv6 interface held
sign-in/restore until the 3 s probe timeout. The preference order (local
before remote, relay last) and the `machineIdentifier` check are
unchanged. Candidate servers in discovery are probed the same way, at
most 4 at a time and started in preference order. Servers beyond that
window are never contacted once a winner is decided.
- **Settings reachability:** all listed servers are probed concurrently.
Each row updates as soon as its own probe finishes, and a newer check
suppresses results from an older one. This is user-initiated and covers
only the servers on screen, so it is not windowed.
- **Collapsing Jellyfin/Emby grids**
(`LibraryPagingModel.loadAllCollapsing`): later pages are fetched
through a 3-page window and ingested strictly in offset order. The
stale-generation guard, the empty-page stop and `serverTotal` handling
are unchanged. A page's fetch error is surfaced only when ingestion
reaches that page, so an error past an empty page is ignored and earlier
pages are still ingested, exactly as in a serial walk. The load also
re-checks that it is still current after the group finishes waiting for
its cancelled fetches.
- **Plex music home:** the history rail starts alongside the hubs
(`async let`).
- **Movie-version chooser:** labels are fetched concurrently and
cancelled with the view. Also fixes a comment that already claimed this.

## Measurements (hermetic; full raw evidence kept privately)
| Item | Before | After |
|---|---|---|
| Connection selection, fake probes (preferred 15 ms, two dead at 3 s,
relay 120 ms) | ~3.1 s (3 runs) | ~12 ms, same winner, 3 probes
cancelled |
| Collapsing grid, 10 later pages at ~40 ms | 415 ms, max 1 in flight |
161 ms, max 3 in flight, same ingest order |

The music history and version-label changes are structural (serial round
trips become overlapped) and were not timed.

## Review round (gpt-6-astra, medium)
An independent review found two major bugs in the first version of the
paging window. Both are fixed in `ba539ec2`:
- A load superseded while the group waited for its cancelled fetches
could still mark itself complete.
- A later page's error could end the load early.

Three new `LibraryPagingModelTests` cases fail on the earlier version
and pass now. The same commit adds the 4-server discovery window (with 2
new `PreferredProbeTests`) and the per-row Settings updates.

## Live A/B (macOS dev host, real servers; `main` vs this branch,
alternating cold launches, 5 measured pairs per backend)
- **Jellyfin collapsing Movies grid** (4 pages): full load median about
512 ms on `main` vs about 425 ms here, about 17% faster, and faster in
every pair. The collapsed item count and alphabet rail are identical.
- **Emby collapsing Movies grid** (4 pages on a LAN server, about 25 ms
per page): no measurable difference. Results are identical.
- **Plex session restore:** unchanged at about 3.1 s on both builds. The
preferred server advertises a local connection that is unreachable from
this host. Local connections rank first, so both builds wait out its 3 s
probe timeout before using the remote connection, which answers in about
100 ms. The early return here only helps when the dead connection ranks
*below* the winner. A follow-up that accepts a working lower-ranked
connection without the full timeout is tracked separately.

## Verification
- Hermetic PMSKit tests, including the new `PreferredProbeTests` (5).
- `ci-hygiene.sh`.
- Clean builds: visionOS, iOS and macOS. tvOS is blocked by `main` (see
below).
- macOS hosted app tests, including the new `LibraryPagingModelTests`
cases (bounded window with in-order ingest; an empty later page stops
ingestion).
- visionOS worktree-sim smoke (Plex golden clone): install matches
build, the app stays alive, and Home renders. `session.restore` and
`home.first_content` are in line with baseline launches.

## Open gates
- **Jellyfin/Emby live:** collapsing grid verified on the macOS dev host
(see Live A/B). Not yet exercised on iOS, tvOS or visionOS hardware.
- **Live Plex restore:** exercised on the macOS dev host. It is
unchanged, for the reason given above.
- Physical-device performance acceptance remains the maintainer's.
- No player or transcode changes. `X-Plex-Client-Profile-Name=Generic`
is untouched.
- **tvOS build (pre-existing on `main`):** `tvos-build` fails on
`origin/main` itself. Two PRs that merged close together collided: #365
added a shared `XCTestCase.attachScreen(named:app:)`, and #367 added a
`private func attachScreen` in
`LabstreamTVUITests/LabstreamTVStatsTests.swift`. This PR touches no
tvOS file; the main app target compiles in the other three lanes.
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