Repository navigation
Commit c1de0d0
authored
fix(tray): stop the permanent red badge, and shrink it to a corner dot (#1075)
* fix(tray): stop the permanent red badge, and shrink it to a corner dot
The v0.61.0 tray badge (#1055) sat red indefinitely on an install whose
only error-severity diagnostics belonged to quarantined servers, and it
was drawn as a full-size glyph beside the icon rather than a badge on it.
Tray badge — quarantined servers no longer tint it
worstDiagnosticSeverity and diagnosticCount excluded OAuth
login-required servers but not quarantined ones. mcpproxy still attempts
a connection to a quarantined server so the scanner can export its tool
definitions, and the failed attempt leaves an error-severity diagnostic
behind — while the same payload reports health.level "healthy" /
admin_state "quarantined". The menu header drew a calm yellow dot from
serversNeedingAttention under a red menu-bar dot from
worstDiagnosticSeverity, and the user could not clear it without
approving or disabling the server.
Both properties now share one ServerStatus.isBadgeExempt predicate so
they cannot drift apart, and any future intentional non-connected state
has one place to be added.
Tray badge — drawn as a corner dot, not a glyph beside the icon
The severity badge was a full-size "●" plus a leading space in the
button's attributed title, which widened the status item by about a
character and read as a second icon. It is now a 6pt dot in the icon's
bottom-right corner, as a subview: the status-item image must stay
isTemplate to track the light/dark menu bar and to invert while the menu
is open, and template rendering forces every pixel monochrome, so a
coloured dot composited into the image comes back black. The view is
hit-test transparent and ignored by accessibility, since the button
already publishes the whole state as its label.
⏹ (core stopped) and ⚠ (core error) keep their full-size glyphs: those
mean "nothing is working", which is worth the width and would be lost if
collapsed into the same dot.
Diagnostics — two of mcpproxy's own messages no longer say "file a bug"
`command "npx" has no args` (emitted by our own pre-spawn validation in
connection_stdio.go) and the legacy-SSE `4xx for initialize POST` both
fell through to MCPX_UNKNOWN_UNCLASSIFIED, whose catalog entry offers a
"Report a bug" button. They now classify as MCPX_CONFIG_INVALID_COMMAND
and MCPX_HTTP_LEGACY_SSE, with catalog entries and docs pages. The
legacy-SSE rule is matched before the generic HTTP status-text fallback,
which would otherwise claim it as a bare 403/404 and send the user
hunting for a credential problem that does not exist.
Logging — one ListTools failure was three ERROR lines
core.Client, managed.Client and Manager.discoverTools each logged the
same failed list operation at ERROR. On an install with several stdio
servers the periodic sweep hit this roughly once a minute per server,
indefinitely. The two inner layers drop to Debug; the manager keeps the
line at Warn, since it deliberately skips markSwept so the next sweep
retries — a failure the code already plans to retry is not an error.
Tests
- Swift: quarantine/OAuth badge exemption from live /api/v1/servers
payload shapes, including that a genuinely broken server still tints
red and that the spoken count agrees with the badge.
- Swift: corner-dot geometry and colour asserted by rendering the view
offscreen and reading pixels back — the status item cannot be
screenshotted without a Screen Recording grant, and "it looked right
once" is not a regression test.
- Go: both new codes classify from the verbatim v0.61.0 error strings,
ordinary HTTP statuses are unaffected, and both codes are registered.
- Go: one ListTools failure is reported by exactly one layer, not at
ERROR, and is still reported at all.
* fix(tray): anchor the badge dot to the icon, not the button
Cross-model review (opencode, gpt-5.6-sol) caught a real defect in the
corner-dot badge: it was a 6x6 subview positioned from `button.bounds` at
update time and pinned with `[.minXMargin, .maxYMargin]`. That anchors to
the BUTTON's bottom-right, but the dot belongs to the CENTRED 18pt icon,
and it broke in two independent ways.
* Rate mismatch. When the status button shrinks by N, a right-pinned
subview moves left by N while the centred icon's right edge moves left
by only N/2 — the badge slides off the glyph it is badging.
* Stale bounds. NSStatusItem is variableLength and resizes
asynchronously, so the `button.bounds` read immediately after clearing
`attributedTitle` (which updateStatusIcon does, in the same pass) is
still the old, wider value. The dot is then laid out against an icon
centre that no longer exists.
The overlay now fills the button, autoresizes with `[.width, .height]`,
and computes the dot inside `draw(_:)` from its own live bounds. Any
resize simply repaints in the right place, which removes both failure
modes rather than patching either. `hitTest` already returned nil, which
is what keeps the now-full-size overlay from swallowing every click.
Note `needsDisplayOnBoundsChange` is a CALayer property and does not exist
on NSView — the review suggested it and it does not compile. `setFrameSize`
is overridden instead.
Tests
The drawing tests now RENDER the view and scan the bitmap for the pixels
it actually painted, converting device pixels to points, rather than
sampling one computed point. The earlier version guessed the bitmap's
y-flip, read a transparent pixel, and would have reported "the view drew
nothing" as a colour failure. Scanning asserts position, colour and
restraint together and survives a geometry retune. Added:
- the dot tracks the icon across button widths (the regression above)
- a resize re-renders it in its new place
- only the corner dot is painted, never a wash over the whole icon
* fix(tray): the status button is FLIPPED — pin it, test it, document it
Multi-agent verification found what both I and the cross-model review
missed, by compiling against real AppKit rather than reasoning about it:
NSView().isFlipped = false
NSButton().isFlipped = true
NSStatusBarButton.isFlipped = true
The first commit in this PR (9c740c0) therefore shipped the badge in the
icon's TOP-right corner, not the bottom-right its comment and commit
message both claimed. `y = 2` in a flipped button is 2pt from the TOP, and
`.maxYMargin` pins to the TOP. Rendered inside a real 36x22 status button
the dot landed at bitmap rows 4-15 of 44 (top-first).
The second commit (5e773a9) already corrected it — but incidentally,
because TrayBadgeDotView is a plain NSView and computes the dot in its own
unflipped space. Nothing recorded that the design depends on that, and no
test could tell the two apart: every badge test rendered the view
standalone, where the flip never enters the picture.
* `isFlipped` is now overridden to `false` explicitly. It is load-bearing,
not incidental — overriding it to true silently moves the badge back to
the top-right.
* TrayBadgeDotView's and badgeDotFrame's comments described the OLD bug
wrongly (they said the mask pinned bottom-right). Corrected, with the
flipped-coordinate trap written down as the reason the design is shaped
the way it is.
* New TrayBadgeInStatusButtonTests renders the overlay inside a REAL
NSStatusBarButton and asserts the dot is in the visual lower-right.
Mutation-tested: flipping the overlay fails it with "badge is in the
TOP half — the flipped-coordinate bug is back (rows 4...15 of 44)",
matching the shipped bug's measured position exactly.
Also from the sweep:
* The legacy-SSE string is mcp-go's exported `transport.ErrLegacySSEServer`,
NOT one of ours as the classifier comment, the test file and the PR body
all claimed. Corrected, `errors.Is` added as the primary check (the
substring fallback stays, since the upstream layer stringifies the error
and breaks the errors.Is chain), and TestLegacySSESentinelStillMatches
pins the vendored wording — otherwise a routine mcp-go bump silently
regresses MCPX_HTTP_LEGACY_SSE to MCPX_HTTP_404 with the suite green.
* `serversWithDiagnostic` was left on the narrower OAuth-only predicate
when isBadgeExempt was introduced, breaking the "these filter
identically" invariant at birth. Nothing consumes it today, which is
precisely why the drift would have surfaced late. Aligned, and pinned by
a test.
* `isQuarantineReview`'s comment claimed `quarantined` and `admin_state`
were two independent signals. They are not — health/calculator.go derives
the second from the first. The check is kept as belt-and-braces; the
claim is corrected.
* Added the composition case nothing covered: servers are quarantined on
add, so a newly added npx-with-no-args server is quarantined AND broken.
It asks for review rather than raising a red badge — deliberate, now
pinned, along with the case that it DOES alarm once released.
* test(tray): skip the status-button render test when there is no window server
TrayBadgeInStatusButtonTests creates a real NSStatusBar item, which is the
whole point — the flipped-coordinate bug is invisible to a standalone
render. But `swift test` runs on a macos-latest runner whose window-server
state is not guaranteed, and there `item.button` is nil. XCTUnwrap turned
that into a FAILURE, so a green local run could have gone red in CI for a
reason the test cannot assert there.
Throws XCTSkip instead. The assertions are about AppKit geometry inside a
real button; with no button there is nothing to assert, and that is a skip,
not a defect.1 parent 0ace8e1 commit c1de0d0
21 files changed
Lines changed: 1356 additions & 41 deletions
File tree
- docs/errors
- internal
- diagnostics
- upstream
- core
- managed
- native/macos/MCPProxy
- MCPProxyTests
- MCPProxy
- API
- Menu
- State
- website
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
346 | 355 | | |
347 | 356 | | |
348 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
349 | 376 | | |
350 | 377 | | |
351 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
| |||
0 commit comments