Skip to content

feat: Support source remapping during ad hoc filter import - #3367

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
drew/import-adhoc-filter-sources
Oct 14, 2026
Merged

kodiakhq[bot] merged 3 commits into
mainfrom
drew/import-adhoc-filter-sources

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR updates the dashboard import page to allow ad hoc filter sources (both sources and appliesToSources) re-mappable during import.

Note: adhoc filters are not yet rendered, so you won't see imported filters show up in the UI yet.

Screenshots or video

Screenshot 2026-10-14 at 7 23 43 AM

How to test

Here's an importable template to try

Save it as a JSON file and import it

{"version":"0.1.0","name":"My Dashboard","tiles":[{"id":"m60b2zw4eha3zyqbo80vgl","x":0,"y":0,"w":8,"h":10,"config":{"name":"","source":"Demo Logs","displayType":"line","granularity":"auto","alignDateRangeToGranularity":true,"select":[{"aggFn":"count","aggCondition":"","aggConditionLanguage":"lucene","valueExpression":""}],"where":"","whereLanguage":"lucene"}}],"filters":[{"id":"65892bc6-0548-4049-a732-70f6c7d4c933","name":"Extra SQL Filters","variableName":"Extra_SQL_Filters","type":"ADHOC","sourceType":"sql","sources":["Demo Logs","Demo Traces"],"appliesToSourceIds":["Demo Traces","Demo Sessions","Demo Logs"],"isBroadcastEnabled":true,"isVariableEnabled":true}]}

References

  • Linear Issue: Closes HDX-5659
  • Related PRs:

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: afeba95

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

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 14, 2026 4:32pm UTC
hyperdx-storybook Ready Ready Preview Oct 14, 2026 4:32pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 124 in total (1.72%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new actionable findings.

Summary

Adds source remapping for ad hoc filters during dashboard import.

  • Dashboard imports keep ad hoc filters with mapped sources.

No new actionable findings were identified.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Template source names] --> B[Match local sources by name and kind]
  B --> C[Mapping controls]
  D[Tile source remap] --> E[Update matching source slots]
  E --> C
  C --> F[Check required sources and kinds]
  F --> G[Save mapped IDs and original conditions]
Loading

Reviews (5) · Last reviewed commit: "Merge branch 'main' into drew/import-adh..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 415 passed • 1 skipped • 1235s

Status Count
✅ Passed 415
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the drew/import-adhoc-filter-sources branch from 54a6a2b to 0566292 Compare October 14, 2026 11:38
@pulpdrew
pulpdrew marked this pull request as ready for review October 14, 2026 11:38
@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

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

Why this tier:

  • Diff size: 330 production lines changed (Tier 2 max: < 250)

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

Stats
  • Production files changed: 1
  • Production lines changed: 330 (+ 653 in test files, excluded from tier calculation)
  • Branch: drew/import-adhoc-filter-sources
  • Author: pulpdrew

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

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor

1 posted as inline comment(s) on the changed lines.


Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The ad hoc source-remapping flow is type-correct end to end, the four prior Greptile findings about remap ordering (replace-in-place, fill-unresolved-by-position, successive remaps, and the Title Case label) are all addressed, and savedFilterValues now pass through without source-id leakage. One correctness regression and a few nits remain.

🟡 P2 — recommended

  • packages/app/src/DBDashboardImportPage.tsx:841 — Emptying an applies-to or ad hoc source multiselect makes react-hook-form report the field as not dirty (its default is []), so a later tile remap sharing that template source name passes the isDirty guard, re-reads multiMappingSlotsRef, and restores the sources the user deliberately removed, persisting a mis-scoped filter on import.
    • Fix: Track user-initiated multiselect edits independently of isDirty — e.g. drop the key from multiMappingSlotsRef on any manual change and skip propagation for it — so a remap cannot resurrect a cleared list.
    • correctness, julik-frontend-races, previous-comments
🔵 P3 nitpicks (3)
  • packages/app/src/DBDashboardImportPage.tsx:464 — The schema comment on filterAppliesToSourceMappings still says empty means "applies to all" but after this change an empty ad hoc applies-to list means "apply to the filter's own data sources," conflating two meanings.
    • Fix: Update the comment to spell out the divergent ad hoc semantics.
  • packages/app/src/DBDashboardImportPage.tsx:617 — multiMappingSlotsRef is a positional side-channel kept consistent with form state only inside propagateToMultiMapping; a future setValue on these fields that forgets the ref would leave it stale and clobber the field on the next propagation.
    • Fix: Document the lockstep invariant at the setValue call site, or derive slots on demand from the current form value plus templateNames instead of caching.
  • packages/app/src/DBDashboardImportPage.tsx:518 — superRefine and the ad hoc multiselect JSX call getAdhocFilterSourceKinds(filter.sourceType) directly while the PR adds appliesToSourceKinds(filter) as the canonical kind source, leaving two parallel lookups that can drift.
    • Fix: Route both call sites through appliesToSourceKinds, or drop the wrapper.

Reviewers (7): correctness, julik-frontend-races, previous-comments, kieran-typescript, testing, maintainability, project-standards.

Testing gaps:

  • No regression test for the P2 above: clear a filter's applies-to/ad hoc multiselect, then remap a tile whose template source name is in that filter, and assert the cleared entries are not restored.
  • The promql ad hoc path (sourceType: 'promql') is uncovered — every unit and e2e template uses sourceType: 'sql', so the PromQL kind message and allowed-kinds branch never execute.
  • The adversarial reviewer did not return before synthesis; its corrupt-save focus was partially covered by the correctness and previous-comments reviewers (onSubmit zip and savedFilterValues passthrough verified safe).

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@pulpdrew
pulpdrew force-pushed the drew/import-adhoc-filter-sources branch from 0566292 to ea474d5 Compare October 14, 2026 11:54
<Table.Tr>
<Table.Th>Tile / Filter</Table.Th>
<Table.Th>Mapping Type</Table.Th>
<Table.Th>Mapping type</Table.Th>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated a few labels to sentence case while I was here.

@brandon-pereira brandon-pereira left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, I was able to import. LGTM

@kodiakhq
kodiakhq Bot merged commit 0840b8b into main Oct 14, 2026
29 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/import-adhoc-filter-sources branch October 14, 2026 16:35

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — afeba95a Deployed Oct 14, 2026 by vercel[bot]
Preview – hyperdx-storybook — afeba95a Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants