@@ -4,6 +4,7 @@ import { GitMergeIcon, LoaderCircleIcon, Trash2Icon } from "lucide-react";
44import { useMemo } from "react" ;
55
66import { useStore } from "~/store" ;
7+ import { useHandleNewThread } from "~/hooks/useHandleNewThread" ;
78import {
89 gitMergedWorktreeCleanupCandidatesQueryOptions ,
910 gitPruneWorktreesMutationOptions ,
@@ -37,16 +38,16 @@ function resolveWorktreeUsageCount(
3738export function WorktreeCleanupDialog ( ) {
3839 const open = useWorktreeCleanupStore ( ( state ) => state . open ) ;
3940 const closeDialog = useWorktreeCleanupStore ( ( state ) => state . closeDialog ) ;
41+ const { activeThread } = useHandleNewThread ( ) ;
4042 const threads = useStore ( ( state ) => state . threads ) ;
4143 const projects = useStore ( ( state ) => state . projects ) ;
4244 const queryClient = useQueryClient ( ) ;
4345 const activeProject = useMemo ( ( ) => {
44- const firstThread = threads [ 0 ] ;
45- if ( firstThread ) {
46- return projects . find ( ( project ) => project . id === firstThread . projectId ) ?? projects [ 0 ] ?? null ;
46+ if ( activeThread ) {
47+ return projects . find ( ( project ) => project . id === activeThread . projectId ) ?? projects [ 0 ] ?? null ;
4748 }
4849 return projects [ 0 ] ?? null ;
49- } , [ projects , threads ] ) ;
50+ } , [ activeThread , projects ] ) ;
5051 const cwd = activeProject ?. cwd ?? null ;
5152 const threadWorktreePaths = useMemo (
5253 ( ) => threads . map ( ( thread ) => thread . worktreePath ) ,
@@ -133,7 +134,7 @@ export function WorktreeCleanupDialog() {
133134 const usageCount = resolveWorktreeUsageCount ( candidate , threadWorktreePaths ) ;
134135 const displayPath = formatWorktreePathForDisplay ( candidate . path ) ;
135136 const canDelete = usageCount === 0 ;
136- const actionLabel = candidate . pathExists ? "Delete worktree" : "Prune record " ;
137+ const actionLabel = candidate . pathExists ? "Delete worktree" : "Prune stale records " ;
137138
138139 return (
139140 < Card
0 commit comments