Repository navigation
fix(ui/store): clear missing server fields on merge (#438) - #443
Merged
Merged
Conversation
Reported by Jason Landbridge (issue #438): after clicking "Approve all tools" on a server, navigating to the Servers overview page kept showing the "5 pending approval" quarantine badge even though everything was approved. A hard refresh fixed it. Root cause is a generalisation of the previously-special-cased last_error bug: The Pinia stores/servers.ts mergeServers helper updates each existing server in place via Object.assign(existingServer, incomingServer). The backend's enrichServersWithQuarantineStats (internal/httpapi/server.go) only sets `Quarantine` when `pending > 0 || changed > 0`; once all tools are approved the field disappears from the JSON entirely. Object.assign adds and overwrites — it never deletes. The stale `quarantine: { pending_count: 5 }` therefore survived on the in-place reactive object and ServerCard's `server.quarantine?.pending_count` kept rendering the badge until a full page reload replaced the array. The author had already special-cased `last_error` for this exact reason. The same pattern affects every conditional optional field — `quarantine`, `oauth_status`, `token_expires_at`, `user_logged_out`, `health`, `security_scan`, `diagnostic`, `error_code`, etc. — and Jason flagged that he sees similar staleness "in several areas of the UI." Fix: replace the one-field special case with a general key-sync. For each key on the existing server that is absent on the incoming server, delete it before Object.assign. This treats the API response as authoritative (which it is) and works for every conditional field without enumerating them. The existing object reference is still preserved, so v-memo on ServerCard keeps its stable identity and the list does not visually rerender. Tests in frontend/tests/unit/servers-store.spec.ts: * drops the stale quarantine field when the backend stops emitting it * drops last_error on recovery (regression coverage for the original special case the new code subsumes) * drops oauth_status / token_expires_at / user_logged_out together * preserves the existing object reference across merges (identity stability for v-memo) * sanity: still updates and adds present fields 8 tests, all passing (5 new + 3 existing). Note: a complementary backend change — emit `servers.changed` SSE on tool approval — is in a separate PR so a Servers/overview page open in another tab also reactively updates without depending on the Approve flow's explicit fetchServers() call. This PR is the primary fix; the SSE one is the cross-tab improvement. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Deploying mcpproxy-docs with
|
| Latest commit: |
035161e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f58fdce3.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-server-store-clear-stale.mcpproxy-docs.pages.dev |
This was referenced Apr 30, 2026
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 25180916256 --repo smart-mcp-proxy/mcpproxy-go
|
Dumbris
added a commit
that referenced
this pull request
Apr 30, 2026
Companion to PR #443 (frontend mergeServers stale-field clear). Background — issue #438: when a user clicks "Approve all tools" on the Server Detail page, the Servers/overview page (open in another tab, or reached via client-side navigation) keeps showing the "N pending approval" quarantine badge until a manual reload. PR #443 fixes the specific case where the user navigates to Servers in the SAME session, because the click handler explicitly calls serversStore.fetchServers(). This PR fixes the cross-tab / cross-session case: ApproveTools now publishes a servers.changed runtime event with reason="tools_approved" after successfully updating tool approval records. The event already exists for every other server-state mutation (enable/disable, restart, quarantine toggle, sync, server connected/disconnected, tools indexed — see internal/runtime/lifecycle.go); this fills in the one missing call site so any subscribed UI surface (web UI in another tab, tray, future clients) re-fetches authoritative state without depending on the acting tab to broadcast. The emit: - happens once per ApproveTools call, after the loop, gated on approved > 0 — bulk approval of 50 tools doesn't spam 50 events; a no-op call (e.g. tools that don't have records) emits nothing - includes server, approved_count, and approved_by in the payload so consumers can render targeted toasts ("3 tools approved on github by user@…") without needing a follow-up GET Tests in internal/runtime/tool_approval_event_test.go: * TestApproveTools_EmitsServersChanged — pre-seed a pending record, subscribe to the bus, call ApproveTools, assert one servers.changed (reason=tools_approved) within 2s, with the expected payload fields. * TestApproveTools_NoEventOnNoOp — call ApproveTools on a tool with no record (warn-and-continue path), assert NO event is published. Co-authored-by: Claude Code <[email protected]>
1 of 2 tasks
Dumbris
added a commit
that referenced
this pull request
May 2, 2026
…#445) The release-notes generator (scripts/generate-release-notes.sh) feeds commit subjects to Claude with no edition context, and Claude has been inventing edition annotations from thin air: - v0.29.0: "*Note: The onboarding improvements primarily affect the **Personal Edition** desktop application.*" - v0.29.1: "**Personal Edition (macOS)**" header - v0.29.2: "*Note: All changes in this release apply to the Teams edition only.*" — wrong, all three PRs (#442, #443, #444) modify shared code (internal/runtime/, frontend/) and ship in both editions This patch updates the prompt to: 1. Briefly explain the two-edition build model so the model doesn't have to guess from training data. 2. Forbid edition-only annotations unless a commit subject explicitly says so (e.g. contains "(server)", "(teams)", "server-only"). 3. Forbid speculation from subject keywords (ui/runtime/oauth/etc). 4. Use "Server edition", not "Teams edition" — Teams is an internal package name. 5. Default to BOTH editions when unsure. The v0.29.2 release body has been hand-corrected separately. Co-authored-by: Claude Code <[email protected]>
13 of 18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #438. Generalises the previously-special-cased
last_errorclear in the PiniamergeServershelper to handle every conditionally-emitted optional field onServer.The bug Jason hit
After clicking Approve all tools on the Server Detail page, navigating to the Servers overview kept showing the "5 pending approval" quarantine badge. A hard browser refresh fixed it. He also flagged seeing similar stale-state in several other places.
Root cause
frontend/src/stores/servers.ts::mergeServersupdates each existing server in place viaObject.assign(existing, incoming). The backend'senrichServersWithQuarantineStats(internal/httpapi/server.go:1143-1148) only setsQuarantinewhenpending > 0 || changed > 0:```go
if pending > 0 || changed > 0 {
servers[i].Quarantine = &contracts.QuarantineStats{
PendingCount: pending,
ChangedCount: changed,
}
}
```
After the user approves everything the field disappears from the JSON entirely.
Object.assignadds and overwrites — it never deletes. The stalequarantine: { pending_count: 5 }therefore survives on the reactive object andServerCard'sserver.quarantine?.pending_countkeeps rendering the badge.The author of this code already noticed the pattern for
last_errorand special-cased it. The same trap exists for every other optional field the backend conditionally emits:quarantinepending > 0 || changed > 0last_erroroauth_status,token_expires_atuser_logged_outhealth,diagnostic,error_codesecurity_scanconnected_at,last_reconnect_at,reconnect_countFix
Replace the one-field special case with a general key-sync: for each key on the existing server that is absent on the incoming server,
deleteit beforeObject.assign. The API response is authoritative; this treats it that way. The existing object reference is still preserved soServerCard'sv-memokeeps stable identity and the list does not visually re-render.Tests (
frontend/tests/unit/servers-store.spec.ts)5 new + 3 existing = 8 passing:
quarantinefield when the backend stops emitting itlast_erroron recovery (regression coverage for the previous special case)oauth_status/token_expires_at/user_logged_outtogetherv-memo)Test plan
Note on cross-tab updates
A complementary backend change — emit `servers.changed` SSE after `ApproveTools` — will land in a separate PR so a Servers/overview tab open elsewhere also reactively updates without depending on the Approve flow's explicit `fetchServers()` call. This PR is the primary fix Jason saw; the SSE one is the cross-tab improvement.
🤖 Generated with Claude Code