diff --git a/libs/sdk-js/src/react/stream.tsx b/libs/sdk-js/src/react/stream.tsx index 5eeafb6ed..a8df9e626 100644 --- a/libs/sdk-js/src/react/stream.tsx +++ b/libs/sdk-js/src/react/stream.tsx @@ -329,8 +329,6 @@ export function useStream< const [flatValues, flatPaths] = (() => { const result: ThreadState[] = []; - - // TODO: this is kinda ugly const flatPaths: Record< string, { current: string[] | undefined; branches: string[][] | undefined } @@ -475,7 +473,6 @@ export function useStream< // @ts-expect-error if (checkpoint != null) delete checkpoint.thread_id; - // TODO: why non-existent assistant ID does not throw an error here? const run = (await client.runs.stream(usableThreadId, assistantId, { input: values as Record, config: submitOptions?.config, @@ -496,6 +493,12 @@ export function useStream< streamMode, })) as AsyncGenerator; + // Unbranch things + const newPath = submitOptions?.checkpoint?.checkpoint_id + ? flatPaths[submitOptions?.checkpoint?.checkpoint_id]?.current + : undefined; + if (newPath != null) setBranchPath(newPath ?? []); + // Assumption: we're setting the initial value // Used for instant feedback setStreamValues(() => {