Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/AI-AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ destinations (`rclone`/`restic`/ssh) talk to the network.
| `provenance` | `{}` | the bundled-binary audit manifest (`PROVENANCE.json`). |
| `backup-info` | `{ref}` | `{ok,...}` one backup's full details (version, install source, state, date, mode, size, items, permission counts, device) |
| `backup-icon` | `{ref}` | `{ok,icon}` base64 PNG from the manifest (works when the app is uninstalled) |
| `backup-icons` | `{refs:[...]}` | `{ok,icons:{<ref>:<b64 or "">}}` batched `backup-icon`; `""` = no icon, unknown refs left out |
| `delete-backup` | `{ref}` | `{ok,deleted}` (ref must be under the backups dir) |
| `prune` | `{package,user?,keep}` | `{ok,pruned:[...]}` keep newest N of a package |
| `log-read` | `{limit?}` | `{ok,entries:[...]}` audit log, newest first |
Expand Down
11 changes: 11 additions & 0 deletions module/scripts/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,17 @@ EOF
ic="$("$JQ" -r '.package.icon // empty' "$m" 2>/dev/null)"
if [ -n "$ic" ]; then ok "\"icon\":\"$ic\""; else err ERR_ICON "no icon in manifest"; fi ;;

backup-icons)
# batched backup-icon: {refs:[...]} -> {ok:true,icons:{<ref>:<b64 or "">}}, "" = the backup
# has no icon. Invalid refs and refs without a manifest are left out of the map.
JQ="$(command -v "$BIN/jq" 2>/dev/null || echo jq)"
printf '%s' "$ARGS_B64" | base64 -d 2>/dev/null | "$JQ" -r '.refs[]? | strings' 2>/dev/null \
| while IFS= read -r ref; do
[ -n "$(ref_root "$ref")" ] || continue
[ -f "$ref/manifest.json" ] || continue
"$JQ" -c --arg r "$ref" '{($r): (.package.icon // "")}' "$ref/manifest.json" 2>/dev/null
done | "$JQ" -s -c '{ok:true, icons:(add // {})}' ;;

