Show only commands in Codex shell tool calls (#2029)

* fix(codex): hide shell launchers from command summaries

Codex only unwrapped POSIX shells from /bin. Commands launched through /usr/bin/zsh therefore exposed the wrapper in the tool-call row.

* test(codex): preserve shell wrapper path coverage
This commit is contained in:
Mohamed Boudra
2026-07-12 23:12:20 +02:00
committed by GitHub
parent a849bc6bda
commit 4a1534cacd
2 changed files with 22 additions and 17 deletions

View File

@@ -51,23 +51,26 @@ describe("codex tool-call mapper", () => {
});
});
it("unwraps shell wrapper strings for commandExecution", () => {
const item = expectMapped(
mapCodexToolCallFromThreadItem({
type: "commandExecution",
id: "codex-call-wrapper-string",
status: "running",
command: '/bin/zsh -lc "echo hello"',
cwd: "/tmp/repo",
}),
);
it.each(['/bin/zsh -lc "echo hello"', '/usr/bin/zsh -lc "echo hello"'])(
"unwraps zsh wrapper strings for commandExecution: %s",
(command) => {
const item = expectMapped(
mapCodexToolCallFromThreadItem({
type: "commandExecution",
id: "codex-call-wrapper-string",
status: "running",
command,
cwd: "/tmp/repo",
}),
);
expect(item.detail).toEqual({
type: "shell",
command: "echo hello",
cwd: "/tmp/repo",
});
});
expect(item.detail).toEqual({
type: "shell",
command: "echo hello",
cwd: "/tmp/repo",
});
},
);
it("unwraps pwsh wrapper strings for commandExecution on Windows", () => {
const item = expectMapped(

View File

@@ -221,7 +221,9 @@ const CodexThreadItemSchema = z.discriminatedUnion("type", [
function maybeUnwrapShellWrapperCommand(command: string): string {
const trimmed = command.trim();
const unixWrapperMatch = trimmed.match(/^(?:\/bin\/)?(?:zsh|bash|sh)\s+-(?:lc|c)\s+([\s\S]+)$/);
const unixWrapperMatch = trimmed.match(
/^(?:(?:\/[^/\s]+)*\/)?(?:zsh|bash|sh)\s+-(?:lc|c)\s+([\s\S]+)$/,
);
if (unixWrapperMatch) {
const candidate = unixWrapperMatch[1]?.trim() ?? "";
if (!candidate) {