Skip to content

ui: Extract FilterPill, add filter editor components - #3317

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
drew/adhoc-filter-pill
Oct 7, 2026
Merged

kodiakhq[bot] merged 4 commits into
mainfrom
drew/adhoc-filter-pill

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR extracts a FilterPill component from the ActiveFilterPills list component, and adds additional adhoc-filter-related components used to edit a filter's key, operator, and value. Storybooks are provided covering the new and existing functionality.

Screenshots or video

Screenshot 2026-10-07 at 11 37 21 AM
Screen.Recording.2026-10-07.at.11.25.26.AM.mov

How to test on Vercel preview

Regression testing on the search page: test adding a filter and editing its value in the pill

New functionality: view the storybook

References

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

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6984a89

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 7, 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 7, 2026 5:36pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hyperdx-storybook Ignored Ignored Preview Oct 7, 2026 5:36pm UTC

Request Review

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 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: 869 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: 8
  • Production lines changed: 869 (+ 634 in test files, excluded from tier calculation)
  • Branch: drew/adhoc-filter-pill
  • 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 7, 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 127 in total (1.77%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Oct 7, 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.

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

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

Findings outside the changed lines

3 minor
  • 🔵 packages/app/src/components/FilterPill/FilterConditionEditor.tsx:625 — Editing an existing condition pre-fills both inputs, so Autocomplete narrows the suggestions to the current key/value → Mantine Autocomplete filters data by the typed value. With initial={{ key: 'SeverityText', value: 'debug' }} (the EditingExisting story), the key list shows only SeverityText and the value list shows only debug, so the user can't browse alternatives without clearing the field first. FilterValueEditor already handles this (FilterValueEditor.tsx:1128-1130) by starting the draft empty and putting the current value in the placeholder. Do the same here, or pass a filter that shows every option while the input still equals initial.
  • 🔵 packages/app/src/components/FilterPill/FilterConditionEditor.tsx:638 — Apply and value-Enter still submit an empty value, which the key-Enter handler says it avoids → The comment at line 654 says Enter in the key input focuses the value "instead of applying an empty-value filter". But canSubmit only checks key and operator, so clicking Apply, or pressing Enter in an empty value input, submits { value: '' } (e.g. =~ '' or LIKE ''). Either add value.trim() to canSubmit, or delete the comment if empty values are meant to be allowed.
  • 🔵 packages/app/src/components/FilterPill/FilterPill.stories.tsx:872 — Mapping a FilterCondition to pill props (operator label, negated accent) exists only in a story → FilterOperatorOption.negated and label are documented as controlling the pill's accent and operator text, but nothing outside ConditionEditorDemo reads them (operator?.label ?? condition.operator, isExcluded={operator?.negated}). Every real caller would have to copy that lookup. Add a small helper next to filterOperators.ts (e.g. getPillOperatorProps(operators, condition)), or let FilterPill take the operator option directly, so the mapping has one source of truth.

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

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Extracts and refactors filter UI components.

The PR appears safe to merge; no new blocking issue was established.

What we checked:

  • Invalid filters stay remove-only: FilterPill excludes invalid filters from editing and returns the plain pill without a popover.

Summary

Extracts FilterPill and FilterValueEditor from ActiveFilterPills. Adds FilterConditionEditor, shared autocomplete behavior, SQL and PromQL operator choices, stories, and unit tests.

  • The previous-review merge bases differ, so this review used the full PR diff.
  • No new actionable issues or repository-rule violations were established.
  • pulpdrew manually resolved the previous suggestion thread without explanation.
  • Tests and visual checks were not run; dependencies are not installed.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into drew/adhoc-filt..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This PR extracts FilterPill/FilterValueEditor from ActiveFilterPills and adds new, not-yet-wired filter-editor components (FilterAutocomplete, FilterConditionEditor, filterOperators) with stories and tests. The production-reachable path (ActiveFilterPills → FilterPill + FilterValueEditor) is behavior-preserving and covered by the existing integration tests; the notable defects live in FilterConditionEditor, which no production code consumes yet, so they cannot cap higher than P2.

🟡 P2 -- recommended

  • packages/app/src/components/FilterPill/FilterConditionEditor.tsx:106 -- During the 300 ms key debounce and value fetch, the value Autocomplete still receives the previous key's valueOptions and only shows a spinner, so a user can pick and apply a value belonging to the old key, emitting a mismatched {key, value} condition; this is the prior Greptile P2 that was marked resolved without a code change.
    • Fix: Gate the option list on the loading state (options={isValueLoading ? [] : valueOptions}) and reset value when the key changes so a stale value cannot be applied under the new key.
    • previous-comments, julik-frontend-races, correctness, testing
  • packages/app/src/components/FilterPill/FilterValueEditor.tsx:67 -- The clipboard copy-failure branch in this newly extracted component (error notification plus early return, no success state) is untested; the unit test never clicks Copy and the integration test mocks copyTextToClipboard to always resolve true.
    • Fix: Add a FilterValueEditor unit test that mocks copyTextToClipboard to resolve false and asserts the error notification fires while the success checkmark does not appear.
  • packages/app/src/components/FilterPill/FilterConditionEditor.tsx:43 -- FilterConditionEditor, the SQL/PromQL operator presets, getFilterOperators, and the entire PromQL path have no production consumer and are exercised only by stories and tests, shipping an unused generic editor and a second operator language as maintained-but-dead surface area.
    • Fix: Confirm the wiring PR is imminent, or defer the PromQL preset and condition editor until a real consumer exists.
🔵 P3 nitpicks (4)
  • packages/app/src/components/FilterPill/FilterConditionEditor.tsx:57 -- operator is seeded from operators[0]?.value/initial only on mount, so swapping the operators or initial prop on a mounted editor leaves stale state (blank Select, yet Apply still submits the old operator); latent because no caller reuses a mounted instance today.
    • Fix: Reconcile operator/key/value via an effect or a reset key when operators/initial change, or document that callers must remount.
    • kieran-typescript, adversarial
  • packages/app/src/components/FilterPill/FilterConditionEditor.tsx:77 -- Apply can emit an empty or whitespace-only value because canSubmit checks only key and operator and submit passes value untrimmed, inconsistent with the key-input Enter handler and FilterValueEditor, which both avoid empty values.
    • Fix: Trim value in submit and require a non-empty value in canSubmit where empty is nonsensical.
  • packages/app/src/components/FilterPill/FilterConditionEditor.tsx:65 -- The onKeyChange effect depends on the onKeyChange identity and fires with an empty key on mount, so a caller passing an inline (unstable) callback would re-trigger value fetches on every render.
    • Fix: Hold the callback in a ref and depend only on [debouncedKey], or document that onKeyChange must be referentially stable.
  • packages/app/src/mocks/filterValues.ts:36 -- useMockValues returns the previous key's values after the key is cleared (isLoading false with stale data); story/mock-only impact.
    • Fix: Return empty data when key is falsy.

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

Testing gaps:

  • No unit test for FilterAutocomplete's highlighted-option vs free-text Enter handling; covered only indirectly through the integration test.
  • No test that reopening a pill's value editor resets the draft to empty — the behavior now relies on Mantine Popover unmounting the dropdown rather than an explicit effect.
  • getFilterOperators() language-dispatch branch in filterOperators.ts is never invoked by a test.

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

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 405 passed • 1 skipped • 1441s

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

Tests ran across 4 shards in parallel.

View full report →

Comment thread packages/app/src/mocks/filterValues.ts Resolved
// (column missing on the active source) can only be removed. Both keep the
// plain remove-only pill; only included/excluded pills open the action menu.
// (column missing on the active source) can only be removed.
const isEditable = pill.type !== 'range' && !isInvalid;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 minor — !isInvalid check repeats a guard that FilterPill already applies

FilterPill already sets isEditable = renderPopover != null && !isInvalid (FilterPill/FilterPill.tsx:968). In SearchFilterPill, isEditable only needs to be pill.type !== 'range' for deciding whether to pass renderPopover. Keep !isInvalid only in the enabled condition of useGetKeyValues, so the invalid-pill rule lives in one place.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@kodiakhq
kodiakhq Bot merged commit 01fdc5d into main Oct 7, 2026
29 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/adhoc-filter-pill branch October 7, 2026 17:47
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