Skip to content

Add playback mode selection#9

Merged
mgabor3141 merged 5 commits intomgabor3141:mainfrom
JanneSaukkio:playback-mode
Mar 8, 2025
Merged

Add playback mode selection#9
mgabor3141 merged 5 commits intomgabor3141:mainfrom
JanneSaukkio:playback-mode

Conversation

@JanneSaukkio
Copy link
Contributor

@JanneSaukkio JanneSaukkio commented Mar 6, 2025

Playback mode selection to the Blueprint page. Tested on Factorio 2.0.32 Space Age.

kuva

closes #3

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a playback mode option in the results view, allowing users to choose among “global,” “surface,” and “local” modes.
    • Blueprint generation now adapts its output based on the selected playback mode, enhancing customization and flexibility.
  • Chores

    • Updated the version of the "miditorio" package from "2.1.4" to "2.2.0".

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2025

Walkthrough

The update introduces a playback mode feature in the ResultStage component, which now includes a playbackMode state and renders radio buttons for mode selection. This playback mode is integrated into the blueprint generation process by modifying several functions, including the speaker section and song conversion logic. The changes ensure that the selected playback mode is consistently utilized across the UI and data processing layers.

Changes

Files Change Summary
app/components/result-stage.tsx Added new constant playbackModeOptions, a state variable playbackMode (initialized to 'global'), and a radio button section for selecting playback mode. Updated effect dependencies and the call to songToFactorio to include the new playbackMode parameter; playback mode selection disabled when target version is '1'.
app/lib/song-to-factorio.ts
app/lib/blueprint/speaker-section.ts
Updated function signatures and parameter processing to include playbackMode. In songToFactorio.ts, both songToFactorio and songToFactorioData now accept playbackMode, and the Speakers type is modified accordingly. In speaker-section.ts, the destructuring in the forEach loop now includes playbackMode, replacing the hardcoded 'global' value with the dynamic mode passed in.
app/lib/factorio-blueprint-schema.ts Expanded the PlaybackMode type definition by including an additional literal 'local' alongside the existing 'surface' and 'global' options.
app/lib/blueprint/blueprint.ts Updated toBlueprint function signature to include playbackMode, which is passed to getSpeakerSection.
app/lib/song-to-factorio.test.ts Modified the invocation of songToFactorio in a test case to include the new playbackMode parameter, changing it to songToFactorio(processedSong, signals, 'global').
.github/workflows/test.yml Removed environment variables NEXT_PUBLIC_POSTHOG_HOST and NEXT_PUBLIC_POSTHOG_KEY, and added SKIP_ENV_VALIDATION set to 1.
package.json Updated the version of the package "miditorio" from "2.1.4" to "2.2.0".

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant RS as ResultStage
    participant ST as songToFactorio
    participant DT as Data Processors

    U->>RS: Select playback mode via radio button
    RS->>RS: Update playbackMode state
    RS->>ST: Call songToFactorio(song, signals, playbackMode)
    ST->>DT: Process song data with playbackMode
    DT-->>ST: Return blueprint result
    ST-->>RS: Return updated blueprint
Loading

Possibly related PRs

  • CI Improvements #11: Involves modifications to the handling of the playbackMode parameter, which is crucial for the functionality of the songToFactorio function and its associated components.

Poem

I’m a coding rabbit, hopping with delight,
Playback modes now shine ever so bright.
From UI clicks to blueprint play,
Every change dances in a brand new way.
With a twitch of my whiskers, I cheer this code,
Carrots and code on the same happy road!


📜 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 143a557 and 8762a28.

📒 Files selected for processing (8)
  • .github/workflows/test.yml (1 hunks)
  • app/components/result-stage.tsx (5 hunks)
  • app/lib/blueprint/blueprint.ts (3 hunks)
  • app/lib/blueprint/speaker-section.ts (2 hunks)
  • app/lib/factorio-blueprint-schema.ts (1 hunks)
  • app/lib/song-to-factorio.test.ts (1 hunks)
  • app/lib/song-to-factorio.ts (3 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/lib/song-to-factorio.ts
  • app/lib/factorio-blueprint-schema.ts
  • app/lib/blueprint/speaker-section.ts
🔇 Additional comments (12)
.github/workflows/test.yml (1)

10-10: Environment variable change looks good

The addition of SKIP_ENV_VALIDATION: 1 will allow the workflow to run without validating environment variables, which is appropriate for CI/CD testing.

app/lib/song-to-factorio.test.ts (1)

51-51: Test updated correctly for new parameter

The test has been properly updated to include the new 'global' playback mode parameter, ensuring compatibility with the function signature change.

app/components/result-stage.tsx (7)

7-7: Import added correctly

The PlaybackMode type is properly imported from the schema file.


33-40: Well-structured playback mode options

The playback mode options are clearly defined with descriptive labels and helpful tooltips. Good use of a Record type to organize the options.


49-49: State initialized with sensible default

Setting 'global' as the default playback mode is appropriate as it's the most common use case.


58-62: Function call properly updated

The songToFactorio function call is correctly updated to include the playback mode parameter.


71-71: Analytics tracking included

Good practice to include the new playback mode in analytics tracking.


76-76: Effect dependency updated

The effect dependency list is correctly updated to include playbackMode.


112-132: UI implementation is clean and user-friendly

The playback mode selection UI is well implemented with:

  • Clear labeling
  • Radio button implementation consistent with the version selector
  • Tooltips for additional information
  • Proper disabling for Factorio 1.x compatibility
app/lib/blueprint/blueprint.ts (3)

3-3: Import added correctly

The PlaybackMode type is properly imported from the schema file.


63-63: Function signature updated properly

The toBlueprint function signature has been updated correctly to include the new playbackMode parameter with proper type annotation.

Also applies to: 69-70


91-91: Parameter correctly passed to getSpeakerSection

The playbackMode parameter is properly passed to the getSpeakerSection function.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@mgabor3141 mgabor3141 linked an issue Mar 8, 2025 that may be closed by this pull request
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 8, 2025

@mgabor3141 mgabor3141 merged commit 7e03ea0 into mgabor3141:main Mar 8, 2025
4 of 5 checks passed
@mgabor3141
Copy link
Owner

Thank you for your contribution!

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.

Feature Request - Change Playback Mode

2 participants