TestToolCallFlushesStreamedContent: a tool-call event ends the content phase. Whatever streamed before it is rendered and committed *now*, so the user sees styled text *before* the inline tool-call status, not all at once at turn end.
(t *testing.T)
| 2493 | i = j |
| 2494 | break |
| 2495 | } |
| 2496 | } |
| 2497 | continue |
| 2498 | } |
| 2499 | b.WriteByte(s[i]) |
| 2500 | } |
| 2501 | return b.String() |
| 2502 | } |
| 2503 | |
| 2504 | // TestStreamContentShowsLiveInViewport: a mid-turn content event populates the |
| 2505 | // streaming buffer, promotes phase thinking→streaming, and is visible in View() |
| 2506 | // before any EventDone: the "tokens stream immediately" promise. |
| 2507 | func TestStreamContentShowsLiveInViewport(t *testing.T) { |
| 2508 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 2509 | m.phase = phaseThinking |
| 2510 | out, _ := m.handleStream(llm.Event{Kind: llm.EventContent, Content: "hello world"}) |
| 2511 | om := out.(Model) |
| 2512 | if om.phase != phaseStreaming { |
| 2513 | t.Fatalf("first content chunk should promote phase to streaming, got %v", om.phase) |
| 2514 | } |
nothing calls this directly
no test coverage detected