Skip to content

fix(search): Prevent Ask AI from doubling pasted query text#116050

Merged
isaacwang-sentry merged 1 commit into
masterfrom
isaacwang/aiml-2875-fix-ask-ai-paste-duplication
May 26, 2026
Merged

fix(search): Prevent Ask AI from doubling pasted query text#116050
isaacwang-sentry merged 1 commit into
masterfrom
isaacwang/aiml-2875-fix-ask-ai-paste-duplication

Conversation

@isaacwang-sentry
Copy link
Copy Markdown
Member

@isaacwang-sentry isaacwang-sentry commented May 21, 2026

Summary

  • Fixes a bug where pasting text into the search bar and clicking "Ask AI" would double the query text (e.g. "show me errors" → "show me errors show me errors")
  • Root cause: when the entire query is free text, the initialSeerQuery builder filters it out, falls back to the unfiltered query, then appends inputValue again
  • Adds !inputValue guard to the fallback branch in 4 strategy wrappers (Logs, Spans, Metrics, Discover Issues), matching the fix already present in issueList/issueListSeerComboBox.tsx

Fixes AIML-2875

Test plan

  • Existing askSeerComboBox.spec.tsx tests pass
  • Lint passes on all changed files
  • Manual: paste a natural language query into Logs/Spans/Metrics search bar → click Ask AI → query text should appear once, not doubled
  • Manual: existing filter + pasted free text (e.g. browser.name:Firefox + paste "show me errors") → Ask AI shows browser.name:Firefox show me errors

When the entire search query is free text (e.g. pasted natural language),
the initialSeerQuery builder would fall back to the unfiltered query after
filtering removed all tokens, then also append the inputValue — producing
the query text twice.

Add a !inputValue guard to the fallback branch so it only fires when no
free-text filtering occurred, matching the fix already present in
issueList/issueListSeerComboBox.tsx.

Fixes AIML-2875
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@isaacwang-sentry isaacwang-sentry requested review from a team as code owners May 21, 2026 20:23
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 21, 2026

AIML-2875

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.62%

@isaacwang-sentry
Copy link
Copy Markdown
Member Author

Screen.Recording.2026-05-21.at.1.30.48.PM.mov

Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! 🥔

The existing code looks like something that's ripe for a post-release cleanup (lots of duplication, not so many tests) but ACK that that's not something introduced in this PR.

} else if (queryDetails?.queryToUse) {
} else if (!inputValue && queryDetails?.queryToUse) {
initialSeerQuery = queryDetails.queryToUse;
}
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.

matching the fix already present in issueList/issueListSeerComboBox.tsx

[Refactor] [Testing] So this area of code is duplicated in now 5 separate components, none of which have attached unit tests in this PR? IMO this level of duplication is not good for product health/quality. Looking through the views/explore/*/*TabSeerComboBox.tsx components, there's a heck of a lot of nearly-identical code.

I don't want to block a small fix to this existing code, but I'd strongly recommend deduplicating these 5 components as a followup.

@isaacwang-sentry isaacwang-sentry merged commit 54dfe15 into master May 26, 2026
74 checks passed
@isaacwang-sentry isaacwang-sentry deleted the isaacwang/aiml-2875-fix-ask-ai-paste-duplication branch May 26, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants