File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
site/src/modules/resources/AgentLogs Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,18 @@ export function useAgentLogs(
31
31
const queryOptions = agentLogs ( workspaceId , agentId ) ;
32
32
const { data : logs , isFetched } = useQuery ( { ...queryOptions , enabled } ) ;
33
33
34
+ // Track the ID of the last log received when the initial logs response comes
35
+ // back. If the logs are not complete, the ID will mark the start point of the
36
+ // Web sockets response so that the remaining logs can be received over time
34
37
const lastQueriedLogId = useRef ( 0 ) ;
35
38
useEffect ( ( ) => {
36
- const lastLog = logs ?. at ( - 1 ) ;
37
- const canSetLogId = lastLog !== undefined && lastQueriedLogId . current === 0 ;
39
+ const isAlreadyTracking = lastQueriedLogId . current !== 0 ;
40
+ if ( isAlreadyTracking ) {
41
+ return ;
42
+ }
38
43
39
- if ( canSetLogId ) {
44
+ const lastLog = logs ?. at ( - 1 ) ;
45
+ if ( lastLog !== undefined ) {
40
46
lastQueriedLogId . current = lastLog . id ;
41
47
}
42
48
} , [ logs ] ) ;
You can’t perform that action at this time.
0 commit comments