/ components / messages / teamMemSaved.ts
teamMemSaved.ts
 1  import type { SystemMemorySavedMessage } from '../../types/message.js'
 2  
 3  /**
 4   * Returns the team-memory segment for the memory-saved UI, plus the count so
 5   * the caller can derive the private count without accessing teamCount itself.
 6   * Plain function (not a React component) so the React Compiler won't hoist
 7   * the teamCount property access for memoization. This module is only loaded
 8   * when feature('TEAMMEM') is true.
 9   */
10  export function teamMemSavedPart(
11    message: SystemMemorySavedMessage,
12  ): { segment: string; count: number } | null {
13    const count = message.teamCount ?? 0
14    if (count === 0) return null
15    return {
16      segment: `${count} team ${count === 1 ? 'memory' : 'memories'}`,
17      count,
18    }
19  }