Conversation
Replace all htmx-driven interactions with lightweight custom JS handlers: - Extend form-fetch-action with `data-swap` attribute for HTML response swapping (star, watch, follow, issue subscribe, notifications) - Add individual init functions for special patterns (admin dashboard polling, workflow dispatch, last commit loader, user cards refresh, editor diff preview, code expander buttons) - Replace HX-Request/HX-Redirect/hx-trigger headers with X-Gitea-Page-Action/X-Gitea-Redirect/X-Gitea-Dispatch-Event - Remove htmx.org and idiomorph packages, all hx-* template attributes, htmx.process() calls, htmx event listeners, and related config Ref: go-gitea#35059 Co-Authored-By: Claude (Opus 4.6) <[email protected]>
|
WIP, currently this was only tested using those e2e tests in the commit. We may evaluate dropping some of these tests later if not valuable, they are primarily there to aid in this migration. |
|
I think we need to manually rewrite some parts. Some AI code really looks like slop and isn't the proper way. Teaching AI to make it right will definitely spend more time than I just rewrite them with a proper design. |
|
Yes, this is only a starting point. Still better than manually starting from scratch imho. I'm not so well-versed around |
The `.form-fetch-action` selector now matches multiple forms on the page since watch/unwatch also uses this class. Use a more specific selector that includes the `.comment` class. Co-Authored-By: Claude (Opus 4.6) <[email protected]>
|
Will take a look when I get some time (if no hurry). Some brief ideas after I proposed #35059
|
|
Note that |
There was a problem hiding this comment.
Pull request overview
This PR removes the htmx dependency and replaces its usage across templates, frontend JS, and backend response headers with custom lightweight fetch/swap handlers and data-global-init initializers.
Changes:
- Remove
htmx/idiomorphpackages, globalwindow.htmxwiring, and allhx-*template usage. - Add/extend custom JS handlers for HTML swapping (
form-fetch-action+data-swap) and page-specific dynamic behaviors (polling, loaders, dispatch inputs, code expanders, editor diff preview, user card refresh). - Replace HTMX-specific request/response headers with
X-Gitea-Page-Action/X-Gitea-Redirect/X-Gitea-Dispatch-Event, and update tests accordingly.
Reviewed changes
Copilot reviewed 36 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| web_src/js/vitest.setup.ts | Removes Happy DOM polyfill that was only needed for htmx evaluation. |
| web_src/js/index.ts | Drops global htmx error listeners and related imports. |
| web_src/js/globals.ts | Removes htmx/idiomorph global setup and config. |
| web_src/js/globals.d.ts | Removes window.htmx type declaration. |
| web_src/js/features/repo-issue-sidebar-combolist.ts | Removes htmx.process() calls after DOM replacements. |
| web_src/js/features/repo-home.ts | Adds data-global-init handler to load last-commit content via POST. |
| web_src/js/features/repo-editor.ts | Adds editor “diff” tab preview via custom POST + innerHTML swap. |
| web_src/js/features/repo-diff.ts | Removes htmx.process() and adds click handler for code-expander-button using data-url. |
| web_src/js/features/repo-actions.ts | Adds workflow-dispatch ref change handler to fetch and swap input HTML. |
| web_src/js/features/notification.ts | Removes htmx.process() after notification DOM replacement. |
| web_src/js/features/common-page.ts | Adds user-cards refresh listener driven by a dispatched DOM event and HTML parsing. |
| web_src/js/features/common-fetch-action.ts | Extends form-fetch-action with data-swap HTML swapping + new headers/redirect/event handling. |
| web_src/js/features/admin/common.ts | Adds admin system status polling init via data-global-init. |
| vite.config.ts | Removes eval: false exception previously required by htmx. |
| types.d.ts | Removes htmx ESM module shim declaration. |
| tests/integration/editor_test.go | Updates selector for upload form to match updated markup. |
| tests/integration/compare_test.go | Updates code expander button attribute assertions from hx-get to data-url. |
| tests/e2e/page-actions.test.ts | Adds Playwright coverage for replaced page-actions and polling/loader behaviors. |
| templates/user/notification/notification_div.tmpl | Switches notification actions to form-fetch-action + data-swap. |
| templates/shared/user/profile_big_avatar.tmpl | Replaces follow/unfollow htmx button with form-fetch-action swap form. |
| templates/repo/watch_unwatch.tmpl | Replaces watch/unwatch htmx boosting/targeting with swap form. |
| templates/repo/view_list.tmpl | Replaces htmx last-commit loader attributes with data-global-init + URL attribute. |
| templates/repo/user_cards.tmpl | Removes htmx-driven auto-refresh wiring; relies on dispatched event + JS refresh. |
| templates/repo/star_unstar.tmpl | Replaces star/unstar htmx boosting/targeting with swap form. |
| templates/repo/issue/view_content/watching.tmpl | Replaces issue subscribe toggle htmx with swap form. |
| templates/repo/editor/edit.tmpl | Removes htmx diff preview attributes; adds data-diff-* used by JS. |
| templates/repo/actions/workflow_dispatch.tmpl | Replaces htmx change-triggered inputs reload with data-global-init handler. |
| templates/repo/actions/workflow_dispatch_inputs.tmpl | Updates comments to reflect new dynamic-loading behavior without htmx. |
| templates/org/follow_unfollow.tmpl | Replaces org follow/unfollow htmx button with swap form. |
| templates/base/head.tmpl | Removes htmx attributes from <body>. |
| templates/admin/dashboard.tmpl | Replaces htmx polling with data-global-init polling. |
| services/gitdiff/gitdiff.go | Replaces hx-get/hx-target button HTML with data-url for expander. |
| services/context/base.go | Replaces HTMX redirect handling with X-Gitea-Page-Action / X-Gitea-Redirect. |
| services/context/base_test.go | Updates redirect test to assert new headers. |
| routers/web/repo/watch.go | Switches response event header from hx-trigger to X-Gitea-Dispatch-Event. |
| routers/web/repo/star.go | Switches response event header from hx-trigger to X-Gitea-Dispatch-Event. |
| package.json | Removes htmx.org and idiomorph dependencies. |
| pnpm-lock.yaml | Removes locked packages for htmx.org and idiomorph. |
| eslint.config.ts | Removes restricted-import rules and global for htmx. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Clear is-loading class from commit message cells when the POST request fails or returns a non-OK status, preventing the file list from being stuck in a permanent loading state. Co-Authored-By: Claude (Opus 4.6) <[email protected]>
Replace all htmx-driven interactions with lightweight custom JS handlers:
form-fetch-actionwithdata-swapattribute for HTML response swapping (star, watch, follow, issue subscribe, notifications)HX-Request/HX-Redirect/hx-triggerheaders withX-Gitea-Page-Action/X-Gitea-Redirect/X-Gitea-Dispatch-Eventhtmx.organdidiomorphpackages, allhx-*template attributes,htmx.process()calls, htmx event listeners, and related configFixes: #35059
This PR was written with the help of Claude Opus 4.6