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: opt-in Beeper read receipts behind a consent step (#9985)
Adam Eivy9a5ef4b8057f
diff --git a/client/src/components/messages/beeper/BeeperSettingsPanel.jsx b/client/src/components/messages/beeper/BeeperSettingsPanel.jsxindex ec760cbbf4..236a1ad0b0 100644--- a/client/src/components/messages/beeper/BeeperSettingsPanel.jsx+++ b/client/src/components/messages/beeper/BeeperSettingsPanel.jsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useState } from 'react';-import { Save, Loader2, MessageCircle, ShieldCheck, ShieldAlert, RefreshCw, Clock, Link2, Unlink, HardDrive, Download } from 'lucide-react';+import { Save, Loader2, MessageCircle, ShieldCheck, ShieldAlert, RefreshCw, Clock, Link2, Unlink, HardDrive, Download, CheckCheck } from 'lucide-react';import toast from '../../ui/Toast';import Modal from '../../ui/Modal';import BrailleSpinner from '../../BrailleSpinner';@@ -53,6 +53,7 @@ export default function BeeperSettingsPanel({ realtime: realtimeProp = null, onRconst [savingToken, setSavingToken] = useState(false);const [confirmingDisconnect, setConfirmingDisconnect] = useState(false);const [disconnecting, setDisconnecting] = useState(false);+ const [consentingReceipts, setConsentingReceipts] = useState(false);const mountedRef = useMounted();const loadStatus = useCallback(async () => {@@ -273,6 +274,28 @@ export default function BeeperSettingsPanel({ realtime: realtimeProp = null, onR</span></label>+ {/* Real read receipts (#9985): default OFF. Turning ON goes through+ the consent modal below; turning OFF is immediate. Like every+ field here it only takes effect on Save. */}+ <label htmlFor="beeper-read-receipts" className="flex items-start gap-2 text-sm text-gray-200 cursor-pointer">+ <input+ id="beeper-read-receipts"+ type="checkbox"+ checked={form.sendReadReceipts}+ onChange={(e) => {+ if (e.target.checked) setConsentingReceipts(true);+ else setForm((prev) => ({ ...prev, sendReadReceipts: false }));+ }}+ className="w-4 h-4 mt-0.5 accent-port-accent"+ />+ <span>+ Send read receipts to Beeper+ <span className="block text-xs text-gray-500">+ Off by default — opening a conversation here only marks it seen in PortOS. When on, it also marks the chat read in Beeper.+ </span>+ </span>+ </label>+<div className="pt-1"><buttontype="button"@@ -299,6 +322,15 @@ export default function BeeperSettingsPanel({ realtime: realtimeProp = null, onRonCleared={() => { loadStatus(); onBreakerCleared?.(); }}/>+ <ReadReceiptConsentModal+ open={consentingReceipts}+ onCancel={() => setConsentingReceipts(false)}+ onConfirm={() => {+ setForm((prev) => ({ ...prev, sendReadReceipts: true }));+ setConsentingReceipts(false);+ }}+ />+<AttachmentMirrorCard budgetGb={form.attachmentBudgetGb} settingsDirty={dirty || saving} />{statusLoading ? (@@ -935,3 +967,46 @@ function BackfillConsentModal({ open, summary, onCancel, onConfirm }) {</Modal>);}++// The explicit consent step (#9985) for real read receipts. Read receipts are+// the one Beeper-visible side effect of simply opening a conversation — the+// people on the other end see the chat as read — so enabling them is a+// deliberate second step rather than a bare checkbox.+function ReadReceiptConsentModal({ open, onCancel, onConfirm }) {+ if (!open) return null;+ return (+ <Modal open={open} onClose={onCancel} size="sm" ariaLabel="Send read receipts to Beeper">+ <div className="bg-port-card border border-port-border rounded-lg p-5 space-y-4">+ <div className="flex items-center gap-2">+ <CheckCheck size={18} className="text-port-accent" />+ <h3 className="text-white font-medium">Send read receipts?</h3>+ </div>+ <p className="text-sm text-gray-400">+ When you open a conversation with new activity in PortOS, PortOS will also mark that chat as+ read in Beeper. On networks that support them, the people you are talking to may see that you+ have read their messages.+ </p>+ <p className="text-xs text-gray-500">+ You can turn this off again at any time. Until you save, nothing changes.+ </p>+ <div className="flex flex-wrap justify-end gap-2">+ <button+ type="button"+ onClick={onCancel}+ className="min-h-[36px] px-3 text-xs text-gray-400 transition-colors hover:text-gray-200"+ >+ Cancel+ </button>+ <button+ type="button"+ onClick={onConfirm}+ className="inline-flex min-h-[36px] items-center gap-1.5 rounded-lg bg-port-accent/20 px-3 text-xs text-port-accent transition-colors hover:bg-port-accent/30"+ >+ <CheckCheck size={12} />+ Enable read receipts+ </button>+ </div>+ </div>+ </Modal>+ );+}diff --git a/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx b/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsxindex 930513387b..673970bf4b 100644--- a/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx+++ b/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx@@ -427,7 +427,7 @@ describe('BeeperSettingsPanel — settings', () => {fireEvent.click(saveButton);await waitFor(() => expect(api.updateSettings).toHaveBeenCalledWith({beeper: {- enabled: true, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: false,+ enabled: true, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: false, sendReadReceipts: false,},}));expect(toast.success).toHaveBeenCalled();@@ -452,11 +452,52 @@ describe('BeeperSettingsPanel — settings', () => {await waitFor(() => expect(api.updateSettings).toHaveBeenCalledWith({beeper: {- enabled: false, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: true,+ enabled: false, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: true, sendReadReceipts: false,},}));});+ // #9985: real read receipts are OFF by default and only turn on after an+ // explicit consent step; cancelling the step changes nothing.+ it('keeps read receipts off until the consent modal is confirmed, then saves the opt-in', async () => {+ api.getBeeperStatus.mockResolvedValue({ tokenConfigured: false, reachable: null, accounts: [] });+ api.updateSettings.mockResolvedValue({ beeper: {} });+ await renderPanel();++ const checkbox = await screen.findByLabelText(/Send read receipts to Beeper/);+ expect(checkbox).not.toBeChecked();++ fireEvent.click(checkbox);+ expect(await screen.findByRole('heading', { name: 'Send read receipts?' })).toBeInTheDocument();+ expect(checkbox).not.toBeChecked();+ expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();++ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));+ expect(screen.queryByRole('heading', { name: 'Send read receipts?' })).toBeNull();+ expect(checkbox).not.toBeChecked();++ fireEvent.click(checkbox);+ fireEvent.click(await screen.findByRole('button', { name: 'Enable read receipts' }));+ expect(checkbox).toBeChecked();++ fireEvent.click(screen.getByRole('button', { name: 'Save' }));+ await waitFor(() => expect(api.updateSettings).toHaveBeenCalledWith({+ beeper: expect.objectContaining({ sendReadReceipts: true }),+ }));+ });++ it('turns read receipts off immediately without a consent step', async () => {+ api.getSettings.mockResolvedValue({ beeper: { ...BASE_SETTINGS.beeper, sendReadReceipts: true } });+ api.getBeeperStatus.mockResolvedValue({ tokenConfigured: false, reachable: null, accounts: [] });+ await renderPanel();++ const checkbox = await screen.findByLabelText(/Send read receipts to Beeper/);+ expect(checkbox).toBeChecked();+ fireEvent.click(checkbox);+ expect(checkbox).not.toBeChecked();+ expect(screen.queryByRole('heading', { name: 'Send read receipts?' })).toBeNull();+ });+it('disables Retry while the form has unsaved edits, per the save-gating convention', async () => {api.getBeeperStatus.mockResolvedValue({tokenConfigured: true, reachable: false, lastProbeError: 'refused', baseUrl: 'http://127.0.0.1:23373', accounts: [],diff --git a/client/src/hooks/useBeeperSettings.js b/client/src/hooks/useBeeperSettings.jsindex 05b6e8013f..91e3fe42bb 100644--- a/client/src/hooks/useBeeperSettings.js+++ b/client/src/hooks/useBeeperSettings.js@@ -14,6 +14,9 @@ const DEFAULTS = {// off is the only safe default — this is an explicit opt-in, never inferred// from the baseUrl the user typed.allowNonLoopbackBaseUrl: false,+ // Opt-in real read receipts (#9985): default OFF, enabled only through the+ // consent step in the settings panel.+ sendReadReceipts: false,};// `value === ''` (a cleared field) falls back to the default; any other@@ -37,7 +40,7 @@ const clampBudget = (value) => Math.max(0.1, Math.min(1000, toFiniteNumber(value// dedicated connect routes (#31) — the Beeper card's Connect / paste /// Disconnect actions, never this settings save.//-// `save()` always PUTs the complete five-field object, never a diff — same+// `save()` always PUTs the complete settings object, never a diff — same// convention as `useSyncSourceSettings` for iMessage/Signal/Spotify/YouTube —// so a partial edit can never silently drop a sibling field on the server's// generic top-level shallow merge.@@ -68,6 +71,7 @@ export function useBeeperSettings() {attachmentBudgetGb: Number.isFinite(config.attachmentBudgetGb) ? config.attachmentBudgetGb : DEFAULTS.attachmentBudgetGb,allowNonLoopbackBaseUrl: typeof config.allowNonLoopbackBaseUrl === 'boolean'? config.allowNonLoopbackBaseUrl : DEFAULTS.allowNonLoopbackBaseUrl,+ sendReadReceipts: config.sendReadReceipts === true,};setForm(next);setSaved(next);@@ -92,6 +96,7 @@ export function useBeeperSettings() {attachmentBudgetGb: clampBudget(form.attachmentBudgetGb),baseUrl: (form.baseUrl || '').trim() || DEFAULTS.baseUrl,allowNonLoopbackBaseUrl: Boolean(form.allowNonLoopbackBaseUrl),+ sendReadReceipts: form.sendReadReceipts === true,};setSaving(true);const settings = await updateSettings({ beeper: next }).catch(() => null);diff --git a/server/lib/mediaValidation.js b/server/lib/mediaValidation.jsindex 224df5bdc0..d101e20326 100644--- a/server/lib/mediaValidation.js+++ b/server/lib/mediaValidation.js@@ -86,6 +86,9 @@ export const beeperSettingsSchema = z.object({baseUrl: z.string().trim().min(1).max(500).optional(),attachmentBudgetGb: z.number().min(0.1).max(1000).optional(),allowNonLoopbackBaseUrl: z.boolean().optional(),+ // Opt-in real read receipts (#9985): when true, opening a thread also tells+ // Beeper the chat was read. Absent/false = PortOS-local "seen" only.+ sendReadReceipts: z.boolean().optional(),}).strict().superRefine((value, ctx) => {if (value.baseUrl === undefined) return;const parsed = parseBrowserOrigin(value.baseUrl);diff --git a/server/routes/beeper.js b/server/routes/beeper.jsindex a12d14771d..64eef69fdd 100644--- a/server/routes/beeper.js+++ b/server/routes/beeper.js@@ -268,10 +268,11 @@ router.post('/conversations/:id/low-priority', asyncHandler(async (req, res) =>// POST /api/beeper/conversations/:id/seen — the LOCAL "seen in PortOS"// watermark (#83), the fix for opening an unread thread leaving its badge-// untouched. Unlike archive/low-priority above, this NEVER calls Beeper: no-// PATCH, no read receipt, nothing that reaches the source network — just a-// local `seen_at` stamp the read model compares against the conversation's-// own activity (`markConversationSeen`). No request body: it is called with+// untouched. Unlike archive/low-priority above, this never PATCHes Beeper: it+// stamps a local `seen_at` the read model compares against the conversation's+// own activity (`markConversationSeen`). The only thing that can reach the+// source network is the opt-in read receipt (`settings.beeper.sendReadReceipts`,+// default OFF, #9985). No request body: it is called with// nothing to validate beyond the id, on every thread open and, cheaply, again// when a new message lands in the open thread.router.post('/conversations/:id/seen', asyncHandler(async (req, res) => {diff --git a/server/services/beeperConversations.js b/server/services/beeperConversations.jsindex b32933ada6..6ac28c6c0b 100644--- a/server/services/beeperConversations.js+++ b/server/services/beeperConversations.js@@ -25,7 +25,8 @@import { query, withTransaction } from '../lib/db.js';import { ServerError } from '../lib/errorHandler.js';import { resolveLinkedPersonId } from '../lib/tribeMatch.js';-import { updateChat } from './beeperClient.js';+import { markRead, updateChat } from './beeperClient.js';+import { getSettings } from './settings.js';import {getConversationAttachmentBytes,purgeConversationAttachments,@@ -508,25 +509,41 @@ export async function listNetworks() {* time only moves forward across calls to the same row, so the two are* equivalent here and the plain assignment says that more plainly.*- * TODO(#9985): a settings toggle to also send a real read receipt through- * Beeper's own API is the natural next wave — it would PATCH-then-mirror the- * same way `setConversationFlag` does, gated behind that toggle and its own- * consent step, and default OFF. Out of scope for this change.+ * The ONE exception is the opt-in read receipt (#9985): when+ * `settings.beeper.sendReadReceipts` is true (default OFF, enabled only through+ * the settings consent step) and the thread had unseen activity, a best-effort+ * `markRead` also tells Beeper the chat was read. The local stamp is written+ * FIRST and is the source of truth for the badge, so a Beeper failure is logged+ * and swallowed — it must never un-see a thread the user is looking at, and the+ * route is called silently on every thread open.*/export async function markConversationSeen(conversationId) {const found = await query(- 'SELECT id FROM beeper_conversations WHERE id = $1',+ 'SELECT id, source_chat_id, seen_at, last_activity, created_at FROM beeper_conversations WHERE id = $1',[conversationId],);- if (!found?.rows?.[0]) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });+ const row = found?.rows?.[0];+ if (!row) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });+ const hadUnseenActivity = !isSeenLocally(row);await query('UPDATE beeper_conversations SET seen_at = NOW(), updated_at = NOW() WHERE id = $1',[conversationId],);+ if (hadUnseenActivity) await sendReadReceiptIfEnabled(row);return getConversation(conversationId);}+async function sendReadReceiptIfEnabled(row) {+ const settings = await getSettings().catch(() => null);+ if (settings?.beeper?.sendReadReceipts !== true) return;+ try {+ await markRead(row.source_chat_id);+ } catch (err) {+ console.warn(`⚠️ Beeper read receipt failed for conversation ${row.id}: ${err.message}`);+ }+}+// ---------------------------------------------------------------------------// Wired rail controls (#9: Archive and Low priority)// ---------------------------------------------------------------------------diff --git a/server/services/beeperConversations.test.js b/server/services/beeperConversations.test.jsindex a64b5ae2d4..ca2bd5b7b6 100644--- a/server/services/beeperConversations.test.js+++ b/server/services/beeperConversations.test.js@@ -22,7 +22,8 @@ vi.mock('../lib/db.js', () => ({withTransaction: vi.fn(),ensureSchema: vi.fn(async () => {}),}));-vi.mock('./beeperClient.js', () => ({ updateChat: vi.fn() }));+vi.mock('./beeperClient.js', () => ({ updateChat: vi.fn(), markRead: vi.fn() }));+vi.mock('./settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));// `beeperTribe.js` imports `./tribe.js` at the top level for its own// touchpoint/roster logic, unrelated to the parity test below — stubbed so// importing it here doesn't drag in tribe.js's own real (and much heavier)@@ -30,7 +31,8 @@ vi.mock('./beeperClient.js', () => ({ updateChat: vi.fn() }));vi.mock('./tribe.js', () => ({ listPeople: vi.fn(async () => []) }));import { query, withTransaction } from '../lib/db.js';-import { updateChat } from './beeperClient.js';+import { markRead, updateChat } from './beeperClient.js';+import { getSettings } from './settings.js';import * as beeperTribe from './beeperTribe.js';import {listConversations,@@ -631,6 +633,47 @@ describe('markConversationSeen — the local watermark write, never a Beeper calexpect(updateChat).not.toHaveBeenCalled();});+ // #9985: the opt-in read receipt is the only path from this write to Beeper.+ describe('opt-in read receipt', () => {+ const stubSeenWrite = (existing) => {+ vi.mocked(query)+ .mockResolvedValueOnce({ rows: [existing] })+ .mockResolvedValueOnce({ rows: [] })+ .mockResolvedValueOnce({ rows: [conversationRow()] })+ .mockResolvedValueOnce({ rows: [] });+ };+ const unseen = { id: CONV_A, source_chat_id: 'chat-example-1', seen_at: null, last_activity: '2026-09-01T10:00:00.000Z', created_at: '2026-08-01T10:00:00.000Z' };++ it('sends nothing to Beeper by default', async () => {+ stubSeenWrite(unseen);+ await markConversationSeen(CONV_A);+ expect(markRead).not.toHaveBeenCalled();+ });++ it('marks the chat read in Beeper when enabled and the thread had unseen activity', async () => {+ vi.mocked(getSettings).mockResolvedValueOnce({ beeper: { sendReadReceipts: true } });+ stubSeenWrite(unseen);+ await markConversationSeen(CONV_A);+ expect(markRead).toHaveBeenCalledWith('chat-example-1');+ });++ it('does not repeat the receipt for a thread already seen locally', async () => {+ vi.mocked(getSettings).mockResolvedValueOnce({ beeper: { sendReadReceipts: true } });+ stubSeenWrite({ ...unseen, seen_at: '2026-09-02T00:00:00.000Z' });+ await markConversationSeen(CONV_A);+ expect(markRead).not.toHaveBeenCalled();+ });++ it('still stamps and returns the conversation when Beeper rejects the receipt', async () => {+ vi.mocked(getSettings).mockResolvedValueOnce({ beeper: { sendReadReceipts: true } });+ vi.mocked(markRead).mockRejectedValueOnce(new Error('Beeper unreachable'));+ stubSeenWrite(unseen);+ const conversation = await markConversationSeen(CONV_A);+ expect(conversation.id).toBe(CONV_A);+ expect(callFor('UPDATE beeper_conversations SET seen_at = NOW()')).toBeDefined();+ });+ });+it('404s on an unknown conversation without writing anything', async () => {vi.mocked(query).mockResolvedValueOnce({ rows: [] });await expect(markConversationSeen(CONV_B)).rejects.toMatchObject({ status: 404, code: 'NOT_FOUND' });