Skip to content

fix(imagegen): show diffusers version info and fix upgrade flow - #197

Merged
apapi merged 1 commit into
mainfrom
fix-Diffuser-upgrade-button
Sep 24, 2026
Merged

apapi merged 1 commit into
mainfrom
fix-Diffuser-upgrade-button

Conversation

@apapi

@apapi apapi commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

Closes #196

The Diffuser upgrade feature had several issues:

  1. No version info in UI — The upgrade UI did not show the current installed version or the latest available version, so users could not tell whether an upgrade was needed.
  2. Button state incorrect after upgrade — After a successful upgrade, the button stayed enabled and version info was stale.
  3. Upgrade did not actually work — Version constraints in package specs (e.g. diffusers>=0.34.0) caused --upgrade to consider the installed version as already satisfying the constraint, so no newer version was pulled.
  4. State lost on page refresh — Navigating away and back did not re-query the actual installed version, so the UI showed stale info.

Fix

Backend (internal/imagegen/runtime.go)

  • New StatusWithVersions() method enriches Status() with:
    • installedPackageVersion() — probes venv Python via importlib.metadata.version()
    • latestPyPIPackageVersion() — parses the configured mirror PEP 503 simple index page, falls back to pypi.org JSON API
  • New stripVersionSpecs() — removes version constraints before --upgrade so the latest version is installed
  • InstallWithProgressOptions returns StatusWithVersions after upgrade so the frontend gets updated version info immediately

Backend handler (internal/server/handlers_images.go)

  • GET /api/image-runtime uses StatusWithVersions

Frontend (web/src/pages/Settings.tsx, web/src/api/client.ts)

  • Fetch runtime status on page mount to get current and latest versions
  • After upgrade, re-fetch actual installed version and compare to determine success
  • Button states: disabled while upgrading / "Already upgraded" when versions match or just upgraded / "Upgrade Diffuser" when newer version available
  • Version display: current version + latest version (latest only shown when different)
  • getImageRuntimeStatus uses cache: "no-store" to prevent stale responses

API docs (openapi/local-api.json)

  • RuntimeStatus schema: added diffusers_version and diffusers_latest_version fields

i18n (web/src/i18n.ts)

  • Added zh/en keys: current version, latest version, already upgraded, already at latest

Files changed

File Change
internal/imagegen/runtime.go Version query, constraint stripping, StatusWithVersions
internal/server/handlers_images.go GET handler uses StatusWithVersions
openapi/local-api.json Schema: two new fields
internal/server/static/openapi/local-api.json Synced
web/src/api/client.ts Type fields + cache no-store
web/src/i18n.ts zh/en i18n keys
web/src/pages/Settings.tsx Version display, button states, post-upgrade re-fetch

Verification

  • gofmt / go build / go vet / go test ./internal/server/ — all pass
  • tsc --noEmit / vite build — pass
  • Manual test: downgraded to 0.39.0, UI shows current 0.39.0 / latest 0.40.0, click upgrade, success, button disabled showing "Already upgraded", version updated to 0.40.0, navigate away and back, state correct

Problem: The Diffuser upgrade UI did not display the current installed
version or the latest available version. After upgrading, the button
stayed enabled and version info was stale because the frontend never
re-fetched the runtime status. Additionally, version constraints in
package specs (e.g. "diffusers>=0.34.0") prevented --upgrade from
actually picking up a newer release, so the upgrade silently did
nothing.

Changes:
- Add DiffusersVersion and DiffusersLatestVersion fields to
  RuntimeStatus, populated by a new StatusWithVersions method.
- installedPackageVersion: probe the venv Python for the installed
  diffusers version via importlib.metadata.
- latestPyPIPackageVersion: query the configured mirror PEP 503 simple
  index page, or fall back to pypi.org JSON API, to find the latest
  version available from the installer actual package source.
- stripVersionSpecs: strip version constraints from package specs
  before --upgrade so the latest version is installed.
- InstallWithProgressOptions now returns StatusWithVersions so the
  frontend receives updated version info immediately after upgrade.
- GET /api/image-runtime handler uses StatusWithVersions.
- Frontend: fetch runtime status on page mount, show current/latest
  version, disable button and show Already upgraded when versions
  match, re-fetch status after upgrade to reflect the real installed
  version.
- Add cache no-store to getImageRuntimeStatus to prevent stale
  responses.
- Sync openapi/local-api.json schema with new response fields.
- Add i18n keys for version labels and upgrade status messages.
@apapi
apapi merged commit 168f9d7 into main Sep 24, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diffuser点完升级成功后,刷新页面还能接着点升级,已经完成升级了这个按钮能不能置灰

1 participant