delete-backup)
ref="$(printf '%s' "$ARGS_B64" | base64 -d 2>/dev/null | \
"$(command -v "$BIN/jq" 2>/dev/null || echo jq)" -r '.ref // empty' 2>/dev/null)"
Expand Down
70 changes: 53 additions & 17 deletions module/webroot/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ function setupBackNav() {
// --- users --------------------------------------------------------------
var USERS = [];
var activeUser = 0;
function loadUsers() {
helper("list-users").then(function (r) {
function loadUsers() { // returns a promise that settles once the app list request has
return helper("list-users").then(function (r) {
USERS = (r && r.users) ? r.users : [];
var sel = $("#user-sel"), field = $("#user-field");
if (sel) {
Expand All @@ -242,7 +242,7 @@ function loadUsers() {
sel.value = activeUser;
if (field) field.hidden = USERS.length <= 1;
}
loadApps();
return loadApps();
});
}

Expand Down Expand Up @@ -272,7 +272,8 @@ function cacheIcon(pkg, vc, b64) {
// instead of one process per icon. Cache hits are instant.
var _iconQ = [], _iconTimer = null, ICON_BATCH = 40;
function loadIcon(ic) {
var pkg = ic.dataset.pkg; if (!pkg) return;
var pkg = ic.dataset.pkg;
if (!pkg) { if (ic.dataset.bref) loadBackupIcon(ic, ic.dataset.bref); return; }
var vc = ic.dataset.vc || "0", cached = null;
try { cached = localStorage.getItem(iconKey(pkg, vc)); } catch (e) {}
if (cached) { setIcon(ic, cached); return; }
Expand Down Expand Up @@ -369,7 +370,7 @@ function setSelectMode(on) {
}
function loadApps() {
$("#applist").innerHTML = "<li class='muted'>" + I18N.t("apps_loading") + "</li>";
helper("list-apps", { user: activeUser }).then(function (r) {
return helper("list-apps", { user: activeUser }).then(function (r) {
APPS = (r && r.apps) ? r.apps : [];
buildTagChips();
renderApps($("#search").value);
Expand All @@ -391,8 +392,11 @@ function bkMatch(b, q) {
|| ((b.package || "").toLowerCase().indexOf(q) >= 0)
|| ((b.tags || []).some(function (t) { return (t || "").toLowerCase().indexOf(q) >= 0; }));
}
var _bkIcons = [];
function renderBackups(list) {
var ul = $("#backuplist"); ul.innerHTML = "";
if (iconObserver) _bkIcons.forEach(function (ic) { iconObserver.unobserve(ic); });
_bkIcons = [];
BACKUPS = list || [];
var q = (bkQuery || "").toLowerCase().trim();
var shown = q ? BACKUPS.filter(function (b) { return bkMatch(b, q); }) : BACKUPS;
Expand Down Expand Up @@ -421,7 +425,9 @@ function renderBackups(list) {
li.onclick = function () { openBackupInfo(b); };
}
ul.appendChild(li);
loadBackupIcon(ic, b.ref); // icon comes from the manifest, not the live app
// icon comes from the manifest, not the live app; loaded lazily on scroll, like app icons
ic.dataset.bref = b.ref || ""; _bkIcons.push(ic);
if (iconObserver) iconObserver.observe(ic); else loadBackupIcon(ic, b.ref);
});
}
function toggleBkSel(b, on) {
Expand Down Expand Up @@ -457,15 +463,34 @@ function startBatchRestore() {
}
// Backup-list icon: read the icon stored in the manifest, so it shows even when
// the app is uninstalled. Cached per backup ref; "0" marks a backup with no icon.
// Batched like app icons (one helper call per ICON_BATCH refs), and a ref already
// being fetched is not asked for again: re-renders just add their icon to the wait list.
var _bicQ = [], _bicTimer = null, _bicPending = {};
function loadBackupIcon(ic, ref) {
if (!ref) return;
var key = "vdb_bic:" + ref, cached = null;
try { cached = localStorage.getItem(key); } catch (e) {}
var cached = null;
try { cached = localStorage.getItem("vdb_bic:" + ref); } catch (e) {}
if (cached) { if (cached !== "0") setIcon(ic, cached); return; }
helper("backup-icon", { ref: ref }).then(function (r) {
if (r && r.ok && r.icon) { try { localStorage.setItem(key, r.icon); } catch (e) {} setIcon(ic, r.icon); }
else { try { localStorage.setItem(key, "0"); } catch (e) {} }
});
if (_bicPending[ref]) { _bicPending[ref].push(ic); return; }
_bicPending[ref] = [ic]; _bicQ.push(ref);
if (_bicQ.length >= ICON_BATCH) flushBackupIcons();
else if (!_bicTimer) _bicTimer = setTimeout(flushBackupIcons, 120);
}
function flushBackupIcons() {
if (_bicTimer) { clearTimeout(_bicTimer); _bicTimer = null; }
if (!_bicQ.length) return;
var refs = _bicQ.splice(0, ICON_BATCH);
var done = function (map) {
refs.forEach(function (ref) {
var ics = _bicPending[ref] || []; delete _bicPending[ref];
// only an answered ref is cached ("" = no icon); a failed call is retried on a later render
if (!map || !Object.prototype.hasOwnProperty.call(map, ref)) return;
try { localStorage.setItem("vdb_bic:" + ref, map[ref] || "0"); } catch (e) {}
if (map[ref]) ics.forEach(function (ic) { setIcon(ic, map[ref]); });
});
};
helper("backup-icons", { refs: refs }).then(function (r) { done(r && r.ok && r.icons); }, function () { done(null); });
if (_bicQ.length) _bicTimer = setTimeout(flushBackupIcons, 0); // drain remaining
}
// backup details (tap a backup entry)
function openBackupInfo(b) {
Expand Down Expand Up @@ -2023,8 +2048,12 @@ function setBlock(pkg, on) {
// persist CFG; surface a failure instead of letting the in-memory toggle silently diverge from disk
function saveCfg() { helper("config-set", CFG).then(function (r) { if (r && r.ok === false) modalAlert(errMsg(r)); }).catch(function () { modalAlert(errMsg()); }); }
function persistBlocklist() { saveCfg(); }
// The Settings pickers each hold a row per app. They are built only while the Settings tab is
// shown (loadSettings rebuilds both whenever the tab opens), so loading the app list on the Apps
// tab no longer renders every app three times.
function settingsShown() { var p = $("#settings"); return !!(p && p.classList.contains("active")); }
function buildBlockPicker() {
var ul = $("#block-applist"); if (!ul) return;
var ul = $("#block-applist"); if (!ul || !settingsShown()) return;
if (iconObserver) _blockIcons.forEach(function (ic) { iconObserver.unobserve(ic); });
_blockIcons = []; ul.innerHTML = "";
visibleApps("", true).forEach(function (a) {
Expand Down Expand Up @@ -2104,7 +2133,7 @@ function openAppItemsModal(pkg, label) {
}
function closeAppItemsModal() { $("#appitems-modal").hidden = true; _aiPkg = null; }
function buildAppItemsPicker() {
var ul = $("#ai-applist"); if (!ul) return;
var ul = $("#ai-applist"); if (!ul || !settingsShown()) return;
if (iconObserver) _aiIcons.forEach(function (ic) { iconObserver.unobserve(ic); });
_aiIcons = []; ul.innerHTML = "";
visibleApps("", true).forEach(function (a) {
Expand Down Expand Up @@ -2963,13 +2992,20 @@ function boot() {
initVdlu(); // VDLU: evaluate reboot banner + auto_on_webui_open on load (panel mounts on tab open)

helper("config-get").then(function (c) { CFG = c || {}; activeUser = (CFG.user != null) ? (CFG.user | 0) : 0; return I18N.init(CFG.language || "auto"); })
.then(function () { I18N.apply(); loadDests(); loadSettings(); loadUsers(); loadOverview(); reattachOps(); recoverPendingAuth(); deferredUpdateCheck(); });
.then(function () {
I18N.apply();
// The bridge runs one exec at a time, so call order is load order. The app list is the
// first screen: ask for it first, and queue what the other tabs need only behind it.
var rest = function () {
loadOverview(); reattachOps(); loadDests(); loadSettings(); recoverPendingAuth(); deferredUpdateCheck();
helper("sanitize").catch(function () {}); // self-heal backup-folder perms, fire-and-forget
};
loadUsers().then(rest, rest);
});

helper("ping").then(function (r) {
if (r && r.version) { $("#ver").textContent = r.version; if ($("#about-ver")) $("#about-ver").textContent = r.version + " - " + (r.abi || ""); }
});

// self-heal backup-folder perms once per load (fire-and-forget, never blocks the UI).
helper("sanitize").catch(function () {});
}
document.addEventListener("DOMContentLoaded", boot);
17 changes: 12 additions & 5 deletions module/webroot/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ html[data-theme="light"] {
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Controls behave like app controls: a long press on a tab, button or tappable row no longer
starts a text selection or the link/callout menu, and taps skip the double-tap-zoom wait.
Text in rows, notices and dialogs stays selectable. */
.tabs, .tab, .btn, .icon-btn, .segment, .row.tappable .name, .row.tappable .pkg, summary.section-head {
-webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button, .tab, .row.tappable, summary, input[type="checkbox"] { touch-action: manipulation; }
html, body { margin: 0; }
body {
background: var(--bg); color: var(--text);
Expand All @@ -98,8 +105,9 @@ body {
display: flex; align-items: center; gap: 12px;
padding: 14px 16px calc(14px) 16px;
padding-top: calc(14px + env(safe-area-inset-top));
background: color-mix(in srgb, var(--bg) 86%, transparent);
backdrop-filter: saturate(140%) blur(10px);
/* opaque, no backdrop-filter: a blur under a sticky bar re-composites everything that
scrolls beneath it every frame, which is what made scrolling stutter in the WebView */
background: var(--bg);
border-bottom: 1px solid var(--line);
}
.topbar .logo { width: 38px; height: 38px; border-radius: 10px; flex: none; }
Expand Down Expand Up @@ -253,8 +261,7 @@ button { cursor: pointer; font-family: inherit; }
position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
display: flex; gap: 2px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none;
padding-bottom: calc(6px + env(safe-area-inset-bottom));
background: color-mix(in srgb, var(--bg) 90%, transparent);
backdrop-filter: saturate(140%) blur(12px);
background: var(--bg); /* opaque, no backdrop-filter (see .topbar) */
border-top: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
Expand Down Expand Up @@ -312,7 +319,7 @@ button { cursor: pointer; font-family: inherit; }

/* ---- modal (floating, centered) ---- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
justify-content: center; background: rgba(2,6,16,.66); backdrop-filter: blur(2px);
justify-content: center; background: rgba(2,6,16,.72);
padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); }
.modal[hidden] { display: none; }
/* the generic confirm/alert always opens on top of another modal (e.g. delete from
Expand Down