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

Function TestFocusBlurMsgsAreInert

internal/tui/tui_test.go:2844–2870  ·  view source on GitHub ↗

TestFocusBlurMsgsAreInert: terminal focus reports arrive as tea.FocusMsg / tea.BlurMsg under tea.WithReportFocus. They must never touch the textarea (no inserted chars, no height change), else the UI slides up when another window steals focus.

(t *testing.T)

Source from the content-addressed store, hash-verified

2842 {Role: chmctx.RoleTool, Content: "out"},
2843 }, true},
2844 {"no assistant at all", []chmctx.Message{
2845 {Role: chmctx.RoleUser, Content: "go"},
2846 }, false},
2847 }
2848 for _, tc := range cases {
2849 if got := newestAssistantEmpty(tc.hist); got != tc.want {
2850 t.Errorf("%s: newestAssistantEmpty = %v, want %v", tc.name, got, tc.want)
2851 }
2852 }
2853}
2854
2855// TestEmptyReplyNudgeRePromptsThenRecovers: a turn whose first round comes back
2856// with no content and no tool call (the dominant silent death: a thinking
2857// model's tool call swallowed into the reasoning channel) must be reprompted
2858// once, not ended silently. Here the second round produces a real summary, so
2859// the run self heals.
2860func TestEmptyReplyNudgeRePromptsThenRecovers(t *testing.T) {
2861 var round int
2862 handler := func(w http.ResponseWriter, _ *http.Request) {
2863 w.Header().Set("Content-Type", "text/event-stream")
2864 round++
2865 if round == 1 {
2866 // Empty assistant message: stop with no content delta, no tool calls.
2867 fmt.Fprintf(w, "data: %s\n\n", `{"type":"response.completed","response":{"usage":{"output_tokens":1}}}`)
2868 return
2869 }
2870 fmt.Fprintf(w, "data: %s\n\n", `{"type":"response.output_text.delta","delta":"fixed and verified"}`)
2871 fmt.Fprintf(w, "data: %s\n\n", `{"type":"response.completed","response":{"usage":{"output_tokens":3}}}`)
2872 }
2873

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
ValueMethod · 0.80
HeightMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected