Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix state problems with main volume dial #389

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Fix state problems with main volume dial #389

merged 3 commits into from
Jan 13, 2025

Conversation

neilenns
Copy link
Owner

@neilenns neilenns commented Jan 13, 2025

Summary by CodeRabbit

  • Chores

    • Updated VSCode spell-checking dictionary with new words
  • Bug Fixes

    • Refined connection state handling for audio managers
    • Simplified volume and connection status checks in controllers
  • Refactor

    • Adjusted main volume refresh logic during connection events
    • Streamlined volume change and connection state tracking mechanisms
    • Enhanced feedback setting logic based on voice connection status

@neilenns neilenns added the bug Something isn't working label Jan 13, 2025
@neilenns neilenns self-assigned this Jan 13, 2025
Copy link

coderabbitai bot commented Jan 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces modifications to several files related to track audio management and volume control. The changes primarily focus on adjusting connection state handling, refreshing volume controls, and updating feedback mechanisms. The modifications affect the main volume and station volume controllers, as well as the track audio connection and voice connected state event handlers. The changes refine the logic for managing audio connections and updating user interface elements accordingly.

Changes

File Change Summary
.vscode/settings.json Updated spell-check word list, adding "ATIS" and reordering entries
src/controllers/mainVolume.ts Modified refreshImage and refreshTitle methods to use isVoiceConnected and improve error handling
src/controllers/stationVolume.ts Simplified connection condition in refreshTitle method
src/events/trackAudio/connected.ts Removed trackAudioManager.refreshMainVolume() call
src/events/trackAudio/voiceConnectedState.ts Added trackAudioManager.refreshMainVolume() when voice is connected

Possibly related issues

Possibly related PRs

Poem

🎛️ Volumes dance, connections sing,
A rabbit's code takes flight on wing.
Refresh and update, state so bright,
TrackAudio's magic takes its might!
Knobs twirl with technical grace 🐰


📜 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 3bad519 and 96c7e96.

📒 Files selected for processing (1)
  • src/controllers/mainVolume.ts (1 hunks)

🪧 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. (Beta)
  • @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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/events/trackAudio/mainVolumeChange.ts (1)

23-23: Enhance logging with controller context.

While adding logging is good, including the controller identifier would make debugging easier, especially when multiple controllers are involved.

-      logger.info(`Setting mainVolume to ${data.value.volume.toString()}`);
+      logger.info(`Setting mainVolume to ${data.value.volume.toString()} for controller ${entry.action.context}`);
src/controllers/mainVolume.ts (1)

177-185: Consider extracting color values to constants.

The color values are used in multiple places. Extracting them to constants would improve maintainability and consistency.

+const FEEDBACK_COLORS = {
+  CONNECTED: "white",
+  DISCONNECTED: "grey",
+} as const;

// Then use them in the feedback:
         title: {
-          color: "white",
+          color: FEEDBACK_COLORS.CONNECTED,
         },
         indicator: {
           value: this.volume,
-          bar_fill_c: "white",
+          bar_fill_c: FEEDBACK_COLORS.CONNECTED,
         },
         value: {
           value: `${this.volume.toString()}%`,
-          color: "white",
+          color: FEEDBACK_COLORS.CONNECTED,
         },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bac9881 and 3bad519.

⛔ Files ignored due to path filters (1)
  • com.neil-enns.trackaudio.sdPlugin/images/actions/mainVolume/template.svg is excluded by !**/*.svg
📒 Files selected for processing (6)
  • .vscode/settings.json (2 hunks)
  • src/controllers/mainVolume.ts (2 hunks)
  • src/controllers/stationVolume.ts (1 hunks)
  • src/events/trackAudio/connected.ts (0 hunks)
  • src/events/trackAudio/mainVolumeChange.ts (1 hunks)
  • src/events/trackAudio/voiceConnectedState.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/events/trackAudio/connected.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build, lint and pack
🔇 Additional comments (4)
src/events/trackAudio/voiceConnectedState.ts (1)

11-11: LGTM! Good improvement to state management.

Moving the main volume refresh to the voice connection handler ensures the volume state is synchronized at the right moment - when a voice connection is established.

src/controllers/mainVolume.ts (1)

140-143: LGTM! Good improvement to connection state check.

Using isVoiceConnected instead of isConnected is more precise and better reflects the actual state needed for volume control.

src/controllers/stationVolume.ts (1)

259-259: LGTM! Consistent with mainVolume changes.

The simplified condition using isVoiceConnected aligns with the changes in mainVolume.ts and correctly represents the state needed for volume control.

.vscode/settings.json (1)

25-25: LGTM! Domain-specific terms added to spell checker.

The additions of "ATIS" and "vatsim" to the spell checker dictionary are appropriate for this aviation-focused audio management plugin.

Also applies to: 35-36

Comment on lines 148 to 152
logger.info(
`mainVolume refresh title, isVoiceConnected is ${
trackAudioManager.isConnected ? "true" : "false"
}`
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistent connection check in logging.

The logging message uses isConnected while the code logic uses isVoiceConnected. This inconsistency could lead to confusing logs.

-      `mainVolume refresh title, isVoiceConnected is ${
-        trackAudioManager.isConnected ? "true" : "false"
-      }`
+      `mainVolume refresh title, isVoiceConnected is ${
+        trackAudioManager.isVoiceConnected ? "true" : "false"
+      }`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.info(
`mainVolume refresh title, isVoiceConnected is ${
trackAudioManager.isConnected ? "true" : "false"
}`
);
logger.info(
`mainVolume refresh title, isVoiceConnected is ${
trackAudioManager.isVoiceConnected ? "true" : "false"
}`
);

Copy link

Build for this pull request:
StreamDeck-TrackAudio.zip

@neilenns neilenns merged commit 924e200 into main Jan 13, 2025
2 checks passed
@neilenns neilenns deleted the neilenns/issue388 branch January 13, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant