ibigio/shell-ai

Fix stream / final response content discrepancy (MISSING)

Closed this issue · 1 comments

Context

I noticed with the prompt print first 20 prime numbers (on version v0.3.0) that the streaming response looks ok, but when it gets tea.Printfed it suddenyl has a (MISSING) in the text that didn't used to be there. Weird. Might have to do with the rendering in tea.Printf the final response vs the stream string returned in View()...

Screen.Recording.2023-06-11.at.10.13.51.PM.mov

Task

Investigate and fix it.

Findings

Responses containing % in them were being interpreted as format string params, and with no arguments passed to tea.Printf() were being turned to (MISSING) by Go.

Before switching to tea.Printf in 750a33e I was using a fmt.Printf("%s", m.drawBuffer) so accidentally escaping everything correctly :)

Solution

Pass the string as a format parameter in tea.Printf().
Fixed: e324e35