Skip to content

fix: update version to 0.3.2 and enhance WebSocket settings UI - #9

Open
tobfd wants to merge 1 commit into
masterfrom
fix/patch-code
Open

tobfd wants to merge 1 commit into
masterfrom
fix/patch-code

Conversation

@tobfd

@tobfd tobfd commented Aug 31, 2026

Copy link
Copy Markdown
Owner

This pull request updates the spicetify-connect-api.js extension to version 0.3.2, focusing on improved connection handling, volume/mute logic, parameter validation, and a more robust, accessible settings UI. The changes enhance reliability, security awareness, and user experience.

Key changes include:

Connection and Lifecycle Management

  • Added a teardown function to clean up timers and listeners, and registered it on window.beforeunload for graceful shutdowns. Improved initialization guard with an isInitialized flag to prevent duplicate event listener setup. [1] [2] [3] [4]
  • Added a check to warn users if they're connecting to an insecure remote WebSocket endpoint, encouraging the use of wss:// for remote connections. [1] [2]

Volume and Mute Handling

  • Improved mute/unmute logic to remember and restore the previous volume (preMuteVolume), and ensured volume changes are tracked more accurately. Also updated the volume event polling to initialize state and debounce updates. [1] [2] [3] [4] [5]

Command and Parameter Validation

  • Added stricter validation for incoming WebSocket requests (e.g., SetVolume, Seek) to prevent invalid or malformed commands from causing errors. [1] [2] [3]

Settings UI Improvements

  • Refactored the settings modal to use DOM APIs instead of innerHTML, improving accessibility, maintainability, and style consistency. Enhanced the close button styling and made the UI more robust. [1] [2]

Miscellaneous Updates

  • Bumped the extension version to 0.3.2 and clarified documentation/comments to reflect broader WebSocket server compatibility. [1] [2] [3]

These improvements make the extension more reliable, secure, and user-friendly.

@tobfd
tobfd requested a balanced review from Copilot August 31, 2026 21:52
@tobfd tobfd self-assigned this Aug 31, 2026
@tobfd tobfd added bug Something isn't working Security labels Aug 31, 2026

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tobfd
tobfd requested a balanced review from Copilot September 1, 2026 09:24

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tobfd
tobfd requested a balanced review from Copilot September 1, 2026 16:31

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tobfd
tobfd requested a balanced review from Copilot September 9, 2026 18:13

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

🟡 Changes recommended

The current “Save & Reconnect” flow may not actually reconnect when a socket is OPEN/CONNECTING, and teardown() doesn’t fully clean up the active WebSocket connection/handlers.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

spicetify-connect-api.js:613

  • For accessibility, associate this label with its corresponding input so screen readers and click-to-focus work (set htmlFor to the input’s id).
        keyLabel.textContent = "API Key / Secret Token (Optional)";
        keyLabel.style.display = "block";
        keyLabel.style.marginBottom = "4px";
        keyLabel.style.fontWeight = "bold";

spicetify-connect-api.js:641

  • For accessibility, associate this label with its corresponding input so screen readers and click-to-focus work (set htmlFor to the input’s id).
        intervalLabel.textContent = "Reconnect Interval (ms)";
        intervalLabel.style.display = "block";
        intervalLabel.style.marginBottom = "4px";
        intervalLabel.style.fontWeight = "bold";
  • Files reviewed: 1/1 changed files
  • Comments generated: 5
  • Review effort level: Lite

Comment thread spicetify-connect-api.js
Comment on lines +550 to +565
function teardown() {
if (statePollInterval) {
clearInterval(statePollInterval);
statePollInterval = null;
}
if (reconnectTimer) {
clearTimeout(reconnectTimer);
reconnectTimer = null;
}
if (volumeDebounceTimer) {
clearTimeout(volumeDebounceTimer);
volumeDebounceTimer = null;
}
stopHeartbeat();
isInitialized = false;
}
Comment thread spicetify-connect-api.js
Comment on lines +670 to +684
saveBtn.onclick = () => {
const newUrl = urlInput.value.trim();
const newApiKey = keyInput.value.trim();
const newInterval = intervalInput.value.trim();

if (newUrl) Spicetify.LocalStorage.set(STORAGE_KEYS.SERVER_URL, newUrl);
Spicetify.LocalStorage.set(STORAGE_KEYS.API_KEY, newApiKey);
if (newInterval) Spicetify.LocalStorage.set(STORAGE_KEYS.RECONNECT_INTERVAL, newInterval);

Spicetify.PopupModal.hide();
Spicetify.showNotification("Settings saved! Reconnecting...");

if (reconnectTimer) clearTimeout(reconnectTimer);
connect();
};
Comment thread spicetify-connect-api.js
Comment on lines +583 to +587
urlLabel.textContent = "WebSocket Server URL";
urlLabel.style.display = "block";
urlLabel.style.marginBottom = "4px";
urlLabel.style.fontWeight = "bold";

Comment thread spicetify-connect-api.js

const urlHelp = document.createElement("small");
urlHelp.style.color = "#aaa";
urlHelp.innerHTML = "Use <code>ws://127.0.0.1:9090</code> for local, <code>wss://IP:PORT:9090</code> for encrypted connections or <code>wss://DOMAIN:PORT</code> for remote connections.";
Comment thread spicetify-connect-api.js
Comment on lines +732 to 739
closeBtn.onmouseenter = () => {
closeBtn.style.color = "#fff";
closeBtn.style.background = "rgba(255, 255, 255, 0.1)";
};
closeBtn.onmouseleave = () => {
closeBtn.style.color = "#b3b3b3";
closeBtn.style.background = "transparent";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants