Skip to content

Commit 3ea2333

Browse files
committed
fix(terminal): clamp output panel against the live CSS-var width
The ResizeObserver clamp compared the persisted store width, which is intentionally stale during a drag; a terminal shrink mid-drag could overwrite the live width with a stale store value. Compare against the live --output-panel-width variable (store as pre-write fallback) so the clamp converges with the drag instead of fighting it.
1 parent ac89025 commit 3ea2333

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,10 @@ export const Terminal = memo(function Terminal() {
12551255
/**
12561256
* Adjust output panel width on resize.
12571257
* Closes the output panel if there's not enough space for the minimum width.
1258+
* The clamp compares against the live `--output-panel-width` CSS variable
1259+
* (the visual width — during a drag it runs ahead of the store, which only
1260+
* commits on release) so a resize mid-drag can never stomp the drag with a
1261+
* stale store value; the store value is the fallback before any write.
12581262
*/
12591263
useEffect(() => {
12601264
const el = terminalRef.current
@@ -1271,7 +1275,11 @@ export const Terminal = memo(function Terminal() {
12711275
return
12721276
}
12731277

1274-
if (outputPanelWidth > maxWidth) {
1278+
const liveWidth = Number.parseFloat(
1279+
document.documentElement.style.getPropertyValue('--output-panel-width')
1280+
)
1281+
const currentWidth = Number.isNaN(liveWidth) ? outputPanelWidth : liveWidth
1282+
if (currentWidth > maxWidth) {
12751283
setOutputPanelWidth(Math.max(maxWidth, MIN_OUTPUT_PANEL_WIDTH_PX))
12761284
}
12771285
}

0 commit comments

Comments
 (0)