Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f177024
refactor(spf): consolidate text track sync into FSM-based syncTextTracks
cjpillsbury Mar 31, 2026
580dee9
refactor(spf): remove textBufferState coupling from TextTrackSyncState
cjpillsbury Mar 31, 2026
9001a16
refactor(spf): delete superseded text track reactors and their tests
cjpillsbury Mar 31, 2026
5fd5dfb
refactor(spf): remove owners.textTracks map in favour of mediaElement…
cjpillsbury Mar 31, 2026
1381df1
refactor(spf): simplify cleanupModes listener — drop redundant remove…
cjpillsbury Mar 31, 2026
e0d8411
feat(spf): add TextTracksActor — wraps HTMLMediaElement.textTracks, o…
cjpillsbury Mar 31, 2026
8b06751
refactor(spf): add segment tracking to TextTracksActor context
cjpillsbury Mar 31, 2026
d88859f
refactor(spf): integrate TextTracksActor into loadTextTrackCues; remo…
cjpillsbury Mar 31, 2026
9214fd7
feat(spf): add TextTrackSegmentLoaderActor; migrate loadTextTrackCues…
cjpillsbury Mar 31, 2026
f7f6521
refactor(spf): align text track actor message/context shapes with Sou…
cjpillsbury Mar 31, 2026
d48b5d8
refactor(spf): add SerialRunner.settled; simplify TextTrackSegmentLoa…
cjpillsbury Mar 31, 2026
656909c
refactor(spf): tighten getSegmentsToLoad param type; minor actor cleanup
cjpillsbury Mar 31, 2026
bddea24
feat(spf): add createActor factory with SerialRunner.whenSettled
cjpillsbury Apr 1, 2026
33fd5dd
refactor(spf): migrate TextTrackSegmentLoaderActor to createActor fac…
cjpillsbury Apr 1, 2026
35103a3
refactor(spf): migrate TextTracksActor to createActor factory
cjpillsbury Apr 1, 2026
e68b133
refactor(spf): promote whenSettled to RunnerLike; full RunnerLike con…
cjpillsbury Apr 1, 2026
aa9ac91
feat(spf): add createReactor factory; migrate syncTextTracks
cjpillsbury Apr 1, 2026
e324b1d
refactor(spf): migrate resolvePresentation to createReactor
cjpillsbury Apr 1, 2026
0a39776
refactor(spf): expand resolvePresentation to 4-state FSM with deriveS…
cjpillsbury Apr 1, 2026
d936a3d
refactor(spf): remove explicit transition('resolved') from fetch task
cjpillsbury Apr 1, 2026
fdf2a4c
feat(spf): add always effects to createReactor; apply to resolvePrese…
cjpillsbury Apr 1, 2026
1868f08
refactor(spf): simplify syncTextTracks FSM using always monitor
cjpillsbury Apr 1, 2026
59f7196
refactor(spf): migrate loadTextTrackCues to createReactor
cjpillsbury Apr 1, 2026
4626b46
docs(spf): document always-before-state ordering guarantee in createR…
cjpillsbury Apr 1, 2026
f6eb96d
refactor(spf): remove segmentLoaderActor guard from monitoring-for-loads
cjpillsbury Apr 1, 2026
88ab0f7
refactor(spf): extract teardownActors helper; scope monitoring-for-lo…
cjpillsbury Apr 1, 2026
2809fd2
fix(spf): destroy owner actors on engine destroy; type text track act…
cjpillsbury Apr 1, 2026
c775735
docs(spf): document Actor/Reactor factories and text track reference …
cjpillsbury Apr 2, 2026
a8a3eb6
docs(spf): add signals design doc; update primitives.md and index
cjpillsbury Apr 2, 2026
afc3756
docs(spf): expand signals doc with three additional reasons for choos…
cjpillsbury Apr 2, 2026
bcede92
docs(spf): add RxJS-style and signals implementations to trackPlaybac…
cjpillsbury Apr 2, 2026
26fde91
docs(spf): add lower structural overhead section to signals doc
cjpillsbury Apr 2, 2026
421139d
docs(spf): merge structural overhead and versatility sections; reorde…
cjpillsbury Apr 2, 2026
c101bd4
docs(spf): reframe signals.md sections as general primitives concerns
cjpillsbury Apr 2, 2026
b20eb38
docs(spf): update primitives.md to reflect settled decisions post-spike
cjpillsbury Apr 2, 2026
a9c58ce
docs(spf): add cross-reference from factory doc ordering caveat to si…
cjpillsbury Apr 3, 2026
52c247e
refactor(spf): migrate trackPlaybackInitiated to createReactor FSM
cjpillsbury Apr 3, 2026
b74830f
feat(spf): migrate trackPlaybackInitiated to createReactor FSM
cjpillsbury Apr 3, 2026
651cbc0
feat(spf): add entry/reactions split to createReactor state definitions
cjpillsbury Apr 3, 2026
e4c8385
refactor(spf): unify ReactorEffectFn and lift makeCtx/wrapResult in c…
cjpillsbury Apr 3, 2026
6a96c4c
refactor(spf): extract registerEffects helper in createReactor
cjpillsbury Apr 3, 2026
e7da5d6
feat(spf): allow single-fn shorthand for always/entry/reactions in cr…
cjpillsbury Apr 3, 2026
52d5b2f
fix(spf): restore forEach in registerEffects
cjpillsbury Apr 3, 2026
329f018
refactor(spf): use single-fn shorthand in all reactors
cjpillsbury Apr 3, 2026
f323518
feat(spf): replace always with derive in createReactor
cjpillsbury Apr 3, 2026
5d7c091
refactor(spf): give ReactorDeriveFn the same ctx signature as Reactor…
cjpillsbury Apr 3, 2026
2a0f653
refactor(spf): hoist toCall out of effect body in registerEffects; ad…
cjpillsbury Apr 3, 2026
eb18955
refactor(spf): replace untracked boolean with toFnCall parameter in r…
cjpillsbury Apr 3, 2026
216abcc
refactor(spf): replace registerEffects with descriptor-list pattern i…
cjpillsbury Apr 3, 2026
a91274f
refactor(spf): make toFnCall optional on EffectDescriptor with identi…
cjpillsbury Apr 3, 2026
3702730
refactor(spf): remove context and transition from reactor public API
cjpillsbury Apr 3, 2026
7119cd6
refactor(spf): align naming — snapshot.value, State type params, moni…
cjpillsbury Apr 3, 2026
df0d3a1
refactor(spf): rename internal status variables to state
cjpillsbury Apr 3, 2026
b1abae4
refactor(spf): align naming — State type params, monitor field, inlin…
cjpillsbury Apr 3, 2026
d940e29
docs(spf): update actor-reactor-factories design doc to reflect settl…
cjpillsbury Apr 3, 2026
58f70fa
fix(spf): resolve pre-existing test failures — fetch pollution and pa…
cjpillsbury Apr 3, 2026
15d585f
refactor(spf): establish Machine type hierarchy with createMachineCore
cjpillsbury Apr 6, 2026
8e1c5af
feat(spf): add createTransitionActor, migrate TextTracksActor to redu…
cjpillsbury Apr 6, 2026
240b9a0
refactor(spf): replace TextTrackSegmentLoaderActor FSM with CallbackA…
cjpillsbury Apr 6, 2026
2336b51
refactor(spf): use createMachineCore in SourceBufferActor
cjpillsbury Apr 6, 2026
737ba4c
refactor(spf): collapse batch() into send() as BatchMessage
cjpillsbury Apr 6, 2026
75d6ab5
refactor(spf): make SourceBufferActor.send() fire-and-forget; bridge …
cjpillsbury Apr 6, 2026
cf9238b
refactor(spf): migrate SourceBufferActor to createActor; move signal …
cjpillsbury Apr 6, 2026
26a39a5
docs(spf): expand actor-reactor-factories with XState async work mode…
cjpillsbury Apr 6, 2026
b347855
refactor(spf): add getContext to HandlerContext; eliminate workingCtx…
cjpillsbury Apr 6, 2026
96ef0a8
refactor(spf): rename getCtx → getContext in task factories
cjpillsbury Apr 6, 2026
8e9a21f
refactor(spf): rename onPartialContext → setContext in task factories
cjpillsbury Apr 6, 2026
9e71e6a
docs(spf): record state-scoped runner as deferred, not open
cjpillsbury Apr 6, 2026
6ee3374
refactor(spf): replace per-message AbortSignal with cancel message
cjpillsbury Apr 6, 2026
30deacc
refactor(spf): extract onMessage helper to deduplicate idle handlers
cjpillsbury Apr 6, 2026
7d8346b
refactor(spf): use forEach in batch handler
cjpillsbury Apr 6, 2026
e05cb32
refactor(spf): migrate SegmentLoaderActor to createActor + add Serial…
cjpillsbury Apr 6, 2026
99c8b9d
docs(spf): update lifecycle scoping note to reflect SegmentLoaderActo…
cjpillsbury Apr 7, 2026
f23bfef
fix(spf): add destroyed guard to TextTrackSegmentLoaderActor
cjpillsbury Apr 8, 2026
44c6739
refactor(spf)!: rename createActor/createReactor to createMachineActo…
cjpillsbury Apr 8, 2026
0f2ee39
docs(spf): update design docs for current actor/reactor API
cjpillsbury Apr 8, 2026
98c7b24
refactor(spf): rename reactor `reactions` to `effects`
cjpillsbury Apr 8, 2026
26e9f80
docs(spf): disambiguate "observable" terminology across docs and code
cjpillsbury Apr 8, 2026
c2d19b4
fix(spf): resolve typecheck errors in machine.ts and track-playback-i…
cjpillsbury Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .claude/plans/spf/actor-migration-assessment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Actor Migration Assessment

