Skip to content

Replay the running Paint look to the receiver after a brain restart - #181

Merged
devin-ai-integration[bot] merged 5 commits into
mainfrom
devin/1795998296-paint-look-restore-replay
Nov 30, 2026
Merged

devin-ai-integration[bot] merged 5 commits into
mainfrom
devin/1795998296-paint-look-restore-replay

Conversation

@pyramation

@pyramation pyramation commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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 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:

pattern?: { code: string; params: Record<string, unknown> }
  • 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.

After restart


IlluminateSF opened this PR for Dan
Implemented in session Fix saved Paint looks not replaying after restart
Review with Devin · Open in Devin Desktop


Summary by CodeRabbit

  • New Features
    • Saved active patterns, their settings, animation speed, and master brightness are restored after a server restart when applicable.
    • Saved looks remain available without restarting a pattern that was deliberately stopped.
  • Bug Fixes
    • Master brightness now synchronizes correctly with the operator interface, defaulting to 100 when the saved value is missing or invalid.
    • Startup skips saved patterns with invalid settings, and shutdown preserves the latest state.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Changes: Pattern persistence

Layer / File(s) Summary
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.
Synchronize brightness settings
packages/ui/src/lib/socket-state.ts, packages/ui/src/app.tsx, packages/ui/__tests__/socket-state.test.ts
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

@coderabbitai coderabbitai Bot 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.

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.

Files selected for processing: 5

  • packages/server/__tests__/paint-look-replay.test.ts
  • packages/server/src/server.ts
  • packages/ui/__tests__/socket-state.test.ts
  • packages/ui/src/app.tsx
  • packages/ui/src/lib/socket-state.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Restored brightness leaves slider maxed — Brain now sends restored brightness in connection settings and the UI initializes the slider from it.

View findings in Devin Review · Follow Devin's work

Devin Review

@devin-ai-integration
devin-ai-integration Bot merged commit a525ec6 into main Nov 30, 2026
7 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1795998296-paint-look-restore-replay branch November 30, 2026 00:47
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