Skip to content

Commit

Permalink
Fix web terminal cursor issue (#6805)
Browse files Browse the repository at this point in the history
Signed-off-by: Waleed Malik <[email protected]>
  • Loading branch information
ahmedwaleedmalik authored Sep 3, 2024
1 parent 35dce88 commit 58186ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/api/pkg/handler/websocket/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ func Terminal(ctx context.Context, ws *websocket.Conn, client ctrlruntimeclient.
websocketConn: ws,
userEmailID: userEmailID,
clusterClient: client,
sizeChan: make(chan remotecommand.TerminalSize),
doneChan: make(chan struct{}),
},
ws); err != nil {
log.Logger.Debug(err)
Expand Down
11 changes: 11 additions & 0 deletions modules/web/src/app/shared/components/terminal/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ export class TerminalComponent implements OnChanges, OnInit, OnDestroy, AfterVie

const delayFn = debounce(() => {
fitAddon.fit();
// Sync pty size on window resize
const dimensions = fitAddon.proposeDimensions();
this._resizePty(dimensions.cols, dimensions.rows);
}, this.DELAY_TIMEOUT);
delayFn();

Expand Down Expand Up @@ -334,4 +337,12 @@ export class TerminalComponent implements OnChanges, OnInit, OnDestroy, AfterVie
Op: Operations.Refresh,
});
}

private _resizePty(cols: number, rows: number): void {
this._webTerminalSocketService.sendMessage({
Op: 'resize',
Cols: cols,
Rows: rows,
});
}
}

0 comments on commit 58186ff

Please sign in to comment.