Skip to content

feat: Add ability to disable data sources (fixes #1545)#2186

Open
brandon-pereira wants to merge 5 commits intomainfrom
brandon/disable-datasource
Open

feat: Add ability to disable data sources (fixes #1545)#2186
brandon-pereira wants to merge 5 commits intomainfrom
brandon/disable-datasource

Conversation

@brandon-pereira
Copy link
Copy Markdown
Member

@brandon-pereira brandon-pereira commented May 4, 2026

Summary

Continues #1567 (originally authored by @alok87) — adds the ability to enable/disable data sources from the UI. Disabled sources remain visible in Team Settings → Sources but are filtered out of every source-selection dropdown across the app.

This branch was opened to take #1567 across the finish line: address the open review comments and bring it up to date with main.

Screenshots

Screenshot 2026-05-04 at 11 25 23 AM Screenshot 2026-05-04 at 11 25 32 AM Screenshot 2026-05-04 at 11 25 36 AM

Changes vs. the original PR

Review feedback addressed

  • @brandon-pereira: Form-managed save instead of inline mutation — Removed handleDisabledToggle in SourceForm.tsx. The toggle now just updates form state via Controller/onChange; the value is persisted on Save Source like every other field, which is consistent with the rest of the form.
  • @elizabetdev: Keep the chevron at full opacity when a source is disabled — Moved the opacity: 0.5 rule from the outer Flex to the inner content <div> in SourcesList.tsx. The expand/collapse arrow stays bright so the row still reads as interactive and the user can re-enable the source.
  • @brandon-pereira: Use a changeset, not direct CHANGELOG edits — Already addressed by @alok87 in 15ed071b; .changeset/clever-sources-disable.md is in place and the manual CHANGELOG.md edits were dropped.

Merge with main

main had moved significantly (Mantine v7 → v9 upgrade, source-model refactor to a discriminated union, local-mode storage moved to localStore, etc.). Conflict resolution highlights:

  • packages/api/src/models/source.ts — Added disabled: { type: Boolean, default: false } to the new sourceBaseSchema (the common-fields base for the discriminator), instead of the old monolithic schema the original PR was modifying.
  • packages/common-utils/src/types.tsdisabled: z.boolean().optional() lives on BaseSourceSchema alongside querySettings and timestampValueExpression, so all source kinds inherit it via .extend(...).
  • packages/app/src/source.ts — Adopted main's cleaner localSources.update(...) + standard invalidateQueries flow. The original PR's bespoke setQueryData in onSuccess is no longer needed now that the toggle goes through the regular form-save path.
  • packages/app/src/components/SourceSelect.tsx — Added !source.disabled to main's restructured values useMemo (which now handles connection/kind filtering and create/edit action items).
  • packages/app/src/KubernetesDashboardPage.tsx — Combined main's !! truthy coercion with the !s.disabled filter.

Behavior (unchanged from #1567)

  • Sources have a disabled boolean (default false).
  • Disabled sources are hidden from every source dropdown: Search, Sessions, Services dashboard, Kubernetes dashboard, generic SourceSelect, and the auto-default-source logic.
  • Disabled sources are still visible in Team Settings → Sources at 50% opacity (chevron stays at 100%) so they can be re-enabled.

Verification

  • make ci-lint
  • make ci-unit ✅ (815 + 1537 = 2,352 tests passing)
  • tsc --noEmit clean across common-utils, api, and app

Related

alok87 and others added 2 commits January 8, 2026 09:19
- Add 'disabled' field to source schema (common-utils, api, app)
- Move enable/disable toggle to expanded form header (top right)
- Dim disabled sources in list view (50% opacity when closed)
- Show full opacity when form is open for editing
- Filter out disabled sources in search page, dashboards, sessions
- Add changeset for release management
- Smooth transition effects for visual feedback

Based on PR feedback, form simplification will be addressed separately.
…ource

# Conflicts:
#	packages/api/src/models/source.ts
#	packages/app/src/KubernetesDashboardPage.tsx
#	packages/app/src/components/SourceSelect.tsx
#	packages/app/src/source.ts
#	packages/common-utils/src/types.ts
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment May 4, 2026 6:08pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: 51348f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/common-utils Minor
@hyperdx/api Minor
@hyperdx/app Minor
@hyperdx/otel-collector Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)
  • Touches API routes or data models — hidden complexity risk

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 14
  • Production lines changed: 88 (+ 60 in test files, excluded from tier calculation)
  • Branch: brandon/disable-datasource
  • Author: brandon-pereira

To override this classification, remove the review/tier-3 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@brandon-pereira brandon-pereira requested review from a team and teeohhem and removed request for a team May 4, 2026 17:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

PR Review

✅ No critical issues found.

A few minor observations:

  • ⚠️ Explanatory comments in DBSearchPage.tsx (// Filter out disabled sources) — project convention (AGENTS.md) says to skip comments where the code is self-evident; the filter predicate already communicates intent.
  • ⚠️ Inline style prop in SourcesList.tsx — Mantine's opacity and transition props exist; consistent to use them instead of a raw style object, but not a blocker.
  • ℹ️ No test coverage for toggling disabled via the API PUT/PATCH path — the existing integration tests only assert disabled: false in snapshot output; a round-trip test (create → disable → fetch) would add confidence, but not required to merge.

Overall the implementation is clean: schema, Zod type, UI toggle, and all filtering sites are consistent; test coverage for getDefaultSourceId is thorough.

- Add unit tests for getDefaultSourceId covering all-disabled,
  disabled-last-selected fallback, mixed enabled/disabled, and
  unknown-id fallback cases
- Show a 'Disabled' Badge next to the source name in SourcesList
  so the state is immediately apparent (not just lower opacity).
  Also drops the now-vestigial <Flex> wrapper around the source
  details that had no siblings.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

E2E Test Results

All tests passed • 160 passed • 3 skipped • 1198s

Status Count
✅ Passed 160
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Claude finished @brandon-pereira's task in 1m 11s —— View job


Re-review: All items addressed ✅

  • Review test coverage for getDefaultSourceId
  • Review <Badge>Disabled</Badge> + <Flex> changes in SourcesList.tsx
  • Verify overall implementation quality

Test coverage (DBSearchPage.test.tsx:394–446): The 7 new tests are well-structured and comprehensively cover the function's contract. Notably, the { id: 'c' } (no disabled key) case at line 415 correctly validates that undefined is treated as enabled — this aligns with how !s.disabled evaluates in the implementation. Tests match the implementation exactly.

SourcesList.tsx changes (lines 159–196): Clean. The vestigial inner <Flex> is gone; the name + badge now live in a <Group>. The <Badge size="xs" variant="light" color="gray">Disabled</Badge> makes state immediately clear without relying on opacity alone. The opacity: 0.5 is scoped to the content <div>, and the chevron <ActionIcon> is correctly outside it — rows still read as interactive for re-enabling.

Alerts out-of-scope: Agreed — silently suppressing alerts on disable would be a footgun. The clear call-out in the PR description is the right approach.

This looks ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants