1+ import { usePageVisibility } from "@solid-primitives/page-visibility"
12import { Component , createEffect , createMemo , createSignal , For , Match , on , Show , Switch , type JSX } from "solid-js"
23import stripAnsi from "strip-ansi"
34import { createStore } from "solid-js/store"
@@ -254,8 +255,6 @@ function urls(text: string | undefined) {
254255const CONTEXT_GROUP_TOOLS = new Set ( [ "read" , "glob" , "grep" , "list" ] )
255256const HIDDEN_TOOLS = new Set ( [ "todowrite" , "todoread" ] )
256257
257- import { pageVisible } from "../hooks/use-page-visible"
258-
259258function createGroupOpenState ( ) {
260259 const [ state , setState ] = createStore < Record < string , boolean > > ( { } )
261260 const read = ( key ?: string , collapse ?: boolean ) => {
@@ -277,6 +276,7 @@ function createGroupOpenState() {
277276function shouldCollapseGroup (
278277 statuses : ( string | undefined ) [ ] ,
279278 opts : { afterTool ?: boolean ; groupTail ?: boolean ; working ?: boolean } ,
279+ pageVisible : ( ) => boolean ,
280280) {
281281 if ( opts . afterTool ) return true
282282 if ( opts . groupTail === false ) return true
@@ -363,6 +363,7 @@ export function AssistantParts(props: {
363363} ) {
364364 const data = useData ( )
365365 const emptyParts : PartType [ ] = [ ]
366+ const pageVisible = usePageVisibility ( )
366367 const groupState = createGroupOpenState ( )
367368 const grouped = createMemo ( ( ) => {
368369 const keys : string [ ] = [ ]
@@ -485,11 +486,15 @@ export function AssistantParts(props: {
485486 groupTail ?: boolean ,
486487 group ?: { part : ToolPart ; message : AssistantMessage } [ ] ,
487488 ) =>
488- shouldCollapseGroup ( group ?. map ( ( item ) => item . part . state . status ) ?? [ ] , {
489- afterTool,
490- groupTail,
491- working : props . working ,
492- } )
489+ shouldCollapseGroup (
490+ group ?. map ( ( item ) => item . part . state . status ) ?? [ ] ,
491+ {
492+ afterTool,
493+ groupTail,
494+ working : props . working ,
495+ } ,
496+ pageVisible ,
497+ )
493498 const value = ctx ( )
494499 if ( value ) return groupState . read ( value . groupKey , collapse ( value . afterTool , value . tail , value . parts ) )
495500 const entry = part ( )
0 commit comments