You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replay the running Paint look to the receiver after a brain restart - #181
After a brain restart, the Looks library was restored, so the saved look showed in the UI. The running pattern was never persisted, though, so on reconnect the receiver had no evalPattern to replay and got no output. This happened whether aircraft lockout was on or off.
The brain now saves the active pattern in PersistedState:
When it saves: on evalPattern and on setPatternParam while a pattern is active, and it clears the pattern on stopPattern. A save that is still pending is flushed on stop().
When it restores: once patternEngine.init() finishes and before any queued commands run. The existing receiver connect handoff then sends the pattern as usual.
What it skips: a pattern stopped on purpose, a pattern with an invalid persisted shape, and a pattern that is superseded by an active playlist or animation. Saved library entries are never selected automatically.
Regression test: packages/server/__tests__/paint-look-replay.test.ts covers save → restart → receiver handoff, a deliberate stop, and invalid persisted code. Before the fix, the restart case failed because the receiver command was undefined.
Browser check with aircraft lockout disabled and no OSC hardware: after restarting the brain, the same look shows as Running without clicking recall, and a fresh receiver emitted all 28 fixtures.
Save pattern state packages/server/src/server.ts, packages/server/__tests__/paint-look-replay.test.ts
The server saves brightness and eligible pattern data after pattern changes and stops. It ignores messages after shutdown and flushes pending saves. Integration tests cover stopped patterns and shutdown snapshots.
Restore and verify patterns packages/server/src/server.ts, packages/server/__tests__/paint-look-replay.test.ts
The server restores valid saved patterns after engine initialization, along with saved animation speed and brightness. Tests cover replay, preview state, receiver handoff, and invalid saved code.
The UI clamps finite brightness values to 0–100 and defaults invalid values to 100. The operator view initializes brightness from server settings. Socket-state tests cover the settings values.
Possibly related PRs
constructive-io/wavegrid#159: It changes pattern-engine initialization and readiness behavior, which this PR uses when restoring saved patterns.
Suggested reviewers:tandpfun
Change: Bug fix
Merge Risk: Minimal · up to e7ca1
This change saves the running pattern and master brightness, restores them after a brain restart, and replays the pattern to a reconnecting receiver. Deliberately stopped, invalid, or playlist-superseded patterns are not replayed. No concrete defects remain after review, and the replay and brightness-sync tests cover the changed behavior.
Security architecture risk: Moderate · up to e7ca1
A restart can restore a look or brightness setting that an operator had already stopped or replaced if the server exits before saving the change. Normal shutdown saves pending changes, and receivers configured for aircraft lockout still require a valid permit before emitting output.
Retained concerns
Minor · reliability · inferred: The server applies stop, clear, and brightness changes before committing them to the restart snapshot. If it exits before the pending write, the previous checkpoint can restart a stopped pattern or restore a higher brightness on reconnecting receivers where output is permitted. Graceful shutdown flushes the pending write; the merge-base server did not replay standalone patterns or reload saved master brightness.
Security review details
Security Blast Radius
inferred — The demonstrated exposure is the output associated with one server snapshot: the restored pattern can reach reconnecting, authorized, unscoped peers through the existing handoff and affect fixtures served by their receivers. The comparison establishes no new cross-project route.
Trust Boundaries and Controls
observed — WebSocket upgrade still requires an accepted token or receiver key and extension authorization. The replay command is not itself a permit: a receiver configured for aircraft lockout clears its permit on connection and gates physical output on a valid, unexpired permit.
Hardening Proposals
proposed — Make stop and clear durable before treating them as complete for restart purposes. Use atomic snapshot replacement and verify that restart after interruption does not re-enable stopped output or undo a committed brightness reduction.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (1)
Advisory architecture findings (1)
Minor — The server applies stop, clear, and brightness changes before committing them to the restart snapshot. If it exits before the pending write, the previous checkpoint can restart a stopped pattern or restore a higher brightness on reconnecting receivers where output is permitted. Graceful shutdown flushes the pending write; the merge-base server did not replay standalone patterns or reload saved master brightness.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 88f50ad8-6457-4dd7-8af8-d87380f7e7e2
Commits
Reviewing files that changed from the base of the PR and between e79ef81 and e7ca1a4.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
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
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.
Summary
After a brain restart, the Looks library was restored, so the saved look showed in the UI. The running pattern was never persisted, though, so on reconnect the receiver had no
evalPatternto replay and got no output. This happened whether aircraft lockout was on or off.The brain now saves the active pattern in
PersistedState:evalPatternand onsetPatternParamwhile a pattern is active, and it clears the pattern onstopPattern. A save that is still pending is flushed onstop().patternEngine.init()finishes and before any queued commands run. The existing receiver connect handoff then sends the pattern as usual.Regression test:
packages/server/__tests__/paint-look-replay.test.tscovers save → restart → receiver handoff, a deliberate stop, and invalid persisted code. Before the fix, the restart case failed because the receiver command was undefined.Browser check with aircraft lockout disabled and no OSC hardware: after restarting the brain, the same look shows as Running without clicking recall, and a fresh receiver emitted all 28 fixtures.
Implemented in session Fix saved Paint looks not replaying after restart
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit