Skip to content

Enforce piped for playback toggle#316

Merged
n-ce merged 9 commits into
mainfrom
enforce-piped
Jun 8, 2025
Merged

Enforce piped for playback toggle#316
n-ce merged 9 commits into
mainfrom
enforce-piped

Conversation

@n-ce
Copy link
Copy Markdown
Owner

@n-ce n-ce commented Jun 8, 2025

Summary by CodeRabbit

  • New Features
    • Added a new playback setting to enforce Piped for playback, now available in the settings menu.
    • Introduced a corresponding toggle for this setting, allowing users to enable or disable enforced Piped playback.
  • Localization
    • Added an English localization string for the new "Enforce Piped for Playback" setting.
  • Style
    • Improved formatting and readability of the playback settings interface.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 8, 2025

Walkthrough

The changes introduce a new enforcePiped boolean property to the application state, update localization to support a new playback setting label, and adjust logic in several modules to respect this new property when configuring playback and handling errors. Additionally, formatting in the playback settings component is improved for readability, with no changes to its logic or behavior.

Changes

File(s) Change Summary
src/components/Settings/playback.ts Reformatted and adjusted indentation in template code for readability; no logic or behavior changes
src/lib/store.ts Added enforcePiped: boolean property to exported state object, initialized to false; removed usePiped from player object
src/locales/en.json Added localization key "settings_enforce_piped": "Enforce Piped for Playback"
src/modules/start.ts Replaced assignments to store.player.usePiped with updates to state.enforcePiped
src/modules/audioErrorHandler.ts Updated error handling logic to check enforcePiped, HLS, or customInstance from state instead of usePiped from store.player
src/modules/getStreamData.ts Changed playback method selection to use state.enforcePiped instead of store.player.usePiped

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsComponent
    participant Store
    participant StartModule
    participant AudioErrorHandler
    participant StreamDataModule

    User->>SettingsComponent: Toggle "Enforce Piped for Playback"
    SettingsComponent->>Store: Update state.enforcePiped
    StartModule->>Store: Read state.enforcePiped on startup
    StartModule->>Store: Update state.enforcePiped based on instance data
    AudioErrorHandler->>Store: Check state.enforcePiped for error handling
    StreamDataModule->>Store: Use state.enforcePiped to select playback method
Loading

Poem

A toggle appears, a new path to guide,
"Enforce Piped" now sits with pride.
The state grows stronger, the logic refined,
With settings and strings all neatly aligned.
Hopping through code, with carrots in sight—
This update brings playback delight! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f729f7 and 13f7681.

📒 Files selected for processing (3)
  • src/modules/audioErrorHandler.ts (1 hunks)
  • src/modules/getStreamData.ts (1 hunks)
  • src/modules/start.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/modules/start.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/modules/getStreamData.ts (1)
src/lib/store.ts (1)
  • state (4-48)
src/modules/audioErrorHandler.ts (2)
src/lib/store.ts (2)
  • store (65-155)
  • state (4-48)
src/lib/utils.ts (1)
  • notify (84-96)
🔇 Additional comments (3)
src/modules/getStreamData.ts (1)

96-96: LGTM! Clean refactoring to use the new state property.

The change correctly replaces store.player.usePiped with state.enforcePiped while maintaining the same conditional logic flow.

src/modules/audioErrorHandler.ts (2)

11-11: LGTM! Correct extraction from the new state structure.

The destructuring properly extracts the refactored properties from state instead of store.player.


13-14:

Details

✅ Verification successful

Verify the broadened error handling condition.

The condition logic has changed significantly from (usePiped && customInstance) || HLS to enforcePiped || HLS || customInstance. This broadens when the early return with error notification occurs, potentially affecting fallback behavior in 403 error scenarios.

Please verify this behavioral change is intentional, as it may impact error recovery mechanisms when only customInstance is set but enforcePiped is false.


🏁 Script executed:

#!/bin/bash
# Description: Search for other usages of similar conditions to understand the intended behavior

# Search for other usages of enforcePiped, customInstance conditions
rg -A 3 -B 3 "enforcePiped.*customInstance|customInstance.*enforcePiped"

# Search for other 403 error handling patterns
rg -A 5 -B 5 "403.*Unauthenticated"

# Search for usePiped references that might need similar updates
rg "usePiped"

Length of output: 1757


🏁 Script executed:

#!/bin/bash
# Capture the full content of src/modules/audioErrorHandler.ts for context
sed -n '1,200p' src/modules/audioErrorHandler.ts

Length of output: 1844


🏁 Script executed:

#!/bin/bash
# Display the content of src/lib/store.ts to understand state definitions
sed -n '1,200p' src/lib/store.ts

Length of output: 3598


Confirm early return for customInstance is intentional

The updated condition

if (enforcePiped || HLS || customInstance)
  return notify(message);

deliberately disables all proxy-based fallback logic whenever the user has opted into Piped (enforcePiped), HLS (HLS), or a custom Invidious instance (customInstance). This matches the intended behavior of surfacing the 403 error immediately in those modes. No changes required.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@n-ce n-ce merged commit fdbfb63 into main Jun 8, 2025
2 checks passed
@n-ce n-ce deleted the enforce-piped branch June 8, 2025 04:27
@n-ce n-ce restored the enforce-piped branch June 8, 2025 04:29
@n-ce n-ce deleted the enforce-piped branch June 8, 2025 04:30
This was referenced Jul 31, 2025
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