- 
                Notifications
    You must be signed in to change notification settings 
- Fork 749
feat: add support for Codex agent #6901
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c11fa51
              
                feat: add support for Codex agent
              
              
                mscolnick 367af24
              
                upgrade and handle errors
              
              
                mscolnick 8832710
              
                fix
              
              
                mscolnick 5239899
              
                dedupe
              
              
                mscolnick 099b2af
              
                fix test
              
              
                mscolnick aeed4dc
              
                improved diff
              
              
                mscolnick 178ac54
              
                more fixes
              
              
                mscolnick e503b6c
              
                Update frontend/src/components/chat/acp/blocks.tsx
              
              
                mscolnick 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
    
  
  
    
              
  
    
      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 | ||||
|---|---|---|---|---|---|---|
|  | @@ -22,7 +22,8 @@ import { | |||||
| XIcon, | ||||||
| } from "lucide-react"; | ||||||
| import React from "react"; | ||||||
| import { mergeToolCalls } from "use-acp"; | ||||||
| import { JsonRpcError, mergeToolCalls } from "use-acp"; | ||||||
| import { z } from "zod"; | ||||||
| import { ReadonlyDiff } from "@/components/editor/code/readonly-diff"; | ||||||
| import { JsonOutput } from "@/components/editor/output/JsonOutput"; | ||||||
| import { Button } from "@/components/ui/button"; | ||||||
|  | @@ -31,6 +32,7 @@ import { | |||||
| PopoverContent, | ||||||
| PopoverTrigger, | ||||||
| } from "@/components/ui/popover"; | ||||||
| import { uniqueByTakeLast } from "@/utils/arrays"; | ||||||
| import { logNever } from "@/utils/assertNever"; | ||||||
| import { cn } from "@/utils/cn"; | ||||||
| import { Strings } from "@/utils/strings"; | ||||||
|  | @@ -102,13 +104,20 @@ export const ErrorBlock = (props: { | |||||
| onRetry?: () => void; | ||||||
| onDismiss?: () => void; | ||||||
| }) => { | ||||||
| const { message } = props.data; | ||||||
| const error = props.data; | ||||||
| let message = props.data.message; | ||||||
|  | ||||||
| // Don't show WebSocket connection errors | ||||||
| if (message.includes("WebSocket")) { | ||||||
| return null; | ||||||
| } | ||||||
|  | ||||||
| if (error instanceof JsonRpcError) { | ||||||
| const dataStr = | ||||||
| typeof error.data === "string" ? error.data : JSON.stringify(error.data); | ||||||
| message = `${dataStr} (${error.code})`; | ||||||
| } | ||||||
|  | ||||||
| return ( | ||||||
| <div | ||||||
| className="border border-[var(--red-6)] bg-[var(--red-2)] rounded-lg p-4 my-2" | ||||||
|  | @@ -307,7 +316,9 @@ export const AgentThoughtsBlock = (props: { | |||||
| }; | ||||||
|  | ||||||
| export const PlansBlock = (props: { data: PlanNotificationEvent[] }) => { | ||||||
| const plans = props.data.flatMap((item) => item.entries); | ||||||
| // Dedupe plans by text, take the last one which may have a status update | ||||||
| let plans = props.data.flatMap((item) => item.entries); | ||||||
| plans = uniqueByTakeLast(plans, (item) => item.content); | ||||||
|  | ||||||
| return ( | ||||||
| <div className="rounded-lg border bg-background p-2 text-xs"> | ||||||
|  | @@ -529,6 +540,7 @@ export const SessionNotificationsBlock = < | |||||
| data: T[]; | ||||||
| startTimestamp: number; | ||||||
| endTimestamp: number; | ||||||
| isLastBlock: boolean; | ||||||
| }) => { | ||||||
| if (props.data.length === 0) { | ||||||
| return null; | ||||||
|  | @@ -537,7 +549,9 @@ export const SessionNotificationsBlock = < | |||||
|  | ||||||
| const renderItems = (items: T[]) => { | ||||||
| if (isToolCalls(items)) { | ||||||
| return <ToolNotificationsBlock data={items} />; | ||||||
| return ( | ||||||
| <ToolNotificationsBlock data={items} isLastBlock={props.isLastBlock} /> | ||||||
| ); | ||||||
| } | ||||||
| if (isAgentThoughts(items)) { | ||||||
| return ( | ||||||
|  | @@ -591,6 +605,7 @@ export const CurrentModeBlock = (props: { | |||||
|  | ||||||
| export const ToolNotificationsBlock = (props: { | ||||||
| data: (ToolCallNotificationEvent | ToolCallUpdateNotificationEvent)[]; | ||||||
| isLastBlock: boolean; | ||||||
| }) => { | ||||||
| const toolCalls = mergeToolCalls(props.data); | ||||||
|  | ||||||
|  | @@ -604,7 +619,9 @@ export const ToolNotificationsBlock = (props: { | |||||
| ? "success" | ||||||
| : item.status === "failed" | ||||||
| ? "error" | ||||||
| : item.status === "in_progress" || item.status === "pending" | ||||||
| : (item.status === "in_progress" || | ||||||
| item.status === "pending") && | ||||||
| !props.isLastBlock | ||||||
| ? "loading" | ||||||
| : undefined | ||||||
| } | ||||||
|  | @@ -631,7 +648,7 @@ export const DiffBlocks = (props: { | |||||
| return ( | ||||||
| <div | ||||||
| key={item.path} | ||||||
| className="border rounded-md overflow-hidden bg-[var(--gray-2)] overflow-y-auto scrollbar-thin" | ||||||
| className="border rounded-md overflow-hidden bg-[var(--gray-2)] overflow-y-auto scrollbar-thin max-h-64" | ||||||
| > | ||||||
| {/* File path header */} | ||||||
| <div className="px-2 py-1 bg-[var(--gray-2)] border-b text-xs font-medium text-[var(--gray-11)]"> | ||||||
|  | @@ -651,8 +668,12 @@ export const DiffBlocks = (props: { | |||||
| function toolTitle( | ||||||
| item: Pick<ToolCallUpdateNotificationEvent, "title" | "kind" | "locations">, | ||||||
| ) { | ||||||
| const prefix = | ||||||
| item.title || Strings.startCase(item.kind || "") || "Tool call"; | ||||||
| let title = item.title; | ||||||
| // Hack: sometimes title comes back: "undefined", so lets undo that | ||||||
| if (title === '"undefined"') { | ||||||
| title = undefined; | ||||||
| } | ||||||
| const prefix = title || Strings.startCase(item.kind || "") || "Tool call"; | ||||||
| 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. should it be this? 
        Suggested change
       
 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. it evaluates to the same | ||||||
| const firstLocation = item.locations?.[0]; | ||||||
| // Add the first location if it is not in the title already | ||||||
| if (firstLocation && !prefix.includes(firstLocation.path)) { | ||||||
|  | @@ -699,6 +720,22 @@ export const ToolBodyBlock = (props: { | |||||
|  | ||||||
| // Completely empty | ||||||
| if (!content && !hasLocations && rawInput) { | ||||||
| // HACK: if the raw input is `abs_path`, `old_string`, `new_string` then handle it as if it is a diff | ||||||
| const rawDiff = rawDiffSchema.safeParse(rawInput); | ||||||
| if (rawDiff.success) { | ||||||
| return ( | ||||||
| <DiffBlocks | ||||||
| data={[ | ||||||
| { | ||||||
| type: "diff", | ||||||
| oldText: rawDiff.data.old_string, | ||||||
| newText: rawDiff.data.new_string, | ||||||
| path: rawDiff.data.abs_path, | ||||||
| }, | ||||||
| ]} | ||||||
| /> | ||||||
| ); | ||||||
| } | ||||||
| // Show rawInput | ||||||
| return ( | ||||||
| <pre className="bg-[var(--slate-2)] p-1 text-muted-foreground border border-[var(--slate-4)] rounded text-xs overflow-auto scrollbar-thin max-h-64"> | ||||||
|  | @@ -728,3 +765,9 @@ export const ToolBodyBlock = (props: { | |||||
| </div> | ||||||
| ); | ||||||
| }; | ||||||
|  | ||||||
| const rawDiffSchema = z.object({ | ||||||
| abs_path: z.string(), | ||||||
| old_string: z.string(), | ||||||
| new_string: z.string(), | ||||||
| }); | ||||||
  
    
      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
    
  
  
    
              
      
      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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.