From 55572eae44a2a503e8fd32ed307d4dc5f3446b31 Mon Sep 17 00:00:00 2001 From: Stratou Date: Fri, 31 Oct 2025 11:29:08 +0100 Subject: [PATCH] [ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402) ## Summary Fixes the suggestions of timeseries (instead of all indices) in TS command after one selected image ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit 3c9fadb499cb1c765d6823d25deaaf530b49ac14) # Conflicts: # src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts --- .../commands/timeseries/autocomplete.test.ts | 7 +++++++ .../commands_registry/commands/timeseries/autocomplete.ts | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts index 59c7eb174acd5..c3b396474cf92 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts @@ -66,6 +66,13 @@ describe('TS Autocomplete', () => { ]); }); + test('can suggest timeseries after one already selected', async () => { + const suggestions = await suggest('TS timeseries_index, '); + const labels = suggestions.map((s) => s.label); + + expect(labels).toEqual(['timeseries_index_with_alias', 'time_series_index']); + }); + test('discriminates between indices and aliases', async () => { const suggestions = await suggest('TS '); const indices: string[] = suggestions diff --git a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts index b329c24cab173..d1c7b446ef3fe 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts @@ -68,10 +68,12 @@ export async function autocomplete( // TS something/ // TS something, / else if (indexes.length) { - const sources = context?.sources ?? []; + const timeSeriesSources = + context?.timeSeriesSources?.map(({ name }) => ({ name, hidden: false })) ?? []; + const additionalSuggestions = await additionalSourcesSuggestions( innerText, - sources, + timeSeriesSources, indexes.map(({ name }) => name), [] );