agent-ecosystem/src/renderer/utils/teamMessageKey.ts
iliya 40beaf20d9 feat: implement message read tracking and enhance UI components
- Added `useTeamMessagesRead` hook to manage read state of messages within a team, utilizing local storage for persistence.
- Introduced `toMessageKey` utility for generating stable keys for messages based on their properties.
- Enhanced `CollapsibleTeamSection` to display a secondary badge for unread message counts.
- Updated `TeamDetailView` to calculate and pass unread message counts to `CollapsibleTeamSection`.
- Implemented message visibility tracking in `ActivityTimeline` to mark messages as read when they enter the viewport.
2026-02-23 15:02:33 +02:00

14 lines
491 B
TypeScript

import type { InboxMessage } from '@shared/types';
const FALLBACK_SLICE = 80;
/**
* Stable key for a team message. Prefer messageId; otherwise build from timestamp, from, and text.
*/
export function toMessageKey(message: InboxMessage): string {
if (typeof message.messageId === 'string' && message.messageId.trim().length > 0) {
return message.messageId;
}
const text = (message.text ?? '').slice(0, FALLBACK_SLICE);
return `${message.timestamp}-${message.from}-${text}`;
}