agent icon: 404 when unconfigured, client-side fallback

hive_sh4re::assets::branding_svg() resolved a server-side default
icon at runtime from HIVE_ASSETS_DIR — the only consumer was
serve_icon(), which fell back to it whenever the agent had no
`hyperhive.icon` override. Removed both the fallback and the
function: serve_icon() now 404s when /etc/hyperhive/icon.svg is
absent, and the per-agent web UI (app.js) picks up the existing
dashboard swarm.js pattern — swap the <img> src to the
frontend-bundled /favicon.svg on load failure, guarded against
looping if the fallback itself 404s.

Updated the doc/comment claims that said the server always returns
an image (docs/web-ui/agent.md, nix/agent-modules/default.nix, the
hive-c0re/forge/users.rs comment referencing the old shared-asset
set). forge-avatar-sync and the matrix avatar sync are unaffected —
both are gated on hyperhive.icon != null and never depended on the
removed fallback.
This commit is contained in:
iris 2026-08-10 20:35:23 +02:00 committed by mara
commit e525dcb6d4
6 changed files with 49 additions and 38 deletions

View file

@ -38,6 +38,22 @@ window.marked = marked;
// native confirm()/alert() dialogs that broke out of the page theme.
bindAsyncForms(() => refreshState());
// ─── header icon fallback ───────────────────────────────────────────────
// `/icon` 404s when this agent has no `hyperhive.icon` override (see
// hive-agent::web_ui::screen::serve_icon — no bundled server-side
// default any more). Mirrors the dashboard's `swarm.js` `/favicon.svg`
// fallback: fire-and-forget load, swap on failure, guarded so a 404 on
// the fallback itself can't loop.
(function bindHeaderIconFallback() {
const iconImg = document.querySelector('.agent-icon');
if (!iconImg) return;
iconImg.addEventListener('error', () => {
if (iconImg.dataset.fallback) return;
iconImg.dataset.fallback = '1';
iconImg.src = '/favicon.svg';
});
})();
// ─── side panel (singleton drawer for inbox + loose-ends flyouts) ──────
// The shared `<hive-side-panel>` element (see @hive/shared/side-panel.js
// for the chrome/behavior it owns), created once, eagerly, when this