Skip to content

Commit a5cfe8c

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
fix: reopen artifacts sidebar when returning to a backgrounded tab
1 parent b843092 commit a5cfe8c

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/lib/components/chat/Chat.svelte

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,25 @@
738738
};
739739
init();
740740
741+
const onVisibilityChange = () => {
742+
if (document.visibilityState === 'visible') {
743+
getContents();
744+
const contents = get(artifactContents);
745+
if (contents && contents.length > 0 && !get(showControls) && !get(mobile)) {
746+
showArtifacts.set(true);
747+
showControls.set(true);
748+
}
749+
}
750+
};
751+
document.addEventListener('visibilitychange', onVisibilityChange);
752+
741753
return () => {
742754
try {
743755
pageSubscribe();
744756
showControlsSubscribe();
745757
selectedFolderSubscribe();
746758
window.removeEventListener('message', onMessageHandler);
759+
document.removeEventListener('visibilitychange', onVisibilityChange);
747760
$socket?.off('events', chatEventHandler);
748761
audioQueueInstance?.destroy();
749762
audioQueue.set(null);

0 commit comments

Comments
 (0)