use workingDir if shellInstance is nil otherwise use cwd if shellInstance is not nil

Fuad created

Change summary

internal/llm/tools/shell/shell.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

internal/llm/tools/shell/shell.go 🔗

@@ -47,8 +47,10 @@ func GetPersistentShell(workingDir string) *PersistentShell {
 		shellInstance = newPersistentShell(workingDir)
 	})
 
-	if shellInstance == nil || !shellInstance.isAlive {
+	if shellInstance == nil {
 		shellInstance = newPersistentShell(workingDir)
+	} else if !shellInstance.isAlive {
+		shellInstance = newPersistentShell(shellInstance.cwd)
 	}
 
 	return shellInstance