tui: show /help at the bottom of the transcript instead of the top

the help block was prepended to the chat, which pushed any existing
conversation off the top of the viewport on anything but the
shortest sessions. appending it (with scrollOffset=0 so the viewport
sticks to the bottom) means /help is always visible right above the
editor, exactly where the user's eye is already looking.

login / model / sessions dialogs already render in the bottom-sticky
band between chat and editor, so they weren't affected.
This commit is contained in:
patriceckhart 2026-04-18 11:31:06 +02:00
parent 8a13141ace
commit c0f685f498

View file

@ -349,9 +349,12 @@ func (i *Interactive) redraw() {
chat = append(welcomeBanner(i.cfg.Theme), chat...)
}
// /help block: rendered above the welcome / transcript when active.
// /help block: appended to the transcript so it appears at the
// bottom of the chat area (right above the status bar / editor).
// Prepending it would push long conversations off the top of the
// viewport, which users would miss entirely.
if len(i.helpBlock) > 0 {
chat = append(append([]string(nil), i.helpBlock...), chat...)
chat = append(chat, i.helpBlock...)
}
if i.statusOK != "" {
@ -716,6 +719,10 @@ func (i *Interactive) runSlash(ctx context.Context, cmd string) (done bool) {
i.helpBlock = renderHelpBlock(i.cfg.Theme, i.lastCols())
i.statusErr = ""
i.statusOK = ""
// Pin the viewport to the newest content so the help block,
// which we just appended to the end of the transcript, is
// what the user actually sees.
i.scrollOffset = 0
i.mu.Unlock()
case "/login":
i.dialog.Open()