-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Live removal of issue comments using htmx websocket #28958
base: main
Are you sure you want to change the base?
Conversation
I will wait with further development until #28880 has a final decision for now. Just wanted to do this POC to see and show the team if it could be used for the discussed realtime topics as well. |
Wouldn't we say htmx will be used on simple situation? I think this page is very complex. |
I agree with lunny, this is more complex than I imagined but hey, if it works that's awesome. Do we really have 2 way communication here though? Maybe SSE fits better for this use case |
This comment was marked as resolved.
This comment was marked as resolved.
We need a Websocket in any case as SSE is too limiting:
|
Is it fine to hook into |
I think it should be. You need to implemente a new notifier like notification. |
Maybe a notification icon or notification list is a better start to introduce the WebSocket. |
To be honest, I agree with it. And share my thoughts here:
|
Regarding this problem, I found a good project. I don’t know if it will help us achieve it. |
the websocket extension not found |
Imho we should just nuke all the EventSource/SSE code. It's messy, broken and I don't think it ever worked correctly. I'd also appreciate if we had a simple way to test server-sent messages on the devtest pages.
GitHub has the complexity that their WebSocket is in SharedWorker, maybe that is a source of bugs. I don't recommend for the first implementation to use SharedWorker. It seems like a half-baked browser API. |
As explained before I would suggest small steps & PRs here. Adjusting the notification area or the bell icon would require touching frontend code that is not really related to a functional websocket update system.
I don't think it is a problem. Both parts do not conflict and actually it could be pretty smart to test and stabilize the websocket first with UI parts that wont break the exisitng UX for the beginning. Worst case some hiccup would currently not update the UI and the user would not even notice it.
@wxiaoguang I've updated the issue description to explain the concept / idea again. Seems like it wasn't clear enough. Adding it for several events (issue comment added, PR description updates etc) takes time, but in general I can't seem why this could not be done. Main task would be to align templates so that you can easily render parts of them. For example to update an issue comment it would be required to be able to render only one comment. I had the comment updating / adding working already, mainly removed it again to keep changes low and focus on the concept.
@hiifong Updated the link.
That would be the next step / PR I would suggest. |
I guess I can make a PR to nuke EventSource. I don't usually like PRs that only remove functionality, but we have to take this step by step and now is a good time to do it given that the 1.24 release is a while off. |
I would suggest to only use one approach to avoid unnecessary technical debt. At least, eventsource + websocket uses one more connection to the server, which consumes more resources. You could take a look at my PRs: https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3Awxiaoguang+is%3Aclosed , many of them are "fix this", "fix that", "refactor xxxx". I have spent too much time on legacy unmaintained code. That's why I strongly prefer to improve the whole code quality and improve maintainability.
That's the real challenge: how to correctly "align", there are too many details (UI component init, markdown math render, PR conversation layout, etc), it is somewhat possible, but I do not think we have that manpower, and it makes it much difficult (or blocks) to improve/refactor the issue page in the future: every small change needs to keep the WS module working correctly. In other words, "Return on Investment (ROI)" is poor. Overall I think introducing websocket is good, while I think these problems could be addressed/commented at the moment:
What do you think? Oh, one more thing: should we really use htmx websocket? Does it have limits? Will it fully satisfy our requirements in the future? It seems that it is difficult to make htmx call our JS code properly. My intuition tells me that Gitea is too large and complex, maybe it needs its own websocket frontend module (handler). |
First step into "realtime" updating UI using htmx with ws extension as discussed in bigskysoftware/htmx#2287 and #25661
Concept
By using htmx we use a websocket to send dom elements matched by #id to clients to update specific parts of the UI.
Some examples where this could be used
Note
As rendering comments was changing a few templates I started implementing the concept for live updates
for removing a comment for now to focus on the websocket logic. Other updating logic will be straightforward to add > in followup PRs.
How it works in detail:
/-/ws
dom.load
:{ action: "subscrib", data: { url: "http://localhost:3000/anbraten/test/issues/1"}}
to the server to let it know it is interested in updates relevant for this pageScreencast.from.2024-02-16.17-50-20.webm
Using a pub/sub system the notifier events are also sent to other servers which forward them again to all relevant & locally connected clients:
TODO
websocket logic based on #26679 and #27806