MCPcopy Index your code
hub / github.com/coder/agentapi / cleanTerminalInput

Function cleanTerminalInput

e2e/echo.go:173–191  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

171}
172
173func cleanTerminalInput(input string) string {
174 // Strip ANSI escape sequences
175 input = stripansi.Strip(input)
176
177 // Remove bracketed paste mode sequences (^[[200~ and ^[[201~)
178 bracketedPasteRe := regexp.MustCompile(`\x1b\[\d+~`)
179 input = bracketedPasteRe.ReplaceAllString(input, "")
180
181 // Remove backspace sequences (character followed by ^H)
182 backspaceRe := regexp.MustCompile(`.\x08`)
183 input = backspaceRe.ReplaceAllString(input, "")
184
185 // Remove other common control characters
186 input = strings.ReplaceAll(input, "\x08", "") // backspace
187 input = strings.ReplaceAll(input, "\x7f", "") // delete
188 input = strings.ReplaceAll(input, "\x1b", "") // escape (if any remain)
189
190 return strings.TrimSpace(input)
191}
192
193func runSpinner(ctx context.Context) <-chan struct{} {
194 done := make(chan struct{})

Callers 1

runEchoAgentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected