Remove browser resize triggers
This commit is contained in:
parent
116847ab58
commit
9bc77292cd
1 changed files with 1 additions and 75 deletions
|
|
@ -1256,12 +1256,9 @@
|
||||||
session.outputRenderedLength = 0;
|
session.outputRenderedLength = 0;
|
||||||
renderSessions();
|
renderSessions();
|
||||||
|
|
||||||
// If expanding, resize the PTY to fit the viewport
|
|
||||||
if (session.expanded) {
|
if (session.expanded) {
|
||||||
// Wait for DOM to update before measuring
|
// Wait for DOM to update before initializing UI state
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
handleSessionResize(Number(sessionId));
|
|
||||||
// After mount, ensure we start at bottom and initialize UI state
|
|
||||||
scrollToBottom(Number(sessionId));
|
scrollToBottom(Number(sessionId));
|
||||||
updateScrollButton(Number(sessionId));
|
updateScrollButton(Number(sessionId));
|
||||||
initSessionOutputUI(Number(sessionId));
|
initSessionOutputUI(Number(sessionId));
|
||||||
|
|
@ -2134,74 +2131,6 @@
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Viewport-based PTY resize
|
|
||||||
let resizeDebounceTimer = null;
|
|
||||||
|
|
||||||
function measureTerminalCols() {
|
|
||||||
// Create a hidden span with monospace font to measure character width
|
|
||||||
const $measure = document.createElement('span');
|
|
||||||
$measure.style.fontFamily = '"SF Mono", Monaco, "Cascadia Code", "Courier New", monospace';
|
|
||||||
$measure.style.fontSize = `${state.settings.fontSize}px`;
|
|
||||||
$measure.style.lineHeight = '1.5';
|
|
||||||
$measure.style.visibility = 'hidden';
|
|
||||||
$measure.style.position = 'absolute';
|
|
||||||
$measure.textContent = 'X'.repeat(100); // Measure 100 chars
|
|
||||||
document.body.appendChild($measure);
|
|
||||||
|
|
||||||
const charWidth = $measure.offsetWidth / 100;
|
|
||||||
document.body.removeChild($measure);
|
|
||||||
|
|
||||||
// Get terminal container width (accounting for padding)
|
|
||||||
const $container = document.querySelector('.session-output');
|
|
||||||
if (!$container) {
|
|
||||||
return 80; // Default fallback
|
|
||||||
}
|
|
||||||
|
|
||||||
const containerWidth = $container.clientWidth - 32; // 16px padding on each side
|
|
||||||
const cols = Math.floor(containerWidth / charWidth);
|
|
||||||
|
|
||||||
// Clamp to reasonable bounds
|
|
||||||
return Math.max(40, Math.min(cols, 300));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resizeSessionPTY(sessionId, cols, rows) {
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/sessions/${sessionId}/resize`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ cols, rows }),
|
|
||||||
});
|
|
||||||
if (!res.ok) {
|
|
||||||
console.error('Failed to resize session PTY:', await res.text());
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error resizing session PTY:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSessionResize(sessionId) {
|
|
||||||
const cols = measureTerminalCols();
|
|
||||||
const rows = 24; // Reasonable default row count
|
|
||||||
resizeSessionPTY(sessionId, cols, rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleWindowResize() {
|
|
||||||
if (resizeDebounceTimer) {
|
|
||||||
clearTimeout(resizeDebounceTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeDebounceTimer = setTimeout(() => {
|
|
||||||
// Resize all expanded sessions
|
|
||||||
state.sessions.forEach((session) => {
|
|
||||||
if (session.expanded) {
|
|
||||||
handleSessionResize(session.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 300); // Debounce for 300ms
|
|
||||||
}
|
|
||||||
|
|
||||||
window.scrollToBottom = (sessionId) => {
|
window.scrollToBottom = (sessionId) => {
|
||||||
const $outputContainer = document.getElementById(`session-output-${sessionId}`);
|
const $outputContainer = document.getElementById(`session-output-${sessionId}`);
|
||||||
if ($outputContainer) {
|
if ($outputContainer) {
|
||||||
|
|
@ -2213,9 +2142,6 @@
|
||||||
loadSettings();
|
loadSettings();
|
||||||
applySettings();
|
applySettings();
|
||||||
connectSSE();
|
connectSSE();
|
||||||
|
|
||||||
// Set up window resize listener for PTY viewport resize
|
|
||||||
window.addEventListener('resize', handleWindowResize);
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue