MCPcopy Create free account
hub / github.com/diillson/chatcli / Guard

Method Guard

cli/coder/input_guard.go:144–153  ·  view source on GitHub ↗

Guard runs the full pre-prompt sequence: flush TTY → drain channel. Callers should invoke this BEFORE rendering the UI, then call IntentDebounce AFTER the UI is rendered. Returns true if any layer discarded user input — callers may want to surface this in the UI ("ignored prefilled input").

(ch <-chan string)

Source from the content-addressed store, hash-verified

142// Returns true if any layer discarded user input — callers may want to
143// surface this in the UI ("ignored prefilled input").
144func (g *InputGuard) Guard(ch <-chan string) bool {
145 anyDiscarded := false
146 if err := g.FlushTTYInput(); err != nil {
147 g.logger.Debug("input guard: FlushTTYInput failed (non-fatal)", zap.Error(err))
148 }
149 if drained := g.DrainStdinChannel(ch); len(drained) > 0 {
150 anyDiscarded = true
151 }
152 return anyDiscarded
153}
154
155// preview returns a short, escape-stripped excerpt of an input line for
156// safe logging. We never want to dump full user input to the log.

Calls 3

FlushTTYInputMethod · 0.95
DrainStdinChannelMethod · 0.95
ErrorMethod · 0.65