Spaces:
Runtime error
Runtime error
| /** | |
| * fork.ts — Pure function to fork a SavedResponse into a new ChatState. | |
| * | |
| * Extracted from App.tsx handleSelectSavedResponse for testability. | |
| * | |
| * Requirements: 7.5 | |
| */ | |
| import type { ChatState, SavedResponse } from "../types"; | |
| /** | |
| * Forks a SavedResponse into a new ChatState. | |
| * | |
| * The new ChatState: | |
| * - Has a new conversationId (distinct from source_conversation_id) | |
| * - messages equals messages_pair from the SavedResponse | |
| * - history equals history_pair from the SavedResponse | |
| * - results contains { "1": sr.result } | |
| * - Streaming state is reset (null/empty/false) | |
| * | |
| * @param sr - The SavedResponse to fork | |
| * @param newConversationId - A new UUID for the forked session | |
| * @returns A fresh ChatState seeded with the saved response data | |
| */ | |
| export function forkSavedResponse( | |
| sr: SavedResponse, | |
| newConversationId: string | |
| ): ChatState { | |
| return { | |
| conversationId: newConversationId, | |
| messages: sr.messages_pair, | |
| history: sr.history_pair, | |
| results: { "1": sr.result }, | |
| streamingIndex: null, | |
| streamingContent: "", | |
| isStreaming: false, | |
| }; | |
| } | |