MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestStatusBarLiveTimerAndFrozenSummary

Function TestStatusBarLiveTimerAndFrozenSummary

internal/tui/tui_test.go:2288–2313  ·  view source on GitHub ↗

TestStatusBarLiveTimerAndFrozenSummary: during an active turn the bar shows the phase label plus a ticking wall-clock; at idle after a clean finish it shows the frozen ✓, the wall-clock duration, and the avg rate that divides into it (5000 tok ÷ 100s = 50 tok/s).

(t *testing.T)

Source from the content-addressed store, hash-verified

2286 // XML tool-call body.
2287 coderLeak := "Let me search.\n<tool_call>\n<function=bash>\n<parameter=cmd>ls</parameter>\n</function>\n</tool_call>"
2288 // General JSON tool-call body, the target model class, NO `<function=`.
2289 denseLeak := "Let me search.\n<tool_call>\n{\"name\": \"bash\", \"arguments\": {\"cmd\": \"ls\"}}\n</tool_call>"
2290 clean := "Done - built and tested, all green."
2291
2292 for name, leak := range map[string]string{"coder-xml": coderLeak, "dense-json": denseLeak} {
2293 if w := toolCallLeakWarning([]chmctx.Message{{Role: chmctx.RoleAssistant, Content: leak}}); w == "" {
2294 t.Fatalf("%s: leaked tool call must produce a warning", name)
2295 }
2296 }
2297 if w := toolCallLeakWarning([]chmctx.Message{{Role: chmctx.RoleAssistant, Content: clean}}); w != "" {
2298 t.Fatalf("clean reply must not warn, got %q", w)
2299 }
2300 // A message that carried a real structured tool call never leaked, even if
2301 // its prose quotes the `<tool_call>` tag: the ToolCalls gate keeps it clean.
2302 withCall := chmctx.Message{
2303 Role: chmctx.RoleAssistant,
2304 Content: "Running the build via a <tool_call> now.",
2305 ToolCalls: []chmctx.ToolCall{{ID: "1", Name: "bash", Arguments: map[string]any{"cmd": "go build ./..."}}},
2306 }
2307 if w := toolCallLeakWarning([]chmctx.Message{withCall}); w != "" {
2308 t.Fatalf("a turn with a structured tool call must not warn on incidental prose, got %q", w)
2309 }
2310 // An old leak followed by a clean reply must stay silent: only the newest
2311 // assistant message is the one that just ended the turn.
2312 hist := []chmctx.Message{
2313 {Role: chmctx.RoleAssistant, Content: coderLeak},
2314 {Role: chmctx.RoleUser, Content: "go on"},
2315 {Role: chmctx.RoleAssistant, Content: clean},
2316 }

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
stripANSIFunction · 0.85
renderStatusBarMethod · 0.80

Tested by

no test coverage detected