Filter unsupported DEC private mode 7727 from terminal output

Shells (e.g. via Tera Term conventions) emit CSI ?7727h/l to toggle
Application Escape Key mode, which ghostty-web does not implement.
This produces noisy console warnings in the browser.

Strip these sequences server-side in the output pipeline (both
TerminalSession and DockerExecSession) before they reach the client,
using the same pattern as the existing DA response filter.
This commit is contained in:
GitHub Copilot
2026-02-17 20:38:55 +00:00
parent af79bdd59f
commit edfa239c3e
3 changed files with 14 additions and 2 deletions
+1
View File
@@ -147,6 +147,7 @@ func (s *DockerExecSession) handleOutput(data []byte) {
tracker := s.tracker
connector := s.connector
s.mu.Unlock()
filtered = FilterUnsupportedModes(filtered)
dispatchSessionOutput(filtered, tracker, s.replay, connector)
}
+12 -2
View File
@@ -6,8 +6,9 @@ import (
)
var (
daResponsePattern = regexp.MustCompile(`\x1b\[[?>=][\d;]*c`)
daPartialPattern = regexp.MustCompile(`\x1b(?:\[(?:[?>=][\d;]*)?)?$`)
daResponsePattern = regexp.MustCompile(`\x1b\[[?>=][\d;]*c`)
daPartialPattern = regexp.MustCompile(`\x1b(?:\[(?:[?>=][\d;]*)?)?$`)
unsupportedModePattern = regexp.MustCompile(`\x1b\[\?7727[hl]`)
)
func FilterDASequences(data []byte, escapeBuffer []byte) ([]byte, []byte) {
@@ -28,3 +29,12 @@ func FilterDASequences(data []byte, escapeBuffer []byte) ([]byte, []byte) {
}
return filtered, nil
}
// FilterUnsupportedModes strips DEC private mode sequences that ghostty-web
// does not implement, preventing noisy console warnings in the browser.
func FilterUnsupportedModes(data []byte) []byte {
if !bytes.Contains(data, []byte("\x1b[?7727")) {
return data
}
return unsupportedModePattern.ReplaceAll(data, nil)
}
+1
View File
@@ -136,6 +136,7 @@ func (s *TerminalSession) handleOutput(data []byte) {
tracker := s.tracker
connector := s.connector
s.mu.Unlock()
filtered = FilterUnsupportedModes(filtered)
dispatchSessionOutput(filtered, tracker, s.replay, connector)
}