MCPcopy Create free account
hub / github.com/codehamr/codehamr / cmdClear

Method cmdClear

internal/tui/slash.go:198–226  ·  view source on GitHub ↗
(_ []string)

Source from the content-addressed store, hash-verified

196 // hides the segment until the new backend reports its own.
197 m.budget = cloud.BudgetStatus{}
198}
199
200func (m Model) cmdClear(_ []string) (tea.Model, tea.Cmd) {
201 m.history = nil
202 m.scroll.Reset()
203 m.sessionTokens = 0
204 m.streamingEstimate = 0
205 // Drop any queued follow-up: it targeted the conversation just wiped.
206 m.queued = nil
207 // Reset the repeated-failure streak so the next turn starts clean.
208 m.failKey, m.failStreak = "", 0
209 // The banner offers /clear as one of its two remedies, so clearing must
210 // re-arm it: a re-filled window is a new occurrence, not the same one.
211 m.ctxPressureWarned = false
212 // Wipe prompt recall too: in-memory ring and on-disk .codehamr/history,
213 // or leftover history would contradict the "fresh start" promise.
214 m.promptHistory = nil
215 m.histIdx = -1
216 _ = clearPromptHistory(m.cfg.Dir)
217 // Full wipe (unlike Ctrl+L, which redraws but keeps scrollback).
218 // tea.ClearScreen emits \x1b[2J, which only wipes the viewport; the
219 // saved-lines buffer needs eraseScrollback (DECSED 3) too, or old replies
220 // stay scrollable above the reset line. tea.Sequence keeps the print from
221 // racing past the clear (tea.Batch runs both concurrently and the print
222 // could land first, then get wiped). scroll keeps the line for resize
223 // replay; outbox is cleared because the Sequence owns the print now.
224 line := styleOK.Render("✓ conversation reset")
225 m.scroll.WriteString(line + "\n")
226 m.outbox = nil
227 // Wrap like the outbox drain would: this Println bypasses it (the Sequence
228 // owns the print), and every string handed to tea.Println must be wrapped
229 // or an over-width line drifts the renderer's cursor math.

Callers

nothing calls this directly

Calls 3

clearPromptHistoryFunction · 0.85
wrapForScrollbackFunction · 0.85
ResetMethod · 0.80

Tested by

no test coverage detected