fix: preserve terminal buffer across tab switches and focus regain
Render all terminal sessions and hide inactive ones with display:none so xterm instances are no longer unmounted/remounted when switching tabs. Remove terminal.clear() on the connected status message: the server keeps the session buffer, and clearing was erasing visible content when the tab regained focus or reconnected. - Keep TerminalComponent instances alive in both Desktop and Mobile views. - Only refit/resize on reconnect instead of clearing. Closes terminal redraw on focus regain.
This commit is contained in:
@@ -174,9 +174,11 @@ export const TerminalComponent = React.forwardRef<TerminalRef, TerminalProps>(
|
||||
if (msg.status === "connected") {
|
||||
setStatus("connected");
|
||||
setError(null);
|
||||
// Clear terminal and refit after reset/reconnect
|
||||
// Refit after reset/reconnect but do NOT clear the
|
||||
// terminal: the server keeps the session buffer, and
|
||||
// clearing would erase it when the user switches back
|
||||
// to an already-connected session.
|
||||
if (termRef.current) {
|
||||
termRef.current.clear();
|
||||
requestAnimationFrame(() => {
|
||||
if (fitAddonRef.current && termRef.current) {
|
||||
fitAddonRef.current.fit();
|
||||
|
||||
Reference in New Issue
Block a user