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)
| 142 | // Returns true if any layer discarded user input — callers may want to |
| 143 | // surface this in the UI ("ignored prefilled input"). |
| 144 | func (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. |