in codex-cli/src/components/chat/terminal-chat-tool-call-command.tsx [79:141]
export function TerminalChatToolCallApplyPatch({
commandForDisplay,
patch,
}: {
commandForDisplay: string;
patch: string;
}): React.ReactElement {
const ops = React.useMemo(() => parseApplyPatch(patch), [patch]);
const firstOp = ops?.[0];
const title = React.useMemo(() => {
if (!firstOp) {
return "";
}
return capitalize(firstOp.type);
}, [firstOp]);
const filePath = React.useMemo(() => {
if (!firstOp) {
return "";
}
return shortenPath(firstOp.path || ".");
}, [firstOp]);
if (ops == null) {
return (
<>
<Text bold color="red">
Invalid Patch
</Text>
<Text color="red" dimColor>
The provided patch command is invalid.
</Text>
<Text dimColor>{commandForDisplay}</Text>
</>
);
}
if (!firstOp) {
return (
<>
<Text bold color="yellow">
Empty Patch
</Text>
<Text color="yellow" dimColor>
No operations found in the patch command.
</Text>
<Text dimColor>{commandForDisplay}</Text>
</>
);
}
return (
<>
<Text>
<Text bold>{title}</Text> <Text dimColor>{filePath}</Text>
</Text>
<Text>
<Text dimColor>$</Text> {commandForDisplay}
</Text>
</>
);
}