fix: prevent closed artifacts from reopening when switching chats (#1280)
This commit is contained in:
parent
4e0e2222ac
commit
6a02d4fa9a
1 changed files with 3 additions and 4 deletions
|
|
@ -6,18 +6,17 @@ import { artifactDefinitions } from "./artifact";
|
|||
import { useDataStream } from "./data-stream-provider";
|
||||
|
||||
export function DataStreamHandler() {
|
||||
const { dataStream } = useDataStream();
|
||||
const { dataStream,setDataStream } = useDataStream();
|
||||
|
||||
const { artifact, setArtifact, setMetadata } = useArtifact();
|
||||
const lastProcessedIndex = useRef(-1);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dataStream?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newDeltas = dataStream.slice(lastProcessedIndex.current + 1);
|
||||
lastProcessedIndex.current = dataStream.length - 1;
|
||||
const newDeltas = dataStream.slice();
|
||||
setDataStream([]);
|
||||
|
||||
for (const delta of newDeltas) {
|
||||
const artifactDefinition = artifactDefinitions.find(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue