Skip to content

universal ai banner for search#3161

Merged
abeglova merged 1 commit intomainfrom
ab/universal-ai-banner
Apr 6, 2026
Merged

universal ai banner for search#3161
abeglova merged 1 commit intomainfrom
ab/universal-ai-banner

Conversation

@abeglova
Copy link
Copy Markdown
Contributor

@abeglova abeglova commented Apr 3, 2026

What are the relevant tickets?

closes https://github.com/mitodl/hq/issues/10802

Description (What does it do?)

The pr adds a banner that links to the UAI program on the search page. The banner should be shown when

  1. there is no search term 2) the search term is one of the terms in the issue

There is a feature flag for the banner

Screenshots (if appropriate):

  • Desktop screenshots
Screenshot 2026-04-03 at 9 45 29 PM
  • Mobile width screenshots
Screenshot 2026-04-03 at 9 45 45 PM

How can this be tested?

Go to search and ensure it works normally

Create a feature flag called "universal-ai-search-banner" in posthog and turn the feature on
When there is no search term you should see the banner
When the search term is one of the terms in the ticket you should see the banner
When there is any other search term you should not see a banner

@abeglova abeglova marked this pull request as ready for review April 4, 2026 01:52
Copilot AI review requested due to automatic review settings April 4, 2026 01:52
@abeglova abeglova changed the title Ab/universal ai banner universal ai banner for search Apr 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Universal AI promotional banner to the search results page, gated behind a PostHog feature flag and displayed only for blank queries or specific AI-related search terms (per HQ issue #10802).

Changes:

  • Introduces UniversalAIBanner with term-matching logic and a CTA linking to the UAI program page.
  • Renders the banner within SearchDisplay and adds a new FeatureFlags.UniversalAISearchBanner enum value.
  • Adds SearchPage test coverage for banner visibility based on feature flag + query term.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
frontends/main/src/page-components/SearchDisplay/UniversalAIBanner.tsx New banner component with search-term matching + feature flag gating + CTA link
frontends/main/src/page-components/SearchDisplay/SearchDisplay.tsx Mounts the banner in the search results UI
frontends/main/src/common/feature_flags.ts Adds universal-ai-search-banner flag identifier
frontends/main/src/app-pages/SearchPage/SearchPage.test.tsx Adds tests verifying banner show/hide behavior

Comment on lines +7 to +9
const BANNER_SEARCH_TERMS_PATTERN =
/^(universal ai|ai|ai basics|ai intro|ai introduction|ai fundamentals|ai foundations|artificial intelligence|machine learning|data analytics|deep learning|prescriptive ai|predictive ai|multimodal ai|large language models|large language model|llms|llm|generative ai|gen ai|ai ethics|optimization|python|computer vision|ai framework|ai models|ai agents|agentic ai|ai and sustainability|ai and health|ai and healthcare|ai and medicine|ai and entrepreneurship)$/i

Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

BANNER_SEARCH_TERMS_PATTERN is a very large, hard-to-maintain regex for an exact-match term list. Since you're effectively doing case-insensitive membership in a fixed list, consider storing the allowed terms in a normalized array/Set (e.g., term.trim().toLowerCase()) and checking set.has(...) instead of a single monolithic regex; it will be easier to update and review safely.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +55
const BannerLink = styled.a(({ theme }) => ({
color: theme.custom.colors.silverGrayDark,
fontWeight: theme.typography.fontWeightMedium,
fontSize: "12px",
whiteSpace: "nowrap",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

BannerLink is an internal navigation link (to a /programs/... route) but it uses a plain <a> element. In this codebase, internal links generally use next/link to avoid full page reloads and enable prefetching; consider switching BannerLink to be styled(Link) (or otherwise wrap with Next.js Link).

Copilot uses AI. Check for mistakes.
required.
</BannerDescription>
</BannerContent>
<BannerLink href={ctaHref}>Learn More</BannerLink>
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The CTA text "Learn More" is generic, which makes link lists ambiguous for screen-reader users. Consider making the accessible name specific (e.g., "Learn more about Universal AI"), either by changing the visible text or adding an aria-label that includes the program name.

Suggested change
<BannerLink href={ctaHref}>Learn More</BannerLink>
<BannerLink
href={ctaHref}
aria-label="Learn more about Universal AI"
>
Learn More
</BannerLink>

Copilot uses AI. Check for mistakes.
"&:hover": {
backgroundColor: theme.custom.colors.lightGray1,
fontWeight: theme.typography.fontWeightBold,
},
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

BannerLink adds hover styling but no visible keyboard focus styling. For accessibility, add an &:focus-visible style (outline/background/etc.) consistent with other interactive elements in this area so keyboard users can see focus.

Suggested change
},
},
"&:focus-visible": {
backgroundColor: theme.custom.colors.lightGray1,
fontWeight: theme.typography.fontWeightBold,
outline: `2px solid ${theme.custom.colors.red}`,
outlineOffset: "2px",
},

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

@abeglova abeglova Apr 6, 2026

Choose a reason for hiding this comment

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

switching from <a> to <Link> fixes this automatically

@shanbady shanbady self-assigned this Apr 6, 2026
Copy link
Copy Markdown
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

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

works as expected so approving 👍

I had two thoughts/questions:

  1. maybe on the next iteration/if we will be tweaking this - is it possible to move the keyword array and the copy+link text into posthog as a payload?
  2. double check if this makes sense but i'm wondering if we are trying to match on any mention of the word "ai" or it is this specific list (otherwise i think we can condernse this list tremendously)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

OpenAPI Changes

No detectable change.

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@abeglova abeglova force-pushed the ab/universal-ai-banner branch from eb281c5 to f351342 Compare April 6, 2026 15:04
@abeglova abeglova merged commit 68d6b92 into main Apr 6, 2026
14 checks passed
@abeglova abeglova deleted the ab/universal-ai-banner branch April 6, 2026 15:10
This was referenced Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants