fix: dismiss composer mention popovers - #156
Merged
Merged
Conversation
kalvinnchau
previously approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Category: fix
User Impact: Users can dismiss mention suggestions with Escape or by clicking elsewhere, then continue writing without the suggestions reopening for the same reference.
Problem: Mention suggestions could remain in the way when text such as a Datadog query contained
@, with no reliable way to leave the suggestion mode. Closing the menu also needed to avoid immediately reopening it as the user continued typing the same token.Solution: Let the shared popover primitive own Escape and outside-click dismissal, while mention state remembers the dismissed token until the user starts a genuinely new reference or draft. The behavior is applied consistently to both composer surfaces and covered by interaction and state-lifecycle tests.
File changes
src/features/chat/hooks/useMentionHandlers.ts
Passes the current draft into mention detection and exposes the explicit dismissal action to composer surfaces.
src/features/chat/ui/ChatInput.tsx
Uses the controlled Popover dismissal lifecycle for outside clicks and routes Escape through the same mention dismissal behavior.
src/features/chat/ui/MentionAutocomplete.tsx
Removes document-level pointer and Escape handling so this component only renders and manages suggestion presentation.
src/features/chat/ui/mentionDetection.ts
Tracks intentionally dismissed mention tokens, keeps them dismissed during continued typing, and resets suppression for replacement tokens or externally changed drafts.
src/shared/ui/GlobalComposerPill.tsx
Applies the same Popover-owned dismissal behavior to the global composer.
src/features/chat/ui/tests/ChatInput.test.tsx
Covers composer-click dismissal, continued typing after Escape, and opening suggestions in a new draft.
src/features/chat/ui/tests/MentionAutocomplete.test.tsx
Removes interaction tests for behavior that is no longer owned by the presentation component.
src/features/chat/ui/tests/mentionDetection.test.ts
Covers same-token suppression, replacement tokens, and the distinction between dismissal and normal closure.