Trim command tool summaries

This commit is contained in:
Codex
2026-05-24 03:10:30 +00:00
parent a31157eea7
commit fd80780581
2 changed files with 5 additions and 18 deletions

View File

@@ -23,7 +23,6 @@ import (
const (
telegramDownloadLimit = 20 * 1024 * 1024
resumeThreadPageSize = 8
commandSummaryLimit = 120
telegramPhotoDirectiveStart = "<!-- telegram-photo "
telegramThreadRenameDirectiveStart = "<!-- codex-thread-rename "
telegramThreadCWDDirectiveStart = "<!-- codex-thread-cwd "
@@ -1194,7 +1193,7 @@ func parseCodexThreadItem(raw json.RawMessage) (codexThreadItemView, error) {
func renderCodexItemStarted(item codexThreadItemView) string {
switch item.Type {
case "commandExecution":
return SummaryDetailsRawHTMLLimited(joinNonEmpty("Tool call: command started", commandSummaryLine(item.Command)), commandStartedDetailsHTML(item), TelegramHTMLMessageLimit)
return SummaryDetailsRawHTMLLimited("Tool call: command started", commandStartedDetailsHTML(item), TelegramHTMLMessageLimit)
case "fileChange":
return "Tool call: file change started"
case "mcpToolCall":
@@ -1221,7 +1220,7 @@ func renderCodexItemCompleted(item codexThreadItemView) string {
if item.ExitCode != nil {
status = fmt.Sprintf("Exit code: %d", *item.ExitCode)
}
return SummaryDetailsRawHTMLLimited(joinNonEmpty("Tool call: command finished", commandSummaryLine(item.Command), status), renderCodexItemDetailsHTML(item), TelegramHTMLMessageLimit)
return SummaryDetailsRawHTMLLimited(joinNonEmpty("Tool call: command finished", status), renderCodexItemDetailsHTML(item), TelegramHTMLMessageLimit)
case "fileChange":
return joinNonEmpty("Tool call: file change finished", fmt.Sprintf("Changed files: %d", len(item.Changes)), "Status: "+item.Status)
case "mcpToolCall":
@@ -1247,21 +1246,9 @@ func renderCodexItemCompleted(item codexThreadItemView) string {
}
}
func commandSummaryLine(command string) string {
command = strings.TrimSpace(command)
if command == "" {
return ""
}
runes := []rune(command)
if len(runes) <= commandSummaryLimit {
return "Command: " + command
}
return "Command: " + string(runes[:commandSummaryLimit]) + "..."
}
func commandStartedDetailsHTML(item codexThreadItemView) string {
var parts []string
if command := strings.TrimSpace(item.Command); command != "" && len([]rune(command)) > commandSummaryLimit {
if command := strings.TrimSpace(item.Command); command != "" {
parts = append(parts, "<b>Command</b>", CodeBlockHTML("bash", command))
}
if cwd := strings.TrimSpace(item.CWD); cwd != "" {
@@ -1296,7 +1283,7 @@ func renderCodexItemDetailsHTML(item codexThreadItemView) string {
switch item.Type {
case "commandExecution":
appendField("CWD", item.CWD)
if command := strings.TrimSpace(item.Command); command != "" && len([]rune(command)) > commandSummaryLimit {
if command := strings.TrimSpace(item.Command); command != "" {
parts = append(parts, "<b>Command</b>", CodeBlockHTML("bash", command))
}
appendInt("Exit code", item.ExitCode)