Skip to content

Commit be509ba

Browse files
authored
fix: incorrect terminal size over ssh (#318)
1 parent a9b4677 commit be509ba

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

crates/atuin-desktop-runtime/src/blocks/terminal.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ pub struct Terminal {
7272

7373
#[builder(default = true)]
7474
pub output_visible: bool,
75+
76+
#[builder(default = 20)]
77+
pub rows: u16,
78+
79+
#[builder(default = 120)]
80+
pub cols: u16,
7581
}
7682

7783
impl FromDocument for Terminal {
@@ -110,6 +116,20 @@ impl FromDocument for Terminal {
110116
.and_then(|v| v.as_bool())
111117
.unwrap_or(true),
112118
)
119+
.rows(
120+
props
121+
.get("rows")
122+
.and_then(|v| v.as_u64())
123+
.map(|v| v as u16)
124+
.unwrap_or(20),
125+
)
126+
.cols(
127+
props
128+
.get("cols")
129+
.and_then(|v| v.as_u64())
130+
.map(|v| v as u16)
131+
.unwrap_or(120),
132+
)
113133
.build();
114134

115135
Ok(terminal)
@@ -246,15 +266,16 @@ impl Terminal {
246266
let pty_id_str = self.id.to_string();
247267
let ssh_pool_clone = ssh_pool.clone();
248268

249-
// Open SSH PTY with cancellation support - use the receiver we took earlier
269+
let initial_cols = self.cols;
270+
let initial_rows = self.rows;
250271
let ssh_result = tokio::select! {
251272
result = ssh_pool_clone.open_pty(
252273
&hostname_clone,
253274
username_clone.as_deref(),
254275
&pty_id_str,
255276
output_sender.clone(),
256-
80,
257-
24,
277+
initial_cols,
278+
initial_rows,
258279
) => {
259280
result.map_err(|e| format!("Failed to open SSH PTY: {}", e))
260281
}
@@ -315,12 +336,12 @@ impl Terminal {
315336
}
316337

317338
let pty = Pty::open(
318-
24,
319-
80,
339+
self.rows,
340+
self.cols,
320341
Some(cwd.to_string()),
321342
env_vars,
322343
metadata.clone(),
323-
None, // Use default shell
344+
None,
324345
)
325346
.await
326347
.map_err(|e| format!("Failed to open local PTY: {}", e))?;

crates/atuin-desktop-runtime/src/ssh/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,8 @@ impl Session {
967967

968968
resize = resize_stream.recv() => {
969969
match resize {
970-
Some((width, height)) => {
971-
let _ = channel.window_change(width as u32, height as u32, 0, 0).await;
970+
Some((rows, cols)) => {
971+
let _ = channel.window_change(cols as u32, rows as u32, 0, 0).await;
972972
}
973973
None => {
974974
tracing::debug!("SSH resize stream closed");

src/lib/blocks/terminal/components/terminal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ const TerminalComponent = ({
125125
terminalRef.current.appendChild(terminalData.terminal.element);
126126
}
127127

128-
// Initial fit
129128
if (terminalData.fitAddon) {
130129
terminalData.fitAddon.fit();
131130
}

0 commit comments

Comments
 (0)