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

Function TestNewestAssistantEmpty

internal/tui/tui_test.go:3202–3234  ·  view source on GitHub ↗

TestNewestAssistantEmpty pins the anomaly detector behind the empty-reply nudge: only a newest assistant message with neither text nor a structured tool call counts as empty. A summary or a tool call is a normal turn.

(t *testing.T)

Source from the content-addressed store, hash-verified

3200// TestStaleProbeDoesNotPrintActivationBannerForNonActiveProfile: a probe for a
3201// profile the user has /models'd away from must not print "✓ active: <profile>":
3202// the banner would be a lie. Pairs with the connection-state guard in
3203// TestStaleProbeForOldProfileDoesNotOverwriteConnectedFlag.
3204func TestStaleProbeDoesNotPrintActivationBannerForNonActiveProfile(t *testing.T) {
3205 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
3206 m.cfg.Active = "local"
3207
3208 out, _ := m.handleProbe(probeMsg{profile: "hamrpass", contextWindow: 262144})
3209 final := out.(Model)
3210 if got := stripANSI(final.scroll.String()); strings.Contains(got, "✓ active: hamrpass") {
3211 t.Fatalf("stale probe must not print activation banner for non-active profile:\n%s", got)
3212 }
3213
3214 // Sanity: probe for the live profile with the live client DOES print the banner.
3215 m2 := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
3216 m2.cfg.Active = "local"
3217 out2, _ := m2.handleProbe(probeMsg{profile: "local", cli: m2.cli, contextWindow: 256000})
3218 final2 := out2.(Model)
3219 if got := stripANSI(final2.scroll.String()); !strings.Contains(got, "✓ active: local") {
3220 t.Fatalf("active-profile probe must print activation banner:\n%s", got)
3221 }
3222}
3223
3224// TestNewestAssistantEmpty pins the anomaly detector behind the empty-reply
3225// nudge: only a newest assistant message with neither text nor a structured
3226// tool call counts as empty. A summary or a tool call is a normal turn.
3227func TestNewestAssistantEmpty(t *testing.T) {
3228 cases := []struct {
3229 name string
3230 hist []chmctx.Message
3231 want bool
3232 }{
3233 {"empty assistant", []chmctx.Message{
3234 {Role: chmctx.RoleUser, Content: "go"},
3235 {Role: chmctx.RoleAssistant, Content: ""},
3236 }, true},
3237 {"whitespace-only assistant", []chmctx.Message{

Callers

nothing calls this directly

Calls 1

newestAssistantEmptyFunction · 0.85

Tested by

no test coverage detected