diff --git a/packages/client/ui-chat/src/client/chat/TurnTailNodeView.tsx b/packages/client/ui-chat/src/client/chat/TurnTailNodeView.tsx index b7c351ac1b..6bb5ad3a98 100644 --- a/packages/client/ui-chat/src/client/chat/TurnTailNodeView.tsx +++ b/packages/client/ui-chat/src/client/chat/TurnTailNodeView.tsx @@ -11,7 +11,7 @@ type TurnTailNodeViewProps = ChatNodeViewProps<'turn-tail'> /** Turn-local actions and feature tail over the Location index, independent of Assistant placement. */ export const TurnTailNodeView = memo(function TurnTailNodeView({ - node, cwd, openFile, forkAt, renderSlot, renderSlotChain, t, useChat, extendedTranscript, + node, cwd, openFile, forkAt, renderSlot, renderSlotChain, renderMessageImages, t, useChat, extendedTranscript, }: TurnTailNodeViewProps) { const data = node.data const hasLaterChatNode = useChat(snapshot => @@ -22,7 +22,8 @@ export const TurnTailNodeView = memo(function TurnTailNodeView({ : undefined if (turn === undefined) return null const closing = data.closing - const owner: TurnTailOwnerProps = { turn, seq: closing?.finalNode.seq ?? data.seq, cwd, openFile } + // The tail's features draw images, such as the ones the Turn produced, with the conversation's own renderer. + const owner: TurnTailOwnerProps = { turn, seq: closing?.finalNode.seq ?? data.seq, cwd, openFile, renderImages: renderMessageImages } const tail = renderSlotChain('conversation.chat.turnTail', owner) if (closing === null) return tail === null ? null :
{tail}
const runMs = turn.start === undefined || turn.end === undefined diff --git a/packages/client/ui-chat/tests/turn-tail-owner.client.spec.tsx b/packages/client/ui-chat/tests/turn-tail-owner.client.spec.tsx new file mode 100644 index 0000000000..0f4498b146 --- /dev/null +++ b/packages/client/ui-chat/tests/turn-tail-owner.client.spec.tsx @@ -0,0 +1,50 @@ +// @vitest-environment jsdom +/** + * The owner the turn tail hands its feature chain: the produced-files feature draws a Turn's images with the + * conversation's own image renderer, which only this owner can carry to it (#761). + */ +import React from 'react' +import { cleanup, render } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { TurnTailNodeView } from '../src/client/chat/TurnTailNodeView.tsx' +import type { TurnTailOwnerProps } from '../src/client/contract/slots.ts' + +afterEach(() => { cleanup() }) + +describe('TurnTailNodeView', () => { + it('hands the turn-tail chain the conversation image renderer with the Turn, workspace, and opener', () => { + const owners: TurnTailOwnerProps[] = [] + const renderSlotChain = vi.fn((_name: string, owner: TurnTailOwnerProps) => { + owners.push(owner) + return null + }) + const renderMessageImages = vi.fn(() => null) + const openFile = vi.fn() + const turn = { turn: 9, status: 'closed', data: { get: () => undefined } } + const props = { + node: { + key: 'tail:9', + kind: 'turn-tail', + location: { kind: 'turn', turn }, + data: { turn: 9, seq: 20121, time: 0, closing: null, branchUnavailable: false }, + }, + cwd: '/w', + openFile, + forkAt: vi.fn(), + renderSlot: vi.fn(() => null), + renderSlotChain, + renderMessageImages, + t: (key: string) => key, + useChat: (select: (snapshot: unknown) => unknown) => select({ + locations: { getTurn: () => ['tail:9'] }, + timeline: { turnOrder: [9] }, + }), + extendedTranscript: false, + } + render()} />) + + expect(renderSlotChain).toHaveBeenCalledWith('conversation.chat.turnTail', expect.anything()) + expect(owners[0]).toMatchObject({ seq: 20121, cwd: '/w', openFile, renderImages: renderMessageImages }) + expect(owners[0]?.turn).toBe(turn) + }) +})