Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([sharing-inbox-live-subscription-badge]): live badge on inbox subscription rows
[._.]/ Adam Eivy8a3a94f1a677
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 071edc4542..89eb52e380 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -27,6 +27,7 @@### Sharing+- **"🔄 live" badge on inbox subscription rows.** Sharing → Inbox now flags subscription rows whose latest manifest was queued within the last 5 minutes with a small green pill (spinning RefreshCw icon + "live" label). Re-exports fire on every record edit with a 3s server-side debounce and propagate via chokidar in <1s, so a recently-received subscription is a real-time "sender is editing right now" signal. Pure `isLiveSubscription(item, now)` helper exported from `client/src/pages/Sharing.jsx` (handles null inputs + unparseable `receivedAt` + one-shot non-subscription shares without throwing); 5 new vitest cases in `Sharing.test.jsx`. Freshness is computed on render so the badge naturally decays as the page re-renders past the 5-min mark.- **Per-sender subscription filenames.** `subscriptionFilename()` now includes the sender's instance id in the bucket-side filename (`sub-<kind>-<recordId>-<senderInstanceId>.json`) so two peers subscribed to the same series/universe don't clobber each other's deterministic share files. Inbox dedup keys on `(recordKind, recordId, senderInstanceId)` so a peer's update no longer wipes the other peer's inbox row. `unsubscribe` best-effort cleans up the pre-v2 sender-less filename when its `senderInstanceId` matches this instance, leaving any other peer's pre-upgrade file intact. New `legacySubscriptionFilename` export for the legacy name. Touched `server/services/sharing/{manifest,subscriptions,importer,exporter}.js` + tests.- **Rotation-orphan inbox cull.** Per-sender inbox dedup means a peer that rotates its `instanceId` (factory reset / new device) would otherwise leave its old identity's row stranded forever. `applyInbox` now culls cross-sender orphans on every subscription-manifest arrival when (a) same `(recordKind, recordId, source)`, (b) different `senderInstanceId`, (c) existing row older than 30 days. The conservative window keeps two legitimately distinct peers with the same display name from being incorrectly culled. Cull removals persist even when the freshness-gate (`inbox-has-newer`) short-circuits the rest of `applyInbox`. 4 new integration tests cover the cull/preserve cases plus the freshness-gate early-return regression.diff --git a/client/src/pages/Sharing.jsx b/client/src/pages/Sharing.jsxindex 1f63271772..4155c47672 100644--- a/client/src/pages/Sharing.jsx+++ b/client/src/pages/Sharing.jsx@@ -9,7 +9,7 @@import { useEffect, useRef, useState } from 'react';import {- Share2, Plus, Trash2, Folder, Inbox, History, Save, Loader2, Check, X, Users, AlertCircle,+ Share2, Plus, Trash2, Folder, Inbox, History, Save, Loader2, Check, X, Users, AlertCircle, RefreshCw,} from 'lucide-react';import toast from '../components/ui/Toast';import FolderPicker from '../components/FolderPicker';@@ -22,6 +22,19 @@ import {const emptyForm = () => ({ name: '', path: '', mode: 'inbox', displayNameOverride: '', bioOverride: '' });+// A subscription row counts as "live" when its latest manifest was queued+// within this window. Re-exports fire on every record edit (debounced ~3s+// server-side) and propagate via chokidar in <1s — so a row received this+// recently means the sender is actively editing the record right now.+const SUBSCRIPTION_LIVE_WINDOW_MS = 5 * 60 * 1000;++export function isLiveSubscription(item, now = Date.now()) {+ if (!item || !item.subscription) return false;+ const receivedMs = Date.parse(item.receivedAt);+ if (!Number.isFinite(receivedMs)) return false;+ return (now - receivedMs) < SUBSCRIPTION_LIVE_WINDOW_MS;+}+export default function Sharing() {const [buckets, setBuckets] = useState([]);const [localSchemaVersion, setLocalSchemaVersion] = useState(null);@@ -485,13 +498,22 @@ function Inboxlist({ bucket, items, onPromote, onDismiss }) {<li key={item.manifestId} className="p-3 bg-port-card border border-port-border rounded-lg"><div className="flex items-start justify-between gap-3"><div className="flex-1 min-w-0">- <div className="text-sm text-white">+ <div className="text-sm text-white flex items-center gap-2 flex-wrap"><span className="text-port-accent">{item.source}</span>{item.producedByVersion && item.producedByVersion !== 'unknown' && (- <span className="text-gray-500 text-[11px]"> (PortOS {item.producedByVersion})</span>+ <span className="text-gray-500 text-[11px]">(PortOS {item.producedByVersion})</span>+ )}+ <span className="text-gray-600">· {item.kind}</span>+ <span className="text-gray-600">· {new Date(item.receivedAt || item.createdAt).toLocaleString()}</span>+ {isLiveSubscription(item) && (+ <span+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-port-success/10 border border-port-success/30 text-[10px] text-port-success"+ title={`Subscription refreshed within the last ${SUBSCRIPTION_LIVE_WINDOW_MS / 60000} minutes — sender is actively editing`}+ >+ <RefreshCw size={9} className="animate-spin [animation-duration:3s]" />+ live+ </span>)}- <span className="text-gray-600"> · {item.kind}</span>- <span className="text-gray-600"> · {new Date(item.receivedAt || item.createdAt).toLocaleString()}</span></div>{item.sourceBio ? (<div className="text-[11px] text-gray-500 mt-0.5 italic">{item.sourceBio}</div>diff --git a/client/src/pages/Sharing.test.jsx b/client/src/pages/Sharing.test.jsxnew file mode 100644index 0000000000..f74c191dc2--- /dev/null+++ b/client/src/pages/Sharing.test.jsx@@ -0,0 +1,56 @@+import { describe, it, expect, vi } from 'vitest';++// Sharing.jsx pulls in socket.io-client at module scope (auto-connects).+// Stub it so the test runner doesn't try to open a network socket.+vi.mock('../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn() } }));+vi.mock('../services/api', () => ({+ listShareBuckets: vi.fn(),+ createShareBucket: vi.fn(),+ updateShareBucket: vi.fn(),+ deleteShareBucket: vi.fn(),+ listShareInbox: vi.fn(),+ promoteShareInboxItem: vi.fn(),+ dismissShareInboxItem: vi.fn(),+ listShareActivity: vi.fn(),+ getSettings: vi.fn(),+ updateSettings: vi.fn(),+}));++import { isLiveSubscription } from './Sharing';++const NOW = Date.parse('2026-05-18T12:00:00Z');++describe('isLiveSubscription', () => {+ it('returns true for a subscription row received within the live window', () => {+ const item = {+ subscription: { recordKind: 'universe', recordId: 'u-1' },+ receivedAt: '2026-05-18T11:57:00Z', // 3 min ago+ };+ expect(isLiveSubscription(item, NOW)).toBe(true);+ });++ it('returns false for a subscription row received outside the live window', () => {+ const item = {+ subscription: { recordKind: 'universe', recordId: 'u-1' },+ receivedAt: '2026-05-18T11:50:00Z', // 10 min ago+ };+ expect(isLiveSubscription(item, NOW)).toBe(false);+ });++ it('returns false for a one-shot share (no subscription field) even if recent', () => {+ const item = { subscription: null, receivedAt: '2026-05-18T11:59:30Z' };+ expect(isLiveSubscription(item, NOW)).toBe(false);+ });++ it('returns false when receivedAt is missing or unparseable', () => {+ const subscription = { recordKind: 'universe', recordId: 'u-1' };+ expect(isLiveSubscription({ subscription }, NOW)).toBe(false);+ expect(isLiveSubscription({ subscription, receivedAt: '' }, NOW)).toBe(false);+ expect(isLiveSubscription({ subscription, receivedAt: 'not-a-date' }, NOW)).toBe(false);+ });++ it('returns false for null / non-object inputs without throwing', () => {+ expect(isLiveSubscription(null, NOW)).toBe(false);+ expect(isLiveSubscription(undefined, NOW)).toBe(false);+ });+});