Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions app/shared/src/transcript/goldenTranscriptFixtures.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { describe, expect, it } from 'vitest';
import { blocksToTranscriptItems } from '../chatview/adapter';
import type { TranscriptAgentItem, TranscriptUserItem } from '../chatview/transcript-item';
import {
goldenMixedSourceFullBlockIds,
goldenMixedSourceInspectorOnlyBlockIds,
goldenMixedSourceMainBlockIds,
resolveGoldenMixedSourceMainTranscript,
resolveGoldenMixedSourceTranscript,
} from './goldenTranscriptFixtures';
import { isSidebarOnlyTranscriptBlock } from './types';

describe('golden mixed-source transcript fixture', () => {
it('normalizes Hub user, Edge tool/result, subagent detail, and markdown reply in deterministic order', () => {
const blocks = resolveGoldenMixedSourceTranscript();

expect(blocks.map((block) => block.id)).toEqual([...goldenMixedSourceFullBlockIds]);
expect(blocks.map((block) => block.kind)).toEqual([
'text',
'run_session',
'tool_call',
'tool_call',
'tool_result',
'tool_result',
'subtask',
'route_decision',
'text',
]);
expect(blocks[0]).toEqual(expect.objectContaining({
author: { id: 'user-golden', name: 'Golden User', role: 'human' },
text: 'Kick off the golden mixed-source contract.',
}));
expect(blocks[blocks.length - 1]).toEqual(expect.objectContaining({
author: { id: 'agent-golden-builder', name: 'Builder', role: 'agent' },
text: expect.stringContaining('| order | ordered |'),
}));
});

it('keeps inspector-only details out of the main transcript fixture', () => {
const fullBlocks = resolveGoldenMixedSourceTranscript();
const mainBlocks = resolveGoldenMixedSourceMainTranscript();
const inspectorOnlyBlocks = fullBlocks.filter(isSidebarOnlyTranscriptBlock);

expect(inspectorOnlyBlocks.map((block) => block.id)).toEqual([...goldenMixedSourceInspectorOnlyBlockIds]);
expect(mainBlocks.map((block) => block.id)).toEqual([...goldenMixedSourceMainBlockIds]);

const mainText = JSON.stringify(mainBlocks);
expect(mainText).not.toContain('Deep report should stay in inspector');
expect(mainText).not.toContain('Reviewer QA');
expect(mainText).not.toContain('Route details belong to the inspector DAG.');
});

it('adapts the main fixture into stable ChatView items without losing tool/result ordering', () => {
const items = blocksToTranscriptItems(resolveGoldenMixedSourceMainTranscript());
const userItem = items[0] as TranscriptUserItem;
const agentItem = items[1] as TranscriptAgentItem;

expect(items).toHaveLength(2);
expect(userItem).toMatchObject({
type: 'user',
id: 'hub-message-client-golden-user',
text: 'Kick off the golden mixed-source contract.',
});

expect(agentItem.agent).toBe('Builder');
expect(agentItem.rows.map((row) => row.id)).toEqual([
'edge-event-hub-runtime-evt-golden-call-read-a',
'edge-event-hub-runtime-evt-golden-call-read-b',
]);
expect(agentItem.rows.map((row) => ({
toolCallId: row.toolCallId,
content: row.content,
isResult: row.isResult,
status: row.status,
}))).toEqual([
{
toolCallId: 'read-a',
content: 'A result belongs to src/a.ts',
isResult: true,
status: 'ok',
},
{
toolCallId: 'read-b',
content: 'B result belongs to src/b.ts',
isResult: true,
status: 'ok',
},
]);
expect(agentItem.bubbles).toEqual([
[
'The golden replay summary is below.',
'',
'| Check | Status |',
'| --- | --- |',
'| order | ordered |',
].join('\n'),
]);
});
});
167 changes: 167 additions & 0 deletions app/shared/src/transcript/goldenTranscriptFixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import type { HubMessageTranscriptInput } from './normalizeHubMessages';
import { normalizeHubMessagesToTranscript } from './normalizeHubMessages';
import type { HubRuntimeEventTranscriptInput } from './normalizeHubRuntimeEvents';
import { normalizeHubRuntimeEventsToTranscript } from './normalizeHubRuntimeEvents';
import { orderTranscriptBlocks } from './order';
import { isSidebarOnlyTranscriptBlock, type TranscriptBlock } from './types';

export const GOLDEN_MIXED_SOURCE_SESSION_ID = 'session-golden-chat-flow';
export const GOLDEN_MIXED_SOURCE_TASK_ID = 'golden-chat-flow-task';
export const GOLDEN_MIXED_SOURCE_RUN_ID = 'run-golden-chat-flow';

export const goldenMixedSourceHubMessages: HubMessageTranscriptInput[] = [
{
id: 'message-golden-user',
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
seq_id: 1,
client_msg_id: 'client-golden-user',
sender_type: 'user',
sender_id: 'user-golden',
sender: { nickname: 'Golden User' },
content_type: 'text',
content: 'Kick off the golden mixed-source contract.',
created_at: '2026-06-26T08:00:00Z',
},
];

