ContactActivityPanel
Typed activity timeline for a contact or record, with category tabs, a type filter, relationship summary, upcoming tasks, an emit-only Add menu and a detail sheet with replies and reactions.
Installation
pnpm dlx @kivacore/ui-cli add @kivacore/rn-contact-activity-panelpnpm add @shopify/flash-list @tanstack/react-query react-native-reanimated react-native-gesture-handlerThe panel stacks these regions:
- Header (
contact,showHeader,headerActions). - Category tabs (All / Communication / Tasks / Updates) with counts, plus a filter button that opens the grouped type filter in an action sheet.
- Summary row: last contacted, next activity, open task count, the Ask Kiva Agent button (
renderAiAssistant) and the + Add menu (addActions+onAddActivity). - Upcoming tasks and meetings. Task checkboxes call
onToggleUpcomingTask. - Timeline: calendar day groups (Today, Yesterday, This week, Last week, This month, Last month, Earlier this year, Last year, Older) on a continuous rail. Communication types render as cards (title, preview, time range, attachment and reply counts, participant avatars). Tasks and updates render as one-line rows with an attachment marker. The list is virtualised with FlashList.
- Detail sheet (large action sheet): type chip, time range and full timestamp, a Details block of the activity's own metadata (call direction / duration, meeting location, email recipients, task status / priority / due date, …), participants, body, summary, key points, follow-ups (
onToggleFollowUp), document cards (image thumbnails, per-type icons, tap to open), related records, a reaction row, the reply thread for comments, the primary action and Delete.
The Add menu emits onAddActivity(type). Pass renderAddForm as well and the panel opens your form for the picked type in its own sheet — typically a LogActivityForm scoped with activityTypes={[type]}. Call close() after a successful submit. With a single addActions entry the trigger skips the menu and opens the form directly.
Timestamps
Timeline timestamps count up while the event is recent and become a date once it isn't: now → 5m → 3h → 2d → 3w → 21 Sep → 21 Sep 2025. The units are translation keys (ui.contactActivity.time.*) and the absolute form uses the device locale.
Connect it to Kiva with useKivaContactActivity, which is also re-exported from this component.
Usage
import { ContactActivityPanel, useKivaContactActivity } from '@/components/kiva-native/contact-activity-panel';
function ContactTimeline({ client, contact, meId }) {
const [logType, setLogType] = useState<string | null>(null);
const { panelProps } = useKivaContactActivity({
client,
appSlug: 'base',
dataSourceSlug: 'contact',
recordId: contact.id,
relationSlug: 'contact',
currentUserId: meId
});
return (
<ContactActivityPanel
{...panelProps}
contact={{ name: contact.name, org: contact.company }}
addActions={[
{ type: 'call', label: 'Log call', icon: 'fal phone' },
{ type: 'meeting', label: 'Log meeting', icon: 'fal calendar' },
{ type: 'task', label: 'New task', icon: 'fal square-check' }
]}
onAddActivity={setLogType} />
);
}Without maxHeight the panel is flex-1 and fills its parent, so give the parent a bounded height (a screen, or a sized View). Do not nest it in a vertical ScrollView. Pass maxHeight for a fixed-height panel.
Replies and reactions
For comment activities the detail sheet loads replies with onLoadReplies(activityId) and renders them with the team-chat PostCard / PostComposer (as on web): @ mentions, emoji, attachments and — with dataSources + onSearchEntity — entity links. Submitting calls onCreateComment({ content, parent_id, attachments, linked_entities, mentioned_user_ids, hashtags }). parent_id is the raw comment id taken from metadata.__sourceId. Own replies can be deleted after confirmation (onDeleteComment).
With onToggleReaction, the sheet shows reaction chips for the activity and for each reply. Tap the smiley / + button, or long-press a reply, to pick one of the preset emoji (or More for the full EmojiPicker). targetId is the reply id, or the activity's metadata.__sourceId (falling back to its id).
Editing replies is not offered (the panel has no update callback — same as web).
API Reference
ContactActivityPanelProps
| Prop | Type | Default | Description |
|---|---|---|---|
activities | ContactActivity[] | - | Timeline items. Sorted newest first by created_on (required) |
currentUser | ChatUser | - | Signed-in user (own replies, delete permission) |
users | ChatUser[] | - | Users for avatars, names and mentions |
contactName | string | contact.name | Name used in the empty state |
isLoading | boolean | false | Show the loading skeleton |
isCreatePending | boolean | false | Pending state of the reply composer |
isDeletePending | boolean | false | Pending state of the delete confirmations |
onDeleteActivity | (activityId: string) => void | Promise<void> | - | Enables Delete (after confirmation) on the current user's activities |
onCreateComment | (payload: CreatePostPayload) => void | Promise<void> | - | Post a reply to a comment activity |
onDeleteComment | (commentId: string) => void | Promise<void> | - | Delete an own reply |
onToggleReaction | (targetId: string, emoji: string) => void | Promise<void> | - | Toggle a reaction on an activity or reply |
onUploadFile | (file: NativeFile) => Promise<PostAttachment> | - | Accepted for API parity. Picked files arrive through onCreateComment (attachments) |
onLoadReplies | (activityId: string) => Promise<ChatPost[]> | - | Load a comment activity's replies |
dataSources | DataSourceOption[] | - | Data sources offered by the reply composer's link button (needs onSearchEntity) |
onSearchEntity | (dataSourceId: string, query: string) => Promise<EntitySearchResult[]> | - | Record search for linking an entity to a reply |
activityTypes | ActivityType[] | all 18 | Types offered in the filter and shown in the timeline |
maxHeight | number | - | Fixed panel height in dp. Without it the panel is flex-1 |
className | string | - | Container classes |
contact | ContactActivityContact | - | Header identity |
showHeader | boolean | true | Show the header (needs contact) |
headerActions | ReactNode | - | Slot on the right of the header |
width | 'panel' | 'wide' | 'panel' | Accepted for API parity. Native always uses the compact panel layout |
iconStyle | 'color' | 'mono' | 'color' | Colored or monochrome type chips |
relationshipSummary | RelationshipSummary | - | Summary row values |
upcoming | UpcomingActivity[] | - | Upcoming tasks and meetings |
onToggleUpcomingTask | (id: string) => void | Promise<void> | - | Toggle an upcoming task's checkbox |
upcomingCollapsedCount | number | 4 | Upcoming entries shown before the "N more" control |
weekStartsOn | number | 1 | First day of the week for the timeline day groups (0 = Sunday) |
addActions | AddActivityAction[] | - | Add menu entries (menu shows with onAddActivity or renderAddForm) |
onAddActivity | (type: string) => void | - | Fired when an Add menu entry is picked |
renderAddForm | (context: AddFormContext) => ReactNode | - | Quick-add form for the picked type, opened in its own sheet |
onActivityClick | (activity: ContactActivity) => void | - | Replace the built-in detail sheet |
renderActivityDetail | (activity: ContactActivity) => ReactNode | - | Replace the detail sheet body (header kept) |
onToggleFollowUp | (activityId: string, followUpId: string) => void | Promise<void> | - | Toggle a follow-up checkbox in the detail sheet |
renderAiAssistant | (context: { open: boolean; onOpenChange: (open: boolean) => void }) => ReactNode | - | Ask Kiva Agent slot. The button shows only when this is set. Render your own sheet |
aiAssistantOpen | boolean | - | Controlled Ask Kiva Agent open state |
onAiAssistantOpenChange | (open: boolean) => void | - | Ask Kiva Agent open-state callback |
ContactActivity
| Field | Type | Description |
|---|---|---|
id | string | Activity id |
type | ActivityType | One of 18 types (see below) |
subject | string | Subject (title fallback) |
description | string | Body. Rendered as markdown in the detail sheet |
metadata | Record<string, unknown> | Source data (__sourceId, done, priority, …) |
reply_count | number | Reply count on the card |
created_on | string | ISO timestamp (sort + date group) |
created_by | string | Author user id |
last_modified_on | string | ISO timestamp |
attachments | PostAttachment[] | null | Attached files |
reactions | PostReaction[] | Reactions |
title | string | Display title (falls back to subject) |
preview | string | One-line preview (falls back to the first line of description) |
participants | string[] | Extra participant user ids for the avatar stack |
timeRange | { start: string; end?: string } | Time range chip (14:00–14:45) |
dueDate | string | Due date (tasks) |
actorLabel | string | Actor shown on secondary rows |
summary | string | Detail sheet summary |
keyPoints | string[] | Detail sheet key points |
followUps | { id: string; text: string; done?: boolean }[] | Detail sheet follow-ups |
related | ActivityRelatedEntity[] | Detail sheet related records (filled by the hook, or supplied here) |
primaryAction | { label: string; onClick?: () => void } | Detail sheet primary button |
ActivityType: call, meeting, email, chat, sms, whatsapp, linkedin, note, comment (communication, rendered as cards), task (tasks), status_update, status, file, form, record, trace, record_create, record_update (updates). task, file and form rows open the detail sheet; other update rows are inert.
UpcomingActivity
| Field | Type | Description |
|---|---|---|
id | string | Item id |
kind | 'task' | 'meeting' | Tasks get a checkbox, meetings a calendar chip |
title | string | Title |
sub | string | Secondary line |
due | string | Display label for the due time |
done | boolean | Task done state |
RelationshipSummary
| Field | Type | Description |
|---|---|---|
lastContactedAt | string | ISO, shown relative ("3d ago") |
nextActivityAt | string | ISO, shown as a date |
openTaskCount | number | Open task count |
ContactActivityContact
| Field | Type | Description |
|---|---|---|
name | string | Contact name |
org | string | Organization |
avatarUrl | string | Avatar image |
initials | string | Fallback initials |
AddActivityAction
| Field | Type | Description |
|---|---|---|
type | string | Passed to onAddActivity |
label | string | Menu label |
icon | string | KivaIcon name (for example fal phone). Web takes a lucide component |
ActivityRelatedEntity
| Field | Type | Description |
|---|---|---|
id | string | Related record id |
label | string | Display label |
role | string | Relation the entity came from ("Assignee", "Project") |
onClick | () => void | Opens the record; the chip is inert without it |
AddFormContext
| Field | Type | Description |
|---|---|---|
type | string | The AddActivityAction.type the user picked |
close | () => void | Closes the quick-add sheet |
ChatUser / ChatPost / CreatePostPayload
| Type | Fields |
|---|---|
ChatUser | id, firstname?, lastname?, avatar_url? |
ChatPost | id, content, attachments, reactions, link_previews, linked_entities, hashtags, mentioned_user_ids, reply_count, created_on, created_by, last_modified_on, parent_id |
CreatePostPayload | content, parent_id?, attachments?: NativeFile[], linked_entities?, hashtags?, mentioned_user_ids? |
PostAttachment | id, file_name, file_type, file_size, signed_url |
PostReaction | emoji, user_ids, count |
Components
| Component | Description |
|---|---|
ContactActivityPanel | The full panel |
Exports
| Export | Description |
|---|---|
ACTIVITY_CATEGORIES | ['communication', 'tasks', 'updates'] |
FILTER_GROUPS | Grouped type list used by the filter sheet |
getActivityCategory(type) | Category of a type |
isPrimaryActivity(type) | Whether a type renders as a card |
formatActivityTimestamp(value, t) | Relative-then-absolute timeline timestamp |
formatActivityTimestampFull(value) | Full localized date + time |
getActivityDetailRows(activity, t) | The activity's metadata as label/value rows |
groupActivitiesByDate(activities, weekStartsOn?) | Calendar day groups |
useKivaContactActivity | Kiva data hook (see its page) |
Type Exports
| Type | Description |
|---|---|
ContactActivityPanelProps | Props for ContactActivityPanel |
ContactActivity | Timeline item |
ActivityType / ActivityCategory | Type and category unions |
UpcomingActivity | Upcoming item |
RelationshipSummary | Summary row values |
ContactActivityContact | Header identity |
AddActivityAction | Add menu entry |
AddFormContext | { type, close } handed to renderAddForm |
ActivityRelatedEntity | Related record / person chip |
ActivityDetailRow | One label/value line of the detail sheet's Details block |
DateGroupKey | Timeline day-group key |
ActivityTypeConfig | Per-type icon, label, category, colors |
ChatUser, ChatPost, PostAttachment, PostReaction, CreatePostPayload, LinkedEntity, EntitySearchResult, DataSourceOption | Reply-thread types |
ContactActivityClient, ContactActivitySources, EventTypeNameHints, UpdateStatusInput, ContactActivityPanelData, UseKivaContactActivityOptions, UseKivaContactActivityResult | Hook types (re-exported) |
Translation Keys
| Key | English fallback |
|---|---|
ui.contactActivity.title | Activity |
ui.contactActivity.filterActivities | Filter activities |
ui.contactActivity.selectAll | Select all |
ui.contactActivity.category.<all|communication|tasks|updates> | All / Communication / Tasks / Updates |
ui.contactActivity.filterGroup.<category> | Filter group heading |
ui.contactActivity.type.<activityType> | Per-type label |
ui.contactActivity.group.<today|yesterday|thisWeek|lastWeek|thisMonth|lastMonth|thisYear|lastYear|older> | Day-group heading |
ui.contactActivity.time.now | now |
ui.contactActivity.time.minutes | {{count}}m |
ui.contactActivity.time.hours | {{count}}h |
ui.contactActivity.time.days | {{count}}d |
ui.contactActivity.time.weeks | {{count}}w |
ui.contactActivity.contacted | Contacted |
ui.contactActivity.next | Next |
ui.contactActivity.openTasks | open task(s) |
ui.contactActivity.askKivaAgent | Ask Kiva Agent |
ui.contactActivity.add / ui.contactActivity.addActivity | Add / Add activity |
ui.contactActivity.upcoming | Upcoming |
ui.contactActivity.showMoreUpcoming | Show {{count}} more upcoming |
ui.contactActivity.showLess | Show less |
ui.contactActivity.details | Details |
ui.contactActivity.detail.direction / .inbound / .outbound | Direction / Inbound / Outbound |
ui.contactActivity.detail.duration / .minutes | Duration / {{count}} min |
ui.contactActivity.detail.phone / .location / .eventType / .attendees | Phone / Location / Event type / Attendees |
ui.contactActivity.detail.to / .from / .channel | To / From / Channel |
ui.contactActivity.detail.status / .priority / .dueDate | Status / Priority / Due date |
ui.contactActivity.detail.fileName / .fileType / .record / .url | File / Type / Record / URL |
ui.contactActivity.detail.assignee | Assignee (filled by the hook) |
ui.contactActivity.documents | Documents |
ui.contactActivity.openAttachment | Open {{name}} |
ui.contactActivity.attachmentCount | {{count}} attachment(s) |
ui.contactActivity.related | Related |
ui.contactActivity.summary / .keyPoints / .followUps | Summary / Key points / Follow-ups |
ui.contactActivity.replies / .loadingReplies / .writeReply | Replies / Loading replies… / Write a reply... |
ui.contactActivity.addReaction | Add reaction (native-only) |
ui.contactActivity.deleteActivity | Delete activity |
ui.contactActivity.loadingActivities | Loading activities… |
ui.contactActivity.noActivitiesYet | No activities yet |
ui.contactActivity.activityWithContact | Activity with {{name}} will appear here. |
ui.contactActivity.activityStarted | Log a call, meeting, or email to get started. |
Breaking changes
The panel was rewritten as the web typed timeline.
ActivityItem { id, type, title, description?, timestamp, user, metadata? }was replaced byContactActivity(subject,created_on,created_byresolved againstusers,reply_count, …).ActivityTypegrew from 6 to 18 members.status_changewas removed. Usestatus_updateorstatus.- The built-in "Add activity" form was removed.
onAddActivityis now emit-only,(type: string) => void, instead of({ type, title, description }). Open aLogActivityFormfrom it. emptyMessageandstylewere removed. The empty state is translated (ui.contactActivity.*) and usescontactName. Style the panel withclassName.- Without
maxHeightthe panel isflex-1and must not be nested in a verticalScrollView.