Skip to content

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

feat: working conversation search in the Beeper surface (#9985)

Adam Eivy8066ddff0de6
diff --git a/client/src/components/messages/BeeperTab.test.jsx b/client/src/components/messages/BeeperTab.test.jsx
index c7c7504e6f..c62b8bbe31 100644
--- a/client/src/components/messages/BeeperTab.test.jsx
+++ b/client/src/components/messages/BeeperTab.test.jsx
@@ -226,6 +226,32 @@ describe('deep linking', () => {
});
});
+describe('conversation search', () => {
+ it('reopens a shared ?q= link with the search box open and the term sent to the server', async () => {
+ renderTab('/messages/beeper?q=alice');
+ expect(await screen.findByLabelText('Search conversations by name')).toHaveValue('alice');
+ await waitFor(() => expect(api.getBeeperConversations).toHaveBeenCalledWith(
+ { search: 'alice', archived: false, lowPriority: false },
+ { silent: true },
+ ));
+ });
+
+ it('opens from the toolbar, refetches with the typed term, and clearing it drops the filter', async () => {
+ renderTab('/messages/beeper');
+ fireEvent.click(await screen.findByRole('button', { name: 'Search conversations' }));
+ fireEvent.change(screen.getByLabelText('Search conversations by name'), { target: { value: 'bob' } });
+ await waitFor(() => expect(api.getBeeperConversations).toHaveBeenLastCalledWith(
+ { search: 'bob', archived: false, lowPriority: false },
+ { silent: true },
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Clear search' }));
+ await waitFor(() => expect(api.getBeeperConversations).toHaveBeenLastCalledWith(
+ { archived: false, lowPriority: false },
+ { silent: true },
+ ));
+ });
+});
+
describe('rendering at every install size', () => {
it('renders with zero conversations, and says an empty list is often correct when networks are mirrored and the list loaded fine', async () => {
api.getBeeperNetworks.mockResolvedValue({ networks: [NINE_NETWORKS[0]] });
@@ -492,11 +518,11 @@ describe('the pinned grid is Beeper’s own isPinned, mirrored', () => {
});
describe('unimplemented controls are absent rather than inert', () => {
- it('renders no Requests, Later, add-scope, overflow, search or new-conversation control', async () => {
+ it('renders no Requests, Later, add-scope, overflow or new-conversation control', async () => {
renderTab();
await screen.findByText('Nothing here');
- for (const label of ['Requests', 'Later', 'Add scope', 'More scope options', 'Search conversations', 'New conversation']) {
+ for (const label of ['Requests', 'Later', 'Add scope', 'More scope options', 'New conversation']) {
expect(screen.queryByRole('button', { name: label })).toBeNull();
}
});
diff --git a/client/src/components/messages/beeper/BeeperChatSurface.jsx b/client/src/components/messages/beeper/BeeperChatSurface.jsx
index f0ebea6b59..dd4b451b48 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, Filter, Inbox, Loader2,
- RefreshCw, Settings, TrendingDown,
+ RefreshCw, Search, Settings, TrendingDown, X,
} from 'lucide-react';
import NetworkLogo, { networkLabel } from './BeeperNetworkLogo';
import BeeperThread from './BeeperThread';
@@ -30,7 +30,7 @@ import * as api from '../../../services/api';
* roster and never the reference's user-curated saved scopes at mixed grain
* (a Discord-DMs chip beside a single-server chip). Those are deferred.
* - **`Archive` and `Low priority` are wired**, because `isArchived` and
- * `isLowPriority` are real fields on every chat row. Requests, Later, add-scope, search and
+ * `isLowPriority` are real fields on every chat row. Requests, Later, add-scope and
* new conversation are omitted until they work (#9985) — an inert control
* that looks live is worse than an absent one.
* - **The pinned grid is Beeper's own `isPinned`, mirrored.** PortOS never
@@ -49,7 +49,7 @@ import * as api from '../../../services/api';
*/
// Fixed system scopes, in the reference's own order. Requests, Later, scope
-// management, search and new conversation are omitted until implemented
+// management and new conversation are omitted until implemented
// (tracked in the Beeper enhancements issue, #9985).
const SYSTEM_SCOPES = [
{ id: 'inbox', label: 'Inbox', icon: Inbox },
@@ -84,8 +84,8 @@ const INVALIDATION_MAX_WAIT_MS = 2000;
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) {
- const base = unreadOnly ? { unreadOnly: true } : {};
+function filtersForScope(scope, unreadOnly, search) {
+ const base = { ...(unreadOnly ? { unreadOnly: true } : {}), ...(search ? { search } : {}) };
if (scope === 'archive') return { ...base, archived: true };
if (scope === 'low') return { ...base, lowPriority: true };
if (typeof scope === 'string' && scope.startsWith(NETWORK_SCOPE_PREFIX)) {
@@ -350,6 +350,8 @@ export default function BeeperChatSurface({
const scopeParam = searchParams.get('scope') || 'inbox';
const unreadOnly = searchParams.get('unread') === '1';
+ const search = (searchParams.get('q') || '').trim();
+ const [searchOpen, setSearchOpen] = useState(Boolean(search));
const [networks, setNetworks] = useState([]);
const [conversations, setConversations] = useState([]);
@@ -389,7 +391,7 @@ export default function BeeperChatSurface({
: 'inbox';
const activeNetwork = scopeNetwork(scope);
const unified = !activeNetwork;
- const filters = useMemo(() => filtersForScope(scope, unreadOnly), [scope, unreadOnly]);
+ const filters = useMemo(() => filtersForScope(scope, unreadOnly, search), [scope, unreadOnly, search]);
const setParam = useCallback((key, value) => {
setSearchParams((prev) => {
@@ -889,13 +891,26 @@ export default function BeeperChatSurface({
than an absent one — the file's own governing rule. */}
<span className="truncate">{scopeLabel}</span>
</span>
+ <button
+ type="button"
+ onClick={() => {
+ if (searchOpen) setParam('q', null);
+ setSearchOpen(!searchOpen);
+ }}
+ title="Search conversations"
+ aria-label="Search conversations"
+ aria-pressed={searchOpen}
+ className={`ml-auto inline-flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1.5 ${searchOpen ? 'bg-port-accent text-port-bg' : 'text-gray-500 hover:text-white'}`}
+ >
+ <Search size={15} />
+ </button>
<button
type="button"
onClick={() => setParam('unread', unreadOnly ? null : '1')}
title="Unread only"
aria-label="Unread only"
aria-pressed={unreadOnly}
- className={`ml-auto inline-flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1.5 ${unreadOnly ? 'bg-port-accent text-port-bg' : 'text-gray-500 hover:text-white'}`}
+ className={`inline-flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1.5 ${unreadOnly ? 'bg-port-accent text-port-bg' : 'text-gray-500 hover:text-white'}`}
>
<Filter size={15} />
</button>
@@ -911,6 +926,30 @@ export default function BeeperChatSurface({
</button>
</div>
+ {searchOpen && (
+ <div className="relative shrink-0 px-3 pb-2">
+ <input
+ type="search"
+ value={search}
+ onChange={(event) => setParam('q', event.target.value || null)}
+ placeholder="Search conversations"
+ aria-label="Search conversations by name"
+ autoFocus
+ className="w-full rounded border border-port-border bg-port-bg px-2 py-1.5 pr-8 text-xs text-white placeholder:text-gray-500 focus:border-port-accent focus:outline-none"
+ />
+ {search && (
+ <button
+ type="button"
+ onClick={() => setParam('q', null)}
+ aria-label="Clear search"
+ className="absolute right-4 top-1/2 -translate-y-1/2 -mt-1 text-gray-500 hover:text-white"
+ >
+ <X size={12} />
+ </button>
+ )}
+ </div>
+ )}
+
{listError && (
<p role="alert" className="mx-3 mb-2 rounded border border-port-error/40 bg-port-error/10 px-2 py-1.5 text-[11px] text-port-error">
{listError}
diff --git a/client/src/services/apiBeeper.js b/client/src/services/apiBeeper.js
index e5724f1c4d..d2ec32ba3c 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, limit, cursor,
+ network, unreadOnly, archived, lowPriority, search, limit, cursor,
} = {}, options = {}) =>
- request(`/beeper/conversations${queryString({ network, unreadOnly, archived, lowPriority, limit, cursor })}`, options);
+ request(`/beeper/conversations${queryString({ network, unreadOnly, archived, lowPriority, search, limit, cursor })}`, options);
export const getBeeperConversation = (conversationId, options = {}) =>
request(`/beeper/conversations/${encodeURIComponent(conversationId)}`, options);
diff --git a/server/routes/beeper.js b/server/routes/beeper.js
index e5e4cd470d..a12d14771d 100644
--- a/server/routes/beeper.js
+++ b/server/routes/beeper.js
@@ -185,6 +185,7 @@ const conversationListQuerySchema = z.object({
unreadOnly: queryBoolean,
archived: queryBoolean,
lowPriority: queryBoolean,
+ search: z.string().trim().max(200).optional(),
limit: z.coerce.number().int().min(1).max(200).optional(),
cursor: z.string().max(500).optional(),
}).strict();
diff --git a/server/routes/beeper.test.js b/server/routes/beeper.test.js
index 7014c9b75d..173860f961 100644
--- a/server/routes/beeper.test.js
+++ b/server/routes/beeper.test.js
@@ -593,6 +593,15 @@ describe('GET /api/beeper/conversations — filters', () => {
expect(listConversations).not.toHaveBeenCalled();
});
+ it('trims and forwards the title search, rejecting an oversized one', async () => {
+ await request(buildApp()).get('/api/beeper/conversations?search=%20alice%20');
+ expect(listConversations).toHaveBeenCalledWith({ search: 'alice' });
+ vi.mocked(listConversations).mockClear();
+ const res = await request(buildApp()).get(`/api/beeper/conversations?search=${'a'.repeat(201)}`);
+ expect(res.status).toBe(400);
+ expect(listConversations).not.toHaveBeenCalled();
+ });
+
it('forwards the pagination cursor untouched', async () => {
vi.mocked(listConversations).mockResolvedValue({ conversations: [], nextCursor: 'next-page-token' });
const res = await request(buildApp()).get('/api/beeper/conversations?cursor=abc123');
diff --git a/server/services/beeperConversations.js b/server/services/beeperConversations.js
index 71a9fac145..3a08155810 100644
--- a/server/services/beeperConversations.js
+++ b/server/services/beeperConversations.js
@@ -270,7 +270,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, limit, cursor,
+ network, unreadOnly, archived, lowPriority, search, limit, cursor,
} = {}) {
const pageSize = clampLimit(limit, DEFAULT_CONVERSATION_LIMIT, MAX_CONVERSATION_LIMIT);
const params = [];
@@ -294,6 +294,14 @@ export async function listConversations({
where.push(`c.is_low_priority = $${params.length}`);
}
+ // 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() : '';
+ if (term) {
+ params.push(`%${term.replace(/[\\%_]/g, '\\$&')}%`);
+ where.push(`c.title ILIKE $${params.length}`);
+ }
+
const decoded = decodeCursor(cursor, { idPattern: UUID_PATTERN });
if (decoded) {
params.push(decoded.ts, decoded.id);
diff --git a/server/services/beeperConversations.test.js b/server/services/beeperConversations.test.js
index 6f96538957..a64b5ae2d4 100644
--- a/server/services/beeperConversations.test.js
+++ b/server/services/beeperConversations.test.js
@@ -111,6 +111,22 @@ describe('listConversations — filters are tri-state by omission', () => {
});
});
+describe('listConversations — title search', () => {
+ it('binds a case-insensitive substring pattern with LIKE metacharacters escaped', async () => {
+ vi.mocked(query).mockResolvedValue({ rows: [] });
+ await listConversations({ search: ' 50%_off ' });
+ const [sql, params] = vi.mocked(query).mock.calls[0];
+ expect(flat(sql)).toContain('c.title ILIKE $1');
+ expect(params).toEqual(['%50\\%\\_off%', 51]);
+ });
+
+ it('applies no title predicate for a blank search', async () => {
+ vi.mocked(query).mockResolvedValue({ rows: [] });
+ await listConversations({ search: ' ' });
+ expect(flat(vi.mocked(query).mock.calls[0][0])).not.toContain('ILIKE');
+ });
+});
+
describe('listConversations — keyset pagination', () => {
it('returns a nextCursor only when a further page exists, and resumes from it', async () => {
const rows = Array.from({ length: 3 }, (_, i) => conversationRow({