Skip to content

feat: add periodic auto-refresh for per-user custom apps repos - #877

Merged
tavdog merged 1 commit into
tronbyt:mainfrom
stefanvanburen:custom-apps-auto-refresh
Aug 12, 2026
Merged

feat: add periodic auto-refresh for per-user custom apps repos#877
tavdog merged 1 commit into
tronbyt:mainfrom
stefanvanburen:custom-apps-auto-refresh

Conversation

@stefanvanburen

@stefanvanburen stefanvanburen commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

System apps get a scheduled 12h background refresh (SYSTEM_APPS_AUTO_REFRESH), but per-user custom apps repos were only pulled when first saved or via the manual "Refresh" button on Settings -> Content. Add the same ticker pattern, gated behind a new CUSTOM_APPS_AUTO_REFRESH env var (default false), that iterates over every user with a configured repo and re-pulls it.

Fixes #876.

Summary by CodeRabbit

  • New Features

    • Added an optional setting to automatically refresh configured custom app repositories every 12 hours.
    • Automatic refreshing is disabled by default and can be enabled through configuration.
  • Documentation

    • Documented the new automatic refresh configuration option.

System apps get a scheduled 12h background refresh
(SYSTEM_APPS_AUTO_REFRESH), but per-user custom apps repos were only
pulled when first saved or via the manual "Refresh" button on
Settings -> Content. Add the same ticker pattern, gated behind a new
CUSTOM_APPS_AUTO_REFRESH env var (default false), that iterates over
every user with a configured repo and re-pulls it.

Fixes tronbyt#876
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds the CUSTOM_APPS_AUTO_REFRESH setting and starts a 12-hour background refresh for configured custom-app repositories when enabled.

Changes

Custom Apps Refresh

Layer / File(s) Summary
Refresh configuration
internal/config/config.go, README.md
Adds Settings.CustomAppsAutoRefresh, mapped to CUSTOM_APPS_AUTO_REFRESH, and documents its default value and 12-hour behavior.
Scheduled repository refresh
internal/server/server.go, internal/server/handlers_user.go
Starts the background refresh during server initialization. The scheduler checks the setting, queries users with configured repositories, refreshes each repository, and logs individual failures without stopping the remaining refreshes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NewServer
  participant autoRefreshCustomAppsRepos
  participant refreshAllCustomAppsRepos
  participant Users
  NewServer->>autoRefreshCustomAppsRepos: start background refresh
  autoRefreshCustomAppsRepos->>autoRefreshCustomAppsRepos: wait for 12-hour ticker
  autoRefreshCustomAppsRepos->>refreshAllCustomAppsRepos: refresh configured repositories
  refreshAllCustomAppsRepos->>Users: query users with repository URLs
  refreshAllCustomAppsRepos->>refreshAllCustomAppsRepos: refresh each repository independently
Loading

Suggested reviewers: tavdog

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the addition of periodic auto-refresh for per-user custom app repositories.
Linked Issues check ✅ Passed The changes implement the linked issue's periodic 12-hour background refresh for configured per-user custom app repositories.
Out of Scope Changes check ✅ Passed The changes remain within scope by adding the configuration, scheduler, server startup, and documentation required for auto-refresh.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
internal/server/handlers_user.go (1)

282-299: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add focused coverage for scheduler outcomes.

If internal/server/handlers_user_test.go does not already cover these functions, add tests for the disabled gate, the database-list failure, and continuation after one EnsureRepo failure. Test refreshAllCustomAppsRepos directly so tests do not wait 12 hours.

Also applies to: 304-317

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/server/handlers_user.go` around lines 282 - 299, Add focused tests
in handlers_user_test.go for the scheduler and refresh flow: verify
autoRefreshCustomAppsRepos exits when CustomAppsAutoRefresh is disabled,
refreshAllCustomAppsRepos handles database-list failure, and continues
processing after one EnsureRepo failure. Invoke refreshAllCustomAppsRepos
directly rather than waiting on the 12-hour ticker, and reuse existing test
fixtures or mocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/server/handlers_user.go`:
- Around line 311-315: Introduce a shared per-repository-path lock and use it
around the EnsureRepo call in the scheduled refresh loop and the os.RemoveAll
path in handleSetUserRepo. Ensure both flows derive the same appsPath key and
serialize mutations for that path while allowing unrelated repositories to
proceed concurrently.
- Around line 311-315: Bound each scheduled repository refresh in the loop
around EnsureRepo with a finite timeout or cancellation mechanism, ensuring both
clone and fetch work for a user cannot stall subsequent users; update the
relevant EnsureRepo invocation and preserve the existing error logging and
per-user iteration.

---

Nitpick comments:
In `@internal/server/handlers_user.go`:
- Around line 282-299: Add focused tests in handlers_user_test.go for the
scheduler and refresh flow: verify autoRefreshCustomAppsRepos exits when
CustomAppsAutoRefresh is disabled, refreshAllCustomAppsRepos handles
database-list failure, and continues processing after one EnsureRepo failure.
Invoke refreshAllCustomAppsRepos directly rather than waiting on the 12-hour
ticker, and reuse existing test fixtures or mocks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 21b067ee-d91e-478e-b060-084196f2b600

📥 Commits

Reviewing files that changed from the base of the PR and between d9ec3a1 and fab437f.

📒 Files selected for processing (4)
  • README.md
  • internal/config/config.go
  • internal/server/handlers_user.go
  • internal/server/server.go

Comment thread internal/server/handlers_user.go
@tavdog
tavdog merged commit 29d53f1 into tronbyt:main Aug 12, 2026
7 checks passed
@stefanvanburen
stefanvanburen deleted the custom-apps-auto-refresh branch August 12, 2026 23:42
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-refresh (or API-triggerable refresh) for per-user custom apps repos

2 participants