Skip to content

Host core: playback runs without React - #148

Merged
agorischek merged 2 commits into
mainfrom
playback-store
Nov 21, 2026
Merged

agorischek merged 2 commits into
mainfrom
playback-store

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Step 3 of the headless store design (docs/design/proposals/headless-store.md), stacked on #147.

  • createPlaybackController (projection/playback-controller.ts) drives playbackLifecycle with createActor, outside React:
    • the frames activity runs on an injectable FrameScheduler (requestAnimationFrame by default);
    • the requestPlaying and requestPosition effects go to a PlaybackHost;
    • show(view) sends the *Shown, modeChanged and subjectChanged events, reading the actor's state between sends as before.
    • Construction has no side effects; nothing runs until actor.start().
  • usePlaybackControl keeps only React's part: it creates the controller once, starts it in a layout effect and calls show after every render. Timing and ProjectionController are unchanged.
  • Nothing new is exported: the store composes the controller in step 5, with the settings store as its host. The design note's step 3 says so.
  • Node tests (test/playback-controller.test.mjs) cover starting and stopping, playing to the end, pausing, seeking, a new subject (core- and embedder-controlled) and a declined play, with a hand-stepped scheduler and no React.

Copilot AI 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.

🟡 Changes recommended

Retaining the caller’s mutable view instead of a snapshot can bypass change detection and leave active playback running when reduced motion is enabled.

1 open issue
What changed in this PR

Extracts playback orchestration from React into an internal controller, preparing host core for the headless projection store while retaining the React adapter.

Changes:

  • Adds an actor-backed controller with an injectable frame scheduler and host callbacks.
  • Simplifies usePlaybackControl to manage controller lifecycle and reconcile rendered values.
  • Adds framework-free playback tests and updates the headless-store implementation plan.
File Description
packages/​host/​core/​test/​playback-controller.test.mjs Tests startup, cancellation, playback, seeking, subject changes, and declined play.
packages/​host/​core/​src/​projection/​playback-controller.ts Introduces framework-free playback orchestration and view reconciliation.
packages/​host/​core/​src/​projection/​playback-control.ts Delegates playback to the controller while retaining React integration.
docs/​design/​proposals/​headless-store.md Documents the extraction and defers store composition to step 5.

Review effort: Balanced

createPlaybackController drives playbackLifecycle with createActor: the frame
loop runs on an injectable scheduler (requestAnimationFrame by default), the
playing and position requests go to a host, and show() sends the *Shown events
from what the view shows. Nothing runs until its actor starts.
usePlaybackControl keeps only React's part: it creates the controller once,
starts it in a layout effect and calls show after every render. Node tests
cover playback with a hand-stepped scheduler and no React. Step 3 of the
headless store design.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A host that updates one view object in place and shows it again still has
its subject, mode and reduced-motion changes noticed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 1fa0841 into main Nov 21, 2026
46 checks passed
@agorischek
agorischek deleted the playback-store branch November 21, 2026 20:54
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.

2 participants