feat(tray): add a per-group latency test by LokHsu · Pull Request #8173 · clash-verge-rev/clash-verge-rev · GitHub
Skip to content

feat(tray): add a per-group latency test - #8173

Merged
wonfen merged 6 commits into
clash-verge-rev:devfrom
LokHsu:pr/tray-latency-test
Oct 9, 2026
Merged

wonfen merged 6 commits into
clash-verge-rev:devfrom
LokHsu:pr/tray-latency-test

Conversation

@LokHsu

@LokHsu LokHsu commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7866. Related to #7020; latency color differentiation remains open.

The tray previously offered no way to refresh a group's latency without opening the dashboard. Each group now has a localized Test Latency action, disabled with Testing latency… while running. Measurements allow ten concurrent requests and continue after individual failures. Completion, dashboard group tests, and saved test URLs use the existing tray refresh queue; menu installation and running-state updates have separate serialized ownership.

Dashboard and tray resolve provider members within their group's scope, fixing measurements and histories pointing to another subscription's same-named node. Dashboard caches and listeners use stable source names (proxyName, plus providerName for provider nodes), so inserting nodes or providers cannot transfer a cached result to another node. When provider data is unavailable, nodes exposed by /proxies remain usable.

Only extra[test URL].history participates in comparisons with a cached dashboard measurement. Display falls back to top-level history when no measurement for that URL exists, preserving automatic latency display in Selector groups. A different URL cannot overwrite a valid manual result. Nested groups use the proxy-delay endpoint; unresolved members are skipped. Zero timeout uses the dashboard's 10s default, and tray formatting respects the configured timeout.

Custom URLs are stored per profile for lightweight mode; existing local overrides migrate. Changed inputs commit on blur, Enter, or leaving the editor. Unchanged blur does not save, profile refresh preserves focused drafts, and failed saves retain the input. Effective URL precedence is custom override, core group URL, then configured default. Tray tests and history lookup use the built-in URL for an invalid selected URL; dashboard group buttons retain their existing warning and cancel that test.

Tray provider reads have a 750ms budget within the existing 1s refresh budget. Proxy-view failure is nonfatal: ordinary menu entries still update, without proxy groups, so a stopped core cannot reject an unrelated settings change. Startup already refreshes after core readiness; if that subsequent read also fails, groups await the next existing refresh event.

The focused regressions are retained because the failures can silently display plausible but incorrect values: provider echoes masked scoped resolution; missing provider data disabled available nodes; same-named providers shared a cache; record-ID reuse transferred a 40ms result to another node; and selectors lost their automatic 126ms display. URL tests additionally guard cross-URL cache replacement, malformed URLs, and persistence failures/ordering. These are reproduced feature regressions, not restoration of the removed general proxy-view test suite. An isolated Mihomo fixture confirmed per-URL histories for ordinary nodes and nested groups. All 42 frontend tests, TypeScript, ESLint, architecture checks, and Rust Clippy pass. A temporary DOM fixture using the real input component passed unchanged blur, focused refresh, route unmount, profile switching, and Enter checks without adding project dependencies. Native tray behavior and the OS settings rollback scenario have not been exercised in the real application.

On macOS and Windows, hovering or clicking the tray icon now fetches current proxy histories and selections and updates existing rows in place. Hover prefetch is limited to once per second without suppressing click-triggered refreshes. Unchanged labels/checkmarks are skipped, overlapping refreshes are coalesced, and refresh application is serialized with menu rebuilding. Failed reads keep the current menu usable. A change between provider-aware resolution and core fallback goes through the existing rebuild queue because member identities have changed. Linux has no tray click events and retains its existing refresh behavior. The selected-node display and distinct T/O / -ms states from the author's patch are preserved. An isolated Mihomo url-test produced a 50ms node history without a manual test; a temporary Rust harness using the actual formatting and source-identity helpers verified URL-specific display and provider reindexing. Rust Clippy and formatting checks pass. Native menu interaction has not been exercised in the application; Windows may require reopening a popup if the asynchronous read finishes after it was painted.

