Repository navigation
fix(subtitles): keep cue placement across every retained-store rebuild (#233) - #244
Merged
superuser404notfound merged 2 commits intoJul 29, 2026
Merged
Conversation
#233 added SubtitleCue.placement and the decoders fill it correctly, but every operation that rebuilds a cue to change one field did it by calling the memberwise initializer with the fields it happened to know about. placement is defaulted there for source compatibility, so each of those call sites dropped it and still compiled. insertCueSorted is the decisive one: it stamps the session-monotonic id on every cue entering the retained store, so nothing arriving through the drained embedded path could deliver a placement to a host. trimTextCues (#107) would have dropped it a second time on each teletext page transition. That is the split the reporter observed: a sidecar's cues are published as decoded and a native rendition's go into a store verbatim, so WebVTT placement worked; teletext is an embedded track and never got one. Rebuilds now go through SubtitleCue.with(id:endTime:body:), which carries every field it is not asked to change, so the next field added to the cue cannot repeat this. All eight rebuild sites converted, including the image-only ones where placement is nil by construction today. Reported by tresby (#233). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01At1agC2qU2Y2MX2BKLdT4N
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01At1agC2qU2Y2MX2BKLdT4N
superuser404notfound
deleted the
fix/issue233-placement-dropped-on-insert
branch
July 29, 2026 06:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #233, reported by tresby: no cue reached the host with a
placementon an embedded track, while the same field survived fine on sidecars.What was wrong
5.26.0 added
SubtitleCue.placementand the decoders fill it correctly (EmbeddedSubtitleDecoder.swift:305,SubtitleDecoder.swift:301). Every operation that rebuilds a cue to change one field did it by calling the memberwise initializer with the fields it happened to know about.placementis defaulted there for source compatibility, so each of those call sites dropped it and still compiled.insertCueSortedis the decisive one: it stamps the session-monotonic id (#121) on every cue entering the retained store, so nothing arriving through the drained embedded path could deliver a placement to a host at all.trimTextCues(#107) would have dropped it a second time on each teletext page transition.Why it looked like it worked
Three publishing paths, only one goes through the retained store:
placementsubtitleCues = result.cuesroute.store.appendCuesapplyEventMutations->insertCueSortedThat is exactly the split the reporter saw: WebVTT placement worked through a sidecar, teletext placement did not because it is an embedded track. Colour and the other run attributes were never affected, since they live in the cue body, which every rebuild did carry.
The fix
One internal copy helper,
SubtitleCue.with(id:endTime:body:), which carries every field it is not asked to change. All eight rebuild sites converted, including the image-only ones (PGS trim,Issue100PGSStaleArrival, OCR) where placement is nil by construction today. The next field added to the cue cannot repeat this.Considered and rejected: making the initializer parameter required, which would have caught all eight at compile time but is source-breaking for hosts constructing a cue.
Tests
Issue233PlacementRetentionTests, 8 cases asserting the invariant on the store operations rather than on any one format, since the defect was never format-specific: the id stamp, the anchor point, rich-text bodies, the nil case, the #107 trim, both in the order the drain applies them, plus the shape of the image-only rebuilds.Full suite green: 1252 Swift Testing in 193 suites, 392 XCTest, 0 failures. tvOS Simulator build succeeded.