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: show snoozed Beeper conversations in Later (#9985)
[._.]/ Adam Eivy27403136d2d8
diff --git a/client/src/components/messages/BeeperTab.test.jsx b/client/src/components/messages/BeeperTab.test.jsxindex 4e5b4274b0..66ca3f1ac6 100644--- a/client/src/components/messages/BeeperTab.test.jsx+++ b/client/src/components/messages/BeeperTab.test.jsx@@ -531,11 +531,11 @@ describe('the pinned grid is Beeper’s own isPinned, mirrored', () => {});describe('unimplemented controls are absent rather than inert', () => {- it('renders no Requests, Later or new-conversation placeholder', async () => {+ it('renders no Requests or new-conversation placeholder', async () => {renderTab();await screen.findByText('Nothing here');- for (const label of ['Requests', 'Later', 'More scope options', 'New conversation']) {+ for (const label of ['Requests', 'More scope options', 'New conversation']) {expect(screen.queryByRole('button', { name: label })).toBeNull();}});@@ -1742,3 +1742,24 @@ describe('saved conversation scopes', () => {expect(api.createBeeperScope).toHaveBeenLastCalledWith({ name: saved.name, filters: saved.filters }, { silent: true });});});+++describe('Later system scope', () => {+ it('opens the Later filter from the rail', async () => {+ renderTab('/messages/beeper');+ fireEvent.click(await screen.findByRole('button', { name: 'Later' }));+ await waitFor(() => expect(api.getBeeperConversations).toHaveBeenLastCalledWith(+ { snoozed: true }, { silent: true },+ ));+ expect(screen.getByRole('button', { name: 'Later' })).toHaveAttribute('aria-pressed', 'true');+ });+});+++it('reopens a shared Later URL with search and unread filters', async () => {+ renderTab('/messages/beeper?scope=later&q=example&unread=1');+ await waitFor(() => expect(api.getBeeperConversations).toHaveBeenLastCalledWith(+ { snoozed: true, search: 'example', unreadOnly: true }, { silent: true },+ ));+ expect(screen.getByRole('button', { name: 'Later' })).toHaveAttribute('aria-pressed', 'true');+});diff --git a/client/src/components/messages/beeper/BeeperChatSurface.jsx b/client/src/components/messages/beeper/BeeperChatSurface.jsxindex 8906921cb8..2df6a30ba9 100644--- a/client/src/components/messages/beeper/BeeperChatSurface.jsx+++ b/client/src/components/messages/beeper/BeeperChatSurface.jsx@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useNavigate, useSearchParams } from 'react-router';import {Archive, BellOff, Bookmark, Filter, Inbox, Loader2, MoreHorizontal, Plus,- RefreshCw, Search, Settings, TrendingDown, X,+ RefreshCw, Search, Settings, Clock, TrendingDown, X,} from 'lucide-react';import NetworkLogo, { networkLabel } from './BeeperNetworkLogo';import BeeperThread from './BeeperThread';@@ -48,12 +48,13 @@ import * as api from '../../../services/api';* rendered over the newer one.*/-// Fixed system scopes, in the reference's own order. Requests, Later and+// Fixed system scopes. Requests and// new conversation are omitted until implemented// (tracked in the Beeper enhancements issue, #9985).const SCOPE_EVENTS = ['beeper:invalidate'];const SYSTEM_SCOPES = [{ id: 'inbox', label: 'Inbox', icon: Inbox },+ { id: 'later', label: 'Later', icon: Clock },{ id: 'archive', label: 'Archive', icon: Archive },{ id: 'low', label: 'Low priority', icon: TrendingDown },];@@ -87,6 +88,7 @@ const RECENT_ACTIVITY_WINDOW_MS = 24 * 60 * 60 * 1000;/** The filter set one scope means. Absent keys are absent FILTERS, not `false`. */function filtersForScope(scope, unreadOnly, search) {const base = { ...(unreadOnly ? { unreadOnly: true } : {}), ...(search ? { search } : {}) };+ if (scope === 'later') return { ...base, snoozed: true };if (scope === 'archive') return { ...base, archived: true };if (scope === 'low') return { ...base, lowPriority: true };if (typeof scope === 'string' && scope.startsWith(NETWORK_SCOPE_PREFIX)) {diff --git a/client/src/services/apiBeeper.js b/client/src/services/apiBeeper.jsindex 66e9b20b20..dee17e1783 100644--- a/client/src/services/apiBeeper.js+++ b/client/src/services/apiBeeper.js@@ -28,9 +28,9 @@ export const syncBeeperNow = (options = {}) => request('/beeper/sync', { method:// as the literal "true"/"false" otherwise: the server reads an absent filter as// "do not filter", which is a different query from `false`.export const getBeeperConversations = ({- network, unreadOnly, archived, lowPriority, search, limit, cursor,+ network, unreadOnly, archived, lowPriority, snoozed, search, limit, cursor,} = {}, options = {}) =>- request(`/beeper/conversations${queryString({ network, unreadOnly, archived, lowPriority, search, limit, cursor })}`, options);+ request(`/beeper/conversations${queryString({ network, unreadOnly, archived, lowPriority, snoozed, search, limit, cursor })}`, options);export const getBeeperConversation = (conversationId, options = {}) =>request(`/beeper/conversations/${encodeURIComponent(conversationId)}`, options);diff --git a/docs/features/beeper.md b/docs/features/beeper.mdindex 4928a9e75c..f84b535ca8 100644--- a/docs/features/beeper.md+++ b/docs/features/beeper.md@@ -48,12 +48,13 @@ The endpoints the shipped feature actually calls:| `GET /v1/chats/{chatID}/messages/{messageID}` | The outbox's confirmation fallback || `POST /v1/chats/{chatID}/messages` | The one send call, reached only from the outbox || `PATCH /v1/chats/{chatID}` | The Archive and Low priority rail controls |+| `POST /v1/chats/{chatID}/read` | Optional read receipts, off by default and consent-gated || `GET`/`HEAD /v1/assets/serve` | The attachment mirror — the stream and its size pre-flight || `WS /v1/ws` | The realtime transport || `/.well-known/oauth-authorization-server` and the endpoints it advertises | Connect and disconnect |`beeperClient.js` wraps more of the API than the features currently reach — chat and message-search, read/unread state, reactions, edit and delete, `POST /v1/assets/download`, and the+search, unread state, reactions, edit and delete, `POST /v1/assets/download`, and thesingle-chat GET all have wrappers and tests but no caller in a shipped feature path.Live verification against a real instance was done on **Beeper Desktop 4.3.89**; the@@ -436,12 +437,20 @@ its own `COALESCE(last_activity, created_at)`, and as unread again the moment newith no separate bookkeeping. Because the comparison happens at read time against a column thesweep never touches, the watermark survives every sweep by construction rather than by racing one.-**This never writes to Beeper.** `POST /api/beeper/conversations/:id/seen` is a pure local update —-no `PATCH`, no read receipt, nothing that reaches the source network or shows up on another device-signed into the same account. A settings toggle to *also* send a real read receipt through Beeper's-own API is deliberately out of scope for this change; `markConversationSeen` carries a `TODO(#83)`-at the seam where that PATCH-then-mirror write would go, gated behind its own consent step and-defaulting off, the same way the Archive and Low priority rail controls are wired today.+**Read receipts are off by default.** Opening a thread only updates its local watermark+unless **Send read receipts to Beeper** has been enabled in settings after the explicit consent+step. With that opt-in, opening a thread with unseen activity also makes a best-effort read+receipt call; a Beeper failure does not undo the local seen state.++### Later scope++The **Later** rail button shows conversations whose mirrored Beeper snooze deadline is still+in the future. Snoozes are set or cleared in Beeper Desktop; this scope does not create a separate+PortOS snooze state. The existing sync sweep refreshes snooze state even when a conversation has+no new messages. Older Desktop versions that omit snooze state produce an empty Later list.+Expired deadlines are excluded when the list refreshes through the existing sweep/invalidation+flow. Search, unread filtering, saved scopes, pagination, and shared `?scope=later` links work+with this scope. Other scopes keep their existing filters.### Attachments@@ -688,7 +697,7 @@ its attachments, the token, and anything on the Socket.IO relay.| `GET` | `/api/beeper/status` | The status card's read model: token presence/expiry/provenance/`tokenScopes` (array of strings, `[]` when unknown — a pasted token, fork issue #78), a cached reachability probe, the account roster, realtime state, outbox breaker, sweep progress (`sweep: { running, startedAt, finishedAt, reason, accountsDone, accountsTotal, chats, messages }`, fork issue #80) || `POST` | `/api/beeper/status/check` | Live uncached probe with a coded error per failure mode || `POST` | `/api/beeper/sync` | Run one watermark-bounded sweep now; a sweep already in flight reports `skipped: true` |-| `GET` | `/api/beeper/conversations` | Rail list for one scope (network, unread-only, archived, low-priority), cursor-paginated |+| `GET` | `/api/beeper/conversations` | Rail list for one scope (network, unread-only, archived, low-priority, snoozed, search), cursor-paginated || `GET` | `/api/beeper/networks` | The rail's scope list, derived from the mirror || `GET` | `/api/beeper/conversations/:id` | One conversation with its mirrored participant subset; 404 at `severity: 'warning'` for a stale deep link || `GET` | `/api/beeper/conversations/:id/messages` | Cursor-paginated messages, newest first |diff --git a/server/lib/db/schema/beeper.js b/server/lib/db/schema/beeper.jsindex b69cb63106..270fa223e8 100644--- a/server/lib/db/schema/beeper.js+++ b/server/lib/db/schema/beeper.js@@ -84,6 +84,7 @@ export const beeperDdl = [last_activity TIMESTAMPTZ,unread_count INTEGER NOT NULL DEFAULT 0,seen_at TIMESTAMPTZ,+ snooze_until TIMESTAMPTZ,created_at TIMESTAMPTZ DEFAULT NOW(),updated_at TIMESTAMPTZ DEFAULT NOW(),UNIQUE (account_id, source_chat_id)@@ -108,6 +109,8 @@ export const beeperDdl = [// settings toggle to also send one is out of scope here (see the TODO on// `markConversationSeen`).`ALTER TABLE beeper_conversations ADD COLUMN IF NOT EXISTS seen_at TIMESTAMPTZ`,+ // Beeper owns snooze state. NULL also covers older Desktop API versions.+ `ALTER TABLE beeper_conversations ADD COLUMN IF NOT EXISTS snooze_until TIMESTAMPTZ`,// `idx_beeper_conversations_account_activity (account_id, last_activity DESC)`// served no query: listConversations (services/beeperConversations.js) has// no account_id filter, and its ORDER BY / keyset walk sorts ondiff --git a/server/lib/mediaValidation.js b/server/lib/mediaValidation.jsindex 6196f92992..3494cf850c 100644--- a/server/lib/mediaValidation.js+++ b/server/lib/mediaValidation.js@@ -528,6 +528,7 @@ export const beeperScopeInputSchema = z.object({network: z.string().trim().min(1).max(200).optional(),archived: z.boolean().optional(),lowPriority: z.boolean().optional(),+ snoozed: z.boolean().optional(),unreadOnly: z.boolean().optional(),search: z.string().trim().max(200).optional(),}).strict(),diff --git a/server/routes/beeper.js b/server/routes/beeper.jsindex c8649f635e..ec827a7107 100644--- a/server/routes/beeper.js+++ b/server/routes/beeper.js@@ -232,6 +232,7 @@ const conversationListQuerySchema = z.object({unreadOnly: queryBoolean,archived: queryBoolean,lowPriority: queryBoolean,+ snoozed: queryBoolean,search: z.string().trim().max(200).optional(),limit: z.coerce.number().int().min(1).max(200).optional(),cursor: z.string().max(500).optional(),diff --git a/server/routes/beeper.test.js b/server/routes/beeper.test.jsindex 99de624ef1..161b445c86 100644--- a/server/routes/beeper.test.js+++ b/server/routes/beeper.test.js@@ -572,6 +572,13 @@ describe('GET /api/beeper/outbox and the breaker reset', () => {const CONV_ID = '11111111-1111-4111-8111-111111111111';describe('GET /api/beeper/conversations — filters', () => {+ it('validates and forwards the Later filter', async () => {+ vi.mocked(listConversations).mockResolvedValue({ conversations: [], nextCursor: null });+ const app = buildApp();+ expect((await request(app).get('/api/beeper/conversations?snoozed=true')).status).toBe(200);+ expect(listConversations).toHaveBeenCalledWith({ snoozed: true });+ expect((await request(app).get('/api/beeper/conversations?snoozed=invalid')).status).toBe(400);+ });beforeEach(() => {vi.clearAllMocks();vi.mocked(listConversations).mockResolvedValue({ conversations: [], nextCursor: null });@@ -918,7 +925,7 @@ describe('POST /api/beeper/outbox/:id/reconcile', () => {describe('saved Beeper scopes routes', () => {let settings;- const input = { name: 'Example unread scope', filters: { network: 'signal', unreadOnly: true, archived: false } };+ const input = { name: 'Example unread scope', filters: { network: 'signal', unreadOnly: true, archived: false, snoozed: true } };beforeEach(() => {settings = { beeper: { enabled: true, sendReadReceipts: false }, unrelated: 'preserved' };vi.mocked(getSettings).mockImplementation(async () => settings);diff --git a/server/services/beeperConversations.js b/server/services/beeperConversations.jsindex 6ac28c6c0b..049329d301 100644--- a/server/services/beeperConversations.js+++ b/server/services/beeperConversations.js@@ -136,6 +136,7 @@ function shapeConversation(row) {isArchived: row.is_archived === true,isLowPriority: row.is_low_priority === true,isMuted: row.is_muted === true,+ snoozeUntil: toIso(row.snooze_until),lastActivity: toIso(row.last_activity),unreadCount: isSeenLocally(row) ? 0 : (Number(row.unread_count) || 0),// `null` = this conversation has no mirrored message yet, which is@@ -271,7 +272,7 @@ async function attachParticipants(conversations, { cap = LIST_PARTICIPANT_CAP }* happens to choose (audit cluster 06, indexes and query plans).*/export async function listConversations({- network, unreadOnly, archived, lowPriority, search, limit, cursor,+ network, unreadOnly, archived, lowPriority, snoozed, search, limit, cursor,} = {}) {const pageSize = clampLimit(limit, DEFAULT_CONVERSATION_LIMIT, MAX_CONVERSATION_LIMIT);const params = [];@@ -295,6 +296,11 @@ export async function listConversations({where.push(`c.is_low_priority = $${params.length}`);}+ if (typeof snoozed === 'boolean') {+ const activeSnooze = '(c.snooze_until IS NOT NULL AND c.snooze_until > NOW())';+ where.push(snoozed ? activeSnooze : `NOT ${activeSnooze}`);+ }+// Title search: a case-insensitive substring match with LIKE metacharacters// escaped, so a query of `50%` finds "50%" rather than everything.const term = typeof search === 'string' ? search.trim() : '';diff --git a/server/services/beeperConversations.test.js b/server/services/beeperConversations.test.jsindex ca2bd5b7b6..e08b2e8d50 100644--- a/server/services/beeperConversations.test.js+++ b/server/services/beeperConversations.test.js@@ -80,6 +80,17 @@ const callFor = (fragment) => vi.mocked(query).mock.calls.find(([sql]) => flat(sbeforeEach(() => vi.clearAllMocks());describe('listConversations — filters are tri-state by omission', () => {+ it('filters Later by a future snooze deadline and exposes its mirrored value', async () => {+ const snoozeUntil = '2030-09-01T00:00:00.000Z';+ vi.mocked(query).mockResolvedValue({ rows: [] });+ vi.mocked(query).mockResolvedValueOnce({ rows: [conversationRow({ snooze_until: snoozeUntil })] });+ const page = await listConversations({ snoozed: true });+ expect(flat(vi.mocked(query).mock.calls[0][0])).toContain('c.snooze_until IS NOT NULL AND c.snooze_until > NOW()');+ expect(page.conversations[0].snoozeUntil).toBe(snoozeUntil);+ vi.mocked(query).mockClear();+ await listConversations({ snoozed: false });+ expect(flat(vi.mocked(query).mock.calls[0][0])).toContain('NOT (c.snooze_until IS NOT NULL AND c.snooze_until > NOW())');+ });it('applies no archived/low-priority predicate when the caller omits them', async () => {vi.mocked(query).mockResolvedValue({ rows: [] });await listConversations({});diff --git a/server/services/beeperSync.js b/server/services/beeperSync.jsindex 70d057a3fb..375cca4a45 100644--- a/server/services/beeperSync.js+++ b/server/services/beeperSync.js@@ -219,6 +219,7 @@ export function normalizeChatRow(chat) {isArchived: chat?.isArchived === true,isLowPriority: chat?.isLowPriority === true,isMuted: chat?.isMuted === true,+ snoozeUntil: toIsoOrNull(chat?.snooze?.snoozeUntil),lastActivity: toIsoOrNull(chat?.lastActivity),unreadCount: Number.isFinite(chat?.unreadCount) ? Math.max(0, Math.trunc(chat.unreadCount)) : 0,};@@ -430,18 +431,18 @@ async function refreshAccounts(clientOptions) {async function upsertConversation(chat) {const result = await query(`INSERT INTO beeper_conversations (account_id, network, source_chat_id, title, type, is_group,- is_pinned, is_archived, is_low_priority, is_muted, last_activity, unread_count)- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)+ is_pinned, is_archived, is_low_priority, is_muted, last_activity, unread_count, snooze_until)+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)ON CONFLICT (account_id, source_chat_id) DO UPDATE SET network = EXCLUDED.network,title = EXCLUDED.title, type = EXCLUDED.type, is_group = EXCLUDED.is_group,is_pinned = EXCLUDED.is_pinned, is_archived = EXCLUDED.is_archived,is_low_priority = EXCLUDED.is_low_priority, is_muted = EXCLUDED.is_muted,last_activity = COALESCE(EXCLUDED.last_activity, beeper_conversations.last_activity),- unread_count = EXCLUDED.unread_count, updated_at = NOW()+ unread_count = EXCLUDED.unread_count, snooze_until = EXCLUDED.snooze_until, updated_at = NOW()RETURNING id`,[chat.accountId, chat.network, chat.sourceChatId, chat.title, chat.type, chat.isGroup,- chat.isPinned, chat.isArchived, chat.isLowPriority, chat.isMuted, chat.lastActivity, chat.unreadCount,+ chat.isPinned, chat.isArchived, chat.isLowPriority, chat.isMuted, chat.lastActivity, chat.unreadCount, chat.snoozeUntil,],);return result.rows[0]?.id ?? null;@@ -740,7 +741,24 @@ async function sweepAccount(account, clientOptions, observedAt, personIndex) {for (const chat of page.items) {const stored = cursors.get(String(chat?.id ?? ''));- if (!chatNeedsSweep(chat, stored)) continue;+ if (!chatNeedsSweep(chat, stored)) {+ // Snooze state can change without message activity. Refresh it on every+ // enumerated chat without refetching history or rewriting unchanged rows.+ const normalized = normalizeChatRow(chat);+ if (normalized.accountId && normalized.sourceChatId) {+ // eslint-disable-next-line no-await-in-loop -- one mirrored chat at a time+ await query(+ `UPDATE beeper_conversations SET snooze_until = $3, updated_at = NOW()+ WHERE account_id = $1 AND source_chat_id = $2+ AND snooze_until IS DISTINCT FROM $3::timestamptz`,+ [normalized.accountId, normalized.sourceChatId, normalized.snoozeUntil],+ ).catch((err) => {+ failedChats++;+ console.error(`❌ ${LOG_PREFIX}: chat state refresh failed: ${err.message}`);+ });+ }+ continue;+ }// eslint-disable-next-line no-await-in-loop -- one chat at a time; each is its own transactionconst result = await sweepChat({chat, stored, clientOptions, observedAt, personIndex,diff --git a/server/services/beeperSync.test.js b/server/services/beeperSync.test.jsindex c38d151513..1440f6ca9e 100644--- a/server/services/beeperSync.test.js+++ b/server/services/beeperSync.test.js@@ -1253,3 +1253,26 @@ describe('stored-message event reconciliation', () => {expect(txWrites).toEqual([]);});});+++describe('Later scope mirror', () => {+ it('mirrors and clears snoozes on caught-up chats without rereading message history', async () => {+ const lastActivity = '2026-09-01T00:00:00.000Z';+ const snoozeUntil = '2030-09-01T00:00:00.000Z';+ storedCursorRows = [{ chat_id: 'chat-later', cursor: 'cursor-later', last_activity: lastActivity }];+ const chat = { id: 'chat-later', accountID: 'acct-a', network: 'Example Net', lastActivity,+ snooze: { snoozeUntil } };+ installFetch({ chatPages: [{ items: [chat], hasMore: false }] });+ await runBeeperSweep({ reason: 'manual' });+ let writes = dbCalls.filter(({ text }) => text.includes('UPDATE beeper_conversations SET snooze_until'));+ expect(writes.at(-1).text).toContain('snooze_until IS DISTINCT FROM $3::timestamptz');+ expect(writes.at(-1).params).toEqual(['acct-a', 'chat-later', snoozeUntil]);+ expect(messageRequests()).toHaveLength(0);++ installFetch({ chatPages: [{ items: [{ ...chat, snooze: null }], hasMore: false }] });+ await runBeeperSweep({ reason: 'manual' });+ writes = dbCalls.filter(({ text }) => text.includes('UPDATE beeper_conversations SET snooze_until'));+ expect(writes.at(-1).params[2]).toBeNull();+ expect(messageRequests()).toHaveLength(0);+ });+});