From e7058b6b6da82a1bc54fa43f437e53748ba78c20 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 30 Apr 2026 16:31:31 -0400 Subject: [PATCH] fix(ui): include stage in leaf coalesce key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-Agent flagged that the leaf coalesceKey omitted `stage`, so two adjacent no-requestId logs differing only by stage (e.g. one logging `route` and the next `dispatch`) would merge into a single `×2` row, hiding a distinct entry. Add `stage` to the coalesce tuple. New unit test asserts that two leaves identical except for stage stay as separate rows. Refs #1138, #1151 --- ui/src/components/logs/derive-trace-groups.ts | 1 + .../ui/components/logs-derive-trace-groups.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ui/src/components/logs/derive-trace-groups.ts b/ui/src/components/logs/derive-trace-groups.ts index f0cfecef..a533fc38 100644 --- a/ui/src/components/logs/derive-trace-groups.ts +++ b/ui/src/components/logs/derive-trace-groups.ts @@ -33,6 +33,7 @@ function coalesceKey(entry: LogsEntry): string { return [ entry.event ?? '', entry.message ?? '', + entry.stage ?? '', entry.module ?? entry.source ?? '', entry.level, entry.requestId ?? '', diff --git a/ui/tests/unit/ui/components/logs-derive-trace-groups.test.ts b/ui/tests/unit/ui/components/logs-derive-trace-groups.test.ts index 41a726e9..1fef043f 100644 --- a/ui/tests/unit/ui/components/logs-derive-trace-groups.test.ts +++ b/ui/tests/unit/ui/components/logs-derive-trace-groups.test.ts @@ -119,6 +119,17 @@ describe('deriveTraceGroups', () => { expect(leaves.every((l) => l.repeatCount === undefined)).toBe(true); }); + it('keeps adjacent leaves with different stages as separate rows (round-6 fix)', () => { + const result = deriveTraceGroups( + leafEntries( + { id: '1', timestamp: 't1', event: 'e', message: 'm', stage: 'route' }, + { id: '2', timestamp: 't2', event: 'e', message: 'm', stage: 'dispatch' } + ) + ); + expect(result).toHaveLength(2); + expect(result.every((r) => r.kind === 'leaf' && r.repeatCount === undefined)).toBe(true); + }); + it('keeps adjacent leaves with different messages as separate rows', () => { const result = deriveTraceGroups( leafEntries(