-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(meetings): calendar-triggered auto-join prompt + Meeting Assistant settings UI #3721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YellowSnnowmann
merged 11 commits into
tinyhumansai:main
from
YellowSnnowmann:feat/gmeet-autojoin
Jun 17, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a71a12a
feat(notifications): add CoreNotificationCard for meeting auto-join p…
YellowSnnowmann 43318b7
refactor(notifications): replace console.debug with debug library in …
YellowSnnowmann 7c182fb
test(notifications): simplify notificationReceived action dispatch in…
YellowSnnowmann 8cbaf2e
feat(meetings): add Meeting Assistant settings panel and related func…
YellowSnnowmann f10fb2d
feat(meetings): enhance calendar event handling with auto-join policy…
YellowSnnowmann 45d6a77
test(notifications): enhance CoreNotificationCard tests for button st…
YellowSnnowmann ea341a8
test(notifications): add tests for action button behavior in CoreNoti…
YellowSnnowmann 35fcbae
fix(translations): update meeting notification texts for French, Port…
YellowSnnowmann 62584f3
test(planner): update meeting extraction test for imminent meetings w…
YellowSnnowmann 69a59b4
feat(meetings): enhance meeting handling with reply anchor resolution
YellowSnnowmann af621df
feat(meetings): enhance MeetingSettingsPanel with rollback functional…
YellowSnnowmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
app/src/components/notifications/CoreNotificationCard.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| /** | ||
| * Action-button contract for core notification cards (issue #3507). | ||
| * Asserts that the calendar auto-join prompt renders its buttons, dispatches | ||
| * the `openhuman.agent_meetings_notification_action` RPC with the right | ||
| * params on click, and surfaces an error when the RPC rejects. | ||
| */ | ||
| import { fireEvent, render, screen, waitFor } from '@testing-library/react'; | ||
| import { Provider } from 'react-redux'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { store } from '../../store'; | ||
| import { type NotificationItem } from '../../store/notificationSlice'; | ||
| import CoreNotificationCard from './CoreNotificationCard'; | ||
|
|
||
| const callCoreRpc = vi.hoisted(() => vi.fn()); | ||
| vi.mock('../../services/coreRpcClient', () => ({ callCoreRpc })); | ||
|
|
||
| function makeItem(overrides: Partial<NotificationItem> = {}): NotificationItem { | ||
| return { | ||
| id: 'meet-auto-join:m1', | ||
| category: 'meetings', | ||
| title: 'Meeting starting: Standup', | ||
| body: 'Add Tiny to this meeting?', | ||
| timestamp: Date.now(), | ||
| read: false, | ||
| actions: [ | ||
| { actionId: 'join_listen', label: 'Join (listen only)', payload: { meetingId: 'm1' } }, | ||
| { actionId: 'join_active', label: 'Join & reply', payload: { meetingId: 'm1' } }, | ||
| { actionId: 'skip', label: 'Not this one', payload: { meetingId: 'm1' } }, | ||
| { actionId: 'always_join', label: 'Always join', payload: { meetingId: 'm1' } }, | ||
| ], | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| function renderCard(item: NotificationItem) { | ||
| return render( | ||
| <Provider store={store}> | ||
| <CoreNotificationCard notification={item} /> | ||
| </Provider> | ||
| ); | ||
| } | ||
|
|
||
| describe('CoreNotificationCard', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| store.dispatch({ type: 'notifications/clearAll' }); | ||
| }); | ||
|
|
||
| it('renders a localized button per action', () => { | ||
| renderCard(makeItem()); | ||
| expect(screen.getByRole('button', { name: 'Join (listen only)' })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: 'Join & reply' })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: 'Not this one' })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: 'Always join' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('dispatches the notification-action RPC with action_id + payload on click', async () => { | ||
| callCoreRpc.mockResolvedValue({ ok: true }); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Join (listen only)' })); | ||
|
|
||
| await waitFor(() => expect(callCoreRpc).toHaveBeenCalledTimes(1)); | ||
| expect(callCoreRpc).toHaveBeenCalledWith({ | ||
| method: 'openhuman.agent_meetings_notification_action', | ||
| params: { action_id: 'join_listen', payload: { meetingId: 'm1' } }, | ||
| }); | ||
| }); | ||
|
|
||
| it('marks the notification read in the store after a successful action', async () => { | ||
| callCoreRpc.mockResolvedValue({ ok: true }); | ||
| store.dispatch({ type: 'notifications/notificationReceived', payload: makeItem() }); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Not this one' })); | ||
|
|
||
| await waitFor(() => { | ||
| const item = store.getState().notifications.items.find(i => i.id === 'meet-auto-join:m1'); | ||
| expect(item?.read).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| it('clears the action buttons after a successful action so it cannot be re-clicked', async () => { | ||
| callCoreRpc.mockResolvedValue({ ok: true }); | ||
| store.dispatch({ type: 'notifications/notificationReceived', payload: makeItem() }); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Not this one' })); | ||
|
|
||
| await waitFor(() => { | ||
| const item = store.getState().notifications.items.find(i => i.id === 'meet-auto-join:m1'); | ||
| expect(item?.actions ?? []).toHaveLength(0); | ||
| }); | ||
| }); | ||
|
|
||
| it('keeps the action buttons when the RPC rejects', async () => { | ||
| callCoreRpc.mockRejectedValue(new Error('boom')); | ||
| store.dispatch({ type: 'notifications/notificationReceived', payload: makeItem() }); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Not this one' })); | ||
|
|
||
| await waitFor(() => | ||
| expect( | ||
| screen.getByText('Could not complete that action. Please try again.') | ||
| ).toBeInTheDocument() | ||
| ); | ||
| const item = store.getState().notifications.items.find(i => i.id === 'meet-auto-join:m1'); | ||
| expect(item?.actions).toHaveLength(4); | ||
| }); | ||
|
|
||
| it('surfaces an error message when the RPC rejects', async () => { | ||
| callCoreRpc.mockRejectedValue(new Error('boom')); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Always join' })); | ||
|
|
||
| await waitFor(() => | ||
| expect( | ||
| screen.getByText('Could not complete that action. Please try again.') | ||
| ).toBeInTheDocument() | ||
| ); | ||
| }); | ||
|
|
||
| it('renders nothing actionable when there are no actions', () => { | ||
| renderCard(makeItem({ actions: [] })); | ||
| expect(screen.queryByRole('button')).toBeNull(); | ||
| }); | ||
|
|
||
| it('disables all buttons while an action RPC is in flight', async () => { | ||
| let resolve!: (v: unknown) => void; | ||
| callCoreRpc.mockImplementation( | ||
| () => | ||
| new Promise(r => { | ||
| resolve = r; | ||
| }) | ||
| ); | ||
| renderCard(makeItem()); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Join (listen only)' })); | ||
|
|
||
| // All buttons should be disabled while the call is pending. | ||
| const buttons = screen.getAllByRole('button'); | ||
| buttons.forEach(btn => expect(btn).toBeDisabled()); | ||
|
|
||
| resolve({ ok: true }); | ||
| await waitFor(() => buttons.forEach(btn => expect(btn).not.toBeDisabled())); | ||
| }); | ||
|
|
||
| it('shows no unread dot when notification is already read', () => { | ||
| renderCard(makeItem({ read: true })); | ||
| expect(document.querySelector('[aria-hidden="true"]')).toBeNull(); | ||
| }); | ||
|
|
||
| it('shows unread dot when notification is unread', () => { | ||
| renderCard(makeItem({ read: false })); | ||
| expect(document.querySelector('[aria-hidden="true"]')).toBeInTheDocument(); | ||
| }); | ||
| }); |
157 changes: 157 additions & 0 deletions
157
app/src/components/notifications/CoreNotificationCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| import debug from 'debug'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import { useT } from '../../lib/i18n/I18nContext'; | ||
| import { callCoreRpc } from '../../services/coreRpcClient'; | ||
| import { useAppDispatch } from '../../store/hooks'; | ||
| import { | ||
| clearNotificationActions, | ||
| markRead, | ||
| type NotificationItem, | ||
| } from '../../store/notificationSlice'; | ||
| import NotificationBody from './NotificationBody'; | ||
|
|
||
| // Namespaced debug per project logging rules (mirrors nativeNotifications). | ||
| const log = debug('notifications:core-card'); | ||
|
|
||
| /** Relative human-readable time string from epoch ms, e.g. "2m ago". */ | ||
| function relativeTime(timestampMs: number): string { | ||
| const diff = Math.max(0, Date.now() - timestampMs); | ||
| const s = Math.floor(diff / 1000); | ||
| if (s < 60) return `${s}s ago`; | ||
| const m = Math.floor(s / 60); | ||
| if (m < 60) return `${m}m ago`; | ||
| const h = Math.floor(m / 60); | ||
| if (h < 24) return `${h}h ago`; | ||
| return `${Math.floor(h / 24)}d ago`; | ||
| } | ||
|
YellowSnnowmann marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Map a known meeting auto-join action id to its i18n key so button labels | ||
| * are localized rather than trusting the (English) label the core sends. | ||
| * Unknown action ids fall back to the server-provided label. | ||
| */ | ||
| const ACTION_LABEL_KEYS: Record<string, string> = { | ||
| join_listen: 'notifications.meeting.joinListen', | ||
| join_active: 'notifications.meeting.joinActive', | ||
| skip: 'notifications.meeting.skip', | ||
| always_join: 'notifications.meeting.alwaysJoin', | ||
| }; | ||
|
|
||
| /** Primary (filled) vs secondary (outline) styling per action id. */ | ||
| function isPrimaryAction(actionId: string): boolean { | ||
| return actionId === 'join_listen' || actionId === 'join_active'; | ||
| } | ||
|
|
||
| interface Props { | ||
| notification: NotificationItem; | ||
| } | ||
|
|
||
| /** | ||
| * Renders a core-originated notification (from `state.notifications.items`) | ||
| * that carries action buttons — e.g. the calendar auto-join prompt | ||
| * (issue #3507). Clicking a button dispatches the | ||
| * `openhuman.agent_meetings_notification_action` RPC and marks the item read. | ||
| */ | ||
| const CoreNotificationCard = ({ notification: n }: Props) => { | ||
| const { t } = useT(); | ||
| const dispatch = useAppDispatch(); | ||
| const [pendingActionId, setPendingActionId] = useState<string | null>(null); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| const handleAction = async (actionId: string, payload: unknown) => { | ||
| if (pendingActionId) return; // ignore double-clicks while a call is in flight | ||
| setPendingActionId(actionId); | ||
| setError(null); | ||
| log('action click id=%s notification=%s', actionId, n.id); | ||
| try { | ||
| await callCoreRpc<{ ok: boolean }>({ | ||
| method: 'openhuman.agent_meetings_notification_action', | ||
| params: { action_id: actionId, payload }, | ||
| }); | ||
| log('action ok id=%s', actionId); | ||
| dispatch(markRead({ id: n.id })); | ||
| // Remove the buttons so the handled prompt can't be re-clicked (which would | ||
| // re-fire bot:join, or flip always_join after a skip). Without this the | ||
| // card stays pinned in NotificationCenter with live actions. | ||
| dispatch(clearNotificationActions({ id: n.id })); | ||
| } catch (err) { | ||
| log('action failed id=%s err=%o', actionId, err); | ||
| setError(t('notifications.meeting.actionError')); | ||
| } finally { | ||
| setPendingActionId(null); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| className={`w-full p-3 border-b border-stone-100 dark:border-neutral-800 transition-colors duration-150 ${ | ||
| n.read ? 'bg-white dark:bg-neutral-900' : 'bg-primary-50/30' | ||
| }`} | ||
| data-testid="core-notification-card"> | ||
| <div className="flex items-start gap-3"> | ||
| {/* Unread dot — reserve space so text stays aligned whether read or unread */} | ||
| <div className="mt-1.5 flex-shrink-0 w-2"> | ||
| {!n.read && ( | ||
| <span className="block w-2 h-2 rounded-full bg-primary-500" aria-hidden="true" /> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="flex-1 min-w-0 text-left"> | ||
| {/* Header row: category badge + timestamp */} | ||
| <div className="flex items-center gap-2 mb-1"> | ||
| <span className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium border bg-stone-100 dark:bg-neutral-800 text-stone-700 dark:text-neutral-200 border-stone-200 dark:border-neutral-800"> | ||
| {t(`notifications.category.${n.category}`)} | ||
| </span> | ||
| <span className="ml-auto text-[11px] text-stone-400 dark:text-neutral-500 flex-shrink-0"> | ||
| {relativeTime(n.timestamp)} | ||
| </span> | ||
| </div> | ||
|
|
||
| {/* Title */} | ||
| <p className="text-sm font-medium text-stone-900 dark:text-neutral-100">{n.title}</p> | ||
|
|
||
| {/* Body */} | ||
| {n.body && ( | ||
| <p | ||
| data-testid="core-notification-body" | ||
| className="text-xs text-stone-500 dark:text-neutral-400 mt-0.5"> | ||
| <NotificationBody body={n.body} /> | ||
| </p> | ||
| )} | ||
|
|
||
| {/* Action buttons */} | ||
| {n.actions && n.actions.length > 0 && ( | ||
| <div className="flex flex-wrap items-center gap-2 mt-2"> | ||
| {n.actions.map(action => { | ||
| const labelKey = ACTION_LABEL_KEYS[action.actionId]; | ||
| const label = labelKey ? t(labelKey) : action.label; | ||
| const primary = isPrimaryAction(action.actionId); | ||
| return ( | ||
| <button | ||
| key={action.actionId} | ||
| type="button" | ||
| disabled={pendingActionId !== null} | ||
| onClick={() => { | ||
| void handleAction(action.actionId, action.payload); | ||
| }} | ||
| className={`px-2.5 py-1 rounded-lg text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${ | ||
| primary | ||
| ? 'bg-primary-500 text-white hover:bg-primary-600' | ||
| : 'bg-stone-100 dark:bg-neutral-800 text-stone-700 dark:text-neutral-200 hover:bg-stone-200 dark:hover:bg-neutral-800/60' | ||
| }`}> | ||
| {label} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
| )} | ||
|
|
||
| {error && <p className="text-xs text-red-600 mt-1.5">{error}</p>} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CoreNotificationCard; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.