Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/osv-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
contents: read
security-events: write
actions: read
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@b1d267aea5211fa648d9d442fa64b90dbdcbdd36" # v2.7.0
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@32d3cd482bdadfb38b186c0ad1b031902d55d932" # v2.7.1
with:
scan-args: |-
-r
Expand All @@ -65,7 +65,7 @@ jobs:
contents: read
security-events: write
actions: read
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@b1d267aea5211fa648d9d442fa64b90dbdcbdd36" # v2.7.0
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@32d3cd482bdadfb38b186c0ad1b031902d55d932" # v2.7.1
with:
scan-args: |-
-r
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
with:
results_file: results.sarif
results_format: sarif
Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Condensed release history, newest first.

## Unreleased

Nothing yet.

---

## 2026-11-28 — v1.2.1: backups without tokens, one play per song, room for your own GPU work

Fixes found in the two weeks after 1.2.0, on the owner's NAS and PC:

**Curatarr steps aside for training and tagging runs, not only for games.** A PyTorch run is
`python.exe`, and `python.exe` counted as a system process: the card check never saw it. A training
run that drew 82-92 % of the card with under 1 GB of VRAM also slipped past the full-card gate (memory
Expand Down Expand Up @@ -35,9 +43,16 @@ other self-hosted apps, the backup holds what cannot be rebuilt: the database.
discovery follow a redirect only on the app's own scheme, host and port (one NAS, an app per port).
SoulSync's logo shows again: its icon link carries a `?v=` query, which the address check refused.

**From the bots:** the setup wizard moves focus to the new step's heading, the arr discovery checks
each redirect hop, and the Wrap-Up's comebacks find a title's last earlier play through the title
indexes.
**From the bots:** the setup wizard moves focus to the new step's heading and keeps it when a
connect button is redrawn; tab rows have one Tab stop and move with the arrow keys; the arr
discovery checks each redirect hop; the Wrap-Up's comebacks and discoveries find a title's earlier
plays through the title indexes (a play exactly a year before still counts as a comeback). The
nightly backup also drops the Jellyfin webhook secret, and a media-server switch's restore point,
which keeps every token, stays 0600 whatever `BACKUP_GROUP_READABLE` says.

**A test that broke with the calendar.** The milestone announcement window read the real clock
while its test used a fixed date, so every CI run turned red from 2026-11-22. The window takes the
same clock as the rest now; the app's behaviour is unchanged.

---

Expand Down
2 changes: 1 addition & 1 deletion deploy/truenas/catalog/SUBMITTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the issue, the fork and the pull request carry his account.

1. **A release.** The catalog pins a fixed image tag: publish one
(`docs/RELEASING.md`), then set it in `ix_values.yaml` (`images.image.tag`)
and in `app.yaml` (`app_version`). Both say `1.2.0`, the newest release.
and in `app.yaml` (`app_version`). Both say `1.2.1`, the newest release.
2. **Icon and screenshots.** The catalog hosts them on the TrueNAS CDN: attach
`assets/brand/curatarr-app-icon.png` and three screenshots from
`docs/screenshots/desktop/` to the pull request; the reviewer uploads them
Expand Down
2 changes: 1 addition & 1 deletion deploy/truenas/catalog/curatarr/app.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
annotations:
min_scale_version: 24.10.2.2
app_version: 1.2.0
app_version: 1.2.1
capabilities: []
categories:
- media
Expand Down
2 changes: 1 addition & 1 deletion deploy/truenas/catalog/curatarr/ix_values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
images:
image:
repository: ghcr.io/randomname653/curatarr
tag: "1.2.0"
tag: "1.2.1"
container_utils_image:
repository: ghcr.io/truenas/containers/container-utils
tag: "1.1.2@sha256:6ddfdc314af9d18cfacb836ad266ef0ed91fecaa3686b20be72e464972860c08"
Expand Down
3 changes: 2 additions & 1 deletion frontend/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { submitSetupCode, setupCodeKey, useOllama, hideOnboarding, onSetupCurato
import { activityTabKey, cancelTask, loadScheduled, loadTaskHistory, reloadPage, runScheduledJob, setHistoryFilter, showActivityTab, showNoopRuns, toggleHideNoop } from './activity.js';
import { checkMappingCoverage, closeKbDrilldown, kbDismissFinding, kbFixMatch, kbIgnore, kbRetry, kbUnignore, loadCacheInventory, loadEnrichStatus, loadKbAttention, loadKbItems, loadMappingStats, loadProfiles, runMaintenance, showKbTab, startBackfill, startSprint, stopBackfill, stopSprint } from './kb.js';
import { checkOrphans, loadLibraryConfig, saveLibraries, searchOnEnter } from './libraries.js';
import { _errMsg, activeDialog, closeMenus, syncTabRoles, closeModal, toggleMenu, keyActivate, hideOnError, onPageLoad, posterLoaded, toast, trapFocus } from './ui.js';
import { _errMsg, activeDialog, closeMenus, syncTabRoles, tabRowKey, closeModal, toggleMenu, keyActivate, hideOnError, onPageLoad, posterLoaded, toast, trapFocus } from './ui.js';
import { condensePrinciples, downscaleDone, liftProtection, loadDownscale, loadJudgeProtections, loadPrinciples, loadRedundancy, loadUpgrades, setPrinciple, shutdownServer, curationSection, checkUncensored } from './curation.js';
import { answerFollowup, askTonight, correctChatAnchor, explainFollowup, hideMoment, hideTonight, momentPlaylist, titleKeep, titleWatchlist, tonightNext, tonightWatchlist, deleteFromDiscussion, discussLastPlayed, exitDiscussion, fillPrompt, handleKey, hideFollowup, jumpLatest, newChat, onApplyOrphanRepair, onDiscussDeletion, onDiscussRec, saveComment, sendMessage, useStarter } from './chat.js';
import { discussPrinciple, loadUnreadMessages, respondToMessage, skipMessage, toggleMsgPanel } from './notifications.js';
Expand Down Expand Up @@ -103,6 +103,7 @@ window.addEventListener('storage', ev => {
});
document.addEventListener('keydown', ev => {
if (ev.key === 'Tab') { trapFocus(ev, activeDialog()); return; }
tabRowKey(ev);
if (ev.key !== 'Escape') return;
const menu = document.querySelector('.menu.open');
if (menu) { // innermost layer first; focus back on its button
Expand Down
3 changes: 3 additions & 0 deletions frontend/js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function jellyfinConnectAgain() {
state.setupData.jellyfin_ticket = '';
state.setupData.jellyfin_connected = null;
renderSetupStep(state.setupStep);
document.getElementById('s-jellyfin-url')?.focus(); // the button that was pressed is gone
}

// A radio change redraws the whole step; focus would fall to <body> and the
Expand Down Expand Up @@ -181,6 +182,7 @@ export async function startPlexConnect(btn) {
state.setupData._plex_code = r.code;
state.setupData._plex_login = {id: r.login_id, nonce: r.nonce};
renderSetupStep(state.setupStep);
document.getElementById('plex-connect-btn')?.focus(); // the redraw replaced the pressed button
const until = Date.now() + (r.expires_in || 900) * 1000;
stopPlexConnect();
_plexPoll = setInterval(async () => {
Expand Down Expand Up @@ -220,6 +222,7 @@ export function plexConnectAgain() {
Object.assign(state.setupData, {plex_ticket: '', plex_servers: null, plex_server_id: '',
plex_account: '', _plex_code: null, _plex_login: null});
renderSetupStep(state.setupStep);
document.getElementById('plex-connect-btn')?.focus(); // the link that was pressed is gone
}

export function pickPlexServer(el) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/js/swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ export function swipeCategory(cat) {
function _renderTabs() {
const el = _el('swipe-tabs');
if (!el) return;
const had = el.contains(document.activeElement); // the redraw would drop a keyboard user's focus
el.innerHTML = _cats().map(([c, label]) =>
`<button class="cat-tab${c === _cat ? ' active' : ''}" role="tab" aria-selected="${c === _cat}" ${act('swipeCategory', c)}>${esc(label)}</button>`).join('');
if (had) el.querySelector('.cat-tab.active')?.focus();
}

function _renderReactions() {
Expand Down
21 changes: 21 additions & 0 deletions frontend/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,30 @@ export function syncTabRoles(root = document) {
tab.setAttribute('role', 'tab');
tab.setAttribute('aria-selected', String(tab.classList.contains('active')));
}
// One Tab stop per row, on the chosen tab; the arrows move along it.
const tabs = [...list.querySelectorAll(':scope > [role="tab"]')];
const stop = tabs.find(x => x.classList.contains('active')) || tabs.find(x => !x.hidden);
for (const tab of tabs) tab.tabIndex = tab === stop ? 0 : -1;
}
}

// Arrow keys, Home and End move focus along a tab row (WAI-ARIA tabs,
// manual activation: Enter or Space picks the tab, as the button already
// does). Activity's own row has its handler and is left to it.
export function tabRowKey(ev) {
const keys = ['ArrowRight', 'ArrowLeft', 'Home', 'End'];
if (!keys.includes(ev.key) || ev.altKey || ev.ctrlKey || ev.metaKey) return;
const list = ev.target.closest?.('.cat-tabs, .arr-tabs');
if (!list || list.classList.contains('act-tabs') || ev.target.parentElement !== list) return;
const tabs = [...list.querySelectorAll(':scope > [role="tab"]')].filter(x => !x.hidden);
const i = tabs.indexOf(ev.target);
if (i < 0) return;
const j = ev.key === 'Home' ? 0 : ev.key === 'End' ? tabs.length - 1
: (i + (ev.key === 'ArrowRight' ? 1 : -1) + tabs.length) % tabs.length;
ev.preventDefault();
tabs[j].focus();
}

// skeletonHtml(label, {kind, n}) — the shape of what is loading, shimmering
// like a poster that has not arrived: 'cards' (recommendations, deletions),
// 'rows' (lists), 'tiles' (Wrap-Up). The label stays for screen readers and
Expand Down
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Settings(BaseSettings):
# Beta: feature-complete enough to run a household, not
# stable enough to promise anything. One declaration only —
# the file headers deliberately carry no version.
VERSION: str = "1.2.0"
VERSION: str = "1.2.1"
# HOST is the BIND address only (0.0.0.0 = serve the LAN, intentional for
# the multi-user household). It is NOT a navigable origin — browser-facing
# defaults (PLEX_REDIRECT_URI, CORS_ORIGINS) stay localhost-based and must
Expand Down
9 changes: 6 additions & 3 deletions src/database/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ def backup_modes() -> tuple:

def _secure_db_files() -> None:
"""Ensure SQLite files in data/ and .env are 0600; backups follow
backup_modes() (POSIX only)."""
backup_modes() (POSIX only) - except a media-server switch's restore
point (backups/rebind-*/), a full copy with the tokens, which stays 0600."""
import os
import stat
import logging as _logging
Expand All @@ -761,8 +762,10 @@ def _secure_db_files() -> None:
for ext in ("*.db", "*.sqlite3", "*.sqlite3-wal", "*.sqlite3-shm", "*.db-wal", "*.db-shm"):
for p in DATA_DIR.rglob(ext):
try:
in_backups = backups in p.resolve().parents
os.chmod(p, backup_modes()[0] if in_backups else stat.S_IRUSR | stat.S_IWUSR)
rp = p.resolve()
stripped = (backups in rp.parents
and not rp.relative_to(backups).parts[0].startswith("rebind-"))
os.chmod(p, backup_modes()[0] if stripped else stat.S_IRUSR | stat.S_IWUSR)
except FileNotFoundError:
pass # a -wal/-shm sidecar checkpointed away mid-scan
except OSError as e:
Expand Down
6 changes: 5 additions & 1 deletion src/services/media_server/rebind.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,14 @@ async def apply_plan(plan: Plan, *, target_adapter, chroma=None, backup_root: Op
if (m := running_manifest(root)) is not None:
raise RuntimeError(f"an unfinished rebind is on record ({m}) - finish it with --undo first")
folder = root / f"rebind-{datetime.utcnow():%Y%m%d-%H%M%S}"
folder.mkdir()
# The restore point is the whole database, members' Plex tokens included
# (the nightly copy blanks them, this one must restore as it was): 0600
# in a 0700 folder like the live database, not the umask's 0644.
folder.mkdir(mode=0o700)
snap = str(folder / "curatarr.db")
if not await run_read(scheduler._snapshot_sqlite, _db_path(), snap):
raise RuntimeError("the database backup failed its integrity check - nothing was changed")
os.chmod(snap, 0o600)
pairs = dict(plan.items)
users = {sid: tid for _, (sid, tid, _) in plan.users.items()}
libs = {s: t for s, (t, _) in plan.libraries.items()}
Expand Down
7 changes: 4 additions & 3 deletions src/services/milestones.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ def history(user_id: int) -> list:
return sorted(items, key=lambda m: m["reached_at"], reverse=True)


def pending_announcements(user_id: int) -> list:
"""Newly reached milestones the curator has not offered yet. Blocking."""
def pending_announcements(user_id: int, now: Optional[datetime] = None) -> list:
"""Newly reached milestones the curator has not offered yet. Blocking.
``now`` as in store(): a test's fixed clock, the real one otherwise."""
d = _load(user_id)
keys = set(d.get("pending") or [])
off = kinds_off(user_id)
now = datetime.utcnow()
now = now or datetime.utcnow()
out = []
for m in d.get("items") or []:
if _mkey(m) not in keys or m.get("kind") in off:
Expand Down
12 changes: 9 additions & 3 deletions src/services/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,12 +1512,16 @@ def _snapshot_sqlite(db_path: str, dest: str) -> bool:
# server's own token lives in .env, never in the database. Plex keeps its
# token out of its database backups the same way.
_SECRET_COLUMNS = (("users", "plex_token"), ("sessions", "access_token"), ("sessions", "refresh_token"))
# app_state rows that are credentials. The Jellyfin webhook secret: without
# it the route is off, and the admin's next look at the setup card makes a
# new one to paste into the plugin.
_SECRET_STATE_KEYS = ("jellyfin_hook_secret",)


def _strip_secrets(dest: str) -> bool:
"""Blank the token columns in a backup copy, overwriting the old bytes
(secure_delete), and leave it one file (out of WAL mode). True when the
copy still checks."""
"""Blank the token columns and drop the secret app_state rows in a
backup copy, overwriting the old bytes (secure_delete), and leave it one
file (out of WAL mode). True when the copy still checks."""
con = sqlite_connect(dest)
try:
con.execute("PRAGMA journal_mode=DELETE")
Expand All @@ -1526,6 +1530,8 @@ def _strip_secrets(dest: str) -> bool:
for table, col in _SECRET_COLUMNS:
if table in tables and col in {r[1] for r in con.execute(f'PRAGMA table_info("{table}")')}: # nosec B608 - literals above
con.execute(f'UPDATE "{table}" SET "{col}" = NULL WHERE "{col}" IS NOT NULL') # nosec B608 - literals above
if "app_state" in tables:
con.executemany("DELETE FROM app_state WHERE key = ?", [(k,) for k in _SECRET_STATE_KEYS])
con.commit()
return (con.execute("PRAGMA quick_check(1)").fetchone() or ["?"])[0] == "ok"
finally:
Expand Down
23 changes: 19 additions & 4 deletions src/services/wrapup_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,15 @@ def _discovery(db, W, user_id, period, types, titles) -> dict:
return {}
keys = [t["title"] for t in titles]
key = func.coalesce(W.series_title, W.title)
known = {k for (k,) in db.query(key).filter(
W.user_id == user_id, W.viewed_at < period.start,
W.media_type.in_(types), key.in_(keys)).distinct()}
# One index probe per title that stops at its first earlier play: a regular
# artist has thousands, and DISTINCT over them all was the cost.
known = set()
for k in keys:
if db.query(W.id).filter(
W.user_id == user_id, W.viewed_at < period.start, W.media_type.in_(types),
# Spelled out like _comebacks: ``coalesce(...) = k`` walks every earlier play.
(W.series_title == k) | (W.series_title.is_(None) & (W.title == k))).first():
known.add(k)
total = sum(t["hours"] for t in titles) or 1
new = [t for t in titles if t["title"] not in known]
return {"new_share": round(sum(t["hours"] for t in new) / total, 2),
Expand All @@ -617,7 +623,16 @@ def _comebacks(db, W, user_id, period, types) -> list:
W.viewed_at >= period.start, W.viewed_at < period.end).group_by(key).all() if k}
if not inside:
return []
names = list(inside)
# A title played inside the year before the latest first play cannot have a
# gap that long; one range scan on ix_wh_user_type_viewed drops those, so
# the max() look-up below only walks the history of the few that remain
# (an artist the member plays all the time has thousands of earlier plays).
cutoff = max(inside.values()) - timedelta(days=_COMEBACK_GAP_DAYS)
recent = {k for (k,) in db.query(key).filter(
W.user_id == user_id, W.media_type.in_(types),
# strictly after: a play exactly a year before is still a comeback
W.viewed_at > cutoff, W.viewed_at < period.start).distinct()}
names = [k for k in inside if k not in recent]
out = []
for i in range(0, len(names), 500):
for k, last in db.query(key, func.max(W.viewed_at)).filter(
Expand Down
Loading