mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 08:00:59 +00:00
Fix TUI rendering with wrong dimensions after suspend/resume
- Send SIGWINCH to self on terminal start to refresh stale dimensions (Unix only) - Change requestRender(true) to set previousWidth = -1 to trigger widthChanged - Update first render condition to skip when widthChanged is true Fixes #599
This commit is contained in:
parent
019ad0ec11
commit
d7394eb109
3 changed files with 13 additions and 3 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- TUI renders with wrong dimensions after suspend/resume if terminal was resized while suspended ([#599](https://github.com/badlogic/pi-mono/issues/599))
|
||||||
|
|
||||||
## [0.42.4] - 2026-01-10
|
## [0.42.4] - 2026-01-10
|
||||||
|
|
||||||
## [0.42.3] - 2026-01-10
|
## [0.42.3] - 2026-01-10
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,12 @@ export class ProcessTerminal implements Terminal {
|
||||||
// Set up resize handler immediately
|
// Set up resize handler immediately
|
||||||
process.stdout.on("resize", this.resizeHandler);
|
process.stdout.on("resize", this.resizeHandler);
|
||||||
|
|
||||||
|
// Refresh terminal dimensions - they may be stale after suspend/resume
|
||||||
|
// (SIGWINCH is lost while process is stopped). Unix only.
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
process.kill(process.pid, "SIGWINCH");
|
||||||
|
}
|
||||||
|
|
||||||
// Query and enable Kitty keyboard protocol
|
// Query and enable Kitty keyboard protocol
|
||||||
// The query handler intercepts input temporarily, then installs the user's handler
|
// The query handler intercepts input temporarily, then installs the user's handler
|
||||||
// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ export class TUI extends Container {
|
||||||
requestRender(force = false): void {
|
requestRender(force = false): void {
|
||||||
if (force) {
|
if (force) {
|
||||||
this.previousLines = [];
|
this.previousLines = [];
|
||||||
this.previousWidth = 0;
|
this.previousWidth = -1; // -1 triggers widthChanged, forcing a full clear
|
||||||
this.cursorRow = 0;
|
this.cursorRow = 0;
|
||||||
}
|
}
|
||||||
if (this.renderRequested) return;
|
if (this.renderRequested) return;
|
||||||
|
|
@ -334,8 +334,8 @@ export class TUI extends Container {
|
||||||
// Width changed - need full re-render
|
// Width changed - need full re-render
|
||||||
const widthChanged = this.previousWidth !== 0 && this.previousWidth !== width;
|
const widthChanged = this.previousWidth !== 0 && this.previousWidth !== width;
|
||||||
|
|
||||||
// First render - just output everything without clearing
|
// First render - just output everything without clearing (assumes clean screen)
|
||||||
if (this.previousLines.length === 0) {
|
if (this.previousLines.length === 0 && !widthChanged) {
|
||||||
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
||||||
for (let i = 0; i < newLines.length; i++) {
|
for (let i = 0; i < newLines.length; i++) {
|
||||||
if (i > 0) buffer += "\r\n";
|
if (i > 0) buffer += "\r\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue