Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions server/drivers/codex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ describe("CodexDriver turns (fake app-server)", () => {
expect(threadStart.params).toMatchObject({ model: "gpt-5.6-sol", modelProvider: "openai" });
});

it("keeps the full command when a Windows interpreter prefix is long", async () => {
await create({ mode: "windows-command" });
await instance.adapter.sendTurn({ threadId: "t-windows-command", text: "read notes" });

const command = [
"\"C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\"",
"-Command",
`\"Get-Content -Raw -LiteralPath 'C:\\Users\\Ada\\workspaces\\${"very-long-folder\\".repeat(8)}NOTES.md'\"`,
].join(" ");
expect(command.length).toBeGreaterThan(200);
const opened = await recorder.until((event) => event.type === "request.opened");
expect(recorder.events.find((event) => event.type === "item.started")).toMatchObject({
type: "item.started",
title: command,
});
expect(opened).toMatchObject({ requestType: "permission", summary: command });

await instance.adapter.respondToRequest("t-windows-command", opened.requestId!, { behavior: "allow" });
await recorder.until((event) => event.type === "turn.completed");
});

it("uses the instance environment for the Codex process", async () => {
const codexHome = join(scratch, "custom-codex-home");
await create({ environment: { CODEX_HOME: codexHome } });
Expand Down
4 changes: 2 additions & 2 deletions server/drivers/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
const requestId = newId();
const summary =
typeof params.command === "string"
? params.command.slice(0, 200)
? params.command
: Array.isArray(params.questions)
? params.questions.map((q: any) => q.question ?? q.header).filter(Boolean).join(" · ")
: typeof params.reason === "string"
Expand Down Expand Up @@ -325,7 +325,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
const item = p.item ?? {};
const title =
item.type === "commandExecution"
? String(item.command ?? "shell").slice(0, 80)
? String(item.command ?? "shell")
: item.type === "fileChange"
? "edit"
: item.type === "mcpToolCall"
Expand Down
19 changes: 14 additions & 5 deletions server/testing/fake-codex-app-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// initialize/thread/turn handshake, then plays a scripted turn. Like the
// real app-server, it never exits on its own — the driver kills it.
//
// FAKE_CODEX_MODE happy (default) | approval | resume | stream |
// FAKE_CODEX_MODE happy (default) | approval | resume | stream | windows-command |
// logged-in-stdout | logged-out | unauthorized
// FAKE_CODEX_DUMP path to write {argv, env, calls, decision} as JSON
//
Expand Down Expand Up @@ -121,7 +121,7 @@ process.stdin.on("data", (chunk) => {
case "thread/start":
out({ jsonrpc: "2.0", id: msg.id, result: { thread: { id: "codex-thread-1" }, model: "fake-codex-model" } });
break;
case "turn/start":
case "turn/start": {
if (mode === "unauthorized") {
out({
jsonrpc: "2.0",
Expand All @@ -134,15 +134,24 @@ process.stdin.on("data", (chunk) => {
break;
}
out({ jsonrpc: "2.0", id: msg.id, result: { ok: true } });
notify("item/started", { item: { id: "i1", type: "commandExecution", command: "ls -la" } });
const command = mode === "windows-command"
? [
"\"C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\"",
"-Command",
`\"Get-Content -Raw -LiteralPath 'C:\\Users\\Ada\\workspaces\\${"very-long-folder\\".repeat(8)}NOTES.md'\"`,
].join(" ")
: "ls -la";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
notify("item/started", { item: { id: "i1", type: "commandExecution", command } });
notify("item/started", { item: { id: "w1", type: "webSearch", query: "OpenMausBot" } });
if (mode === "approval") {
out({ jsonrpc: "2.0", id: 100, method: "execCommandApproval", params: { command: "rm -rf scratch" } });
if (mode === "approval" || mode === "windows-command") {
const approvalCommand = mode === "windows-command" ? command : "rm -rf scratch";
out({ jsonrpc: "2.0", id: 100, method: "execCommandApproval", params: { command: approvalCommand } });
// turn continues from the approval response handler above
} else {
finishTurn();
}
break;
}
default:
if (msg.id !== undefined) out({ jsonrpc: "2.0", id: msg.id, result: {} });
}
Expand Down
Loading