test: cover task detail live timeline updates

This commit is contained in:
2026-05-26 13:49:31 +08:00
parent 41ac87e322
commit 55b39563a0
2 changed files with 35 additions and 1 deletions

View File

@ -117,6 +117,11 @@ function appendEvent(collection: ProcessEvent[], event: ProcessEvent): ProcessEv
return [...collection, event];
}
function hasTaskMetadata(item: { metadata?: Record<string, unknown> }): boolean {
const taskId = item.metadata?.task_id;
return typeof taskId === 'string' && taskId.trim().length > 0;
}
function createEventId(event: ProcessWsEvent): string {
if (event.type === 'process_cancel_ack') {
return `${event.type}:${event.run_id}`;
@ -393,7 +398,11 @@ export const useChatStore = create<ChatStore>((set, get) => ({
const incomingArtifacts = projection.artifacts || [];
const incomingRunIds = new Set(incomingRuns.map((run) => run.run_id));
const nextRuns = [
...state.processRuns.filter((run) => run.session_id !== sessionId && !incomingRunIds.has(run.run_id)),
...state.processRuns.filter((run) => {
if (incomingRunIds.has(run.run_id)) return false;
if (run.session_id !== sessionId) return true;
return hasTaskMetadata(run);
}),
...incomingRuns,
];
const liveRunIds = new Set(nextRuns.map((run) => run.run_id));