on main help sign in
fix(noninteractive): strip leading newline from assistant responses

💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>

commit60ca35fa116b4f897e7d0d443fd66b427efe7591 authorChristian Rocha <christian@rocha.is> dateSun 2 Nov 2025, 09:03 (1 year ago) parent389a6ab
1 file changed+7
internal/agent/agent.go+7
internal/agent/agent.go+7
@@ -276,6 +276,13 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*fantasy
276276 return a.messages.Update(genCtx, *currentAssistant)
277277 },
278278 OnTextDelta: func(id string, text string) error {
279+ // Strip leading newline from initial text content. This is is
280+ // particularly important in non-interactive mode where leading
281+ // newlines are very visible.
282+ if len(currentAssistant.Parts) == 0 && strings.HasPrefix(text, "\n") {
283+ text = strings.TrimPrefix(text, "\n")
284+ }
285+
279286 currentAssistant.AppendContent(text)
280287 return a.messages.Update(genCtx, *currentAssistant)
281288 },