feat(session): surface background shell and subagent work (#360)

* feat(session): surface background shell and subagent work

* fix(session): address review feedback on background work UI
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-26 15:49:49 -04:00
1 parent 8b806e865f
commit 1389e8e59c
20 files changed
+802 -13

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import { useMemo } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { listShells, removeShell, type ShellInfo } from '@/api/opencode'
import { shellsQueryKey } from '@/lib/queryInvalidation'
import { showToast } from '@/lib/toast'
export function useSessionShells(sessionID: string | undefined, directory: string | undefined) {
const query = useQuery({
queryKey: shellsQueryKey(directory),
queryFn: () => listShells(directory ?? ''),
enabled: Boolean(directory),
staleTime: Infinity,
})
const shells = useMemo(
() =>
(query.data ?? []).filter(
(shell) => shell.status === 'running' && shell.metadata.sessionID === sessionID,
),
[query.data, sessionID],
)
return shells
}
export function useKillShell(directory: string | undefined) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (id: string) => removeShell(id, directory ?? ''),
onSuccess: (_result, id) => {
queryClient.setQueryData<ShellInfo[]>(shellsQueryKey(directory), (current) =>
current?.filter((shell) => shell.id !== id),
)
},
onError: (error) => {
showToast.error(error instanceof Error ? error.message : 'Failed to kill shell command')
},
})
}