Skip to content

fix: client: terminal: refit after show - #485

Open
giulianoliker wants to merge 1 commit into
coderaiser:masterfrom
giulianoliker:fix/terminal-refit
Open

giulianoliker wants to merge 1 commit into
coderaiser:masterfrom
giulianoliker:fix/terminal-refit

Conversation

@giulianoliker

Copy link
Copy Markdown

Fixes the terminal opening at the wrong size, the known issue noted in #484 (Cyan-Sinko theme).

Cause: terminal.js and terminal-run.js create gritty on document.body. Gritty runs xterm's fit addon once at that point, against the body, and refits only on window resize. View.show then moves the terminal into the modal. Nothing refits it there, so its rows and columns still match the body, not the view.

With light and dark the body and the view happen to give the same size, so the problem doesn't show. I measured both at 1920×1080, 1440×900, 1280×720, 1024×768, 880×800, 768×1024, 600×900 and 375×812, and the terminal fit every time. With a different page layout, such as the Cyan-Sinko theme, the terminal opens up to 252px taller than the view (bottom rows cut off) and uses only about 60% of the width, until the window is resized.

Fix: dispatch resize in afterShow, so gritty refits to the view. Gritty keeps its fit addon private, so this triggers the refit through gritty's own resize listener. Cloud Commander's own resize handler also runs; it acts only below the one-panel width when the right panel is active, which is already the state there.

Since gritty is also part of the Cloud Commander project, an alternative would be a small public fit() in gritty instead of dispatching resize. Happy to do it that way if you prefer.

Before After
Cyan-Sinko, 1440×900 1020px of rows in an 828px view 816px of rows in 828px
light, 1440×900 860 in 860 860 in 860 (unchanged)
  • commit message named according to Contributing Guide
  • npm run fix:lint is OK (it leaves no changes)
  • npm test is OK (364/364, on Linux with Node 24)

Built with help from Claude Code; I reviewed and tested it myself.

gritty fits the terminal to document.body when it is created and refits
on window resize only, so after View.show moves it into the modal the
size can be wrong until the window is resized. Dispatch resize in
afterShow so gritty refits to the view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@giulianoliker giulianoliker mentioned this pull request Oct 19, 2026
3 tasks done

This branch has not been deployed

No deployments
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.

1 participant