test(ui-chat): pin the input position order and a later-anchored Turn control
The position-order case includes `input`. A Turn without opening input whose control anchors after a position-less row still renders the control before the group that holds that row.
This commit is contained in:
1 parent
8f5139b2c8
commit
9a78e752b1
2 files changed
+25
-5
No files matched your search
@@ -25,12 +25,13 @@ function members(segments: GroupTreeSegments, turns: readonly number[]): number[
|
||||
|
||||
describe('Chat group tree', () => {
|
||||
it('orders positions from the outermost exchange inward', () => {
|
||||
const at = (groupTree?: ChatGroupTree) => (['exchange', 'turn', 'process'] as const)
|
||||
const at = (groupTree?: ChatGroupTree) => (['exchange', 'input', 'turn', 'process'] as const)
|
||||
.map(position => isAtOrOutside({ groupTree }, position))
|
||||
expect(at('exchange')).toEqual([true, true, true])
|
||||
expect(at('turn')).toEqual([false, true, true])
|
||||
expect(at('process')).toEqual([false, false, true])
|
||||
expect(at(undefined)).toEqual([false, false, false])
|
||||
expect(at('exchange')).toEqual([true, true, true, true])
|
||||
expect(at('input')).toEqual([false, true, true, true])
|
||||
expect(at('turn')).toEqual([false, false, true, true])
|
||||
expect(at('process')).toEqual([false, false, false, true])
|
||||
expect(at(undefined)).toEqual([false, false, false, false])
|
||||
})
|
||||
|
||||
it('starts the latest segment at the last opening Turn and reports only the Turns that moved', () => {
|
||||
|
||||
@@ -261,6 +261,25 @@ describe('Definition-owned Chat process groups', () => {
|
||||
expect(h.store.entries[0]).toEqual({ kind: 'node', key: control.key })
|
||||
})
|
||||
|
||||
it('sorts a later-anchored Turn control before the process of a Turn without opening input', () => {
|
||||
// A Turn opened by a reply that declares no position: the control's own anchor follows the reply.
|
||||
const control: ChatNode<'turn-process'> = {
|
||||
key: 'control', id: '1', kind: 'turn-process', target: 'chat', anchorSeq: 6.9,
|
||||
location: { kind: 'turn', turn }, visibility: 'visible', groupTree: 'turn',
|
||||
data: {
|
||||
turn: 1, controlAnchorSeq: 6, processStartSeq: 1, answerAnchorSeq: null,
|
||||
answerStep: null, inlineReasoning: false, messageCount: 0, toolCallCount: 1, subagentCount: 0,
|
||||
},
|
||||
}
|
||||
const h = harness([tool('reply', 6), control, tool('after', 8)])
|
||||
expect(h.snapshot.order).toEqual(['control', 'reply', 'after'])
|
||||
expect(h.store.entries.map(entry => entry.kind)).toEqual(['node', 'group'])
|
||||
expect(h.store.entries[0]).toEqual({ kind: 'node', key: control.key })
|
||||
const group = h.store.entries[1]!
|
||||
if (group.kind !== 'group') throw new Error('expected group')
|
||||
expect(h.store.groupSource(group.key).getSnapshot()?.members.map(member => member.key)).toEqual(['reply', 'after'])
|
||||
})
|
||||
|
||||
it('retains a group through repeated prepends and a later append', () => {
|
||||
const b = tool('b', 4)
|
||||
const c = tool('c', 6)
|
||||
|
||||
Reference in new issue
Block a user