Files
skillshare/internal/server/handler_version.go
T
Willie a2f958d288 feat(ui): background mode, in-place upgrade, and PWA support
Three user-visible additions to the web dashboard, plus the CLI surface
needed to drive them.

* `skillshare ui start` / `skillshare ui stop` — run the dashboard as a
  managed background process. Re-running start reuses the existing
  healthy process; stop uses the remembered host/port. Foreground
  `skillshare ui` keeps working unchanged. Process tracking lives in
  ui_process_{unix,windows,other}.go via a PID + current-state file.
* `--app` — opens the dashboard in a Chromium app-mode window (Chrome,
  Edge, Brave) on macOS, Windows, and Linux for a separate Dock/taskbar
  entry without browser chrome.
* In-place upgrade from the browser — the Update dialog and the Doctor
  page's Version card now expose an Update now button. Backed by two
  new endpoints (POST /api/upgrade, POST /api/restart in
  handler_restart_upgrade.go); the browser polls GET /api/health and
  reloads once the new server is ready. Dev builds short-circuit with
  `devMode: true` and a simulated restart so the flow can be exercised
  without rebuilding the binary.
* Progressive Web App — site.webmanifest, app icons (192/512), and a
  minimal service worker registered from main.tsx. Supporting browsers
  can install the dashboard as a standalone desktop app.
* Doctor Version card redesign — state-coloured icon (blue when an
  update is available, green when up to date), explicit
  `current → latest` delta, Update button only when there is something
  to upgrade.
* i18n — translate "DEV mode" in zh-TW / zh-CN / ko (previously left
  as raw English).

Adds CHANGELOG.md and website changelog entries for v0.19.20 and
refreshes website/docs/reference/commands/ui.md to document the new
modes, --app flag, new REST endpoints, and the in-place upgrade flow.
2026-05-24 01:21:06 +08:00

64 lines
1.8 KiB
Go

package server
import (
"net/http"
"skillshare/internal/config"
versioncheck "skillshare/internal/version"
)
func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
// Snapshot config under RLock, then release before I/O.
s.mu.RLock()
source := s.cfg.EffectiveSkillsSource()
projectRoot := s.projectRoot
s.mu.RUnlock()
isProjectMode := projectRoot != ""
cliVersion := versioncheck.Version
cliUpdateAvailable := false
var cliLatest *string
cliDevMode := cliVersion == "" || cliVersion == "dev"
// Dev builds expose a simulated update so the browser update/restart flow can be tested.
if cliDevMode {
latest := "dev-ui-flow"
cliUpdateAvailable = true
cliLatest = &latest
} else if result := versioncheck.Check(cliVersion, versioncheck.InstallDirect); result != nil {
// CLI version check (uses 24h cache)
cliUpdateAvailable = result.UpdateAvailable
cliLatest = &result.LatestVersion
}
// Skill version (local) — always check global source for built-in skill
skillSourceDir := source
if isProjectMode {
if globalCfg, err := config.Load(); err == nil {
skillSourceDir = globalCfg.Source
}
}
skillVersion := versioncheck.ReadLocalSkillVersion(skillSourceDir)
// Skill version (remote) — network call with 3s timeout
var skillLatest *string
skillUpdateAvailable := false
if skillVersion != "" {
if remote := versioncheck.FetchRemoteSkillVersion(); remote != "" {
skillLatest = &remote
skillUpdateAvailable = remote != skillVersion
}
}
writeJSON(w, map[string]any{
"cliVersion": cliVersion,
"cliLatest": cliLatest,
"cliUpdateAvailable": cliUpdateAvailable,
"cliDevMode": cliDevMode,
"skillVersion": skillVersion,
"skillLatest": skillLatest,
"skillUpdateAvailable": skillUpdateAvailable,
})
}