fix(text-editor): re-run the mention search when fulltext indexing advances - #11012
Closed
clayrisser wants to merge 1 commit into
Closed
fix(text-editor): re-run the mention search when fulltext indexing advances#11012clayrisser wants to merge 1 commit into
clayrisser wants to merge 1 commit into
Conversation
MentionPopup issues exactly one searchFor('mention', query) per keystroke
and never retries. Fulltext indexing is asynchronous, so a document
created seconds earlier is routinely absent from that one result and the
popup sits on "No results" until the user retypes the query.
The server already broadcasts TxWorkspaceEvent/WorkspaceEvent.IndexingUpdate
when the index advances, and the client already delivers it to tx
listeners; ActionsPopup uses precisely this to refresh its own fulltext
results. MentionPopup now registers the same listener for the lifetime of
the popup.
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Clay Risser <clayrisser@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
clayrisser
force-pushed
the
fix/mention-popup-reruns-on-indexing-update
branch
from
August 13, 2026 06:47
0284da8 to
fc7911b
Compare
Author
|
Closing — this was opened by an automated agent without my intent. Apologies for the noise. |
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.
Problem
MentionPopup.svelteissues its fulltext query exactly once per query change and never retries:// plugins/text-editor-resources/src/components/MentionPopup.svelte:213,225 const updateItems = reduceCalls(async function (localQuery: string): Promise<void> { … }) $: void updateItems(query)Fulltext indexing is asynchronous. A document created seconds earlier is routinely absent from that one result, and when it is, the popup sits on "No results" until the user changes the query — deleting a character and retyping it is the usual workaround, if the user knows to try it.
So typing
@and the name of a channel, issue or document you just created shows you nothing, and keeps showing you nothing, even after the index has caught up and the server has said so.The client is already told when the index advances. The server broadcasts
TxWorkspaceEventwithWorkspaceEvent.IndexingUpdate, and the client already delivers it to tx listeners.ActionsPopupsubscribes to exactly this to refresh its own fulltext results (plugins/view-resources/src/components/ActionsPopup.svelte:265-272):MentionPopupdoes not. That is the whole difference.Fix
Register the same listener for the lifetime of the popup, using the same
addTxListener/removeTxListenerpair from@hcengineering/presentation(packages/presentation/src/utils.ts:85,96) thatActionsPopupuses:// The fulltext index is written asynchronously, so a document created moments ago // is routinely missing from the first 'mention' search. Re-run the query when the // server broadcasts that indexing advanced, the same way ActionsPopup does. function txListener (txes: Tx[]): void { if ( txes.some( (it) => it._class === core.class.TxWorkspaceEvent && (it as TxWorkspaceEvent).event === WorkspaceEvent.IndexingUpdate ) ) { void updateItems(query) } } onMount(() => { addTxListener(txListener) return () => { removeTxListener(txListener) } })The predicate is copied from
ActionsPopupdeliberately, so the two popups agree about what "indexing advanced" means and a future change to that event shape shows up in both places at once.Scope and residual risk
updateItemsis already wrapped inreduceCalls, so a burst of indexing events collapses rather than issuing a query per event.Verification
Verified against
develop@1be6047c8:MentionPopup.svelte:225is still a bare$: void updateItems(query)with no tx listener, theActionsPopupprecedent is still at:265-272, and bothaddTxListenerandremoveTxListenerare still exported from@hcengineering/presentation.git applyis clean.No automated test is offered.
plugins/text-editor-resourceshas no jest project, and the behaviour is a race between the fulltext pod and a Svelte component. Manual check: create a channel or document, immediately type@plus its name into a message box, and watch the popup populate when indexing catches up instead of staying on "No results".Related
The end-to-end symptom of this also shows up in the sanity suite.
tests/sanity'ssendMentionhas a three-attempt retry that is currently unreachable for an unrelated reason, so this indexing delay turns into a hard failure there rather than a retried one. I have opened that separately as a test-only change; the two are independent and can land in either order.Provenance
Found while chasing an intermittent chat-backlinks failure on a self-hosted deployment: the mention popup would show "No results" for a document that existed and was searchable a moment later. The indexing-delay mechanism above is read from the code and matched against the
ActionsPopupprecedent; the timing window varies with index load and I have not characterised it beyond "seconds".