feat: CC agent features, live call assist, worklist redesign, brand tokens

CC Agent:
- Call transfer (CONFERENCE + KICK_CALL) with inline transfer dialog
- Recording pause/resume during active calls
- Missed calls API (Ozonetel abandonCalls)
- Call history API (Ozonetel fetchCDRDetails)

Live Call Assist:
- Deepgram Nova STT via raw WebSocket
- OpenAI suggestions every 10s with lead context
- LiveTranscript component in sidebar during calls
- Browser audio capture from remote WebRTC stream

Worklist:
- Redesigned table: clickable phones, context menu (Call/SMS/WhatsApp)
- Last interaction sub-line, source column, improved SLA
- Filtered out rows without phone numbers
- New missed call notifications

Brand:
- Logo on login page
- Blue scale rebuilt from logo blue rgb(32, 96, 160)
- FontAwesome duotone CSS variables set globally
- Profile menu icons switched to duotone

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-21 10:36:10 +05:30
parent 99bca1e008
commit 3064eeb444
21 changed files with 2583 additions and 85 deletions

View File

@@ -1,4 +1,4 @@
import { useCallback, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import type { FC, HTMLAttributes } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
@@ -10,8 +10,9 @@ import { Table } from '@/components/application/table/table';
import { Badge } from '@/components/base/badges/badges';
import { Input } from '@/components/base/input/input';
import { Tabs, TabList, Tab } from '@/components/application/tabs/tabs';
import { ClickToCallButton } from './click-to-call-button';
import { PhoneActionCell } from './phone-action-cell';
import { formatPhone } from '@/lib/format';
import { notify } from '@/lib/toast';
import { cx } from '@/utils/cx';
type WorklistLead = {
@@ -24,6 +25,10 @@ type WorklistLead = {
interestedService: string | null;
aiSummary: string | null;
aiSuggestedAction: string | null;
lastContacted: string | null;
contactAttempts: number | null;
utmCampaign: string | null;
campaignId: string | null;
};
type WorklistFollowUp = {
@@ -42,6 +47,7 @@ type MissedCall = {
callerNumber: { number: string; callingCode: string }[] | null;
startedAt: string | null;
leadId: string | null;
disposition: string | null;
};
interface WorklistPanelProps {
@@ -55,7 +61,6 @@ interface WorklistPanelProps {
type TabKey = 'all' | 'missed' | 'callbacks' | 'follow-ups';
// Unified row type for the table
type WorklistRow = {
id: string;
type: 'missed' | 'callback' | 'follow-up' | 'lead';
@@ -70,6 +75,10 @@ type WorklistRow = {
taskState: 'PENDING' | 'ATTEMPTED' | 'SCHEDULED';
leadId: string | null;
originalLead: WorklistLead | null;
lastContactedAt: string | null;
contactAttempts: number;
source: string | null;
lastDisposition: string | null;
};
const priorityConfig: Record<string, { color: 'error' | 'warning' | 'brand' | 'gray'; label: string; sort: number }> = {
@@ -87,9 +96,8 @@ const followUpLabel: Record<string, string> = {
REVIEW_REQUEST: 'Review',
};
// Compute SLA: minutes since created, color-coded
const computeSla = (createdAt: string): { label: string; color: 'success' | 'warning' | 'error' } => {
const minutes = Math.max(0, Math.round((Date.now() - new Date(createdAt).getTime()) / 60000));
const computeSla = (dateStr: string): { label: string; color: 'success' | 'warning' | 'error' } => {
const minutes = Math.max(0, Math.round((Date.now() - new Date(dateStr).getTime()) / 60000));
if (minutes < 1) return { label: '<1m', color: 'success' };
if (minutes < 15) return { label: `${minutes}m`, color: 'success' };
if (minutes < 30) return { label: `${minutes}m`, color: 'warning' };
@@ -99,6 +107,30 @@ const computeSla = (createdAt: string): { label: string; color: 'success' | 'war
return { label: `${Math.floor(hours / 24)}d`, color: 'error' };
};
const formatTimeAgo = (dateStr: string): string => {
const minutes = Math.round((Date.now() - new Date(dateStr).getTime()) / 60000);
if (minutes < 1) return 'Just now';
if (minutes < 60) return `${minutes}m ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours}h ago`;
return `${Math.floor(hours / 24)}d ago`;
};
const formatDisposition = (disposition: string): string =>
disposition.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
const formatSource = (source: string): string => {
const map: Record<string, string> = {
FACEBOOK_AD: 'Facebook',
GOOGLE_AD: 'Google',
WALK_IN: 'Walk-in',
REFERRAL: 'Referral',
WEBSITE: 'Website',
PHONE_INQUIRY: 'Phone',
};
return map[source] ?? source.replace(/_/g, ' ');
};
const IconInbound: FC<HTMLAttributes<HTMLOrSVGElement>> = ({ className }) => (
<FontAwesomeIcon icon={faPhoneArrowDown} className={className} />
);
@@ -127,6 +159,10 @@ const buildRows = (missedCalls: MissedCall[], followUps: WorklistFollowUp[], lea
taskState: 'PENDING',
leadId: call.leadId,
originalLead: null,
lastContactedAt: call.startedAt ?? call.createdAt,
contactAttempts: 0,
source: null,
lastDisposition: call.disposition ?? null,
});
}
@@ -149,6 +185,10 @@ const buildRows = (missedCalls: MissedCall[], followUps: WorklistFollowUp[], lea
taskState: isOverdue ? 'PENDING' : (fu.followUpStatus === 'COMPLETED' ? 'ATTEMPTED' : 'SCHEDULED'),
leadId: null,
originalLead: null,
lastContactedAt: fu.scheduledAt ?? fu.createdAt ?? null,
contactAttempts: 0,
source: null,
lastDisposition: null,
});
}
@@ -171,25 +211,24 @@ const buildRows = (missedCalls: MissedCall[], followUps: WorklistFollowUp[], lea
taskState: 'PENDING',
leadId: lead.id,
originalLead: lead,
lastContactedAt: lead.lastContacted ?? null,
contactAttempts: lead.contactAttempts ?? 0,
source: lead.leadSource ?? lead.utmCampaign ?? null,
lastDisposition: null,
});
}
// Sort by priority (urgent first), then by creation time (oldest first)
rows.sort((a, b) => {
// Remove rows without a phone number — agent can't act on them
const actionableRows = rows.filter(r => r.phoneRaw);
actionableRows.sort((a, b) => {
const pa = priorityConfig[a.priority]?.sort ?? 2;
const pb = priorityConfig[b.priority]?.sort ?? 2;
if (pa !== pb) return pa - pb;
return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
});
return rows;
};
const typeConfig: Record<WorklistRow['type'], { color: 'error' | 'brand' | 'blue-light' | 'gray' }> = {
missed: { color: 'error' },
callback: { color: 'brand' },
'follow-up': { color: 'blue-light' },
lead: { color: 'gray' },
return actionableRows;
};
export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelectLead, selectedLeadId }: WorklistPanelProps) => {
@@ -203,13 +242,10 @@ export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelect
const filteredRows = useMemo(() => {
let rows = allRows;
// Tab filter
if (tab === 'missed') rows = rows.filter((r) => r.type === 'missed');
else if (tab === 'callbacks') rows = rows.filter((r) => r.type === 'callback');
else if (tab === 'follow-ups') rows = rows.filter((r) => r.type === 'follow-up');
// Search filter
if (search.trim()) {
const q = search.toLowerCase();
rows = rows.filter(
@@ -224,10 +260,18 @@ export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelect
const callbackCount = allRows.filter((r) => r.type === 'callback').length;
const followUpCount = allRows.filter((r) => r.type === 'follow-up').length;
// Notification for new missed calls
const prevMissedCount = useRef(missedCount);
useEffect(() => {
if (missedCount > prevMissedCount.current && prevMissedCount.current > 0) {
notify.info('New Missed Call', `${missedCount - prevMissedCount.current} new missed call(s)`);
}
prevMissedCount.current = missedCount;
}, [missedCount]);
const PAGE_SIZE = 15;
const [page, setPage] = useState(1);
// Reset page when filters change
const handleTabChange = useCallback((key: TabKey) => { setTab(key); setPage(1); }, []);
const handleSearch = useCallback((value: string) => { setSearch(value); setPage(1); }, []);
@@ -262,7 +306,7 @@ export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelect
return (
<div className="flex flex-1 flex-col">
{/* Filter tabs + search — single row */}
{/* Filter tabs + search */}
<div className="flex items-end justify-between border-b border-secondary px-5 pt-3 pb-0.5">
<Tabs selectedKey={tab} onSelectionChange={(key) => handleTabChange(key as TabKey)}>
<TabList items={tabItems} type="underline" size="sm">
@@ -294,28 +338,29 @@ export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelect
<Table.Head label="PRIORITY" className="w-20" isRowHeader />
<Table.Head label="PATIENT" />
<Table.Head label="PHONE" />
<Table.Head label="TYPE" />
<Table.Head label="SLA" className="w-20" />
<Table.Head label="ACTIONS" className="w-24" />
<Table.Head label="SOURCE" className="w-28" />
<Table.Head label="SLA" className="w-24" />
</Table.Header>
<Table.Body items={pagedRows}>
{(row) => {
const priority = priorityConfig[row.priority] ?? priorityConfig.NORMAL;
const sla = computeSla(row.createdAt);
const typeCfg = typeConfig[row.type];
const sla = computeSla(row.lastContactedAt ?? row.createdAt);
const isSelected = row.originalLead !== null && row.originalLead.id === selectedLeadId;
// Sub-line: last interaction context
const subLine = row.lastContactedAt
? `${formatTimeAgo(row.lastContactedAt)}${row.lastDisposition ? `${formatDisposition(row.lastDisposition)}` : ''}`
: row.reason || row.typeLabel;
return (
<Table.Row
id={row.id}
className={cx(
'cursor-pointer',
'cursor-pointer group/row',
isSelected && 'bg-brand-primary',
)}
onAction={() => {
if (row.originalLead) {
onSelectLead(row.originalLead);
}
if (row.originalLead) onSelectLead(row.originalLead);
}}
>
<Table.Cell>
@@ -326,44 +371,46 @@ export const WorklistPanel = ({ missedCalls, followUps, leads, loading, onSelect
<Table.Cell>
<div className="flex items-center gap-2">
{row.direction === 'inbound' && (
<IconInbound className="size-3.5 text-fg-success-secondary" />
<IconInbound className="size-3.5 text-fg-success-secondary shrink-0" />
)}
{row.direction === 'outbound' && (
<IconOutbound className="size-3.5 text-fg-brand-secondary" />
<IconOutbound className="size-3.5 text-fg-brand-secondary shrink-0" />
)}
<span className="text-sm font-medium text-primary truncate max-w-[140px]">
{row.name}
</span>
<div className="min-w-0">
<span className="text-sm font-medium text-primary truncate block max-w-[180px]">
{row.name}
</span>
<span className="text-xs text-tertiary truncate block max-w-[200px]">
{subLine}
</span>
</div>
</div>
</Table.Cell>
<Table.Cell>
<span className="text-sm text-tertiary whitespace-nowrap">
{row.phone || '\u2014'}
</span>
{row.phoneRaw ? (
<PhoneActionCell
phoneNumber={row.phoneRaw}
displayNumber={row.phone}
leadId={row.leadId ?? undefined}
/>
) : (
<span className="text-xs text-quaternary italic">No phone</span>
)}
</Table.Cell>
<Table.Cell>
<Badge size="sm" color={typeCfg.color} type="pill-color">
{row.typeLabel}
</Badge>
{row.source ? (
<span className="text-xs text-tertiary truncate block max-w-[100px]">
{formatSource(row.source)}
</span>
) : (
<span className="text-xs text-quaternary"></span>
)}
</Table.Cell>
<Table.Cell>
<Badge size="sm" color={sla.color} type="pill-color">
{sla.label}
</Badge>
</Table.Cell>
<Table.Cell>
<div className="flex items-center gap-1">
{row.phoneRaw ? (
<ClickToCallButton
phoneNumber={row.phoneRaw}
leadId={row.leadId ?? undefined}
size="sm"
/>
) : (
<span className="text-xs text-quaternary">No phone</span>
)}
</div>
</Table.Cell>
</Table.Row>
);
}}