Assessment of migrating SPF's segment-related actors to the `createMachineActor` factory.
Written after completing the text track Actor/Reactor spike. **Partially stale** — see
inline notes for what has been completed.

---

## Background

The text track spike produced reference implementations using three actor patterns:

- `TextTracksActor` — uses `createTransitionActor` (reducer-style, no FSM)
- `TextTrackSegmentLoaderActor` — manual `CallbackActor` (lightweight, no framework)
- Reactors (`syncTextTracks`, `loadTextTrackCues`) — use `createMachineReactor`

The segment-loading layer had three actors to consider:
`SegmentLoaderActor`, `SourceBufferActor`, and `loadSegments` (Reactor).

---

## SegmentLoaderActor ✅ (Completed)

**File:** `packages/spf/src/dom/features/segment-loader-actor.ts`

Migrated to `createMachineActor` with `idle`/`loading` states, `onSettled: 'idle'`,
and continue/preempt logic. The continue case uses `SerialRunner.abortPending()` (added
during migration) — drops queued tasks without touching the in-flight task. In-flight
tracking (`inFlightInitTrackId`, `inFlightSegmentId`) lives in actor context via
`setContext`/`getContext`.

---

## SourceBufferActor ✅ (Completed)

**File:** `packages/spf/src/dom/media/source-buffer-actor.ts`

