Skip to content

Mentions in comments (@User) no longer highlighted #33518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KazzmanK opened this issue Feb 6, 2025 · 8 comments · Fixed by #33554
Closed

Mentions in comments (@User) no longer highlighted #33518

KazzmanK opened this issue Feb 6, 2025 · 8 comments · Fixed by #33554
Assignees
Labels
topic/ui Change the appearance of the Gitea UI type/bug
Milestone

Comments

@KazzmanK
Copy link
Contributor

KazzmanK commented Feb 6, 2025

Description

Previously, mentioned user was rendered as user name and link, now it is not. May be something related to mentions also broken

Screenshots

Image

Image

Gitea Version

1.23.1

Can you reproduce the bug on the Gitea demo site?

No

Operating System

No response

Browser Version

130

@KazzmanK KazzmanK added topic/ui Change the appearance of the Gitea UI type/bug labels Feb 6, 2025
@aceArt-GmbH
Copy link
Contributor

aceArt-GmbH commented Feb 10, 2025

Same on Version: 1.23.3. Worked without problem in 1.22
Some users still work, others not. I do not see a pattern yet

Even mentioning users that are not autocompleted sometimes work

UPDATE:
changing "User visibility" from private or limited to public fixes the problem.
This still seems like a regression?
Changelog does not not mention anything related

@wxiaoguang
Copy link
Contributor

UPDATE:
changing "User visibility" from private or limited to public fixes the problem.
This still seems like a regression?
Changelog does not not mention anything related

Thank you very much, it seems to be a root reason. Maybe related to some refactoring changes. Will try to take a look.

@wxiaoguang wxiaoguang self-assigned this Feb 11, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 11, 2025

I just tried 1.22, the users with "User visibility: Private" can't be highlighted when rendering. It is an old behavior from " Link mentioned user in markdown only if they are visible to viewer #21554 " (since 1.18). So this behavior is not a regression.

Do you have more clues about what's broken?

Update: outdated, I think I know the problem now.

Image

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Feb 11, 2025
@wxiaoguang
Copy link
Contributor

I think I can understand the problem now.

#21554 uses ctx.(*gitea_context.Context) to try to get the web context, it's not right in many cases.

-> Fix context usage #33554

@aceArt-GmbH
Copy link
Contributor

@wxiaoguang thanks for taking a look and fixing 💟
I think this does only affect highlighting and not mentions, but a backport would still be awesome.

Not leaking hidden users is fine, but at least the users that are shown in the autocomplete popup should also be linked (as their presents is already leaked) 😉

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 11, 2025

Yes, it will be backported to 1.23 (I have marked #33554 as "backport/1.23")

Actually it is a regression in 1.23, the full story is like this:

  • #21554 uses direct type-casting (ctx.(*gitea_context.Context)) to get the web context.
  • at that time, it worked, because the ctx was the web context.
  • in 1.23, we refactored the markup rendering system (fixed a lot of legacy problems), and started using a general ctx (not a direct web context anymore)
  • then, the general ctx can't be read by ctx.(*gitea_context.Context) anymore, then #21554 's logic breaks
  • even there are tests, it's unable to catch such an edge case.

It tells us that we need to follow framework's design to write code (again) 😆

wxiaoguang added a commit that referenced this issue Feb 11, 2025
Some old code use direct type-casting to get context, it causes
problems.

This PR fixes all legacy problems and use correct `ctx.Value` to get
low-level contexts.

Fix #33518
@wxiaoguang
Copy link
Contributor

The backport (Fix context usage (#33554) (#33557)) for 1.23 is ready in 1.23 nightly

@aceArt-GmbH
Copy link
Contributor

Works. thanks 💓

@lunny lunny added this to the 1.23.4 milestone Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants