Load mentionValues asynchronously#36739
Conversation
Move mention autocomplete data (participants, assignees, teams) from being embedded inline in every page's HTML to a dedicated JSON endpoint that is fetched on-demand when the user triggers @ mention autocomplete. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mentionValues asynchronously
There was a problem hiding this comment.
Pull request overview
This pull request improves performance by converting mentionValues from server-side template data to an asynchronous API fetch. This eliminates database queries on every issue/pull request page load, deferring the work until the user actually types @ to trigger mention autocomplete.
Changes:
- Removed server-side
mentionValuesinjection from templates and replaced it with a lazy-loading API endpoint - Updated frontend mention matching to fetch data asynchronously when needed
- Refactored backend helper functions to support the new API endpoint
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
templates/base/head_script.tmpl |
Removed server-side mentionValues injection from global config |
web_src/js/globals.d.ts |
Removed mentionValues from window.config TypeScript definition |
web_src/js/vitest.setup.ts |
Removed test fixture mentionValues data |
web_src/js/utils/match.ts |
Added fetchMentionValues function with caching and made matchMention async |
web_src/js/utils/match.test.ts |
Updated tests to mock GET and handle async matchMention |
web_src/js/features/tribute.ts |
Changed mentionCollection values to async callback using fetchMentionValues |
web_src/js/features/comp/TextExpander.ts |
Wrapped mention handling in async IIFE to await matchMention |
routers/web/web.go |
Registered new GET endpoint /-/mentionvalues |
routers/web/repo/mention.go |
New endpoint handler returning JSON mention data (participants, assignees, teams) |
routers/web/repo/issue.go |
Refactored handleMentionableAssigneesAndTeams to getMentionableTeams helper |
routers/web/repo/issue_page_meta.go |
Simplified to only set Assignees data without calling mention handler |
routers/web/repo/issue_list.go |
Simplified to only set Assignees data without calling mention handler |
routers/web/repo/pull.go |
Simplified to only set Assignees data without calling mention handler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Generally LGTM, it's better to have a better name for the router path and function name. |
|
Yeah I will rename. |
|
I will rename alle |
…ntion.go - Rename MentionValues -> GetMentions and route /mentionvalues -> /mentions - Move getMentionableTeams from issue.go to mention.go - Rename MentionValue type to Mention, fetchMentionValues to fetchMentions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Require at least one markdown-capable unit (Code, Issues, PullRequests, Releases, Wiki) read access to use the mentions autocomplete endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace reqUnitsWithMarkdown (which included TypeCode, making it effectively a no-op) with a new reqUnitCommentWriter that requires read access to at least one unit with markdown editors: Issues, PullRequests, Releases, Wiki, or Projects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Mentions do not work at all in the form for me on main branch, so this is new functionality. |
|
I think i can make it work for: I don't think mentions worked on any of these pages before but we can fix it here I guess. |
|
This comment was written by Claude. Here's a summary of all pages with mention autocomplete and what values they display:
* org teams only shown when the repo owner is an organization |
Add /{username}/-/mentions endpoint that returns org members and teams
for mention autocomplete on org-level project pages. Update the JS to
detect org vs repo context and call the appropriate endpoint.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@lunny try again, it should work on all 18 pages mentioned above. |
Add ok: true to the mocked GET response so the res.ok check in fetchMentions does not reject the response. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Works now. It seems wiki editor needs also to add @ and # icons(unrelated to this PR) |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of having the client parse window.location to construct the mentions API URL, pass it from the server via a data-mentions-url attribute on the combo-markdown-editor element. This addresses review feedback that the framework should provide the URL rather than having the client do URL parsing. - Add MentionsUrl template attribute to combomarkdowneditor.tmpl - Show @/# toolbar buttons only when MentionsUrl is set - All template callers pass MentionsUrl from server context - JS reads mentions URL from data attribute, no more URL parsing - Cache the fetch promise to avoid race conditions - Remove redundant MentionSuggestion type, use Mention directly - Reuse parseIssuePageInfo() instead of inline DOM query Co-Authored-By: Claude claude-opus-4-6 20250627 <noreply@anthropic.com>
|
Everything addressed and table in #36739 (comment) is up to date. All pages were tested. |
* origin/main: Optimize Docker build with dependency layer caching (go-gitea#36864) Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861) Fix CodeQL code scanning alerts (go-gitea#36858) Refactor auth middleware (go-gitea#36848) Update Nix flake (go-gitea#36857) Update JS deps (go-gitea#36850) Load `mentionValues` asynchronously (go-gitea#36739) [skip ci] Updated translations via Crowdin
* main: (26 commits) Clean up `refreshViewedFilesSummary` (go-gitea#36868) Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867) Optimize Docker build with dependency layer caching (go-gitea#36864) Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861) Fix CodeQL code scanning alerts (go-gitea#36858) Refactor auth middleware (go-gitea#36848) Update Nix flake (go-gitea#36857) Update JS deps (go-gitea#36850) Load `mentionValues` asynchronously (go-gitea#36739) [skip ci] Updated translations via Crowdin Fix dbfs error handling (go-gitea#36844) Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797) Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798) Fix non-admins unable to automerge PRs from forks (go-gitea#36833) upgrade to github.com/cloudflare/circl 1.6.3, svgo 4.0.1, markdownlint-cli 0.48.0 (go-gitea#36837) Fix dump release asset bug (go-gitea#36799) build(deps): update material-icon-theme v5.32.0 (go-gitea#36832) Fix bug to check whether user can update pull request branch or rebase branch (go-gitea#36465) Fix forwarded proto handling for public URL detection (go-gitea#36810) Fix artifacts v4 backend upload problems (go-gitea#36805) ... # Conflicts: # pnpm-lock.yaml
* giteaofficial/main: Update minimum go version to 1.26.1, golangci-lint to 2.11.2, fix test style (go-gitea#36876) Add render cache for SVG icons (go-gitea#36863) Fix incorrect viewed files counter if reverted change was viewed (go-gitea#36819) [skip ci] Updated translations via Crowdin Clean up `refreshViewedFilesSummary` (go-gitea#36868) Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867) Optimize Docker build with dependency layer caching (go-gitea#36864) Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861) Fix CodeQL code scanning alerts (go-gitea#36858) Refactor auth middleware (go-gitea#36848) Update Nix flake (go-gitea#36857) Update JS deps (go-gitea#36850) Load `mentionValues` asynchronously (go-gitea#36739) [skip ci] Updated translations via Crowdin Fix dbfs error handling (go-gitea#36844) Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797) Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)


Eliminate a few database queries on all issue and pull request pages by moving mention autocomplete data to async JSON endpoints fetched on-demand when the user types
@.See #36739 (comment) for the full table of affected pages.
🤖 Generated with Claude Code