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
5 changes: 3 additions & 2 deletions packages/client/ui-chat/src/client/chat/TurnTailNodeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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 : <div className={css.root}>{tail}</div>
const runMs = turn.start === undefined || turn.end === undefined
Expand Down
50 changes: 50 additions & 0 deletions packages/client/ui-chat/tests/turn-tail-owner.client.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(<TurnTailNodeView {...(props as unknown as React.ComponentProps<typeof TurnTailNodeView>)} />)

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)
})
})