59 lines
3.0 KiB
Markdown
59 lines
3.0 KiB
Markdown
# Plan: Browser Update Check on Startup
|
|
|
|
## Overview
|
|
Add a startup version check that queries the release server for the latest browser version. If a newer version exists, show a dialog offering to download it (same UX as agent download). Also add browser routes to the release server (separate Gitea repo).
|
|
|
|
## Part 1: Release Server — Add Browser Routes
|
|
|
|
### New file: `hiveops-release/src/routes/browser.js`
|
|
Mirror `routes/agent.js` but for a separate browser Gitea repo:
|
|
- Env var: `GITEA_BROWSER_REPO` (default: `hiveops-browser`), reuses existing `GITEA_URL`, `GITEA_TOKEN`, `GITEA_OWNER`
|
|
- Asset mapping: `windows` → `.exe`, `linux` → `.AppImage`
|
|
- Endpoints:
|
|
- `GET /browser/latest` — returns `{ version, name, published, platforms }`
|
|
- `GET /browser/download?platform={windows|linux}&version={optional}` — streams binary
|
|
- `GET /browser/versions` — lists all versions
|
|
- Own release cache (separate from agent)
|
|
|
|
### Modify: `hiveops-release/src/index.js`
|
|
- Import and mount `browserRoutes` alongside `agentRoutes`
|
|
|
|
## Part 2: Browser — API Client Methods
|
|
|
|
### Modify: `hiveops-browser/src/main/api-client.js`
|
|
Add three methods:
|
|
- `checkForBrowserUpdate()` — `GET ${releaseUrl}/browser/latest`, compare version to `app.getVersion()`, return `{ updateAvailable, latestVersion, currentVersion }`
|
|
- `downloadBrowser(platform, savePath, onProgress, abortSignal)` — same pattern as `downloadAgent` but hits `/browser/download`
|
|
- `getBrowserFilename(platform)` — HEAD to `/browser/download` for Content-Disposition filename
|
|
|
|
## Part 3: Browser — Startup Check + Download Flow
|
|
|
|
### Modify: `hiveops-browser/src/main/main.js`
|
|
In `checkServicesAndStart()`, after main window is created (~line 197):
|
|
1. Call `apiClient.checkForBrowserUpdate()` (non-blocking, won't delay startup)
|
|
2. If update available, show dialog: "New version v{latest} available. You are running v{current}. Download?"
|
|
- Buttons: **Download** / **Later**
|
|
3. On "Download":
|
|
- Auto-detect platform via `os.platform()` (no picker needed)
|
|
- Get server filename via `getBrowserFilename()`
|
|
- Show save dialog → download with progress window (reuse existing `openDownloadProgress`)
|
|
4. On "Later": dismiss silently
|
|
5. Entire check wrapped in try/catch — failures logged, never block the app
|
|
|
|
## Files Changed
|
|
|
|
| File | Action |
|
|
|------|--------|
|
|
| `hiveops-release/src/routes/browser.js` | **New** |
|
|
| `hiveops-release/src/index.js` | **Modify** — mount browser routes |
|
|
| `hiveops-browser/src/main/api-client.js` | **Modify** — 3 new methods |
|
|
| `hiveops-browser/src/main/main.js` | **Modify** — update check + download flow |
|
|
|
|
## Verification
|
|
1. `GET /browser/latest` returns version info from release server
|
|
2. Browser logs show update check on startup
|
|
3. If newer version exists, update dialog appears after main window loads
|
|
4. "Download" → save dialog with server filename → progress → completion
|
|
5. "Later" → dismissed, app continues
|
|
6. Release server unreachable → app starts normally, error logged silently
|