mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 05:45:51 +00:00
20 lines
649 B
TypeScript
20 lines
649 B
TypeScript
import { useMemo } from 'react'
|
|
import { useAppState } from '../state/AppState.js'
|
|
import {
|
|
isLocalAgentTask,
|
|
type LocalAgentTaskState,
|
|
} from '../tasks/LocalAgentTask/LocalAgentTask.js'
|
|
|
|
export function useBackgroundAgentTasks(): LocalAgentTaskState[] {
|
|
const tasks = useAppState(s => s.tasks)
|
|
return useMemo(() => {
|
|
const now = Date.now()
|
|
return Object.values(tasks)
|
|
.filter(isLocalAgentTask)
|
|
.filter(t => t.agentType !== 'main-session')
|
|
.filter(t => t.isBackgrounded !== false)
|
|
.filter(t => t.evictAfter === undefined || t.evictAfter > now)
|
|
.sort((a, b) => a.startTime - b.startTime)
|
|
}, [tasks])
|
|
}
|