Skip to content

Fix stacked Ask AI Enter replays and light-mode code contrast - #3055

Merged
yashovardhan merged 4 commits into
mainfrom
fix/ask-ai-enter-poll
Sep 14, 2026
Merged

yashovardhan merged 4 commits into
mainfrom
fix/ask-ai-enter-poll

Conversation

@yashovardhan

@yashovardhan yashovardhan commented Sep 14, 2026

Copy link
Copy Markdown
Member

Summary

  • The Ask AI stale-question guard started a new catch-up poll on every intercepted Enter and never canceled the previous one, so a second Enter before the option caught up could replay submit more than once. Cleanup only removed the keydown listener, so a late interval could still fire after the workaround was torn down. The guard now keeps a single poll, replaces it on a later Enter, and clears it on abandon, catch-up, timeout, and cleanup.
  • Ask AI answers render fenced code as <pre><code class="language-js">, which the site's Prism theme claims with !important and paints in the light gray it uses on the dark code blocks of doc pages. DocSearch backs its code blocks with the modal surface instead, so in light mode that gray landed on near-white (#c8ceda on #f5f5fa, roughly 1.3:1). Ask AI code blocks now take their color from --docsearch-text-color.

Measured after the change: light modal #36395a on #f5f5fa (~9:1), dark modal #e3e3e3 on #36395a. The sidepanel was already covered by existing light and dark overrides and is unchanged.

Test plan

  • Open search, highlight Ask AI while the option still shows a previous query, press Enter twice quickly, and confirm the conversation is submitted once with the typed query.
  • Repeat with a single Enter and confirm catch-up still waits, then submits.
  • Type again or close the modal while a wait is in flight and confirm no stray submit.
  • Navigate away (effect cleanup) while a wait is in flight and confirm no late replay.
  • Ask a question that returns a code block in light mode and confirm the code is legible in both the search modal and the sidepanel.
  • Repeat in dark mode and confirm no regression.

Note

Low Risk
Client-side DocSearch keyboard workaround and scoped CSS override; no auth, API, or data-path changes.

Overview
Fixes double Ask AI submits when Enter is pressed before the highlighted option catches up to the search input. The stale-question guard now keeps at most one catch-up poll: each new Enter clears any in-flight wait, and teardown clears the interval so a replay cannot fire after navigation or after the user already submitted.

Separately, Ask AI markdown code blocks in DocSearch (modal and sidepanel) now use --docsearch-text-color instead of the site Prism theme’s light gray, which was nearly illegible on the light modal surface.

Reviewed by Cursor Bugbot for commit 0d30752. Bugbot is set up for automated code reviews on this repo. Configure here.

A second Enter while waiting used to start another interval, and uninstall left those timers running, so submit could fire more than once or after the listener was gone.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yashovardhan
yashovardhan requested review from a team as code owners September 14, 2026 12:58
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
metamask-docs Ready Ready Preview Sep 14, 2026 2:24pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d118984. Configure here.

Comment thread src/lib/algolia-ask-ai.ts Outdated
DocSearch renders answer code as `<pre><code class="language-js">`, which the site's Prism theme claimed with `!important` and painted in the light gray meant for the dark code blocks on doc pages, leaving it near-invisible on DocSearch's light code background.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yashovardhan yashovardhan changed the title Fix stacked Ask AI Enter replays Fix stacked Ask AI Enter replays and light-mode code contrast Sep 14, 2026
yashovardhan and others added 2 commits September 14, 2026 18:21
The catch-up poll was only replaced when Enter was intercepted again. A later Enter that the guard let through (option already caught up, or no longer highlighted) left that interval running, so a replay could still fire after DocSearch had already handled the question.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yashovardhan
yashovardhan merged commit ebd1b5b into main Sep 14, 2026
19 checks passed
@yashovardhan
yashovardhan deleted the fix/ask-ai-enter-poll branch September 14, 2026 15:01

This branch was successfully deployed

1 active deployment
Preview 0d307528 Deployed Sep 14, 2026 by vercel[bot]
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.

2 participants