Refactor htmx and fetch-action related code#37186
Conversation
a82b0cf to
ea41d60
Compare
b7bf493 to
4001304
Compare
There was a problem hiding this comment.
Pull request overview
This PR is an initial refactor step to replace several htmx-driven interactions with the existing fetch-action mechanism plus a lightweight “fetch sync” DOM update path (including optional Idiomorph morphing), preparing for later removal of htmx.
Changes:
- Reworked
common-fetch-actionto support sync HTML responses (data-fetch-sync) and periodic/auto triggers (data-fetch-trigger). - Updated templates to use
data-fetch-*attributes for watch/unwatch, star/unstar, repo file list last-commit lazy loading, and admin system status refresh. - Removed the htmx morph extension wiring and added direct Idiomorph usage/type declarations.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| web_src/js/globals.ts | Stops loading the htmx Idiomorph extension globally. |
| web_src/js/features/common-fetch-action.ts | Core refactor: adds sync DOM update path, triggers, and Idiomorph integration. |
| web_src/css/repo/home-file-list.css | Tweaks loading indicator styling for file list cells. |
| types.d.ts | Adds a local module declaration for idiomorph. |
| templates/repo/watch_unwatch.tmpl | Switches watch/unwatch to link-action + fetch sync update. |
| templates/repo/star_unstar.tmpl | Switches star/unstar to link-action + fetch sync update. |
| templates/repo/view_list.tmpl | Replaces htmx last-commit lazy loading with fetch-trigger + Idiomorph sync. |
| templates/repo/user_cards.tmpl | Replaces htmx refresh trigger with fetch-reload marker for post-sync refresh. |
| templates/projects/view.tmpl | Renames method attribute to data-fetch-action-method. |
| templates/base/head.tmpl | Removes hx-ext="morph" from <body>. |
| templates/admin/system_status.tmpl | Converts system status refresh to periodic fetch trigger + Idiomorph sync. |
| templates/admin/dashboard.tmpl | Removes wrapper htmx refresh container; uses system_status template directly. |
| routers/web/web.go | Changes /lastcommit/* route from POST to GET. |
| routers/web/repo/watch.go | Removes HX-Trigger response header usage. |
| routers/web/repo/star.go | Removes HX-Trigger response header usage. |
| routers/web/repo/view.go | Adjusts debug helper for clearing commit info (now only clears half). |
| eslint.config.ts | Removes restricted-import entry for idiomorph/htmx since it’s no longer globally loaded. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4001304 to
3b4bcba
Compare
3b4bcba to
3957550
Compare
3957550 to
d20e2d3
Compare
d20e2d3 to
6e62cf8
Compare
6e62cf8 to
1adeebb
Compare
1adeebb to
b85bc2d
Compare
1c3a37a to
070c065
Compare
070c065 to
563d17f
Compare
|
Should probably add some E2E tests for the high-value mechanisms affected here. If you like I can have a look at that. |
There will be more changes. E2E is too early. It can be added after the htmx removal. |
silverwind
left a comment
There was a problem hiding this comment.
Big change surface. I hope it was all tested. Next PR should include some E2E tests to solidify no chances for regressions.
| resp.WriteHeader(http.StatusBadRequest) | ||
| return | ||
| } | ||
| resp.Header().Add("Location", redirect) |
There was a problem hiding this comment.
codeql flagged here with https://github.com/go-gitea/gitea/security/code-scanning/192, false positive?
There was a problem hiding this comment.
False positive.
Actually we have a real security problem to fix in "external render helper".
-> Add test for "fetch redirect", add CSS value validation for external render #37207
* main: Add comment for the design of "user activity time" (go-gitea#37195) fix(api): handle missing base branch in PR commits API (go-gitea#37193) Refactor htmx and fetch-action related code (go-gitea#37186) Fix encoding for Matrix Webhooks (go-gitea#37190) Always show owner/repo name in compare page dropdowns (go-gitea#37172) fix(api): handle fork-only commits in compare API (go-gitea#37185) Improve Contributing docs and set a release schedule (go-gitea#37109) Update Nix flake (go-gitea#37183) Remove outdated RunUser logic (go-gitea#37180) Refactor flash message and remove SanitizeHTML template func (go-gitea#37179) Indicate form field readonly via background (go-gitea#37175) Remove dead CSS rules (go-gitea#37173) Fix flaky `TestCatFileBatch/QueryTerminated` test (go-gitea#37159) Implement logout redirection for reverse proxy auth setups (go-gitea#36085) Add missing `//nolint:depguard` (go-gitea#37162)




This is the first step (the hardest part). I have tested:
The legacy "data-redirect" attribute is removed, it only makes the page reload (sometimes using an incorrect link).
Also did cleanup for some devtest pages.
Next PR will completely remove htmx without introducing so many JS code changes.