mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 00:03:46 +00:00
fix(native-chat): preserve stopped turn identity
This commit is contained in:
@@ -71,7 +71,7 @@ describe('native chat working suppression', () => {
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('stops suppressing when the conversation or user turn changes', () => {
|
||||
it('stops suppressing when the conversation changes', () => {
|
||||
expect(
|
||||
shouldSuppressNativeChatWorking({
|
||||
...interruption,
|
||||
@@ -80,6 +80,20 @@ describe('native chat working suppression', () => {
|
||||
interruption
|
||||
})
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps suppression when an initially unknown session id hydrates', () => {
|
||||
const sessionPendingInterruption = { ...interruption, sessionId: null }
|
||||
expect(
|
||||
shouldSuppressNativeChatWorking({
|
||||
...interruption,
|
||||
working: true,
|
||||
interruption: sessionPendingInterruption
|
||||
})
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps suppressing when the interrupted epoch only gains its transcript id', () => {
|
||||
expect(
|
||||
shouldSuppressNativeChatWorking({
|
||||
...interruption,
|
||||
@@ -87,10 +101,10 @@ describe('native chat working suppression', () => {
|
||||
userTurnKey: 'turn-2',
|
||||
interruption
|
||||
})
|
||||
).toBe(false)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('suppresses an interrupted turn when its working epoch is unavailable', () => {
|
||||
it('falls back to user-turn identity when the working epoch is unavailable', () => {
|
||||
const noEpochInterruption = { ...interruption, workingEpoch: null }
|
||||
expect(
|
||||
shouldSuppressNativeChatWorking({
|
||||
|
||||
@@ -33,16 +33,17 @@ export function shouldSuppressNativeChatWorking(args: {
|
||||
interruption === null ||
|
||||
interruption.paneKey !== args.paneKey ||
|
||||
interruption.agent !== args.agent ||
|
||||
interruption.sessionId !== args.sessionId ||
|
||||
interruption.userTurnKey !== args.userTurnKey
|
||||
(interruption.sessionId != null &&
|
||||
args.sessionId != null &&
|
||||
interruption.sessionId !== args.sessionId)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
interruption.workingEpoch == null ||
|
||||
args.workingEpoch == null ||
|
||||
args.workingEpoch <= interruption.workingEpoch
|
||||
)
|
||||
if (interruption.workingEpoch != null && args.workingEpoch != null) {
|
||||
// A known hook epoch outranks transcript ids replaced during optimistic catch-up.
|
||||
return args.workingEpoch <= interruption.workingEpoch
|
||||
}
|
||||
return interruption.userTurnKey === args.userTurnKey
|
||||
}
|
||||
|
||||
export function shouldShowNativeChatWorking(args: {
|
||||
|
||||
Reference in New Issue
Block a user