MCPcopy Create free account
hub / github.com/diillson/chatcli / RenderStreamBoxStart

Method RenderStreamBoxStart

cli/agent/ui_renderer.go:1210–1235  ·  view source on GitHub ↗

RenderStreamBoxStart draws the top edge of an open card whose contents will be streamed in via StreamOutput. The bottom edge is closed by RenderStreamBoxEnd. Header width is recorded so the footer matches it.

(icon, title, color string)

Source from the content-addressed store, hash-verified

1208// will be streamed in via StreamOutput. The bottom edge is closed by
1209// RenderStreamBoxEnd. Header width is recorded so the footer matches it.
1210func (r *UIRenderer) RenderStreamBoxStart(icon, title, color string) {
1211 header := fmt.Sprintf("%s %s", icon, title)
1212
1213 termWidth, _, err := term.GetSize(int(os.Stdout.Fd())) //#nosec G115 -- value bounded by domain
1214 if err != nil || termWidth <= 0 {
1215 termWidth = 80
1216 }
1217
1218 // "╭── " (4) + header + " " + minimum 6 dashes for visual weight.
1219 const minTail = 6
1220 headerLine := "╭── " + header + " " + strings.Repeat("─", minTail)
1221 visible := VisibleLen(headerLine)
1222 // Extend to a reasonable middle width when the header is short, but
1223 // never wider than the terminal minus a 2-col right gutter.
1224 target := termWidth - 2
1225 if target < visible {
1226 target = visible
1227 }
1228 if extra := target - visible; extra > 0 {
1229 headerLine += strings.Repeat("─", extra)
1230 }
1231 streamBoxHeaderWidth = VisibleLen(headerLine)
1232
1233 fmt.Println()
1234 fmt.Println(r.Colorize(headerLine, color+ColorBold))
1235}
1236
1237// RenderStreamBoxEnd closes the streaming card. Footer length mirrors
1238// the header so the box reads as a balanced shape regardless of how

Callers 1

Calls 2

ColorizeMethod · 0.95
VisibleLenFunction · 0.85

Tested by

no test coverage detected