Skip to content

Commit 5120af5

Browse files
committed
fix: keep artifact nav index when contents are refreshed
1 parent 00bddb6 commit 5120af5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib/components/chat/Artifacts.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
});
9999
100100
artifactContents.subscribe((value) => {
101+
const prevLength = contents.length;
101102
contents = value;
102103
console.log('Artifact contents updated:', contents);
103104
@@ -106,7 +107,9 @@
106107
showArtifacts.set(false);
107108
}
108109
109-
selectedContentIdx = contents ? contents.length - 1 : 0;
110+
if (contents.length > prevLength) {
111+
selectedContentIdx = contents.length - 1;
112+
}
110113
});
111114
});
112115
</script>

0 commit comments

Comments
 (0)