feat(sidebar): hide gears whose agent reports them unavailable - #119
Merged
Conversation
filterGearsByAgentCapabilities is the framework's existing capability-aware gear filter. Today it's only used by the Gears settings page (`/settings/gears`) — so the **sidebar** still renders HAProxy, Logs, Services, Certificates, etc. for an active box whose agent doesn't run any of those gears. Clicking them lands the operator on an empty page or a JSON-envelope error. Run the same filter on the per-box integration list inside InjectIntegrationStatus, so the sidebar reflects what the agent can actually serve. Failures stay fail-open (an unreachable agent does not strip the sidebar) by reusing the existing helper's contract. Phase 2 slice of #112. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies existing agent-capability filtering to sidebar integration rendering so the active box’s navigation better reflects what its agent can serve.
Changes:
- Calls
filterGearsByAgentCapabilitieswhile building per-box sidebar integrations. - Preserves fail-open behavior when capabilities are unavailable.
Two findings: 1. Services dashboard gear had no entry in dashboardGearToAgentGear, so the sidebar filter passed it through unconditionally — the exact symptom this PR was supposed to fix. Map it to "metrics" (the agent gear that registers /api/v1/services per gearbox-agent/internal/gears/metrics/plugin.go), and document that this is imprecise: the agent's metrics gear can be Available on a host where systemd isn't introspectable from the container, so a tighter gate (an explicit `services` capability that advertises systemd reachability) is part of the Phase 2 extension in #112. 2. No regression test covered the middleware path or the filter's fail-open contract. Add three focused tests on filterGearsByAgentCapabilities driven by a real httptest.Server returning a CapabilitiesResponse: - Mjolnir-shaped probe table → only available gears + dashboard- only gears (alerts) survive. - Agent unreachable → fail open, full list passes through. - Older agent that doesn't surface a gear name at all → that gear is kept (forward-compat, mirrors the #116 fix). The tests share a slim Handler fixture (logger, capabilities cache, static servers slice) so they exercise the production fetch path through CapabilitiesCache without needing a DB or auth manager. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
filterGearsByAgentCapabilitiesalready exists and is used by the Gears settings page. Today the sidebar doesn't consult it — so a box whose agent has nohaproxy/logs/services/certificatesgear still renders all those entries in the left nav. Clicking them lands the operator on an empty page or (post-PR fix(errors): emit JSON envelope from WriteHTTPError + harden fetch callers #114) a JSON-envelope error toast.InjectIntegrationStatusso the sidebar shows only what the agent can actually serve for the active box.Phase 2 slice of #112.
Test plan
go build ./...andgo test -count=1 ./internal/framework/handler/...cleanhost/metrics/access-log— confirm the sidebar drops HAProxy / Logs / Services / Certificates entries while keeping Bx / Home / Metrics.🤖 Generated with Claude Code