fix(webui): dedupe sidechannel history records

This commit is contained in:
yiliang114 2026-08-17 02:36:28 +08:00
parent d15e57bd38
commit e6b40e5c38
2 changed files with 47 additions and 1 deletions

View file

@ -4124,6 +4124,20 @@ describe('DaemonSessionProvider', () => {
index < UNRECOGNIZED_DIAGNOSTICS_LIMIT - 1;
index++
) {
if (index === 0) {
yield {
id: 100,
v: 1,
type: 'session_update',
data: {
update: {
sessionUpdate: 'mystery_kind_from_newer_daemon_overlap',
_meta: { 'qwen.session.recordId': 'record-overlap' },
},
},
};
continue;
}
yield {
id: 100 + index,
v: 1,
@ -4158,6 +4172,17 @@ describe('DaemonSessionProvider', () => {
},
},
})),
{
id: 5,
v: 1,
type: 'session_update',
data: {
update: {
sessionUpdate: 'mystery_kind_from_newer_daemon_overlap',
_meta: { 'qwen.session.recordId': 'record-overlap' },
},
},
},
],
hasMore: false,
});
@ -4195,6 +4220,22 @@ describe('DaemonSessionProvider', () => {
expect.objectContaining({ debugReason: 'unrecognized_session_update' }),
);
expect(diagnostics[1]).toEqual(
expect.objectContaining({
debugReason: 'unrecognized_session_update',
sourceRecordIds: ['record-overlap'],
}),
);
expect(
diagnostics.filter((entry) =>
entry.sourceRecordIds?.includes('record-overlap'),
),
).toHaveLength(1);
expect(
diagnostics.filter((entry) =>
entry.sourceRecordIds?.includes('record-old-1'),
),
).toHaveLength(1);
expect(diagnostics[2]).toEqual(
expect.objectContaining({ debugReason: 'unrecognized_event' }),
);
});

View file

@ -278,6 +278,11 @@ function materializeTranscriptHistory(
displayedRecordIds.add(recordId);
}
}
for (const diagnostic of current.unrecognizedDiagnostics) {
for (const recordId of diagnostic.sourceRecordIds ?? []) {
displayedRecordIds.add(recordId);
}
}
const freshEvents =
displayedRecordIds.size === 0
? events
@ -302,7 +307,7 @@ function materializeTranscriptHistory(
nextOrdinal: history.nextOrdinal,
toolBlockByCallId: history.toolBlockByCallId,
permissionBlockByRequestId: history.permissionBlockByRequestId,
// History pages come from older daemon versions are exactly the
// History pages can carry frames recorded by newer daemon versions, exactly
// forward-compat case the sidechannel exists for (#8823); keep them
// instead of dropping the throwaway store's diagnostics.
unrecognizedDiagnostics: history.unrecognizedDiagnostics,