Improve tool detail formatting
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -155,7 +156,7 @@ func TestRenderCodexCommandExecutionItem(t *testing.T) {
|
||||
ExitCode: &exitCode,
|
||||
}
|
||||
text := renderCodexItemCompleted(item)
|
||||
for _, want := range []string{"Tool call: command finished", "Command: go test ./...", "Exit code: 0", "line 1"} {
|
||||
for _, want := range []string{"Tool call: command finished", "Command: go test ./...", "Exit code: 0", "<pre><code class=\"language-text\">line 1\nline 2</code></pre>"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("rendered command item missing %q in %q", want, text)
|
||||
}
|
||||
@@ -169,6 +170,38 @@ func TestRenderCodexStartedItems(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderDynamicToolDetailsSelectsUsefulArguments(t *testing.T) {
|
||||
item := codexThreadItemView{
|
||||
Type: "dynamicToolCall",
|
||||
Namespace: "functions",
|
||||
Tool: "exec_command",
|
||||
Status: "completed",
|
||||
Arguments: json.RawMessage(`{"cmd":"go test ./...","irrelevant":{"large":"object"}}`),
|
||||
}
|
||||
text := renderCodexItemCompleted(item)
|
||||
for _, want := range []string{"Tool: functions.exec_command", "<b>cmd</b>", "language-bash", "go test ./..."} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("rendered tool details missing %q in %q", want, text)
|
||||
}
|
||||
}
|
||||
if strings.Contains(text, "irrelevant") {
|
||||
t.Fatalf("rendered tool details should omit irrelevant argument JSON: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderApprovalDetailsAvoidsRawJSONDump(t *testing.T) {
|
||||
raw := json.RawMessage(`{"command":"go test ./...","cwd":"/workspace/project","unused":{"nested":true}}`)
|
||||
text := renderApprovalHTML("item/commandExecution/requestApproval", raw, "")
|
||||
for _, want := range []string{"Codex requests command approval", "language-bash", "go test ./...", "CWD"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("approval render missing %q in %q", want, text)
|
||||
}
|
||||
}
|
||||
if strings.Contains(text, "unused") {
|
||||
t.Fatalf("approval render should omit unused JSON: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolMessageAddsEditedAtBeforeDetails(t *testing.T) {
|
||||
tool := toolMessageState{
|
||||
toolHTML: SummaryDetailsHTML("Tool call: command finished\nCommand: go test ./...", "full output"),
|
||||
|
||||
Reference in New Issue
Block a user