Skip to content

Commit 9f1fbfd

Browse files
fix: align approval text with codex
1 parent 1f97ebe commit 9f1fbfd

5 files changed

Lines changed: 33 additions & 18 deletions

File tree

src/CodexApprovalHandler.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ import {logger} from "./Logger";
1313
import {stripShellPrefix} from "./CodexEventHandler";
1414
import {ApprovalOptionId} from "./ApprovalOptionId";
1515

16-
const APPROVAL_OPTIONS: acp.PermissionOption[] = [
17-
{ optionId: ApprovalOptionId.AllowOnce, name: "Allow Once", kind: "allow_once" },
18-
{ optionId: ApprovalOptionId.AllowForSession, name: "Allow for Session", kind: "allow_always" },
19-
{ optionId: ApprovalOptionId.RejectOnce, name: "Reject", kind: "reject_once" },
20-
];
2116

2217
// Pair each displayed ACP option with the exact Codex decision it represents,
2318
// so response conversion does not reconstruct decisions from labels or metadata.
@@ -98,7 +93,7 @@ export class CodexApprovalHandler implements ApprovalHandler {
9893
} else if (typeof decision !== "string" && "applyNetworkPolicyAmendment" in decision) {
9994
amendmentIndex = networkAmendmentCount++;
10095
}
101-
return this.convertCommandDecisionToOption(decision, amendmentIndex);
96+
return this.convertCommandDecisionToOption(params, decision, amendmentIndex);
10297
});
10398
}
10499

@@ -128,12 +123,17 @@ export class CodexApprovalHandler implements ApprovalHandler {
128123
}
129124

130125
private convertCommandDecisionToOption(
126+
params: CommandExecutionRequestApprovalParams,
131127
decision: CommandExecutionApprovalDecision,
132128
amendmentIndex: number
133129
): CommandDecisionOption {
134130
if (decision === "accept") {
135131
return {
136-
option: { optionId: ApprovalOptionId.AllowOnce, name: "Yes, proceed", kind: "allow_once" },
132+
option: {
133+
optionId: ApprovalOptionId.AllowOnce,
134+
name: params.networkApprovalContext ? "Yes, just this once" : "Yes, proceed",
135+
kind: "allow_once"
136+
},
137137
decision
138138
};
139139
}
@@ -142,7 +142,9 @@ export class CodexApprovalHandler implements ApprovalHandler {
142142
return {
143143
option: {
144144
optionId: ApprovalOptionId.AllowForSession,
145-
name: "Yes, and don't ask again for this exact command",
145+
name: params.networkApprovalContext
146+
? "Yes, and allow this host for this conversation"
147+
: "Yes, and don't ask again for this command in this session",
146148
kind: "allow_always"
147149
},
148150
decision
@@ -211,8 +213,9 @@ export class CodexApprovalHandler implements ApprovalHandler {
211213
private networkPolicyApprovalLabel(
212214
amendment: { host: string; action: "allow" | "deny" }
213215
): string {
214-
const decision = amendment.action === "deny" ? "No" : "Yes";
215-
return `${decision}, and don't ask again for network access to \`${amendment.host}\``;
216+
return amendment.action === "deny"
217+
? "No, and block this host in the future"
218+
: "Yes, and allow this host in the future";
216219
}
217220

218221
// ACP responses only return the selected optionId. The network field is
@@ -248,7 +251,19 @@ export class CodexApprovalHandler implements ApprovalHandler {
248251
status: "pending",
249252
content: reasonContent ? [reasonContent] : null,
250253
},
251-
options: APPROVAL_OPTIONS,
254+
options: [
255+
{ optionId: ApprovalOptionId.AllowOnce, name: "Yes, proceed", kind: "allow_once" },
256+
{
257+
optionId: ApprovalOptionId.AllowForSession,
258+
name: "Yes, and don't ask again for these files",
259+
kind: "allow_always"
260+
},
261+
{
262+
optionId: ApprovalOptionId.RejectOnce,
263+
name: "No, and tell Codex what to do differently",
264+
kind: "reject_once"
265+
},
266+
],
252267
};
253268
}
254269

src/__tests__/CodexACPAgent/data/approval-command-allow-once.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"optionId": "allow_for_session",
29-
"name": "Yes, and don't ask again for this exact command",
29+
"name": "Yes, and don't ask again for this command in this session",
3030
"kind": "allow_always"
3131
},
3232
{

src/__tests__/CodexACPAgent/data/approval-command-network-policy.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
},
2727
{
2828
"optionId": "allow_for_session",
29-
"name": "Yes, and don't ask again for this exact command",
29+
"name": "Yes, and don't ask again for this command in this session",
3030
"kind": "allow_always"
3131
},
3232
{
3333
"optionId": "apply_network_policy_amendment",
34-
"name": "Yes, and don't ask again for network access to `registry.npmjs.org`",
34+
"name": "Yes, and allow this host in the future",
3535
"kind": "allow_always"
3636
},
3737
{

src/__tests__/CodexACPAgent/data/approval-command-with-rawInput.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
{
3131
"optionId": "allow_for_session",
32-
"name": "Yes, and don't ask again for this exact command",
32+
"name": "Yes, and don't ask again for this command in this session",
3333
"kind": "allow_always"
3434
},
3535
{

src/__tests__/CodexACPAgent/data/approval-file-change.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
"options": [
2121
{
2222
"optionId": "allow_once",
23-
"name": "Allow Once",
23+
"name": "Yes, proceed",
2424
"kind": "allow_once"
2525
},
2626
{
2727
"optionId": "allow_for_session",
28-
"name": "Allow for Session",
28+
"name": "Yes, and don't ask again for these files",
2929
"kind": "allow_always"
3030
},
3131
{
3232
"optionId": "reject_once",
33-
"name": "Reject",
33+
"name": "No, and tell Codex what to do differently",
3434
"kind": "reject_once"
3535
}
3636
]

0 commit comments

Comments
 (0)