Skip to content

Opt-in update banner, off by default - #202

Merged
BaaRai merged 1 commit into
mainfrom
feat/update-banner-opt-in
Nov 12, 2026
Merged

BaaRai merged 1 commit into
mainfrom
feat/update-banner-opt-in

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 12, 2026

Copy link
Copy Markdown
Owner

What

An opt-in update banner, off by default.

  • Opt-in setting: environment variable ARTEX_UPDATE_CHECK (follows the existing ARTEX_* env-flag pattern, e.g. ARTEX_RSI_LESSONS, ARTEX_UNTRUSTED_BOUNDARY). Accepted on-values: 1, true, on, yes. Default: unset = off.
  • Off (default): the backend never calls GitHub; GET /api/health has no latest_version field; the UI renders no banner.
  • On: on an authenticated GET /api/health, the backend asks https://api.github.com/repos/BaaRai/ARTEX/releases/latest for tag_name, at most once per 24 h (in-memory cache: timestamp + tag). A failed check (network error, non-200 such as a rate limit, bad JSON) also stamps the time, shows nothing, and is not retried in that window. The request carries only User-Agent: artex-update-check and Accept: application/vnd.github+json: no cookies, no user or host identifiers.
  • Comparison: uses the existing build version (main.version injected from the git tag by build.sh via ldflags, handed to server.BuildVersion). Leading major.minor.patch is compared (2.2.0-3-gabc-dirty reads as 2.2.0); a non-numeric version such as dev never shows a banner.
  • Banner: a small strip above the top bar in the main layout, linking to https://github.com/BaaRai/ARTEX/releases, with a dismiss button. No modal, no popup, no focus trap. Dismissal is remembered for that version in localStorage via the existing try/catch helpers in web/src/lib/local-storage.client.ts.

Files

  • server/update_check.go: opt-in flag, 24 h cache/decision logic, GitHub fetch, version compare.
  • server/update_check_test.go: unit tests for the decision logic (injected fetch and clock).
  • server/server.go: health adds latest_version only when the check is on and a newer release exists.
  • web/src/lib/api.ts, web/src/app/(main)/_components/main-content.tsx: optional field + banner.
  • .env.example, docker-compose.yml, README.md: document and pass through the flag.

Verification

  • go test ./server/ (full package) passes; new tests: off = no fetch and no banner; on = one fetch within 24 h, a second after 24 h; failure = nothing shown and no retry within 24 h; version comparison table.
  • go vet ./server/, go build ./..., gofmt clean.
  • web/: npx tsc --noEmit and npm run build pass.

Not verified

  • The real GitHub API call was not exercised against the network.
  • The banner was not checked in a running browser.
  • The cache is per process, so a backend restart allows one more check inside the 24 h window.

ARTEX_UPDATE_CHECK=1 lets the backend check the public GitHub releases API
for the latest tag at most once per 24 h (in-memory cache; failures are not
retried in the window) and report it in GET /api/health when it is newer
than the build version. The web UI shows a dismissible strip linking to the
Releases page. Unset (the default), no update request is made.
@BaaRai
BaaRai merged commit 6109917 into main Nov 12, 2026
4 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.

1 participant