Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950package terminalui
import ( "slices" "strings")
// Conversation arranges a message viewport above the active composer or// reasoning picker. Each section already knows how many terminal rows it owns.type Conversation struct { Heading, Status, Rule, Footer string Notices, Messages, Accessories, Input []string}
// TranscriptFrame retains the unpadded rows. Paint a margin directly into the// output builder so unchanged frames don't allocate one new string per line.type TranscriptFrame struct { content string scratch, previous []string margin int}
func (f *TranscriptFrame) Render(page Conversation, margin int, clean func(string) string) string { rows := append(f.scratch[:0], page.Heading, "") rows = append(rows, page.Notices...) rows = append(rows, page.Messages...) rows = append(rows, page.Status) rows = append(rows, page.Accessories...) rows = append(rows, page.Rule) rows = append(rows, page.Input...) rows = append(rows, page.Rule, page.Footer) f.scratch = rows if f.margin == margin && slices.Equal(rows, f.previous) { return f.content } f.previous = append(f.previous[:0], rows...) f.margin = margin pad := strings.Repeat(" ", margin) var out strings.Builder for i, row := range rows { if i != 0 { out.WriteByte('\n') } out.WriteString(pad) out.WriteString(row) } f.content = clean(out.String()) return f.content}