A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(codec): send whether a pane takes bracketed pastes
RoversX0d5461dc6a06
diff --git a/codec/src/lib.rs b/codec/src/lib.rsindex d5ba3a7c..61a4a1bd 100644--- a/codec/src/lib.rs+++ b/codec/src/lib.rs@@ -893,7 +893,9 @@ macro_rules! pdu {/// ClientJoined/ClientLeft./// 82: SwapPanes swaps two panes of a tab, each into the other's place./// 83: Sharing a pane with other accounts on the machine (Share* PDUs).-pub const CODEC_VERSION: usize = 83;+/// 84: Render pushes say whether the program takes pastes bracketed+/// (GetPaneRenderChangesResponse::bracketed_paste).+pub const CODEC_VERSION: usize = 84;// Defines the Pdu enum.// Each struct has an explicit identifying number.@@ -2382,6 +2384,10 @@ pub struct GetPaneRenderChangesResponse {pub input_serial: Option<InputSerial>,pub seqno: SequenceNo,+ /// Whether the program takes pastes bracketed (DECSET 2004). A+ /// client asks before pasting line breaks to one that does not:+ /// each line would run as it went in. Last, as codec 84 added it.+ pub bracketed_paste: bool,}/// `termwiz::input::KeyboardEncoding` for the wire: the termwiz type has no@@ -2840,6 +2846,7 @@ mod golden {mouse_grabbed: false,alt_screen: true,keyboard_encoding: WireKeyboardEncoding::Kitty(3),+ bracketed_paste: true,cursor_position: StableCursorPosition::default(),dimensions: RenderableDimensions {cols: 80,@@ -2936,6 +2943,13 @@ mod golden {[LIST_PANES, &[0]].concat()}+ /// RENDER_CHANGES as codec 84 writes it: whether the program takes+ /// pastes bracketed went on the end, a one after the bytes captured+ /// before.+ fn render_changes_with_bracketed_paste() -> Vec<u8> {+ [RENDER_CHANGES, &[1]].concat()+ }+#[test]fn wire_bytes_are_stable() {assert_eq!(@@ -2945,7 +2959,10 @@ mod golden {assert_eq!(varbincode_bytes(&split_pane()), SPLIT_PANE);assert_eq!(varbincode_bytes(&search_request()), SEARCH);assert_eq!(varbincode_bytes(&client_list_response()), CLIENT_LIST);- assert_eq!(varbincode_bytes(&render_changes_response()), RENDER_CHANGES);+ assert_eq!(+ varbincode_bytes(&render_changes_response()),+ render_changes_with_bracketed_paste()+ );}#[test]@@ -2966,7 +2983,7 @@ mod golden {client_list_response());assert_eq!(- back::<GetPaneRenderChangesResponse>(RENDER_CHANGES),+ back::<GetPaneRenderChangesResponse>(&render_changes_with_bracketed_paste()),render_changes_response());}@@ -3553,7 +3570,7 @@ mod test {// tripwire: whoever bumps the codec must come here, confirm the// round-trips still cover the new version, and advance it// deliberately.- assert_eq!(CODEC_VERSION, 83);+ assert_eq!(CODEC_VERSION, 84);use thinkterm_proto::{AgentEvidence, AgentState, AgentStatus, ProgramBlockedKind, ProgramReport,ProgramReportChild, ProgramReportState,@@ -3623,7 +3640,7 @@ mod test {#[test]fn foreground_program_protocol_round_trip_at_version_74() {// Same tripwire as the agent-status test above.- assert_eq!(CODEC_VERSION, 83);+ assert_eq!(CODEC_VERSION, 84);use thinkterm_proto::ForegroundProgram;fn round_trip(pdu: &Pdu) -> Pdu {@@ -3724,7 +3741,7 @@ mod test {#[test]fn run_state_protocol_round_trip_at_version_80() {// Same tripwire as the agent-status test above.- assert_eq!(CODEC_VERSION, 83);+ assert_eq!(CODEC_VERSION, 84);use thinkterm_proto::{PaneExit, PaneRunState, ProgramState, ShellCommands};let exit = PaneExit {@@ -3823,7 +3840,7 @@ mod test {fn frame_control_extension_round_trips_without_changing_legacy_version() {// The extension is asked for, so it needed no bump of its own; 74// is the foreground program's, which a server sends unasked.- assert_eq!(CODEC_VERSION, 83);+ assert_eq!(CODEC_VERSION, 84);for pdu in [Pdu::GetKittyImage(GetKittyImage { pane_id: 3, image_id: 7, data_hash: [9; 32], have_frames: 2, image_epoch: Some(4) }),Pdu::GetKittyFrameSelections(GetKittyFrameSelections { pane_id: 3, subscribe: true }),diff --git a/mux/src/localpane.rs b/mux/src/localpane.rsindex 87f76864..34d6a674 100644--- a/mux/src/localpane.rs+++ b/mux/src/localpane.rs@@ -818,6 +818,10 @@ impl Pane for LocalPane {}}+ fn bracketed_paste(&self) -> Option<bool> {+ Some(self.terminal.lock().bracketed_paste_enabled())+ }+fn get_title(&self) -> String {let mut title = self.terminal.lock().get_title().to_string();self.spice_title(&mut title);diff --git a/mux/src/pane.rs b/mux/src/pane.rsindex dd0ab5fa..48b9bb75 100644--- a/mux/src/pane.rs+++ b/mux/src/pane.rs@@ -353,6 +353,12 @@ pub trait Pane: Downcast + Send + Sync {Progress::None}fn send_paste(&self, text: &str) -> anyhow::Result<()>;+ /// Whether the program in the pane takes pastes bracketed (DECSET+ /// 2004), so that a newline pasted to it runs nothing by itself. `None`+ /// when this side cannot tell.+ fn bracketed_paste(&self) -> Option<bool> {+ None+ }fn reader(&self) -> anyhow::Result<Option<Box<dyn std::io::Read + Send>>>;/// The pty behind `reader`, when there is one: the reader thread waits/// for it with poll, which is what lets it be parked (seediff --git a/thinkterm-session/src/delta_queue.rs b/thinkterm-session/src/delta_queue.rsindex d7e6ce29..ec1a7c9c 100644--- a/thinkterm-session/src/delta_queue.rs+++ b/thinkterm-session/src/delta_queue.rs@@ -73,6 +73,7 @@ mod render_delta_queue_tests {mouse_grabbed: false,alt_screen: false,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: Default::default(),dimensions: Default::default(),dirty_lines: vec![],@@ -111,6 +112,7 @@ mod render_delta_queue_tests {mouse_grabbed: false,alt_screen: false,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: Default::default(),dimensions: Default::default(),dirty_lines: dirty,diff --git a/thinkterm-session/src/pane.rs b/thinkterm-session/src/pane.rsindex 2477b06b..96435950 100644--- a/thinkterm-session/src/pane.rs+++ b/thinkterm-session/src/pane.rs@@ -240,6 +240,10 @@ impl<H: SessionHost> PaneSession<H> {self.state().mouse_grabbed}+ pub fn bracketed_paste(&self) -> Option<bool> {+ self.state().bracketed_paste+ }+pub fn keyboard_encoding(&self) -> KeyboardEncoding {self.state().keyboard_encoding}@@ -866,6 +870,7 @@ impl<H: SessionHost> PaneSession<H> {}st.mouse_grabbed = delta.mouse_grabbed;st.keyboard_encoding = delta.keyboard_encoding.into();+ st.bracketed_paste = Some(delta.bracketed_paste);let live_preview_accepts_snapshot = st.frontend_preview.is_none_or(|preview| {preview.policy != FrontendPreviewPolicy::LiveResize@@ -1857,6 +1862,7 @@ mod tests {mouse_grabbed,alt_screen,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: Default::default(),dimensions: dims(),dirty_lines: vec![],diff --git a/thinkterm-session/src/pane_state.rs b/thinkterm-session/src/pane_state.rsindex b97a9446..94b2249c 100644--- a/thinkterm-session/src/pane_state.rs+++ b/thinkterm-session/src/pane_state.rs@@ -42,6 +42,9 @@ pub struct PaneState {pub(crate) alt_screen: bool,pub(crate) mouse_grabbed: bool,pub(crate) keyboard_encoding: KeyboardEncoding,+ /// Whether the remote program takes pastes bracketed, once a push+ /// has said.+ pub(crate) bracketed_paste: Option<bool>,pub(crate) dimensions: RenderableDimensions,/// The dimensions most recently confirmed by the remote pane. A GUI/// takeover may resize its local surface optimistically; keeping the@@ -112,6 +115,7 @@ impl PaneState {alt_screen,mouse_grabbed: false,keyboard_encoding: KeyboardEncoding::Xterm,+ bracketed_paste: None,server_dimensions: dimensions,frontend_preview: None,geometry_repair: GeometryRepair::default(),diff --git a/wasm-probe/src/lib.rs b/wasm-probe/src/lib.rsindex 47927592..efb87a83 100644--- a/wasm-probe/src/lib.rs+++ b/wasm-probe/src/lib.rs@@ -371,6 +371,7 @@ mod session_probe {mouse_grabbed: false,alt_screen: false,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: StableCursorPosition {x: cursor_x,y: 2,diff --git a/wezterm-client/src/pane/clientpane.rs b/wezterm-client/src/pane/clientpane.rsindex c09b82d9..0e819bc8 100644--- a/wezterm-client/src/pane/clientpane.rs+++ b/wezterm-client/src/pane/clientpane.rs@@ -1136,6 +1136,10 @@ impl Pane for ClientPane {self.session.is_mouse_grabbed()}+ fn bracketed_paste(&self) -> Option<bool> {+ self.session.bracketed_paste()+ }+fn is_alt_screen_active(&self) -> bool {self.session.is_alt_screen()}diff --git a/wezterm-client/src/share_queue.rs b/wezterm-client/src/share_queue.rsindex 8976782c..2fff62d9 100644--- a/wezterm-client/src/share_queue.rs+++ b/wezterm-client/src/share_queue.rs@@ -281,6 +281,7 @@ mod tests {mouse_grabbed: false,alt_screen,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: StableCursorPosition::default(),dimensions: RenderableDimensions {cols: 80,diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rsindex 30d2c392..fe19f7b7 100644--- a/wezterm-mux-server-impl/src/sessionhandler.rs+++ b/wezterm-mux-server-impl/src/sessionhandler.rs@@ -98,6 +98,7 @@ pub(crate) struct PerPane {mouse_grabbed: bool,alt_screen: bool,keyboard_encoding: WireKeyboardEncoding,+ bracketed_paste: bool,/// Outer None means that this connection has never received application/// palette state for the pane. Inner None is an explicit reset to the/// client's own configured palette.@@ -260,6 +261,7 @@ impl PerPane {mouse_grabbed: self.mouse_grabbed,alt_screen: self.alt_screen,keyboard_encoding: self.keyboard_encoding,+ bracketed_paste: self.bracketed_paste,seqno: self.seqno,}}@@ -274,6 +276,7 @@ impl PerPane {mouse_grabbed,alt_screen,keyboard_encoding,+ bracketed_paste,dimensions,cursor_position,title,@@ -290,6 +293,7 @@ impl PerPane {self.mouse_grabbed = mouse_grabbed;self.alt_screen = alt_screen;self.keyboard_encoding = keyboard_encoding;+ self.bracketed_paste = bracketed_paste;self.seqno = seqno;self.sent_images.remember(&bonus_lines);@@ -299,6 +303,7 @@ impl PerPane {mouse_grabbed,alt_screen,keyboard_encoding,+ bracketed_paste,dirty_lines: dirty_lines.iter().cloned().collect(),dimensions,cursor_position,@@ -328,6 +333,7 @@ struct LastSent {mouse_grabbed: bool,alt_screen: bool,keyboard_encoding: WireKeyboardEncoding,+ bracketed_paste: bool,seqno: SequenceNo,}@@ -336,6 +342,7 @@ struct PaneReading {mouse_grabbed: bool,alt_screen: bool,keyboard_encoding: WireKeyboardEncoding,+ bracketed_paste: bool,dimensions: RenderableDimensions,cursor_position: StableCursorPosition,title: String,@@ -405,6 +412,11 @@ fn read_pane_changes(changed = true;}+ let bracketed_paste = pane.bracketed_paste().unwrap_or(false);+ if bracketed_paste != last.bracketed_paste {+ changed = true;+ }+let dims = pane.get_dimensions();if dims != last.dimensions {changed = true;@@ -465,6 +477,7 @@ fn read_pane_changes(};Some(PaneReading {+ bracketed_paste,mouse_grabbed,alt_screen,keyboard_encoding,diff --git a/wezterm/src/cli/share_watch.rs b/wezterm/src/cli/share_watch.rsindex d73b5829..e9c93374 100644--- a/wezterm/src/cli/share_watch.rs+++ b/wezterm/src/cli/share_watch.rs@@ -1848,6 +1848,7 @@ mod tests {mouse_grabbed: false,alt_screen: false,keyboard_encoding: Default::default(),+ bracketed_paste: false,cursor_position: view.cursor,dimensions: view.dims,dirty_lines,