Skip to content

fix: spawn pty with actual terminal size#23

Merged
jmaxdev merged 2 commits intoTrixtyAI:mainfrom
matiaspalmac:fix/terminal-initial-size
Apr 19, 2026
Merged

fix: spawn pty with actual terminal size#23
jmaxdev merged 2 commits intoTrixtyAI:mainfrom
matiaspalmac:fix/terminal-initial-size

Conversation

@matiaspalmac
Copy link
Copy Markdown
Contributor

Changes

The PTY was hardcoded to open at 24 rows × 80 cols in pty.rs. The shell (PowerShell/bash) would then print its first prompt at 80 cols, and the real size only arrived later via resize_pty when the ResizeObserver in Terminal.tsx fired. That mismatch caused the symptom reported in #13 — after commands like ls/dir followed by clear, the prompt rendered with an extra blank and a truncated path.

  • apps/desktop/src-tauri/src/pty.rs: spawn_pty now accepts optional rows/cols, falling back to 24×80 if not provided.
  • apps/desktop/src/api/tauri.ts: extends the spawn_pty signature accordingly.
  • apps/desktop/src/components/Terminal.tsx: stores the FitAddon in a ref so the PTY effect can call fit() before spawning, then passes term.rows/term.cols to spawn_pty so the shell starts at the correct size.

The existing ResizeObserver + resize_pty flow is untouched — it still handles later container resizes.

Issues

Copilot AI review requested due to automatic review settings April 19, 2026 02:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an initial PTY size mismatch by ensuring the shell is spawned with the terminal’s actual rows/cols (instead of a hardcoded 24×80), addressing the prompt rendering artifact described in issue #13.

Changes:

  • Extend spawn_pty to accept optional rows/cols (with a 24×80 fallback).
  • Update the frontend invoke typing to include the new PTY size parameters.
  • Fit the xterm instance before spawning the PTY, then pass the computed term.rows/term.cols into spawn_pty.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
apps/desktop/src/components/Terminal.tsx Stores FitAddon in a ref, calls fit() before spawning, and passes rows/cols to the PTY spawn invoke.
apps/desktop/src/api/tauri.ts Updates the typed invoke map for spawn_pty to include optional rows/cols.
apps/desktop/src-tauri/src/pty.rs Updates the Tauri spawn_pty command to size the PTY using provided rows/cols with a default fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jmaxdev jmaxdev merged commit 6566ea9 into TrixtyAI:main Apr 19, 2026
4 checks passed
@jmaxdev
Copy link
Copy Markdown
Collaborator

jmaxdev commented Apr 19, 2026

done

@matiaspalmac matiaspalmac deleted the fix/terminal-initial-size branch April 19, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: terminal space bug

3 participants