The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
Search without hits as a list line, player and summary in one card, no key hints on touch (PR 1935)
Janikc0ec20a4e9eb
diff --git a/apps/web/src/app.css b/apps/web/src/app.cssindex 373fca39..f5ed2082 100644--- a/apps/web/src/app.css+++ b/apps/web/src/app.css@@ -1074,6 +1074,15 @@ a.auth-switch {grid-template-columns: var(--ib-columns);white-space: nowrap;}+/* A search without hits (SearchEmpty, ui/listPage.tsx): the list's grey line right under the headings, where the+ first column starts. */+.ib-list .ib-search-none {+ width: 100%;+ max-width: var(--w-list);+ margin: 0 auto;+ box-sizing: border-box;+ padding: 10px var(--gutter) 0 var(--row-lead);+}.ib-cols > span {min-width: 0;overflow: hidden;@@ -2671,6 +2680,26 @@ button.k-link:disabled {color: var(--ink-muted);}+/* Call view: the recording player and the summary as one raised card (CallView), the player on top with one hairline+ under it. The parts lose their own card look; a call with neither draws no card. */+.cv-sum.k-card {+ padding: 0;+ gap: 0;+}+.cv-sum:empty {+ display: none;+}+.cv-sum > .vn,+.cv-sum > .sumcard {+ background: transparent;+ box-shadow: none;+ border: 0;+ border-radius: 0;+}+.cv-sum > .vn + .sumcard {+ border-top: 1px solid var(--line);+}+/* Call view: where the player would be, when the workspace keeps no recordings. */.cv-no-recording {margin: 0;diff --git a/apps/web/src/call/CallView.tsx b/apps/web/src/call/CallView.tsxindex 9ef25dd6..66ecf7f4 100644--- a/apps/web/src/call/CallView.tsx+++ b/apps/web/src/call/CallView.tsx@@ -16,6 +16,7 @@ import {import { useCallAssistantName, useContact } from '../store.tsx'import { firstName, memberAvatar, memberLabel, useMember } from '../team/members.ts'import { clock, dateTimeLabel, callDuration, parseTs, whenLabel } from '../time.ts'+import { Card } from '../ui/form.tsx'import { Avatar, Button, Icon } from '../ui/kit.tsx'import { LiveIndicator } from '../ui/LiveIndicator.tsx'import { registerContactPanel } from './contactPanel.ts'@@ -187,8 +188,9 @@ function Bar({ call, index, count, menu, ...on }: BarProps) {/*** A phone's bottom bar (below 720 px, app.css): the next thing to do with the call within thumb's reach, Call <name>- * back (only when the number is known and not spam or blocked, callBackNumber) and Done. The top bar's Done then- * hides. Not for a live call or one that is done.+ * back (only when the number is known and not spam or blocked, callBackNumber; outlined, in the wide slot) and Done+ * (the black primary, as in the top bar on wide windows). The top bar's Done then hides. Not for a live call or one+ * that is done.*/function PhoneFoot({call,@@ -207,7 +209,7 @@ function PhoneFoot({<div className="cv-foot" role="toolbar" aria-label={t('call.foot.label')}>{canCall && (<Button- variant="primary"+ variant="secondary"icon="phone-out"className="cv-foot-call"title={t('common.withKey', { label: t('inbox.row.callBackTitle'), key: 'C' })}@@ -217,7 +219,7 @@ function PhoneFoot({</Button>)}<Button- variant={canCall ? 'secondary' : 'primary'}+ variant="primary"className="cv-foot-done"title={t('common.withKey', { label: t('shell.command.markDone'), key: 'E' })}onClick={onDone}@@ -456,9 +458,15 @@ export function CallView({ call, segments, search, side, repeatCount = 1, canRevonOpenContact={openContact}/>{live && <LiveCard call={call} segments={segments} assistantName={assistant} />}- {!live && call.recording_key && <RecordingPlayer callId={call.id} callDurationSec={call.duration_sec} />}{!live && !call.recording_key && call.source !== 'sample' && <RecordingNotKept />}- <SummaryCard call={call} />+ {/* Player and summary are one raised card, the player on top with a hairline under it; a call with only+ one of them shows that part alone, with neither the card is not drawn (.cv-sum:empty, app.css). */}+ <Card className="cv-sum">+ {!live && call.recording_key && (+ <RecordingPlayer callId={call.id} callDurationSec={call.duration_sec} />+ )}+ <SummaryCard call={call} />+ </Card>{canReview && <EvaluationCard call={call} />}<BookingCards callId={call.id} />{turns ? (diff --git a/apps/web/src/contacts/Contacts.tsx b/apps/web/src/contacts/Contacts.tsxindex 7ada481d..3c4fa5e8 100644--- a/apps/web/src/contacts/Contacts.tsx+++ b/apps/web/src/contacts/Contacts.tsx@@ -7,7 +7,7 @@ import { parseTs, timeLabel } from '../time.ts'import { Button, cx } from '../ui/kit.tsx'import { Loading, SkeletonRows, useLoading, useLoadState } from '../ui/LoadStates.tsx'import { ColumnHeads } from '../ui/list.tsx'-import { PageTitle, SearchButton, SearchField, ShortcutHints, ZeroState } from '../ui/listPage.tsx'+import { PageTitle, SearchButton, SearchEmpty, SearchField, ShortcutHints, ZeroState } from '../ui/listPage.tsx'import { ContactDetail } from './ContactDetail.tsx'import './contacts.css'import { ImportContacts } from './ImportContacts.tsx'@@ -209,7 +209,12 @@ export function Contacts({ menu, toast, openCall, runUndoable }: Props) {skeleton={<SkeletonRows rows={8} columns={withCompany ? 5 : 4} />}/>) : (- empty && <ZeroState {...contactsEmptyCopy(query)} />+ empty &&+ (query.trim() ? (+ <SearchEmpty message={contactsEmptyCopy(query).title} onClear={page.clearQuery} />+ ) : (+ <ZeroState {...contactsEmptyCopy(query)} />+ )))}</div><Hints open={!!opened} />diff --git a/apps/web/src/contacts/useContactsPage.ts b/apps/web/src/contacts/useContactsPage.tsindex ffd71571..1be34c40 100644--- a/apps/web/src/contacts/useContactsPage.ts+++ b/apps/web/src/contacts/useContactsPage.ts@@ -86,6 +86,11 @@ export function useContactsPage({ remove }: { remove: (contactId: string) => voifocusSearch()}const closeSearch = () => update({ searching: false, query: '', cursorId: null })+ /** Clear search on a search without hits: the field stays open, empty, with the caret in it. */+ const clearQuery = () => {+ flushSync(() => update({ query: '', cursorId: null }))+ focusSearch()+ }function step(by: number) {const i = cursor ? rows.indexOf(cursor) : -1const next = rows[Math.max(0, Math.min(rows.length - 1, i + by))]@@ -120,6 +125,7 @@ export function useContactsPage({ remove }: { remove: (contactId: string) => voisearching: place.searching,openSearch,closeSearch,+ clearQuery,creating: place.creating,startCreate,stopCreate: () => update({ creating: false }),diff --git a/apps/web/src/inbox/Inbox.tsx b/apps/web/src/inbox/Inbox.tsxindex 1831c6df..5a1257d9 100644--- a/apps/web/src/inbox/Inbox.tsx+++ b/apps/web/src/inbox/Inbox.tsx@@ -1,6 +1,7 @@import type { Call, TranscriptSegment } from '@linedesk/db/types'import { useVirtualizer } from '@tanstack/react-virtual'import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type Ref } from 'react'+import { flushSync } from 'react-dom'import type { SegmentsByCall } from '../call/segments.ts'import type { CallGroups, InboxTab } from '../inbox-model.ts'import { useAssistantName, useContact } from '../store.tsx'@@ -15,6 +16,7 @@ import { InboxHead, type InboxHeadProps } from './InboxHead.tsx'import { InboxEmpty } from './InboxEmpty.tsx'import { listFrame } from './listFrame.ts'import { Row, type RowHandlers, rowLabel } from './Row.tsx'+import { focusInboxSearch } from './useInboxView.ts'import { type MessageKey, msg } from '@linedesk/i18n'import { useT } from '@linedesk/i18n/react'@@ -266,6 +268,11 @@ export function Inbox({})// Nothing in the view, once the skeleton (if it showed) has gone.const empty = frame.empty && !waiting+ /** A search without hits: Clear search empties the field and puts the caret back into it. */+ const clearSearch = () => {+ flushSync(() => rest.onSearchChange(''))+ focusInboxSearch()+ }// Screen readers hear the call under the cursor as J and K move it (the rows themselves never take focus).const cursorCall = cursorIndex >= 0 ? list[cursorIndex] : undefinedconst cursorContact = useContact(cursorCall?.contact_id ?? null)@@ -356,6 +363,7 @@ export function Inbox({handledCount={counts.ai}hasAnyCalls={Object.values(counts).some(n => n > 0)}quiet={frame.firstCallLine}+ onClearSearch={clearSearch}/>))}diff --git a/apps/web/src/inbox/InboxEmpty.test.tsx b/apps/web/src/inbox/InboxEmpty.test.tsxindex 306f6221..44565f93 100644--- a/apps/web/src/inbox/InboxEmpty.test.tsx+++ b/apps/web/src/inbox/InboxEmpty.test.tsx@@ -63,8 +63,11 @@ describe('InboxEmpty', () => {expect(render({ tab: 'you', setup: 'connect' })).not.toContain('Connect your number')})- test('search with no hit says what was searched, in the same component', () => {- expect(render({ tab: 'ai', search: 'faucet' })).toContain('<h2>No call mentions “faucet”</h2>')+ test('search with no hit: one grey line under the headings with Clear search, no picture and no heading', () => {+ const html = render({ tab: 'ai', search: 'faucet' })+ expect(html).toBe(+ '<div class="ib-search-none" role="status"><p class="k-list-empty">No call mentions “faucet”. <button type="button" class="k-link">Clear search</button></p></div>',+ )})})diff --git a/apps/web/src/inbox/InboxEmpty.tsx b/apps/web/src/inbox/InboxEmpty.tsxindex 1d2a38bb..c3d67eb5 100644--- a/apps/web/src/inbox/InboxEmpty.tsx+++ b/apps/web/src/inbox/InboxEmpty.tsx@@ -3,7 +3,7 @@ import type { InboxTab } from '../inbox-model.ts'import { useRows } from '../store.tsx'import { appLink } from '../ui/AppLink.tsx'import { Kbd } from '../ui/kit.tsx'-import { ZeroState, type ZeroMark } from '../ui/listPage.tsx'+import { SearchEmpty, ZeroState, type ZeroMark } from '../ui/listPage.tsx'import { T } from '@linedesk/i18n/react'import { i18n } from '../i18n/index.tsx'import { CONNECT_NUMBER } from './goLive.ts'@@ -27,6 +27,8 @@ export type InboxEmptyProps = {/** The first-call line above the list already says what happens when a call comes in. */quiet?: booleansetup?: NoCallsStep+ /** Clear search on the line of a search without hits. */+ onClearSearch?: () => void}/**@@ -93,11 +95,13 @@ export function emptyCopy({}/**- * The one empty state of every inbox view and of search: the same picture, in the same place (the middle- * of the list, below the column headings), with the view's own words.+ * The one empty state of every inbox view: the same picture, in the same place (the middle of the list, below the+ * column headings), with the view's own words. A search without hits is no empty view: one grey line under the+ * headings with Clear search (SearchEmpty).*/export function InboxEmptyState(props: InboxEmptyProps) {const { title, line, mark } = emptyCopy(props)+ if (props.search) return <SearchEmpty message={title} onClear={props.onClearSearch ?? (() => {})} />return <ZeroState title={title} line={line} mark={mark} />}diff --git a/apps/web/src/inbox/useInboxView.ts b/apps/web/src/inbox/useInboxView.tsindex 496e06ca..57e6bddc 100644--- a/apps/web/src/inbox/useInboxView.ts+++ b/apps/web/src/inbox/useInboxView.ts@@ -1,6 +1,7 @@// What the inbox shows and what is selected: the view, the search, the list, the cursor and the open call.import type { Call } from '@linedesk/db/types'import { useEffect, useMemo } from 'react'+import { flushSync } from 'react-dom'import { useSegmentsByCall } from '../call/segments.ts'import {type CallGroups,@@ -18,6 +19,13 @@ import { SEARCH_INPUT_ID } from './InboxHead.tsx'import { matchesSearch } from './search.tsx'import { useCursor } from './useCursor.ts'+/** Put the caret into the search field, its text selected (rendered by then: the callers flush the render first). */+export function focusInboxSearch() {+ const el = document.getElementById(SEARCH_INPUT_ID) as HTMLInputElement | null+ el?.focus()+ el?.select()+}+/*** `me`: the signed-in member's user id (Assigned to me).* `impersonating`: an instance admin looks as this user; opening a call does not mark it read for them.@@ -111,15 +119,15 @@ export function useInboxView(nav.setView({ tab: next, search: null, member: next === 'member' ? forMember : null })setCursor(null)}+ // The field renders and takes the focus in the same task, so a key typed right after the click goes into it, not+ // to the inbox's shortcuts (as Contacts' search, useContactsPage).function openSearch() {- if (nav.callId) nav.closeCall()- else if (!onInbox) nav.go('calls')- nav.setView({ tab, search: search ?? '', member })- setTimeout(() => {- const el = document.getElementById(SEARCH_INPUT_ID) as HTMLInputElement | null- el?.focus()- el?.select()- }, 0)+ flushSync(() => {+ if (nav.callId) nav.closeCall()+ else if (!onInbox) nav.go('calls')+ nav.setView({ tab, search: search ?? '', member })+ })+ focusInboxSearch()}return {diff --git a/apps/web/src/styles.css b/apps/web/src/styles.cssindex 4242acf7..d004fdc4 100644--- a/apps/web/src/styles.css+++ b/apps/web/src/styles.css@@ -865,6 +865,9 @@ body { font-size: 13px; }step scrolls under it; the ⏎ hint only with a keyboard's fine pointer, never on a touch phone. */.ob-foot { position: sticky; bottom: 0; z-index: 1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; margin: -12px 0; background: var(--bg); box-shadow: 0 -10px 10px -2px var(--bg); }@media not ((hover: hover) and (pointer: fine)) { .ob-foot .k-kbds { display: none; } }+/* Touch screens: no key labels inside buttons (esc, ⏎, E): there is usually no keyboard to press them on. The+ tooltips keep their keys where a pointer hovers; the "Next time, press …" tips stay off too (shell/useToast.ts). */+@media (hover: none) and (pointer: coarse) { button .k-kbds { display: none; } }/* On a phone the long step count is out of sight only: screen readers still read it (the short one is aria-hidden). */@media (max-width: 719px) { .ob h1 { font-size: 23px; line-height: 29px; } .ob-row { grid-template-columns: minmax(0, 1fr) auto; } .ob-s { display: none; } .ob-count { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } .ob-top > b { display: none; } .ob-top .ws-mark { margin-right: auto; } .ob-count-short { display: inline; } .ob-top .ob-agent .ai-marks { display: none; } .ob-top .ob-agent .ai-spark { display: inline-block; } .ob-agent { min-width: 0; } .ob-agent .ai-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ob-top .ob-exit-full { display: none; } .ob-top .ob-exit-short { display: inline-flex; } .ob-count.ob-count-label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; display: inline; margin-left: 0; } }@@ -1552,7 +1555,7 @@ mark { background: rgb(250 204 21 / 0.38); color: inherit; border-radius: 2px; p.lvc-pill { margin-left: auto; font-size: 11.5px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--surface-hover); color: var(--ink-muted); }.lvc-note { margin: 0; font-size: 12.5px; color: var(--ink-muted); }.lvc-acts { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }-.sum-todo { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }+.sum-todo { display: grid; gap: 6px; }.k-typing { display: inline-flex; gap: 4px; align-items: center; padding: 10px 12px; }.k-typing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: k-typing 1.2s infinite; }.k-typing i:nth-child(2) { animation-delay: .2s; } .k-typing i:nth-child(3) { animation-delay: .4s; }diff --git a/apps/web/src/ui/listPage.test.tsx b/apps/web/src/ui/listPage.test.tsxindex 25b83c4b..9b538a5f 100644--- a/apps/web/src/ui/listPage.test.tsx+++ b/apps/web/src/ui/listPage.test.tsx@@ -2,7 +2,7 @@ import { renderToStaticMarkup } from 'react-dom/server'import { describe, expect, test } from 'vitest'import { contactsEmptyCopy } from '../contacts/model.ts'import { InboxEmptyState } from '../inbox/InboxEmpty.tsx'-import { PageTitle, SearchButton, SearchField, ShortcutHints, ZeroState } from './listPage.tsx'+import { PageTitle, SearchButton, SearchEmpty, SearchField, ShortcutHints, ZeroState } from './listPage.tsx'const noop = () => {}@@ -69,6 +69,12 @@ describe('list page frame', () => {expect(contacts).toContain('<p class="zero-greet">Everyone who calls shows up here.</p>')})+ test('a contact search without results: the list line with Clear search, like the inbox', () => {+ const html = renderToStaticMarkup(<SearchEmpty message={contactsEmptyCopy('sa').title} onClear={() => {}} />)+ expect(html).toContain('No contact matches “sa”. <button type="button" class="k-link">Clear search</button>')+ expect(html).not.toContain('zero')+ })+test('a contact search without results says so, with no second line', () => {expect(contactsEmptyCopy(' sa ')).toEqual({ title: 'No contact matches “sa”', line: null, mark: 'contact' })const html = renderToStaticMarkup(<ZeroState {...contactsEmptyCopy('sa')} />)diff --git a/apps/web/src/ui/listPage.tsx b/apps/web/src/ui/listPage.tsxindex 0d7f252a..68243ed4 100644--- a/apps/web/src/ui/listPage.tsx+++ b/apps/web/src/ui/listPage.tsx@@ -1,12 +1,14 @@// The frame of a full-window list page (the inbox views, Contacts): one header bar with the page's title// at the left and its actions and Search (/) at the right, which the search field replaces while it is// open; the column headings and rows below (ColumnHeads in list.tsx); one empty state in the middle of the-// list; the shortcut hints at the bottom. Styles: `.ib-head`, `.ib-search`, `.ib-mode`, `.zero`, `.ib-hint`-// in styles.css and app.css.+// list (a search without hits: one grey line under the headings instead); the shortcut hints at the bottom. Styles:+// `.ib-head`, `.ib-search`, `.ib-mode`, `.zero`, `.ib-search-none`, `.ib-hint` in styles.css and app.css.import type { ReactNode } from 'react'+import { LinkButton } from './AppLink.tsx'import { icons } from './icons.ts'import { Button, Icon, Kbd } from './kit.tsx'-import { useT } from '@linedesk/i18n/react'+import { ListEmpty } from './list.tsx'+import { T, useT } from '@linedesk/i18n/react'/** The page's visible title at the left of the header bar, with the number of items in it. */export function PageTitle({ title, count }: { title: string; count?: number }) {@@ -139,3 +141,20 @@ export function ZeroState({ title, line, mark = 'check' }: { title: ReactNode; l</div>)}++/**+ * A search without hits: no picture and no heading (nothing is wrong, the words just don't match), only the list's+ * plain grey line right under the column headings, aligned with the first column, and Clear search.+ */+export function SearchEmpty({ message, onClear }: { message: string; onClear: () => void }) {+ return (+ <div className="ib-search-none" role="status">+ <ListEmpty>+ <T+ k="common.search.noneLine"+ values={{ message, clear: chunks => <LinkButton onClick={onClear}>{chunks}</LinkButton> }}+ />+ </ListEmpty>+ </div>+ )+}diff --git a/packages/i18n/locales/en/common.json b/packages/i18n/locales/en/common.jsonindex def270bb..461b5584 100644--- a/packages/i18n/locales/en/common.json+++ b/packages/i18n/locales/en/common.json@@ -161,6 +161,7 @@"saveBar.undoTip": "Undo the changes","search.button": "Search","search.closeTip": "Close search ({key})",+ "search.noneLine": "{message}. <clear>Clear search</clear>","searchSelect.noMatch": "Nothing matches “{query}”.","searchSelect.placeholder": "Search","searchSelect.searchLabel": "Search: {label}",