Handle legacy Codex approval requests

This commit is contained in:
Codex
2026-05-25 05:43:43 +00:00
parent 9dbf7727c5
commit b46c4beb86
2 changed files with 83 additions and 13 deletions
+28
View File
@@ -84,6 +84,34 @@ func TestApprovalResponseForPermissions(t *testing.T) {
}
}
func TestApprovalResponseForLegacyApproval(t *testing.T) {
approval := store.PendingApproval{Kind: "execCommandApproval"}
response, ok := approvalResponse(approval, "accept").(map[string]any)
if !ok {
t.Fatal("legacy response should be a map")
}
if response["decision"] != "approved" {
t.Fatalf("legacy accept = %v, want approved", response["decision"])
}
response, ok = approvalResponse(approval, "decline").(map[string]any)
if !ok {
t.Fatal("legacy decline response should be a map")
}
if response["decision"] != "denied" {
t.Fatalf("legacy decline = %v, want denied", response["decision"])
}
}
func TestRenderLegacyApprovalDetails(t *testing.T) {
raw := json.RawMessage(`{"conversationId":"thr_1","callId":"call_1","command":["git","remote","-v"],"cwd":"/workspace/project","reason":"Need remote details"}`)
text := renderApprovalHTML("execCommandApproval", raw, "")
for _, want := range []string{"Codex requests command approval", "Need remote details", "language-bash", "git", "CWD"} {
if !strings.Contains(text, want) {
t.Fatalf("legacy approval render missing %q in %q", want, text)
}
}
}
func TestEditReplyMarkupClearsInlineKeyboard(t *testing.T) {
markup := editReplyMarkup(nil)
if markup == nil {