Skip to content

Commit 69a89aa

Browse files
authored
fix: Restore Lucene autocomplete (#2902)
## Summary This PR restores lucene auto-complete across the app, which was broken in #2643 for inputs other than the search page WHERE input. The problem was that in #2643 sourceId became the source of truth for where auto complete suggestions should be queried from, instead of the given tableConnection. However sourceId was not always provided, so when it wasn't no suggestions were queried. The fix has two parts: 1. Provide source id (and date range) at all call sites 2. Where source id is not enough to identify a single table (eg. metrics sources), fallback to the table connection A better solution in the future would be to make source id required in these input components, but that is a larger refactor saved for a later day. ### Screenshots or video ### How to test on Vercel preview Test lucene Auto-complete across the app ### References - Linear Issue: Closes HDX-5101 - Related PRs:
1 parent 018a648 commit 69a89aa

30 files changed

Lines changed: 944 additions & 35 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
fix: Restore Lucene autocomplete

‎packages/app/eslint.config.mjs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ export default [
255255
'@typescript-eslint/no-explicit-any': 'off',
256256
'@next/next/no-html-link-for-pages': 'off',
257257
'playwright/no-networkidle': 'off', // temporary until we have a better way to deal with react re-renders
258+
// Shared helpers that assert on our behalf, so a test calling only these
259+
// still counts as having assertions.
260+
'playwright/expect-expect': [
261+
'warn',
262+
{
263+
assertFunctionNames: [
264+
'expectFieldSuggestion',
265+
'expectValueSuggestion',
266+
],
267+
},
268+
],
258269
// Drop date rules — Date.now() is fine in e2e tests for unique IDs/timestamps
259270
'no-restricted-syntax': ['error', ...UI_SYNTAX_RESTRICTIONS],
260271
// e2e tests live outside src/, so no @/ alias reaches sibling test files

‎packages/app/src/DBDashboardPage.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import {
2323
import { ErrorBoundary } from 'react-error-boundary';
2424
import RGL from 'react-grid-layout';
2525
import { useForm, useWatch } from 'react-hook-form';
26-
import { TableConnection } from '@hyperdx/common-utils/dist/core/metadata';
26+
import {
27+
TableConnection,
28+
tcFromSource,
29+
} from '@hyperdx/common-utils/dist/core/metadata';
2730
import {
2831
convertToDashboardTemplate,
2932
displayTypeSupportsBuilderAlerts,
@@ -1767,9 +1770,8 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
17671770
const tableName = getMetricTableName(source, metricType);
17681771
if (!tableName) continue;
17691772
tc.push({
1770-
databaseName: source.from.databaseName,
1771-
tableName: tableName,
1772-
connectionId: source.connection,
1773+
...tcFromSource(source),
1774+
tableName,
17731775
});
17741776
}
17751777

@@ -2947,6 +2949,7 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
29472949
>
29482950
<SearchWhereInput
29492951
tableConnections={tableConnections}
2952+
dateRange={searchedTimeRange}
29502953
control={control}
29512954
name="where"
29522955
onSubmit={onSubmit}

‎packages/app/src/DashboardFiltersModal.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ const DashboardFilterEditForm = ({
363363
>
364364
<SearchWhereInput
365365
tableConnection={tableConnection}
366+
sourceId={sourceId}
366367
control={control}
367368
name="where"
368369
languageName="whereLanguage"

‎packages/app/src/ServicesDashboardPage/ServicesDashboardPage.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ function ServicesDashboardPage() {
357357
/>
358358
<SearchWhereInput
359359
tableConnection={tcFromSource(source)}
360+
sourceId={sourceId}
361+
dateRange={searchedTimeRange}
360362
control={control}
361363
name="where"
362364
onSubmit={onSubmit}

‎packages/app/src/SessionSubpanel.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ export default function SessionSubpanel({
360360
] as DateRange['dateRange'];
361361
}, [playerStartTs, playerEndTs]);
362362

363+
// The window the events query itself uses, so autocomplete discovers the
364+
// same fields and values the event list can actually match on.
365+
const eventsDateRange = useMemo(
366+
() => [start, end] as DateRange['dateRange'],
367+
[start, end],
368+
);
369+
363370
const { getFieldExpression: getSessionSourceFieldExpression } =
364371
useFieldExpressionGenerator(sessionSource);
365372

@@ -451,6 +458,8 @@ export default function SessionSubpanel({
451458
>
452459
<SearchWhereInput
453460
tableConnection={tcFromSource(traceSource)}
461+
sourceId={traceSource.id}
462+
dateRange={eventsDateRange}
454463
control={control}
455464
name="where"
456465
size="xs"

‎packages/app/src/SessionsPage.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ function SessionsPage() {
450450
/>
451451
<SearchWhereInput
452452
tableConnection={tcFromSource(traceTrace)}
453+
// The WHERE runs against the trace source
454+
sourceId={traceTrace?.id}
455+
dateRange={searchedTimeRange}
453456
control={control}
454457
name="where"
455458
onSubmit={onSubmit}

‎packages/app/src/components/ContextSidePanel.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ export default function ContextSubpanel({
232232
{contextBy === ContextBy.Custom && (
233233
<SearchWhereInput
234234
tableConnection={tcFromSource(source)}
235+
sourceId={source.id}
236+
dateRange={newDateRange}
235237
control={control}
236238
name="where"
237239
enableHotkey

‎packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export function ChartEditorControls({
171171
control={control}
172172
setValue={setValue}
173173
tableSource={tableSource}
174+
dateRange={dateRange}
174175
onSubmit={onSubmit}
175176
onOpenDisplaySettings={openHeatmapSettings}
176177
/>
@@ -199,6 +200,8 @@ export function ChartEditorControls({
199200
)}
200201
<SearchWhereInput
201202
tableConnection={tableConnection}
203+
sourceId={tableSource?.id}
204+
dateRange={dateRange}
202205
control={control}
203206
name="where"
204207
onSubmit={onSubmit}
@@ -430,6 +433,8 @@ export function ChartEditorControls({
430433
/>
431434
<SearchWhereInput
432435
tableConnection={tableConnection}
436+
sourceId={tableSource?.id}
437+
dateRange={dateRange}
433438
control={control}
434439
name="where"
435440
onSubmit={onSubmit}

‎packages/app/src/components/DBEditTimeChartForm/ChartSeriesEditor.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type ChartSeriesEditorProps = {
8989
export function ChartSeriesEditor({
9090
control,
9191
databaseName,
92+
dateRange,
9293
connectionId,
9394
index,
9495
namePrefix,
@@ -430,11 +431,14 @@ export function ChartSeriesEditor({
430431
>
431432
<SearchWhereInput
432433
tableConnection={tableConnection}
434+
sourceId={tableSource?.id}
435+
dateRange={dateRange}
433436
control={control}
434437
name={`${namePrefix}aggCondition`}
435438
onSubmit={onSubmit}
436439
showLabel={false}
437440
additionalSuggestions={attributeSuggestions}
441+
data-testid="series-where-input"
438442
/>
439443
</div>
440444
</>

0 commit comments

Comments
 (0)