Skip to content

Auto-update installed themes and plugins at startup - #689

Merged
compscidr merged 2 commits into
mainfrom
compscidr/auto-update-installed-themes-and-plugins
Oct 17, 2026
Merged

compscidr merged 2 commits into
mainfrom
compscidr/auto-update-installed-themes-and-plugins

Conversation

@compscidr

Copy link
Copy Markdown
Collaborator

Closes #641.

What

  • Compatibility fix (the blocker): UpdateAvailable in both installers now also requires Compatible(running, min_goblog_version). The admin page no longer offers updates that Update() would refuse.
  • AutoUpdate(ctx) on the theme and plugin installers: for each installed item with a compatible update, call Update, log the result. A failure leaves that item as it was and doesn't stop the others.
  • Startup hook in goblog.go: runs in a goroutine (10 min timeout), so an unreachable directory can't block or wedge startup.
  • Settings (Directories tab): auto_update_themes (default on), auto_update_plugins (default off).

Decisions from the issue

  1. Default: themes on, plugins opt-in, as the issue suggested. A theme can still lock an admin out after an upgrade (Restart the login when a callback carries no state at all #640), so themes are on. A plugin runs code, so it waits for an explicit opt-in.
  2. When: startup only. I left out the periodic check; it's easy to add on a ticker later if long-running sites need it.
  3. Failure handling: new tests cover it. A theme update whose templates don't parse leaves the installed theme untouched, and an incompatible release is neither offered nor tried. Plugin Update already rolls back.
  4. Visibility: log lines (Theme auto-update: Updated X to vY, or the failure and the version kept). I left out the note on the admin page; it would need state persisted across restarts.

Test plan

  • go test ./...
  • New TestAutoUpdate in theme/installer and plugin/installer

🤖 Generated with Claude Code

UpdateAvailable now requires the directory release to be compatible with
the running goblog, so the admin page stops offering updates Update()
would refuse with ErrIncompatible.

Both installers gain AutoUpdate(ctx), which applies every compatible
update and logs each result. goblog runs it once at startup in the
background: themes by default (auto_update_themes), plugins only when
auto_update_plugins is turned on.

Closes #641

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 09:29
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
plugin/installer/installer.go 66.66% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes startup to auto-apply updates (including executing downloaded plugin code) and enables theme auto-update by default for all existing installs, a broad operational blast radius that warrants final human review.

No open issues 🎉

What changed in this PR

This PR implements auto-updating of installed directory themes and plugins at startup, closing #641 (which arose from the #640 upgrade trap where an outdated theme could lock an admin out after a goblog upgrade). It builds on the existing Update(ctx, name) machinery in both installers, adding a compatibility gate so only runnable updates are offered/attempted, a non-blocking background runner, and user-facing settings to control the behavior.

Changes:

  • Makes UpdateAvailable in both the theme and plugin installers also require Compatible(running, min_goblog_version), so the admin UI no longer offers updates Update() would refuse with ErrIncompatible.
  • Adds AutoUpdate(ctx) to both installers (per-item, failure-isolated, logged) and a startup hook in goblog.go that runs it in a background goroutine with a 10-minute timeout.
  • Adds auto_update_themes (default on) and auto_update_plugins (default off) settings, surfaced on the Directories settings tab and documented in the README, with tests covering compatible/incompatible/parse-failure cases.
File Description
theme/​installer/​installer.go Adds compatibility check to UpdateAvailable; adds AutoUpdate that updates compatible themes and logs/skips failures.
theme/​installer/​installer_test.go Adds TestAutoUpdate covering compatible apply, incompatible skip, and parse-failure rollback.
plugin/​installer/​installer.go Adds compatibility check to UpdateAvailable; adds AutoUpdate gated on WasmEnabled with rollback-on-failure semantics.
plugin/​installer/​installer_test.go Adds TestAutoUpdate verifying incompatible updates are not offered/applied and a compatible one updates the registry.
goblog.go Adds background goroutine (10-min timeout) invoking theme/plugin AutoUpdate based on the new settings; adds context/time imports.
admin/​settings.go Adds the two auto-update settings to the Directories group with help text.
admin/​settings_test.go Updates expected seeded settings to include the two new checkbox settings.
tools/​migrate.go Seeds auto_update_themes=true and auto_update_plugins=false default settings.
README.md Documents the startup auto-update behavior and how to disable it.

Review effort: Balanced

#685 added "goblog/theme" imports to three test files after #687 renamed
the module, so main's admin and blog tests no longer compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@compscidr
compscidr merged commit a617327 into main Oct 17, 2026
5 checks passed
@compscidr
compscidr deleted the compscidr/auto-update-installed-themes-and-plugins branch October 17, 2026 09:45
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.

Auto-update installed themes and plugins

2 participants