Files
zero/internal/tui/tool_display_test.go
Anandan c0a0389b09 Polish TUI transcript rendering (#334)
* Polish transcript rendering

Tighten transcript spacing, collapse noisy permission/tool rows, and render tool activity with cleaner action-oriented labels.

Improve code and diff rendering with markdown highlighting, cleaner command output blocks, and grouped exploration summaries.

Tested: env GOCACHE=/tmp/zero-go-cache go test ./internal/tui

Tested: git diff --check

* Fix grep exploration rendering on Windows

Keep search query text out of path normalization so regex escapes render consistently across platforms.

Tested: env GOCACHE=/tmp/zero-go-cache go test ./internal/tui

Tested: git diff --check

* Address transcript rendering review

Cache highlighted streaming markdown so closed code blocks are not re-lexed on every live render.

Tighten bare-code detection to avoid highlighting ordinary prose, restore manual permission audit rows, and make exploration details expandable.

Also align diff content/header predicates and use display-width truncation for compact tool output.

Tested: env GOCACHE=/tmp/zero-go-cache go test ./internal/tui

Tested: env GOCACHE=/tmp/zero-go-cache go test -race ./internal/tui

Tested: env GOCACHE=/tmp/zero-go-cache go vet ./...

Tested: git diff --check
2026-06-28 13:41:00 +05:30

42 lines
1.3 KiB
Go

package tui
import (
"strings"
"testing"
"github.com/Gitlawb/zero/internal/tools"
)
func TestToolDisplayNameCleansMCPNames(t *testing.T) {
cases := map[string]string{
"mcp_exa_web_search_exa": "web search",
"mcp_exa_web_fetch_exa": "web fetch",
"mcp_foo_bar": "bar",
"write_file": "Create",
"edit_file": "Edit",
"read_file": "Read",
"bash": "Run",
"browser_open": "Open browser",
"browser_snapshot": "Browser snapshot",
"capture_artifact": "Capture",
"web_search": "web_search", // built-in, unchanged
}
for in, want := range cases {
if got := toolDisplayName(in); got != want {
t.Errorf("toolDisplayName(%q) = %q, want %q", in, got, want)
}
}
}
func TestToolCardHeadShowsCleanMCPName(t *testing.T) {
m := transcriptViewTestModel()
row := transcriptRow{kind: rowToolResult, id: "t", tool: "mcp_exa_web_search_exa", status: tools.StatusOK, detail: "short result"}
out := plainRender(t, m.renderRow(row, m.width, buildRowContext(nil)))
if strings.Contains(out, "mcp_exa_web_search_exa") {
t.Errorf("card head must not show the raw MCP tool name:\n%s", out)
}
if !strings.Contains(out, "web search") {
t.Errorf("card head should show the clean 'web search' label:\n%s", out)
}
}