Migrated to `createMachineActor` with `idle`/`updating` states, `onSettled: 'idle'`,
and a `cancel` message in the `updating` state. The four originally-identified blockers
were resolved:

1. **Awaitable send** — `SegmentLoaderActor` now observes completion via
`waitForIdle(snapshot, signal)` rather than awaiting `send()` directly.
2. **Context as task output** — tasks return new context; `.then(setContext)` commits it.
`getContext` threading ensures each task reads the context committed by the previous task.
3. **`batch()`** — implemented as a message type; handler iterates and schedules all tasks.
4. **Partial updates** — `setContext()` called mid-task for streaming segment progress.

---

## loadSegments (Reactor)

**File:** `packages/spf/src/dom/features/load-segments.ts`

Currently a function with signals/effects inline — it is the Reactor layer that
bridges state → `SegmentLoaderActor` messages. Not itself an actor.

Could be rewritten as a class-based Reactor if a `createMachineReactor` pattern is established
(per the primitives.md design). Lower priority than the actor migrations; natural
follow-on after `SegmentLoaderActor` is migrated.

---

## Status

- ✅ `SegmentLoaderActor` — migrated to `createMachineActor` (with `abortPending()` instead of `replaceQueue()`)
- ✅ `SourceBufferActor` — migrated to `createMachineActor`
- ⬜ `loadSegments` — still function-based; natural follow-on as a `createMachineReactor` migration
Loading
Loading