feat(tools): stream shell_run output live into the TUI
This commit is contained in:
@@ -395,6 +395,28 @@ func TestToolLogOutputUpdatesExistingToolCard(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolLogStreamingChunksAppendToSameCard(t *testing.T) {
|
||||
m := newModel(context.Background(), nil, Options{ModelName: "test-model"})
|
||||
m.messages = append(m.messages, message{role: roleTool, content: `shell_run echo hi`})
|
||||
|
||||
if !m.mergeToolLog("shell_run echo hi\n[output]\none\n") {
|
||||
t.Fatal("expected first mergeToolLog to return true")
|
||||
}
|
||||
if !m.mergeToolLog("shell_run echo hi\n[output]\ntwo\n") {
|
||||
t.Fatal("expected second mergeToolLog to return true")
|
||||
}
|
||||
if len(m.messages) != 1 {
|
||||
t.Fatalf("messages count = %d, want 1", len(m.messages))
|
||||
}
|
||||
plain := stripANSI(m.renderMessages())
|
||||
if !strings.Contains(plain, "one") || !strings.Contains(plain, "two") {
|
||||
t.Fatalf("rendered output missing streamed lines:\n%s", plain)
|
||||
}
|
||||
if strings.Contains(plain, "onetwo") {
|
||||
t.Fatalf("streamed lines were concatenated:\n%s", plain)
|
||||
}
|
||||
}
|
||||
|
||||
type tuiCompactProvider struct{}
|
||||
|
||||
func (tuiCompactProvider) ChatStream(ctx context.Context, req llm.ChatRequest, emit func(llm.StreamEvent) error) error {
|
||||
|
||||
Reference in New Issue
Block a user