feat(jobs): surface background jobs with progress, logs and controls

Add a central job registry that library scans and search index builds
report into, so background work is visible instead of buried in the
settings page.

- backend/jobs: registry with per-job ring-buffer logs, capability-driven
  controls, and one coalesced JobsChanged snapshot at 4Hz
- pause survives restart via a job_state table; a paused scan is adopted
  back on launch and skipped by the soft scan
- top-bar indicator, popover, details drawer and a Jobs page replacing
  the config page's scan UI; per-library start/stop retained
- scan timing breakdown moves into the job log, Full rescan to the Jobs
  page; delete the orphaned library-manager component

Also add cmd/indexbuild and cmd/indexexport so the explore index can be
built once centrally rather than by every install, which today streams
~205GB from the ListenBrainz spark dump on first run. indexbuild picks
build/refresh/rebuild from index state; the Gitea workflow runs it on
push, weekly, or manually and publishes only when content changed.

fresh-install no longer defaults YJ_HOME under /tmp: it is tmpfs on most
distros, and the import needs ~6GB of real disk.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 14:42:22 -04:00
co-authored by Claude Opus 5
parent aead8eaef4
commit 01bc5f2094
48 changed files with 6656 additions and 2271 deletions
+24 -6
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/user"
"path/filepath"
"runtime"
)
@@ -22,14 +23,15 @@ const (
dirTypeData dirType = "data"
)
// envHomeOverride is the environment variable that, when set, relocates
// all YellowJacket config and data under a single base directory. It
// exists so a development build can run against an isolated sandbox
// without touching the current user's real config.toml or yj.db.
const envHomeOverride = "YJ_HOME"
// getUserDirPath returns and creates the path for a user directory.
func getUserDirPath(dt dirType) (string, error) {
currentUser, err := user.Current()
if err != nil {
return "", fmt.Errorf("could not get current user: %w", err)
}
path, err := buildUserDirPath(currentUser.Username, dt)
path, err := resolveUserDirPath(dt)
if err != nil {
return "", err
}
@@ -50,6 +52,22 @@ func getUserDirPath(dt dirType) (string, error) {
return path, nil
}
// resolveUserDirPath picks the base path for a user directory. When
// YJ_HOME is set it wins for every OS, mapping to <YJ_HOME>/<dirType>;
// otherwise the standard OS-specific location is used.
func resolveUserDirPath(dt dirType) (string, error) {
if home := os.Getenv(envHomeOverride); home != "" {
return filepath.Join(home, string(dt)), nil
}
currentUser, err := user.Current()
if err != nil {
return "", fmt.Errorf("could not get current user: %w", err)
}
return buildUserDirPath(currentUser.Username, dt)
}
// buildUserDirPath constructs the OS-specific path for a user directory.
func buildUserDirPath(username string, dt dirType) (string, error) {
// Map directory types to their Unix subdirectory paths