fix: make update banner dynamic instead of static at startup#1725
fix: make update banner dynamic instead of static at startup#1725
Conversation
The update check was only evaluated once at server startup and injected as static values into the HTML template. Long-running servers would never show the update banner even if new versions were released. Now the template functions read from the cache store on every page load, and a periodic background goroutine refreshes the cache every 24 hours.
📝 WalkthroughWalkthroughThe changes refactor update info retrieval from direct fields to an interface-based pattern. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Server as Server
participant Scheduler as Periodic Scheduler
participant Checker as updateChecker
participant Store as upgradeStore (Cache)
participant Template as Template Functions
Note over Server,Template: Server Startup
Server->>Checker: create updateChecker{store: upgradeStore}
Server->>Server: startPeriodicUpdateCheck(ctx)
Note over Scheduler,Store: Initial Check + Scheduling
Server->>Checker: GetUpdateInfo()
Checker->>Store: read cache
Store-->>Checker: cached values
Checker-->>Server: (updateAvailable, latestVersion)
Server->>Store: update cache (initial check)
Server->>Scheduler: schedule periodic checks at CacheTTL
Note over Scheduler,Template: Periodic Update Flow
loop Every CacheTTL
Scheduler->>Checker: GetUpdateInfo()
Checker->>Store: read current cache
Store-->>Checker: cached values
Checker-->>Scheduler: (updateAvailable, latestVersion)
Scheduler->>Store: update cache with latest
end
Note over Template,Store: Template Rendering
Template->>Checker: GetUpdateInfo()
Checker->>Store: read cache
Store-->>Checker: cached values
Checker-->>Template: (updateAvailable, latestVersion)
Template-->>Template: render with update info
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/service/frontend/server.go`:
- Around line 858-859: The call to upgrade.CheckAndUpdateCache currently
discards its returned error (e.g., "_, _ =
upgrade.CheckAndUpdateCache(srv.upgradeStore, config.Version)") so periodic
update-check failures are hidden; change both places where CheckAndUpdateCache
is called to capture the error return, and if non-nil log it (using the server
logger, e.g., srv.logger or appropriate logger in scope) with a clear message
including context (service name/upgradeStore/config.Version) so persistent
failures are visible.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6fdcddfd-225c-48ec-b8de-e5a6f767bf3d
📒 Files selected for processing (2)
internal/service/frontend/server.gointernal/service/frontend/templates.go
|
For airgapped systems, should it be made configurable (default value: true) to switch it off permanently. |
|
Yes, let's add it in backlog. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1725 +/- ##
==========================================
- Coverage 69.57% 69.54% -0.03%
==========================================
Files 398 398
Lines 43877 43877
==========================================
- Hits 30528 30516 -12
- Misses 10891 10911 +20
+ Partials 2458 2450 -8 see 13 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
The update check was only evaluated once at server startup and injected as static values into the HTML template. Long-running servers would never show the update banner even if new versions were released.
Now the template functions read from the cache store on every page load, and a periodic background goroutine refreshes the cache every 24 hours.
Summary by CodeRabbit