installTurnContext cancels any in-flight turn context and installs a fresh per-turn root on m.turnCtx / m.cancel. Cancel-old-then-install-new keeps Ctrl+C consistent: one m.cancel() always unwinds the whole current cascade.
()
| 618 | ch := m.cli.Chat(m.turnCtx, msgs, m.buildTools()) |
| 619 | m.stream = ch |
| 620 | return readEvent(ch) |
| 621 | } |
| 622 | |
| 623 | // installTurnContext cancels any in-flight turn context and installs a fresh |
| 624 | // per-turn root on m.turnCtx / m.cancel. Cancel-old-then-install-new keeps |
| 625 | // Ctrl+C consistent: one m.cancel() always unwinds the whole current cascade. |
| 626 | func (m *Model) installTurnContext() { |
| 627 | if m.cancel != nil { |
| 628 | m.cancel() |
no outgoing calls