From 6f311498aeeb27c0973781961ef94e8d0016ed17 Mon Sep 17 00:00:00 2001 From: akbash Date: Sat, 8 Aug 2026 02:15:56 +0300 Subject: fix: forward pane terminal bells (#2498) refs #2453 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> --- src/pane/terminal.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/pane') diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index 67b57153..8de84af3 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -145,6 +145,7 @@ impl InputState { pub(crate) struct ProcessBytesResult { pub request_render: bool, pub render_delay: Option, + pub terminal_bells: u16, pub clipboard_writes: Vec>, pub reported_cwd: Option, pub terminal_responses: Vec, @@ -1201,6 +1202,7 @@ impl GhosttyPaneTerminal { return ProcessBytesResult { request_render: false, render_delay: None, + terminal_bells: 0, clipboard_writes: Vec::new(), reported_cwd: None, terminal_responses: Vec::new(), @@ -1209,7 +1211,8 @@ impl GhosttyPaneTerminal { let _ = core.terminal.take_pwd_changes(); // Restored history may have exercised terminal callbacks before this live PTY write. - // Those writes must not be delivered as live pane output. + // Those effects must not be delivered as live pane output. + let _ = core.terminal.take_bell_count(); let _ = core.terminal.take_clipboard_writes(); let default_color_observation = core.default_color_tracker.observe(bytes); if shell_pid > 0 && default_color_observation { @@ -1276,6 +1279,7 @@ impl GhosttyPaneTerminal { xtgettcap_responses, &mut terminal_responses, ); + let terminal_bells = core.terminal.take_bell_count(); let clipboard_writes = core.terminal.take_clipboard_writes(); let reported_cwd = core .terminal @@ -1332,6 +1336,7 @@ impl GhosttyPaneTerminal { ProcessBytesResult { request_render, render_delay, + terminal_bells, clipboard_writes, reported_cwd, terminal_responses, @@ -3734,6 +3739,21 @@ mod tests { ); } + #[test] + fn process_pty_bytes_surfaces_live_bells_only() { + let (tx, _rx) = mpsc::channel(4); + let terminal = crate::ghostty::Terminal::new(80, 24, 100).unwrap(); + let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap(); + let pane_id = PaneId::from_raw(1); + + pane.seed_history_ansi("stale\x07"); + let result = pane.process_pty_bytes(pane_id, 0, b"\x07\x1b]0;title\x07\x07", &tx); + + assert_eq!(result.terminal_bells, 2); + let drained = pane.process_pty_bytes(pane_id, 0, b"live output", &tx); + assert_eq!(drained.terminal_bells, 0); + } + #[test] fn process_pty_bytes_surfaces_clipboard_writes_without_other_results() { let (tx, _rx) = mpsc::channel(4); @@ -3749,6 +3769,7 @@ mod tests { assert!(result.request_render); assert_eq!(result.render_delay, None); + assert_eq!(result.terminal_bells, 0); assert_eq!(result.clipboard_writes, vec![b"clipboard".to_vec()]); assert_eq!(result.reported_cwd, None); assert!(result.terminal_responses.is_empty()); -- cgit v1.2.3