export const goldenMixedSourceHubRuntimeEvents: HubRuntimeEventTranscriptInput[] = [
{
id: 'evt-golden-call-read-a',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 1,
event_type: 'run.agent.tool_call',
payload: { callId: 'read-a', toolName: 'Read', path: 'src/a.ts' },
created_at: '2026-06-26T08:00:01Z',
},
{
id: 'evt-golden-call-read-b',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 2,
event_type: 'run.agent.tool_call',
payload: { callId: 'read-b', toolName: 'Read', path: 'src/b.ts' },
created_at: '2026-06-26T08:00:02Z',
},
{
id: 'evt-golden-result-read-a',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 3,
event_type: 'run.agent.tool_result',
payload: { callId: 'read-a', toolName: 'Read', summary: 'A result belongs to src/a.ts' },
created_at: '2026-06-26T08:00:03Z',
},
{
id: 'evt-golden-result-read-b',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 4,
event_type: 'run.agent.tool_result',
payload: { callId: 'read-b', toolName: 'Read', summary: 'B result belongs to src/b.ts' },
created_at: '2026-06-26T08:00:04Z',
},
{
id: 'evt-golden-subagent-report',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 5,
event_type: 'run.agent.subagent_task',
payload: {
title: 'Deep report should stay in inspector',
worker: 'Reviewer QA',
status: 'running',
summary: 'Inspector-only orchestration detail.',
},
created_at: '2026-06-26T08:00:05Z',
},
{
id: 'evt-golden-route-report',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 6,
event_type: 'run.agent.route_decision',
payload: {
action: 'fanout',
nextWorker: 'Reviewer QA',
summary: 'Route details belong to the inspector DAG.',
},
created_at: '2026-06-26T08:00:06Z',
},
{
id: 'evt-golden-markdown-summary',
task_id: GOLDEN_MIXED_SOURCE_TASK_ID,
edge_run_id: GOLDEN_MIXED_SOURCE_RUN_ID,
session_id: GOLDEN_MIXED_SOURCE_SESSION_ID,
agent_instance_id: 'agent-golden-builder',
agent_label: 'Builder',
event_seq: 7,
event_type: 'run.agent.text_block',
payload: {
content: [
'The golden replay summary is below.',
'',
'| Check | Status |',
'| --- | --- |',
'| order | ordered |',
].join('\n'),
},
created_at: '2026-06-26T08:00:07Z',
},
];

export const goldenMixedSourceFullBlockIds = [
'hub-message-client-golden-user',
'hub-runtime-session-golden-chat-flow-task-run-golden-chat-flow',
'edge-event-hub-runtime-evt-golden-call-read-a',
'edge-event-hub-runtime-evt-golden-call-read-b',
'edge-event-hub-runtime-evt-golden-result-read-a',
'edge-event-hub-runtime-evt-golden-result-read-b',
'edge-event-hub-runtime-evt-golden-subagent-report',
'edge-event-hub-runtime-evt-golden-route-report',
'edge-event-hub-runtime-evt-golden-markdown-summary',
] as const;

export const goldenMixedSourceMainBlockIds = [
'hub-message-client-golden-user',
'edge-event-hub-runtime-evt-golden-call-read-a',
'edge-event-hub-runtime-evt-golden-call-read-b',
'edge-event-hub-runtime-evt-golden-result-read-a',
'edge-event-hub-runtime-evt-golden-result-read-b',
'edge-event-hub-runtime-evt-golden-markdown-summary',
] as const;

export const goldenMixedSourceInspectorOnlyBlockIds = [
'hub-runtime-session-golden-chat-flow-task-run-golden-chat-flow',
'edge-event-hub-runtime-evt-golden-subagent-report',
'edge-event-hub-runtime-evt-golden-route-report',
] as const;

export function resolveGoldenMixedSourceTranscript(): TranscriptBlock[] {
return orderTranscriptBlocks([
...normalizeHubMessagesToTranscript(goldenMixedSourceHubMessages),
...normalizeHubRuntimeEventsToTranscript(goldenMixedSourceHubRuntimeEvents),
]);
}

export function resolveGoldenMixedSourceMainTranscript(): TranscriptBlock[] {
return resolveGoldenMixedSourceTranscript().filter((block) => !isSidebarOnlyTranscriptBlock(block));
}
12 changes: 12 additions & 0 deletions app/shared/src/transcript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ export { normalizeHubMessagesToTranscript } from './normalizeHubMessages';
export { hubRuntimeEventFromPayload, normalizeHubRuntimeEventsToTranscript } from './normalizeHubRuntimeEvents';
export { normalizeThreadItemsToTranscript } from './normalizeThreadItems';
export { orderTranscriptBlocks, transcriptBlockTimestampMs } from './order';
export {
GOLDEN_MIXED_SOURCE_RUN_ID,
GOLDEN_MIXED_SOURCE_SESSION_ID,
GOLDEN_MIXED_SOURCE_TASK_ID,
goldenMixedSourceFullBlockIds,
goldenMixedSourceHubMessages,
goldenMixedSourceHubRuntimeEvents,
goldenMixedSourceInspectorOnlyBlockIds,
goldenMixedSourceMainBlockIds,
resolveGoldenMixedSourceMainTranscript,
resolveGoldenMixedSourceTranscript,
} from './goldenTranscriptFixtures';
export {
createAgentActivityStore,
getAgentActivityStore,
Expand Down
Loading
Loading