Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { MOTHERSHIP_WIDTH } from '@/stores/constants'
*/
export function useMothershipResize() {
const mothershipRef = useRef<HTMLDivElement | null>(null)
// Stored so the useEffect cleanup can tear down listeners if the component unmounts mid-drag
const cleanupRef = useRef<(() => void) | null>(null)

const handleResizePointerDown = useCallback((e: React.PointerEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,20 +1246,14 @@ export const Terminal = memo(function Terminal() {
* Closes the output panel if there's not enough space for the minimum width.
*/
useEffect(() => {
const el = terminalRef.current
if (!el) return

const handleResize = () => {
if (!selectedEntry) return

const sidebarWidth = Number.parseInt(
getComputedStyle(document.documentElement).getPropertyValue('--sidebar-width') || '0'
)
const panelWidth = Number.parseInt(
getComputedStyle(document.documentElement).getPropertyValue('--panel-width') || '0'
)

const terminalWidth = window.innerWidth - sidebarWidth - panelWidth
const maxWidth = terminalWidth - TERMINAL_CONFIG.BLOCK_COLUMN_WIDTH_PX
const maxWidth = el.getBoundingClientRect().width - TERMINAL_CONFIG.BLOCK_COLUMN_WIDTH_PX

// Close output panel if there's not enough space for minimum width
if (maxWidth < MIN_OUTPUT_PANEL_WIDTH_PX) {
setAutoSelectEnabled(false)
setSelectedEntryId(null)
Expand All @@ -1273,21 +1267,10 @@ export const Terminal = memo(function Terminal() {

handleResize()

window.addEventListener('resize', handleResize)

const observer = new MutationObserver(() => {
handleResize()
})
const observer = new ResizeObserver(handleResize)
observer.observe(el)

observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['style'],
})

return () => {
window.removeEventListener('resize', handleResize)
observer.disconnect()
}
return () => observer.disconnect()
}, [selectedEntry, outputPanelWidth, setOutputPanelWidth])

return (
Expand Down
Loading