submit commits a user prompt. sendText is the expanded form sent to the LLM (chip labels replaced by their original paste content); echoText is the collapsed form shown in scrollback so the chat doesn't swallow 80 lines of pasted log every turn; entry is the history snapshot replayed by ↑/↓, includi
(sendText, echoText string, entry promptEntry)
| 573 | if r, err := glamour.NewTermRenderer(glamour.WithStandardStyle("dark"), |
| 574 | glamour.WithWordWrap(max(msg.Width-4, 1))); err == nil { |
| 575 | m.renderer = r |
| 576 | } |
| 577 | } |
| 578 | m.recomputeLayout() |
| 579 | if first { |
| 580 | m.splashShown = true |
| 581 | m.outbox = append(m.outbox, m.splashLines()...) |
| 582 | return m, nil |
| 583 | } |
| 584 | if !widthChanged { |
| 585 | return m, nil |
| 586 | } |
| 587 | m.suppressView = true |
| 588 | m.resizeGen++ |
| 589 | gen := m.resizeGen |
| 590 | return m, tea.Tick(resizeSettleDelay, func(time.Time) tea.Msg { |
| 591 | return resizeSettleMsg{gen: gen} |
| 592 | }) |
| 593 | } |
| 594 | |
| 595 | // handleResizeSettle fires once the post-resize debounce expires for the |
| 596 | // matching gen. Wipes the terminal (so previous-width rows can't soft-wrap into |
| 597 | // stair-steps), then re-emits splash, replayed scroll, and any pending outbox |
| 598 | // at the new width. Older debounces self-discard on the gen check. |
| 599 | func (m Model) handleResizeSettle(msg resizeSettleMsg) (tea.Model, tea.Cmd) { |
| 600 | if msg.gen != m.resizeGen { |
| 601 | return m, nil |
| 602 | } |
| 603 | m.suppressView = false |
| 604 | // tea.Sequence keeps order strict; Batch would race the clears with the |
| 605 | // writes. After the wipe every line below is emitted at the current width, |
| 606 | // so no previous-width row can soft-wrap into stair-steps. |
| 607 | cmds := []tea.Cmd{tea.ClearScreen, eraseScrollback} |
| 608 | if splash := strings.Join(m.splashLines(), "\n"); splash != "" { |
| 609 | cmds = append(cmds, tea.Println(wrapForScrollback(splash, m.width))) |
| 610 | } |
| 611 | if scroll := strings.TrimRight(m.scroll.String(), "\n"); scroll != "" { |