Assisted by: Claude Opus 5.5
Assisted by: GPT-6 (Codex)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

The tray's proxy group submenus offered no way to test a group: refreshing
the delays shown there meant opening the dashboard and running a test from
the proxy page.

Add a "Test Latency" entry at the head of each group submenu. It measures
the group through the proxy page's own view, so member resolution and
provider attribution match the page exactly: provider nodes are health
checked on their provider, anything else goes through the proxy delay
endpoint, and members the page cannot resolve are skipped. Nested groups
are therefore tested through their currently selected node, as the page
does. The menu is rebuilt when the run finishes.

The test URL follows the page's chain -- the group's own test URL, then the
configured default, then the built-in one -- including the page's validity
check, so a group with a malformed URL falls back where the page falls back.

A group test started from the app rebuilds the tray as well, so the two
views do not drift.

Co-Authored-By: Claude <noreply@anthropic.com>
@LokHsu
LokHsu force-pushed the pr/tray-latency-test branch from b5af9cb to 0955648 Compare October 7, 2026 14:29
@github-actions

This comment has been minimized.

@LokHsu

LokHsu commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@wonfen

wonfen commented Oct 8, 2026

Copy link
Copy Markdown
Member

Thanks for checking these cases. Could you push your local fixes for (a) and (b) to this PR? We can review and build on those changes.

For (c), I agree that updating existing menu items with set_text and set_checked is preferable to rebuilding the whole menu when only latency or selection changes. The current latency_items registry only tracks the test-action buttons, so we would need to extend it to track the proxy rows as well.

We also need a reliable refresh trigger: updating on menu opening would show recent results on the next open, but would not necessarily reflect automatic tests while the menu stays open. Tauri does not emit tray click events on Linux, so a click-only approach would not cover every platform. We should account for that while preserving the existing synchronization and keeping failed reads nonfatal.

…meouts as T/O

Co-authored-by: wonfen <eiwonfen@gmail.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Summary

  • Verdict: acceptable
  • Issue linkage: present
  • Ownership evidence: sufficient
  • Confidence: low

Signals

  • Closes #7866 points to an independently authored, maintainer-triaged feature request (enhancement, area:tray) that predates the PR. The tray "Test Latency" action maps directly to it.
  • The PR body gives repository-specific reasoning, not generic prose. It covers the tray refresh queue and its 1s budget, provider-scope resolution, per-profile URL storage with migration of existing overrides, and the named failure modes each regression test guards.
  • The work spans 5 commits and the PR is a re-submission of the earlier #8160. Together these show iteration.
  • The PR states what was not validated (native tray behavior and the OS rollback scenario).
  • Scope is broad: 37 files and about 1,100 added lines. It bundles provider-scoped resolution, dashboard cache keying, and custom URL persistence along with the tray feature. The body explains these, but they go beyond what #7866 literally asks for.

Requested Follow-up

No strong AI-slop concern right now. Maintainers may still want the dashboard cache and provider-scoping fixes tracked or explained separately from the tray feature.

Label Outcome

none

Generated by PR AI Slop Review for #8173 · copilot · auto · 15 AIC · ⌖ 0.615 AIC · ⊞ 12.5K · ◷

@LokHsu

LokHsu commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@wonfen
wonfen merged commit cb75105 into clash-verge-rev:dev Oct 9, 2026
16 of 17 checks passed
@LokHsu
LokHsu deleted the pr/tray-latency-test branch October 9, 2026 02:26

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@wonfen 这种东西你能放行进来的?

wonfen added a commit that referenced this pull request Oct 20, 2026
This reverts commit cb75105.

Remove the tray latency test and its dashboard URL persistence and cache
changes because the two entry points have diverging behavior.

Preserve the subsequent IPC binding migration and remove generated fields,
input projections, and locale entries that depended on the reverted feature.
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] macOS菜单栏托盘增加“延迟测速”按钮

3 participants