Unify approval tool message rendering
This commit is contained in:
@@ -199,6 +199,7 @@ func TestRenderCodexCommandExecutionItem(t *testing.T) {
|
||||
item := codexThreadItemView{
|
||||
Type: "commandExecution",
|
||||
Command: "go test ./...",
|
||||
CWD: "/workspace/project",
|
||||
AggregatedOutput: &output,
|
||||
ExitCode: &exitCode,
|
||||
}
|
||||
@@ -208,6 +209,11 @@ func TestRenderCodexCommandExecutionItem(t *testing.T) {
|
||||
t.Fatalf("rendered command item missing %q in %q", want, text)
|
||||
}
|
||||
}
|
||||
commandAt := strings.Index(text, "<b>Command</b>")
|
||||
cwdAt := strings.Index(text, "<b>CWD:</b>")
|
||||
if cwdAt >= 0 && commandAt > cwdAt {
|
||||
t.Fatalf("command label should render before CWD to avoid Telegram attaching it to the CWD line: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderCodexStartedItems(t *testing.T) {
|
||||
@@ -244,11 +250,40 @@ func TestRenderApprovalDetailsAvoidsRawJSONDump(t *testing.T) {
|
||||
t.Fatalf("approval render missing %q in %q", want, text)
|
||||
}
|
||||
}
|
||||
summary, _, _ := strings.Cut(text, "<blockquote expandable>")
|
||||
for _, unwanted := range []string{"go test ./...", "/workspace/project"} {
|
||||
if strings.Contains(summary, unwanted) {
|
||||
t.Fatalf("approval summary should not include %q in %q", unwanted, summary)
|
||||
}
|
||||
}
|
||||
if strings.Contains(text, "unused") {
|
||||
t.Fatalf("approval render should omit unused JSON: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApprovalOnlyToolMessageCanReceiveCompletionDetails(t *testing.T) {
|
||||
exitCode := 0
|
||||
duration := int64(1234)
|
||||
output := "done"
|
||||
tool := toolMessageState{
|
||||
approvalHTML: SummaryDetailsHTML("Codex requests command approval", "approval details"),
|
||||
}
|
||||
tool.toolHTML = renderCodexItemCompleted(codexThreadItemView{
|
||||
Type: "commandExecution",
|
||||
Command: "go test ./...",
|
||||
CWD: "/workspace/project",
|
||||
ExitCode: &exitCode,
|
||||
DurationMs: &duration,
|
||||
AggregatedOutput: &output,
|
||||
})
|
||||
text := tool.html()
|
||||
for _, want := range []string{"Tool call: command finished", "Exit code: 0", "Duration ms", "1234", "Codex requests command approval"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("combined approval tool message missing %q in %q", want, 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