* The fields that make two records the same message, the ones the frontend * buffer compares (app/ui-log.ts): a repeat count carries them too, so it joins * the row of the entry it counts. The detail is compared by its start, which a * field cut on the longer count line leaves intact.
(record: DaemonLogRecord)
| 54 | * field cut on the longer count line leaves intact. |
| 55 | */ |
| 56 | function repeatIdentity(record: DaemonLogRecord): { key: string; session: string; repeat?: number } { |
| 57 | try { |
| 58 | const line: unknown = JSON.parse(record.message); |
| 59 | if (typeof line === 'object' && line !== null && typeof (line as Record<string, unknown>)['message'] === 'string') { |
| 60 | const entry = line as Record<string, unknown>; |
| 61 | const text = (name: string) => typeof entry[name] === 'string' ? entry[name] as string : ''; |
| 62 | const detail = typeof entry['detail'] === 'string' ? entry['detail'] : undefined; |
| 63 | const repeat = repeatCount(detail); |
| 64 | return { key: JSON.stringify([record.level, record.source, record.project ?? '', text('message'), (countedDetail(detail) ?? '').slice(0, 2048), |
| 65 | text('stack').slice(0, 2048), text('url'), entry['line'] ?? null, entry['col'] ?? null]), |
| 66 | session: text('session'), repeat }; |
| 67 | } |
| 68 | } catch { /* A daemon line is plain text. */ } |
| 69 | return { key: JSON.stringify([record.level, record.source, record.project ?? '', record.message]), session: '' }; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Identical messages become one row at their latest position, with how often |
no test coverage detected