fix: terminal sizing and newline rendering issues
- Add ResizeObserver to terminal container for responsive sizing (catches keyboard open/close, header auto-hide, layout changes) - Remove padding from mobile terminal container to maximize space - Fix CSS: ensure xterm viewport fills container height properly - Fix session-card.tsx TypeScript error (removed non-existent port field) - Remove explicit xterm-viewport/xterm-screen width overrides that interfered with xterm.js canvas sizing
This commit is contained in:
@@ -110,9 +110,7 @@ export function SessionCard({
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{session.port && session.status === "running" && (
|
|
||||||
<p className="muted session-card-meta">Port: {session.port}</p>
|
|
||||||
)}
|
|
||||||
{session.created_at && (
|
{session.created_at && (
|
||||||
<p className="muted session-card-meta">
|
<p className="muted session-card-meta">
|
||||||
Created: {new Date(session.created_at).toLocaleDateString()}
|
Created: {new Date(session.created_at).toLocaleDateString()}
|
||||||
|
|||||||
@@ -242,6 +242,25 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
|||||||
|
|
||||||
window.addEventListener("resize", handleResize);
|
window.addEventListener("resize", handleResize);
|
||||||
|
|
||||||
|
// Watch container size changes (keyboard, header auto-hide, etc.)
|
||||||
|
let resizeObserver: ResizeObserver | null = null;
|
||||||
|
if (terminalRef.current && typeof ResizeObserver !== "undefined") {
|
||||||
|
resizeObserver = new ResizeObserver(() => {
|
||||||
|
fitAddon.fit();
|
||||||
|
const { cols, rows } = term;
|
||||||
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
|
ws.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: "resize",
|
||||||
|
cols,
|
||||||
|
rows,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resizeObserver.observe(terminalRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
// Notify parent about terminal readiness
|
// Notify parent about terminal readiness
|
||||||
if (onTerminalReadyRef.current) {
|
if (onTerminalReadyRef.current) {
|
||||||
const sendData = (data: string) => {
|
const sendData = (data: string) => {
|
||||||
@@ -270,6 +289,9 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
|||||||
return () => {
|
return () => {
|
||||||
clearTimeout(resizeTimeout);
|
clearTimeout(resizeTimeout);
|
||||||
window.removeEventListener("resize", handleResize);
|
window.removeEventListener("resize", handleResize);
|
||||||
|
if (resizeObserver) {
|
||||||
|
resizeObserver.disconnect();
|
||||||
|
}
|
||||||
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||||
ws.close();
|
ws.close();
|
||||||
term.dispose();
|
term.dispose();
|
||||||
|
|||||||
+16
-13
@@ -2594,31 +2594,34 @@ a.nav-item,
|
|||||||
padding: var(--space-2);
|
padding: var(--space-2);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal-container .xterm {
|
.terminal-container .xterm {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
height: 100%;
|
||||||
|
|
||||||
.terminal-container .xterm-viewport {
|
|
||||||
width: 100% !important;
|
|
||||||
height: 100% !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.terminal-container .xterm-screen {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.terminal-container .xterm-viewport {
|
|
||||||
background: #1e1e1e !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal-container canvas {
|
.terminal-container canvas {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mobile terminal container - no padding to maximize space */
|
||||||
|
.terminal-wrapper.mobile .terminal-container {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure xterm viewport fills container properly */
|
||||||
|
.terminal-wrapper.mobile .xterm {
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terminal-wrapper.mobile .xterm-viewport {
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsive terminal */
|
/* Responsive terminal */
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.terminal-page {
|
.terminal-page {
|
||||||
|
|||||||
Reference in New Issue
Block a user