From 8bfbe14442804ad8eb0732ae0c603a95652eafdc Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Tue, 25 Aug 2026 14:36:42 +0300 Subject: [PATCH 1/6] fix(webui): honest server, connection and connect-modal states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Web-UI UX audit (docs/qa/ux-audit-webui-2026-08.md) findings F7, F10, F11, F12, F17, F18, F28, F34 plus the F36 items in the same area. F7 — a quarantined server card stated "needs security review" and afforded no way to review. The card now carries a Review action deep-linked to the server's Security tab (where the spec-088 banner holds the verdict and the approve/scan actions), demotes Enable while the server is still held back, and the greyed Scan button says why it is disabled. F10 — the Dashboard "AI Agents" box read ClientStatus.connected from GET /api/v1/connect, which is content-read-free by design (Spec 075) and so reports connected=false for every client, always. The box could never say "Connected" while /sessions listed a live session on the same data. It now derives live clients from active MCP sessions — the same source /sessions and the macOS tray use — with a last-seen time and a link to the session. api.getSessions gains the backend's existing status filter so a small limit cannot be filled by closed sessions and hide a live client. F11 — a DNS failure offered "Restart", which redials the same broken address forever. health.Action now resolves to a new "edit_url" for address errors (no such host, unsupported/missing scheme, malformed URL); "connection refused" deliberately keeps Restart. The action deep-links to the Configuration tab with ?focus=endpoint, and the endpoint is editable there. The server detail page also spoke three status vocabularies at once (Enabled/Active, Online/Offline, Disconnected) with a green check on a server that was down; the tiles now carry exactly two axes — the admin state you set and the health level we observe — and the header badge uses the same unified reading as the Servers-page card. F12 — the Servers card printed the full wrapped Go error chain beside a perfectly good badge. The card shows the plain-language summary with the raw chain behind a details disclosure. The duplicated wrapper text is fixed at the source: mcp-go's streamable-HTTP transport wraps a send failure with the same message at two nesting levels, so adjacent duplicate segments are collapsed once, centrally, on last_error and on the diagnostic cause. F17 — the three registry cards sat above the selector looking exactly like one and were not clickable. They are the selector now (click or keyboard to toggle, visible selected state), the kebab menu no longer doubles as a selection, and the disabled search box says what would enable it. F18 — "connected" meant "the config holds an entry named mcpproxy", so a client pointing at a different instance on a different port showed as connected here. ClientStatus gains proxy_url, registered_url (sanitized the same way a preview's entry summary is) and endpoint_match (this/other/ unknown); a row addressing another instance says so and offers "Point here" instead of a false Disconnect. All rows use one action pattern, Disconnect confirms first and states the backup up front, Connect All names how many clients it would change and explains itself when it is off, and a client with no config names the paths that were searched. F28 — three surfaces for one cause: the auth modal, an inline load error behind it, and a "Connection Lost" toast. The modal now owns the message; the key field is labelled required rather than optional; "Continue Without Auth" is demoted and honest about leaving pages empty; and the key-recovery instructions no longer assume a tray, which headless and server installs do not have. F34 — the security tab printed the Risk Score twice and a bare coloured gauge with an unexplained number. One score, a labelled gauge, and a copyable scan id. F36 — the hub read "just started" on every page load because uptime was measured from when the page first saw the core running; /status and the SSE status frames now report the core's own started_at. The Sessions table's "View Activity" label no longer wraps onto two clipped lines. --- cmd/generate-types/main.go | 4 +- docs/api/rest-api.md | 10 + frontend/src/App.vue | 6 + frontend/src/components/AuthErrorModal.vue | 27 +- frontend/src/components/ConnectModal.vue | 155 ++++++++- frontend/src/components/ConnectionStatus.vue | 9 +- frontend/src/components/ServerCard.vue | 86 ++++- frontend/src/services/api.ts | 12 +- frontend/src/stores/system.ts | 12 + frontend/src/types/api.ts | 18 +- frontend/src/types/contracts.ts | 4 +- frontend/src/utils/health.ts | 1 + frontend/src/utils/sessionLabel.ts | 68 ++++ frontend/src/views/Dashboard.vue | 100 ++++-- frontend/src/views/Repositories.vue | 50 ++- frontend/src/views/ServerDetail.vue | 294 ++++++++++++++++-- frontend/src/views/Servers.vue | 6 +- frontend/src/views/Sessions.vue | 11 +- .../tests/unit/auth-single-surface.spec.ts | 85 +++++ .../tests/unit/connect-endpoint-truth.spec.ts | 215 +++++++++++++ frontend/tests/unit/connect-modal.spec.ts | 22 +- frontend/tests/unit/live-clients.spec.ts | 68 ++++ .../unit/repositories-card-selector.spec.ts | 125 ++++++++ .../unit/server-card-review-and-error.spec.ts | 157 ++++++++++ internal/connect/connect.go | 138 ++++++-- internal/connect/endpoint_match_test.go | 147 +++++++++ internal/contracts/types.go | 2 +- internal/health/calculator.go | 32 ++ internal/health/calculator_test.go | 71 ++++- internal/health/constants.go | 4 + internal/httpapi/server.go | 13 + internal/management/service.go | 8 +- internal/runtime/runtime.go | 15 +- internal/stringutil/strings.go | 31 ++ internal/stringutil/strings_test.go | 54 ++++ oas/docs.go | 2 +- oas/swagger.yaml | 2 +- 37 files changed, 1921 insertions(+), 143 deletions(-) create mode 100644 frontend/tests/unit/auth-single-surface.spec.ts create mode 100644 frontend/tests/unit/connect-endpoint-truth.spec.ts create mode 100644 frontend/tests/unit/live-clients.spec.ts create mode 100644 frontend/tests/unit/repositories-card-selector.spec.ts create mode 100644 frontend/tests/unit/server-card-review-and-error.spec.ts create mode 100644 internal/connect/endpoint_match_test.go diff --git a/cmd/generate-types/main.go b/cmd/generate-types/main.go index d8b8b943e..906ed7a99 100644 --- a/cmd/generate-types/main.go +++ b/cmd/generate-types/main.go @@ -74,6 +74,7 @@ export const HealthActionApprove = 'approve' as const; export const HealthActionViewLogs = 'view_logs' as const; export const HealthActionSetSecret = 'set_secret' as const; export const HealthActionConfigure = 'configure' as const; +export const HealthActionEditURL = 'edit_url' as const; export type HealthAction = | typeof HealthActionNone | typeof HealthActionLogin @@ -82,7 +83,8 @@ export type HealthAction = | typeof HealthActionApprove | typeof HealthActionViewLogs | typeof HealthActionSetSecret - | typeof HealthActionConfigure; + | typeof HealthActionConfigure + | typeof HealthActionEditURL; export interface HealthStatus { level: HealthLevel; diff --git a/docs/api/rest-api.md b/docs/api/rest-api.md index edcf783f5..9e1a24752 100644 --- a/docs/api/rest-api.md +++ b/docs/api/rest-api.md @@ -842,6 +842,9 @@ additive-compatible and gains two fields: | `connected` | bool | mcpproxy registered in the config. Authoritative **only** when `access_state == "accessible"`; `false`/unresolved in the overall listing. | | `access_state` | string | `"unknown"` in the overall listing (not content-checked); resolved to `"accessible"`, `"absent"`, `"malformed"`, or `"denied"` by an on-demand single-client read. | | `remediation` | string | Present only when `access_state == "denied"`; carries the actionable fix text (App Data toggle + `tccutil reset` command). | +| `proxy_url` | string | **This** instance's MCP endpoint. Config-derived (no file read), so it is present on the overall listing too. | +| `registered_url` | string | The endpoint the client's existing entry actually points at, sanitized (query, userinfo and fragment stripped — never a credential). Resolved only by an on-demand read. | +| `endpoint_match` | string | How `registered_url` relates to `proxy_url`: `"this"` (the entry addresses this instance), `"other"` (it addresses a different one), `"unknown"` (the entry has no comparable endpoint, e.g. a stdio command). Empty when `connected` is false or nothing was read. | A client that is installed but not yet content-checked reads as `exists=true, connected=false, access_state="unknown"`. Resolving `connected` @@ -849,6 +852,13 @@ requires an explicit per-client read (the per-client status route below, connect/disconnect, or the CLI `mcpproxy connect` command), which is where a privacy prompt may legitimately appear. +**`connected` alone is not "connected to this instance."** It means an +mcpproxy-shaped entry is present in that client's config — and an entry merely +*named* `mcpproxy` counts, even when its URL addresses another instance on +another port. Consumers that need the stronger claim must check +`endpoint_match == "this"`; a UI showing a bare "Connected" on +`endpoint_match == "other"` is reporting someone else's link as its own. + #### GET /api/v1/connect/{client} On-demand single-client status. Reads the one client's config **at request diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 1d23fbf6b..48a436f43 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -73,11 +73,13 @@ let removeAPIListener: (() => void) | null = null function handleAuthModalClose() { authModal.show = false authModal.lastError = '' + systemStore.setAuthRequired(false) } function handleAuthModalAuthenticated() { authModal.show = false authModal.lastError = '' + systemStore.setAuthRequired(false) // Refresh data now that we're authenticated systemStore.connectEventSource() @@ -87,6 +89,7 @@ function handleAuthModalAuthenticated() { function handleAuthModalRefresh() { authModal.show = false authModal.lastError = '' + systemStore.setAuthRequired(false) // Reconnect with potentially new API key systemStore.connectEventSource() @@ -98,6 +101,9 @@ function handleAuthError(event: APIAuthEvent) { console.log('Global auth error received:', event) authModal.lastError = event.error authModal.show = true + // Audit F28: one cause, one message. The modal now suppresses the reconnect + // toast and the inline load errors it would otherwise compete with. + systemStore.setAuthRequired(true) } onMounted(async () => { diff --git a/frontend/src/components/AuthErrorModal.vue b/frontend/src/components/AuthErrorModal.vue index 19395fc46..8106efed6 100644 --- a/frontend/src/components/AuthErrorModal.vue +++ b/frontend/src/components/AuthErrorModal.vue @@ -13,19 +13,23 @@

How to get the API key:

+
    -
  1. Using Tray: Right-click the MCPProxy tray icon and select "Open Web UI"
  2. -
  3. From Logs: Check mcpproxy startup logs for the API key, then add ?apikey=YOUR_KEY to the URL
  4. -
  5. Manual Entry: Enter your API key below if you have it
  6. +
  7. From the CLI: run mcpproxy doctor, or read api_key in ~/.mcpproxy/mcp_config.json
  8. +
  9. From logs: the key is printed in the mcpproxy startup log
  10. +
  11. Using the tray (desktop installs): right-click the MCPProxy tray icon and select "Open Web UI" — it opens an already-authenticated window
- +
Refresh & Retry -
diff --git a/frontend/src/components/ConnectModal.vue b/frontend/src/components/ConnectModal.vue index e34de74a1..c456bb707 100644 --- a/frontend/src/components/ConnectModal.vue +++ b/frontend/src/components/ConnectModal.vue @@ -35,6 +35,19 @@
{{ client.name }}
{{ client.config_path }}
+ +
+ → {{ client.registered_url }} +
{{ client.note }}
@@ -57,11 +70,31 @@ class="badge badge-warning badge-sm" title="Config exists but could not be parsed" >Unreadable config - Config not found + + Not installed + + Connected to another instance + @@ -336,16 +380,59 @@ - @@ -445,14 +532,54 @@ const connectableClients = computed(() => // Bridge clients (e.g. Claude Desktop) can be connected even without an // existing config file — Connect creates it. A client macOS has blocked // ('denied') is excluded: the write would fail with the same privacy error. + // A row pointing at ANOTHER instance is excluded too: repointing someone + // else's config is a deliberate per-row decision, not a bulk side effect. mergedClients.value.filter( - c => c.supported && (c.exists || c.bridge) && !c.connected && accessState(c) !== 'denied' + c => + c.supported && + (c.exists || c.bridge) && + !c.connected && + accessState(c) !== 'denied' ) ) -const allConnected = computed(() => - connectableClients.value.length === 0 -) +// Audit F18: a disabled primary must say what would enable it. The reasons are +// mutually exclusive in practice, so the most specific one wins. +const connectAllDisabledReason = computed(() => { + const supported = mergedClients.value.filter(c => c.supported) + if (supported.length === 0) return 'No supported MCP clients found on this machine.' + if (supported.every(c => c.connected)) return 'Every supported client is already connected.' + if (supported.some(c => accessState(c) === 'denied')) { + return 'The remaining clients are blocked by macOS — fix access above first.' + } + return 'No client on this machine is ready to connect.' +}) + +function endpointTitle(client: ClientStatus): string { + if (client.endpoint_match === 'other') { + return `This client is registered to ${client.registered_url}, not to this instance (${client.proxy_url ?? 'unknown'}).` + } + return `Registered to ${client.registered_url}` +} + +function notFoundTitle(client: ClientStatus): string { + const paths = client.checked_paths?.length ? client.checked_paths : [client.config_path] + return `No config file found. Looked in:\n${paths.join('\n')}` +} + +// --- Disconnect confirmation (audit F18) --- +const disconnectTarget = ref(null) + +function askDisconnect(client: ClientStatus) { + disconnectTarget.value = client +} + +async function confirmDisconnect() { + const target = disconnectTarget.value + if (!target) return + await disconnect(target.id) + disconnectTarget.value = null +} function clientIcon(client: ClientStatus): string { // Map client icons based on id/name diff --git a/frontend/src/components/ConnectionStatus.vue b/frontend/src/components/ConnectionStatus.vue index 2cc6a43fb..58aaad855 100644 --- a/frontend/src/components/ConnectionStatus.vue +++ b/frontend/src/components/ConnectionStatus.vue @@ -1,7 +1,12 @@