|
|
@@ -87,6 +87,32 @@ describe('ordinary v2 canonical writer', () => {
|
|
|
reopened.close()
|
|
|
}
|
|
|
})
|
|
|
+ it('drops the local queue entry once the upstream accepts the prompt immediately', () => {
|
|
|
+ const { store, send } = setup()
|
|
|
+ store.recordCommand(...scope, 'prompt.submit', { text: '第一问', _delivery_id: 'web:prompt:one' })
|
|
|
+ send('command.confirmed', { delivery_id: 'web:prompt:one' })
|
|
|
+ send('message.start')
|
|
|
+ send('message.delta', { text: '第一答' })
|
|
|
+ // A lingering background job keeps the transcript head "running" after
|
|
|
+ // the visible turn finished.
|
|
|
+ send('message.complete', { text: '第一答', background_pending: 1 })
|
|
|
+ store.recordCommand(...scope, 'prompt.submit', { text: '第二问', _delivery_id: 'web:prompt:two' })
|
|
|
+ expect(store.transcripts.head(...scope).queued).toBe(true)
|
|
|
+ // The upstream was actually idle and accepted the second prompt for
|
|
|
+ // immediate execution; the local queue entry was only a stale mirror.
|
|
|
+ send('command.confirmed', { delivery_id: 'web:prompt:two' })
|
|
|
+ const head = store.transcripts.head(...scope)
|
|
|
+ expect(head.queued).toBe(false)
|
|
|
+ expect(head.queue).toHaveLength(0)
|
|
|
+ send('message.start')
|
|
|
+ send('message.delta', { text: '第二答' })
|
|
|
+ send('message.complete', { text: '第二答' })
|
|
|
+ const all = messages(store)
|
|
|
+ expect(all.filter((m) => m.role === 'user')).toHaveLength(2)
|
|
|
+ expect(all.filter((m) => m.final_result)).toHaveLength(2)
|
|
|
+ expect(new Set(all.filter((m) => m.role === 'assistant').map((m) => m.turn_id)).size).toBe(2)
|
|
|
+ expect(store.transcripts.head(...scope).running).toBe(false)
|
|
|
+ })
|
|
|
it('keeps steer in the current turn without moving the reply behind a future user', () => {
|
|
|
const { store, send } = setup()
|
|
|
store.recordCommand(...scope, 'prompt.submit', { text: '开始', _delivery_id: 'web:prompt:one' })
|