MCPcopy Index your code
hub / github.com/codehamr/codehamr / endTurn

Method endTurn

internal/tui/model.go:653–670  ·  view source on GitHub ↗

endTurn zeroes per-turn state after a turn finishes or aborts. Pair to beginTurn. Cancels the per-turn context unconditionally to release the CancelFunc; Background-rooted contexts otherwise leak one child cancelCtx per turn until the process exits. Drops pending tool calls so a turn cut short mid-d

()

Source from the content-addressed store, hash-verified

651// whose tool_call_id no longer pairs the latest assistant message. Does NOT
652// touch scrollback; callers decide whether to flush streaming or emit a banner.
653func (m *Model) endTurn() {
654 if m.cancel != nil {
655 m.cancel()
656 }
657 m.phase = phaseIdle
658 m.cancel = nil
659 m.turnCtx = nil
660 m.pending = nil
661 m.toolRounds = 0
662 m.runawayNudged = false
663 m.emptyNudged = false
664 m.verifyNudged = false
665 // The queue-refusal hint says "send it when the turn ends"; that moment is
666 // now, so the advice would be stale from the next render on.
667 if m.status == queueSlashHint {
668 m.status = ""
669 }
670}
671
672func (m *Model) buildMessages() []chmctx.Message {
673 ctxSize := m.activeContextSize()

Calls

no outgoing calls