Skip to content

Refactor htmx and fetch-action related code#37186

Open
wxiaoguang wants to merge 1 commit intogo-gitea:mainfrom
wxiaoguang:refactor-htmx
Open

Refactor htmx and fetch-action related code#37186
wxiaoguang wants to merge 1 commit intogo-gitea:mainfrom
wxiaoguang:refactor-htmx

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang commented Apr 12, 2026

This is the first step (the hardest part). I have tested:

  • repo file list last commit message lazy load
  • admin server status monitor
  • watch/unwatch (normal page, watchers page)
  • star/unstar (normal page, watchers page)
  • project view, delete column
  • workflow dispatch, switch the branch
  • commit page: load branches and tags referencing this commit

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.

@wxiaoguang
Copy link
Copy Markdown
Contributor Author

wxiaoguang commented Apr 12, 2026

Repo file list lazy load

image

Workflow dispatch

image image

Commit page

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 12, 2026
@github-actions github-actions bot added topic/code-linting modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Apr 12, 2026
@wxiaoguang wxiaoguang mentioned this pull request Apr 12, 2026
@wxiaoguang wxiaoguang force-pushed the refactor-htmx branch 3 times, most recently from b7bf493 to 4001304 Compare April 12, 2026 09:20
@wxiaoguang wxiaoguang requested a review from Copilot April 12, 2026 09:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-action to 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.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

@wxiaoguang wxiaoguang added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Apr 12, 2026

This comment was marked as outdated.

@wxiaoguang wxiaoguang force-pushed the refactor-htmx branch 9 times, most recently from 1c3a37a to 070c065 Compare April 13, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files topic/code-linting type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants