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:
@@ -147,6 +147,7 @@ func (s *DockerExecSession) handleOutput(data []byte) {
|
|||||||
tracker := s.tracker
|
tracker := s.tracker
|
||||||
connector := s.connector
|
connector := s.connector
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
filtered = FilterUnsupportedModes(filtered)
|
||||||
dispatchSessionOutput(filtered, tracker, s.replay, connector)
|
dispatchSessionOutput(filtered, tracker, s.replay, connector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -6,8 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
daResponsePattern = regexp.MustCompile(`\x1b\[[?>=][\d;]*c`)
|
daResponsePattern = regexp.MustCompile(`\x1b\[[?>=][\d;]*c`)
|
||||||
daPartialPattern = regexp.MustCompile(`\x1b(?:\[(?:[?>=][\d;]*)?)?$`)
|
daPartialPattern = regexp.MustCompile(`\x1b(?:\[(?:[?>=][\d;]*)?)?$`)
|
||||||
|
unsupportedModePattern = regexp.MustCompile(`\x1b\[\?7727[hl]`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func FilterDASequences(data []byte, escapeBuffer []byte) ([]byte, []byte) {
|
func FilterDASequences(data []byte, escapeBuffer []byte) ([]byte, []byte) {
|
||||||
@@ -28,3 +29,12 @@ func FilterDASequences(data []byte, escapeBuffer []byte) ([]byte, []byte) {
|
|||||||
}
|
}
|
||||||
return filtered, nil
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ func (s *TerminalSession) handleOutput(data []byte) {
|
|||||||
tracker := s.tracker
|
tracker := s.tracker
|
||||||
connector := s.connector
|
connector := s.connector
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
filtered = FilterUnsupportedModes(filtered)
|
||||||
dispatchSessionOutput(filtered, tracker, s.replay, connector)
|
dispatchSessionOutput(filtered, tracker, s.replay, connector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user