Skip to content

Filter unreachable servers from selector (newdesign UI)#769

Merged
sstidl merged 5 commits intonewdesignfrom
fix/filter-dead-servers
Mar 18, 2026
Merged

Filter unreachable servers from selector (newdesign UI)#769
sstidl merged 5 commits intonewdesignfrom
fix/filter-dead-servers

Conversation

@sstidl
Copy link
Collaborator

@sstidl sstidl commented Mar 18, 2026

dont show dead servers

@sstidl sstidl requested a review from Copilot March 18, 2026 08:58
@qodo-free-for-open-source-projects
Copy link
Contributor

Review Summary by Qodo

Filter unreachable servers from selector and fix dropdown state management

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Filter unreachable servers from dropdown selector
• Run server reachability checks before populating UI
• Reset dropdown state on each population to prevent stale data
• Prevent duplicate event listener registration on dropdown
Diagram
flowchart LR
  A["Fetch server list"] --> B["Single server?"]
  B -->|Yes| C["Show directly"]
  B -->|No| D["Run reachability checks"]
  D --> E["Filter dead servers"]
  E --> F["Reset dropdown state"]
  F --> G["Populate dropdown UI"]
  G --> H["Register event listeners once"]
Loading

Grey Divider

File Changes

1. frontend/javascript/index.js Enhancement, bug fix +44/-20

Filter dead servers and fix dropdown state management

• Refactored applyServerListJSON() to filter unreachable servers (those with pingT === -1)
 before populating the dropdown
• Added special handling for single-server case to skip reachability checks
• Modified populateDropdown() to reset previous state (clear classes and innerHTML) on each call
 to prevent stale UI
• Added data-hooked flag to prevent duplicate event listener registration when
 populateDropdown() is called multiple times

frontend/javascript/index.js


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Contributor

qodo-free-for-open-source-projects bot commented Mar 18, 2026

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve the “newdesign” frontend server selector by hiding unreachable (“dead”) speedtest servers from the dropdown list, based on the ping reachability results produced by the built-in Speedtest.selectServer logic.

Changes:

  • Defer populating the server dropdown until after selectServer has pinged servers, then filter out servers with pingT === -1.
  • Add UI reset logic in populateDropdown to support re-rendering and avoid duplicate event handler registration.
Comments suppressed due to low confidence (1)

frontend/javascript/index.js:201

  • In the servers.length === 1 path, populateDropdown now removes the .active class (line 193) and then returns without re-adding it. Since .server-selector is display: none unless .active is present, this will hide the server selector entirely when reachability filtering leaves exactly one server alive. Consider always adding .active before returning (or adding it specifically in the single-server branch) so the chosen server remains visible.
  // Reset previous state (populateDropdown can be called multiple times)
  serverSelector.classList.remove("single-server");
  serverSelector.classList.remove("active");
  serverList.classList.remove("active");
  serverList.innerHTML = "";

  // If we have only a single server, just show it
  if (servers.length === 1) {
    serverSelector.classList.add("single-server");
    selectServer(servers[0]);
    return;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the newdesign UI’s server selector to avoid showing unreachable speedtest servers by leveraging LibreSpeed’s built-in server ping/selection, and improves dropdown re-render behavior.

Changes:

  • Delay dropdown population until after Speedtest.selectServer() completes, then filter servers based on reachability (pingT).
  • Keep a fallback to show the full list when no servers are reachable.
  • Reset dropdown DOM/class state on each render and ensure open/close handlers are only attached once.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sstidl and others added 3 commits March 18, 2026 17:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sstidl sstidl self-assigned this Mar 18, 2026
@sstidl sstidl merged commit 1c7c44e into newdesign Mar 18, 2026
@sstidl sstidl deleted the fix/filter-dead-servers branch March 18, 2026 22:09
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.

2 participants