Skip to content

Conversation

@arii
Copy link
Owner

@arii arii commented Feb 10, 2026

Description

Refactor the Spotify polling architecture to improve robustness and testability.

Key changes:

  • Introduced SpotifyManagerContext interface to provide a stable way for SpotifyPlayerManager and SpotifyDeviceManager to access the Spotify SDK and shared state. This resolves the "fragile SDK propagation" issue where managers could hold references to stale SDK instances.
  • Updated SpotifyPlayerManager.refreshPlaybackState to fetch the new playback state before capturing the current local state, ensuring comparisons are made against the most recent data and preventing race conditions.
  • Removed the _test_ block and associated helper methods from SpotifyPolling in favor of more robust integration-style testing using public methods and mocks.
  • Moved SafeSpotifyApi type definition to types/spotify.ts to resolve circular dependency issues between services and types.
  • Updated unit tests for SpotifyPolling, SpotifyPlayerManager, and SpotifyDeviceManager to align with the new architecture and constructor signatures.

Fixes # (issue)

Change Type: 🏗️ Refactoring (code change that neither fixes bug nor adds feature)

PR Scope Checklist

This checklist is mandatory for all PRs.

  • PR has a clear, single purpose: The title and description of the PR clearly state the purpose of the change.
  • All changes relate to the stated objective: The code changes should be directly related to the purpose of the PR.
  • No unrelated cleanup or refactoring: The PR should not contain any changes that are not directly related to the stated objective.
  • Title and description match the actual changes: The title and description should accurately reflect the changes in the PR.
  • Tests cover the specific change scope: The tests should be focused on the changes in the PR and should not include unrelated tests.

Impact Assessment

  • Changes are backward compatible (or breaking changes are documented)
  • Tests are added/updated for new functionality
  • Documentation is updated if needed
  • ADR is created/updated for significant architectural changes
Original PR Body

Refactor the Spotify polling architecture to improve robustness and testability.

Key changes:

  • Introduced SpotifyManagerContext interface to provide a stable way for SpotifyPlayerManager and SpotifyDeviceManager to access the Spotify SDK and shared state. This resolves the "fragile SDK propagation" issue where managers could hold references to stale SDK instances.
  • Updated SpotifyPlayerManager.refreshPlaybackState to fetch the new playback state before capturing the current local state, ensuring comparisons are made against the most recent data and preventing race conditions.
  • Removed the _test_ block and associated helper methods from SpotifyPolling in favor of more robust integration-style testing using public methods and mocks.
  • Moved SafeSpotifyApi type definition to types/spotify.ts to resolve circular dependency issues between services and types.
  • Updated unit tests for SpotifyPolling, SpotifyPlayerManager, and SpotifyDeviceManager to align with the new architecture and constructor signatures.

PR created automatically by Jules for task 2752464580658856891 started by @arii

- Introduce `SpotifyManagerContext` to decouple managers from `SpotifyPolling`.
- Managers now access SDK via `context.getSdk()`.
- Fix state staleness in `SpotifyPlayerManager`.
- Remove `_test_` block from `SpotifyPolling`.
- Move `SafeSpotifyApi` type to `types/spotify.ts`.
- Update unit tests.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions bot changed the title Refactor Spotify Polling Architecture test(medium): Refactor Spotify Polling Architecture Feb 10, 2026
@arii
Copy link
Owner Author

arii commented Feb 10, 2026

📋 Quality Gate Results

Check Status
Knip ✅ success
Lint ✅ success
Slop ✅ success
Build ❌ failure
Infra Tests ❌ skipped
Unit Tests ❌ skipped
Component Tests ❌ skipped
Perf Tests ❌ skipped
Visual Tests ❌ skipped

❌ Build Failure Details

Log file not found.

❌ Infrastructure Test Failure Details

Log file not found.

❌ Unit Test Failure Details

Log file not found.

❌ Component Test Failure Details

Log file not found.

❌ Visual Test Failure Details

Log file not found.

❌ Performance Test Failure Details

Log file not found.

⚠️ Some checks failed. Full logs available in workflow artifacts.


Report generated for commit: 1dda521d9b7e15f2cf859a2aa8678143a3c1b5c7

@google-labs-jules
Copy link
Contributor

📋 Quality Gate Results

Check Status
Knip ✅ success
Lint ✅ success
Slop ✅ success
Build ❌ failure
Infra Tests ❌ skipped
Unit Tests ❌ skipped
Component Tests ❌ skipped
Perf Tests ❌ skipped
Visual Tests ❌ skipped

❌ Build Failure Details

Log file not found.

❌ Infrastructure Test Failure Details

Log file not found.

❌ Unit Test Failure Details

Log file not found.

❌ Component Test Failure Details

Log file not found.

❌ Visual Test Failure Details

Log file not found.

❌ Performance Test Failure Details

Log file not found.

⚠️ Some checks failed. Full logs available in workflow artifacts.


Report generated for commit: 1dda521d9b7e15f2cf859a2aa8678143a3c1b5c7

I have fixed the build failure. The issue was a type mismatch in the fallback stub for SpotifyService in lib/services.ts, where forcePollAndBroadcast was returning void instead of Promise<void>. I have corrected this and verified that the build now passes locally.

@arii arii closed this Feb 11, 2026
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