diff --git a/HANDOFF.md b/HANDOFF.md index 3e7bed7..81816ba 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -52,6 +52,7 @@ Against local open-oscar-server 0.25.0 with `DISABLE_AUTH=true`, TOC listener 98 - **Recent UI/fix pass (2026-12-03):** CSP `upgrade-insecure-requests` disabled for HTTP deployments; TOC status label shows Connected/Disconnected; TOC-sent IMs broadcast into SSE buffer for replay on refresh; frontend `addMessage()` dedupes by msgId/recent same-sender text to prevent duplicate display; message input is textarea with Enter-to-send/Shift+Enter newline; buddy list shows per-person outlined rows with green/red/yellow status dots and handles `presence` updates. - **Login hardening/UX (2026-12-03):** login page includes a simple server-side math bot check (`GET /api/auth/challenge`, validated on login) and configurable server host + Web API/TOC ports (defaults prefilled from env, Claytonia-friendly). Backend auth supports per-login Web API base/TOC host+port. - **ICQ presence shim (2026-12-03, best-effort):** `src/icq-presence.js` applies conservative TOC hints for all-digit/ICQ UINs on signon (`toc_set_idle 0`) without changing AIM flow. ICQ online/offline visibility to others may still depend on open-oscar-server behavior. +- **WebUI ICQ presence overlay (2026-12-03):** `src/web-presence.js` tracks webui-logged-in ICQ/all-digit UINs and broadcasts synthetic SSE `presence` events to webui clients (login/logout/cleanup, replay on SSE connect). Frontend merges buddylist refreshes to preserve presence and prioritizes `online:true` in `buddyStatus()`. This fixes webui buddy-list visibility without patching the server; native AIM/ICQ clients still depend on server-side presence broadcast. - **Web API chat unavailable on 0.25.0:** do not rely on `/chat/*` Web API endpoints on this server. TOC is the working transport for chat/invites. - **TOC is HTTP-mixed on 9898:** normal HTTP clients get 404; TOC clients must send `FLAPON\r\n\r\n` first. Any proxy in front of 9898 must pass raw TCP. - **No reliable all-users list:** Management API not exposed; `memberDir/search` returned empty. UI has direct "Start IM by screen name" flow. diff --git a/public/app.js b/public/app.js index d9ae4d0..ad305a8 100644 --- a/public/app.js +++ b/public/app.js @@ -235,11 +235,31 @@ stream.on('toc_error', (event) => { ui.setChatError(msg); }); +function mergeBuddyPreservePresence(incoming) { + const prev = new Map(); + for (const b of (state.buddies || [])) { + const name = typeof b === 'string' ? b : (b.aimId || b.displayId || b.screenName || b.name || ''); + prev.set(normalizeName(name), b); + } + return (incoming || []).map((b) => { + const name = typeof b === 'string' ? b : (b.aimId || b.displayId || b.screenName || b.name || ''); + const old = prev.get(normalizeName(name)); + if (!old || typeof old === 'string') return b; + const base = typeof b === 'string' ? { screenName: b } : { ...b }; + // Preserve presence fields from previous state unless incoming has explicit ones. + if (base.online === undefined && old.online !== undefined) base.online = old.online; + if (base.idleMins === undefined && old.idleMins !== undefined) base.idleMins = old.idleMins; + if (base.state === undefined && old.state !== undefined) base.state = old.state; + if (base.status === undefined && old.status !== undefined) base.status = old.status; + return base; + }); +} + stream.on('buddylist', (event) => { const d = event.data || event.raw?.eventData || {}; const groups = Array.isArray(d.groups) ? d.groups : []; const buddies = groups.flatMap((g) => Array.isArray(g.buddies) ? g.buddies : []); - state.buddies = buddies; + state.buddies = mergeBuddyPreservePresence(buddies); ui.renderBuddies(state.buddies, (name) => openIM(name)); }); @@ -428,7 +448,7 @@ async function loadBuddies() { ...groups.flatMap((g) => Array.isArray(g.buddies) ? g.buddies : []), ...users, ]; - if (buddies.length) state.buddies = buddies; + if (buddies.length) state.buddies = mergeBuddyPreservePresence(buddies); ui.renderBuddies(state.buddies, (name) => openIM(name)); } catch (err) { console.warn('[buddies] load failed', err.message); diff --git a/public/index.html b/public/index.html index 1ba6f5d..b035787 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@