- 
                Notifications
    You must be signed in to change notification settings 
- Fork 563
feat: Enhance executable resolution by refreshing PATH #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            abcpro1
  wants to merge
  4
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
path-refresh
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +561
        
        
          −210
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -125,34 +125,51 @@ impl ClaudeCode { | |
|  | ||
| apply_overrides(builder, &self.cmd) | ||
| } | ||
| } | ||
|  | ||
| #[async_trait] | ||
| impl StandardCodingAgentExecutor for ClaudeCode { | ||
| async fn spawn(&self, current_dir: &Path, prompt: &str) -> Result<SpawnedChild, ExecutorError> { | ||
| let (shell_cmd, shell_arg) = get_shell_command(); | ||
| async fn spawn( | ||
| &self, | ||
| current_dir: &Path, | ||
| prompt: &str, | ||
| session_id: Option<&str>, | ||
| ) -> Result<SpawnedChild, ExecutorError> { | ||
| let command_builder = self.build_command_builder().await; | ||
| let mut base_command = command_builder.build_initial(); | ||
| let command_parts = if let Some(session_id) = session_id { | ||
| command_builder.build_follow_up(&[ | ||
| "--fork-session".to_string(), | ||
| "--resume".to_string(), | ||
| session_id.to_string(), | ||
| ])? | ||
| } else { | ||
| command_builder.build_initial()? | ||
| }; | ||
|  | ||
| if self.plan.unwrap_or(false) { | ||
| base_command = create_watchkill_script(&base_command); | ||
| } | ||
| let plan_enabled = self.plan.unwrap_or(false); | ||
|  | ||
| if self.approvals.unwrap_or(false) || self.plan.unwrap_or(false) { | ||
| if self.approvals.unwrap_or(false) || plan_enabled { | ||
| write_python_hook(current_dir).await? | ||
| } | ||
|  | ||
| let combined_prompt = self.append_prompt.combine_prompt(prompt); | ||
|  | ||
| let mut command = Command::new(shell_cmd); | ||
| let mut command = if plan_enabled { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly think that this can be removed | ||
| let plan_script = create_watchkill_script(&command_parts.to_shell_string()?); | ||
| let (shell_cmd, shell_arg) = get_shell_command(); | ||
| let mut cmd = Command::new(shell_cmd); | ||
| cmd.arg(shell_arg).arg(plan_script); | ||
| cmd | ||
| } else { | ||
| let (program_path, args) = command_parts.into_resolved().await?; | ||
| let mut cmd = Command::new(program_path); | ||
| cmd.args(&args); | ||
| cmd | ||
| }; | ||
|  | ||
| command | ||
| .kill_on_drop(true) | ||
| .stdin(Stdio::piped()) | ||
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::piped()) | ||
| .current_dir(current_dir) | ||
| .arg(shell_arg) | ||
| .arg(&base_command); | ||
| .current_dir(current_dir); | ||
|  | ||
| let mut child = command.group_spawn()?; | ||
|  | ||
|  | @@ -164,51 +181,21 @@ impl StandardCodingAgentExecutor for ClaudeCode { | |
|  | ||
| Ok(child.into()) | ||
| } | ||
| } | ||
|  | ||
| #[async_trait] | ||
| impl StandardCodingAgentExecutor for ClaudeCode { | ||
| async fn spawn(&self, current_dir: &Path, prompt: &str) -> Result<SpawnedChild, ExecutorError> { | ||
| self.spawn(current_dir, prompt, None).await | ||
| } | ||
|  | ||
| async fn spawn_follow_up( | ||
| &self, | ||
| current_dir: &Path, | ||
| prompt: &str, | ||
| session_id: &str, | ||
| ) -> Result<SpawnedChild, ExecutorError> { | ||
| let (shell_cmd, shell_arg) = get_shell_command(); | ||
| let command_builder = self.build_command_builder().await; | ||
| // Build follow-up command with --resume {session_id} | ||
| let mut base_command = command_builder.build_follow_up(&[ | ||
| "--fork-session".to_string(), | ||
| "--resume".to_string(), | ||
| session_id.to_string(), | ||
| ]); | ||
|  | ||
| if self.plan.unwrap_or(false) { | ||
| base_command = create_watchkill_script(&base_command); | ||
| } | ||
|  | ||
| if self.approvals.unwrap_or(false) || self.plan.unwrap_or(false) { | ||
| write_python_hook(current_dir).await? | ||
| } | ||
|  | ||
| let combined_prompt = self.append_prompt.combine_prompt(prompt); | ||
|  | ||
| let mut command = Command::new(shell_cmd); | ||
| command | ||
| .kill_on_drop(true) | ||
| .stdin(Stdio::piped()) | ||
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::piped()) | ||
| .current_dir(current_dir) | ||
| .arg(shell_arg) | ||
| .arg(&base_command); | ||
|  | ||
| let mut child = command.group_spawn()?; | ||
|  | ||
| // Feed the followup prompt in, then close the pipe | ||
| if let Some(mut stdin) = child.inner().stdin.take() { | ||
| stdin.write_all(combined_prompt.as_bytes()).await?; | ||
| stdin.shutdown().await?; | ||
| } | ||
|  | ||
| Ok(child.into()) | ||
| self.spawn(current_dir, prompt, Some(session_id)).await | ||
| } | ||
|  | ||
| fn normalize_logs(&self, msg_store: Arc<MsgStore>, current_dir: &Path) { | ||
|  | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this and associated logic now that the watchkill script has been removed