fix(webui): preserve answer checkpoints and stream order (#6368)
* fix(webui): preserve answer checkpoints and stream order * fix(stream): close hosted-tool answer segments at the producer
This commit is contained in:
1 parent
d2ab462b42
commit
76da55994b
19 files changed
+745
-195
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { createThreadProjectionState, type ThreadProjectionState } from "./thread-event-projection";
|
||||
import type { UIMessage } from "./types";
|
||||
|
||||
/** Resumable, memory-only state. Visible rows alone are not a projection cursor. */
|
||||
export interface ThreadCheckpoint {
|
||||
projection: ThreadProjectionState;
|
||||
sideChannelTurnIds: Set<string>;
|
||||
}
|
||||
|
||||
export function createThreadCheckpoint(messages: UIMessage[] = []): ThreadCheckpoint {
|
||||
return { projection: createThreadProjectionState(messages), sideChannelTurnIds: new Set() };
|
||||
}
|
||||
|
||||
export function copyThreadCheckpoint(
|
||||
checkpoint: ThreadCheckpoint,
|
||||
messages = checkpoint.projection.messages,
|
||||
): ThreadCheckpoint {
|
||||
return {
|
||||
projection: {
|
||||
...checkpoint.projection,
|
||||
messages,
|
||||
closedAssistantIds: new Set(checkpoint.projection.closedAssistantIds),
|
||||
closedAnswerStreamIds: new Set(checkpoint.projection.closedAnswerStreamIds),
|
||||
closedTurnIds: new Set(checkpoint.projection.closedTurnIds),
|
||||
turnAliases: new Map(checkpoint.projection.turnAliases),
|
||||
},
|
||||
sideChannelTurnIds: new Set(checkpoint.sideChannelTurnIds),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user