Skip to content

feat(048): eliminate remaining tray /api/v1/servers refetches#451

Merged
Dumbris merged 1 commit into
mainfrom
048-tray-refetch-elimination
May 8, 2026
Merged

feat(048): eliminate remaining tray /api/v1/servers refetches#451
Dumbris merged 1 commit into
mainfrom
048-tray-refetch-elimination

Conversation

@Dumbris
Copy link
Copy Markdown
Member

@Dumbris Dumbris commented May 8, 2026

Summary

  • Spec 047 (PR feat(047): cut idle CPU 92% — scanner cache + SSE payload embed + coalescer #450, v0.29.4) eliminated burst-storm refetches. This PR addresses the residual: 5 other call sites in the Swift tray totaling ~8 GETs per 60 s idle.
  • All 5 sites now read SSE-driven appState.servers instead of fetching:
    • CoreProcessManager case "status": — stat-only update, no refetch on connected-count change
    • refreshState (30 s periodic) — drops the refreshServers() call
    • refreshSecurityStatus Docker fallback — reads appState.servers synchronously
    • MCPProxyApp.swift 10 s Timer.publish — removed
    • menuWillOpen — no per-click refetch
  • New 5-minute Combine timer wraps CoreProcessManager.refreshServersForSafetyNet() as a defense-in-depth safety net for missed SSE events.

Verification

Live test on same 30-server / 1.06 GB BBolt scenario as spec 047 (specs/048-tray-refetch-elimination/verification/report.md):

Metric Before this PR (spec 047 only) After this PR
/api/v1/servers GETs / 60 s idle ~8 0
Tray reactivity to disable REST ≤ 2 s 1 s
Tray reactivity to enable REST ≤ 5 s 2 s
GETs during toggle window many (status events) 0

The accessibility-tree state cycle on context7:

T0:                Connected (2 tools) / Disable
+1s after disable: Disabled            / Enable
+2s after enable:  Connected (2 tools) / Disable
                   ^ all driven by SSE; zero refetches in window

Test plan

  • Swift tray builds clean with swiftc (no errors, only pre-existing try? warnings)
  • Live verification: idle for 60 s, count GETs, expect ≤ 1
  • Live verification: toggle a server via REST, expect tray reaction within 5 s
  • Live verification: same toggle window, expect 0 GETs
  • Backward compat: SSE servers.changed fallback path from spec 047 retained — older cores still work
  • Full Go test suite still green (CI will confirm; no Go changes in scope)
  • Build green on macOS/Linux/Windows (CI)

XCTests are not authored: the existing Swift testing convention in this repo doesn't run swift test in CI (CommandLineTools-only environments can't run XCTest, and there's no make swift-test target). Adding tests would document intent but not gate behavior; relied on live verification + mcpproxy-ui-test MCP instead.

Out of scope (deferred)

  • refreshActivity / refreshTokenMetrics / refreshSessions periodic refreshes still hit their respective endpoints every 30 s. Future spec to make those SSE-driven.
  • Docker dockerStatus() and diagnostics() calls inside refreshSecurityStatus are unchanged (independent of server list).
  • Web UI: already covered by spec 047.

Spec & artifacts

🤖 Generated with Claude Code

Spec 047 (PR #450, v0.29.4) eliminated the burst-storm refetch path
(servers.changed -> refetch). This PR addresses the residual: 5 other
call sites in the Swift tray that still hit /api/v1/servers, totaling
~8 GETs per 60 s at idle on a 30-server config.

All 5 sites now read SSE-driven appState.servers in place of fetching:

- CoreProcessManager case "status": no longer refetches on
  connected_count change. Inline stats are merged unconditionally;
  per-server state arrives via the spec 047 servers.changed payload
  within ~50 ms of any actual transition.

- refreshState (30 s periodic) drops the refreshServers() call.
  refreshActivity / refreshSessions / refreshTokenMetrics /
  refreshSecurityStatus stay (SSE doesn't cover those domains).

- refreshSecurityStatus's Docker fallback now reads
  appState.servers synchronously instead of issuing another GET.

- MCPProxyApp's 10 s server-refresh Timer is removed entirely.

- menuWillOpen no longer refetches on every tray click. The menu
  rebuilds from in-memory state only.

In their place: a single 5-minute Combine timer in MCPProxyApp.swift
calls a new CoreProcessManager.refreshServersForSafetyNet() — pure
defense-in-depth in case SSE drops events past the 256-event buffer.

Verification (specs/048-tray-refetch-elimination/verification/report.md)
on the same MCPProxy.app + 30-server scenario as spec 047:
  - 0 GETs / 60 s at idle (was ~8)
  - context7 disable propagates to tray menu in 1 s
  - context7 enable propagates in 2 s
  - 0 GETs during the entire toggle window

Spec, plan, research, data-model, quickstart, tasks all under
specs/048-tray-refetch-elimination/. No core / Go changes.
Backward-compatible with older cores (spec 047 fallback path retained).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 728d82a
Status: ✅  Deploy successful!
Preview URL: https://09bdc488.mcpproxy-docs.pages.dev
Branch Preview URL: https://048-tray-refetch-elimination.mcpproxy-docs.pages.dev

View logs

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 Build Artifacts

Workflow Run: View Run
Branch: 048-tray-refetch-elimination

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (26 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (19 MB)
  • installer-dmg-darwin-arm64 (18 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 25568426295 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris Dumbris merged commit 6a5d39d into main May 8, 2026
39 checks passed
@Dumbris Dumbris deleted the 048-tray-refetch-elimination branch May 8, 2026 17:13
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.

3 participants