Skip to content

improvement(terminal): resize output panel on any layout change via ResizeObserver#4220

Merged
waleedlatif1 merged 1 commit intostagingfrom
improvement/term
Apr 18, 2026
Merged

improvement(terminal): resize output panel on any layout change via ResizeObserver#4220
waleedlatif1 merged 1 commit intostagingfrom
improvement/term

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the terminal's MutationObserver on document.documentElement (watching CSS variable changes) and window.resize listener with a ResizeObserver on the terminal element itself
  • Terminal now measures its own rendered width via getBoundingClientRect(), so it correctly responds to all layout changes — sidebar resize, workflow panel resize, and mothership (chat/resources) resize — without CSS variable plumbing or cross-component coupling
  • Fixes the terminal output panel disappearing when resizing the chat/resources divider on task pages

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…esizeObserver

Replaces MutationObserver on document.documentElement (watching CSS variable
changes) + window resize listener with a ResizeObserver on the terminal element
itself. The terminal now measures its own rendered width directly, so it responds
correctly to all layout changes — sidebar, workflow panel, and mothership resize —
without indirect CSS variable plumbing or cross-component coupling.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 18, 2026 1:17am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 18, 2026

PR Summary

Low Risk
Low risk UI behavior change limited to terminal output panel sizing; main risk is potential missed/extra ResizeObserver callbacks affecting panel open/close behavior on edge layout changes.

Overview
Updates the terminal output panel resize logic to measure available width from terminalRef.getBoundingClientRect() and react to any layout-driven size change by observing the terminal element with ResizeObserver (removing the window.resize listener and MutationObserver on document.documentElement).

This also changes the auto-close behavior to trigger when the terminal’s own width can’t accommodate MIN_OUTPUT_PANEL_WIDTH_PX, addressing cases where resizing adjacent panes (e.g., chat/resources) previously caused the output panel to disappear incorrectly.

Reviewed by Cursor Bugbot for commit 86f5195. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 18, 2026

Greptile Summary

This PR replaces the terminal's MutationObserver (watching CSS variable attribute changes on document.documentElement) and window.resize listener with a ResizeObserver directly on the terminal element. The new approach reads getBoundingClientRect().width from the terminal element itself, which correctly reacts to every layout change — sidebar, workflow panel, and mothership divider — without any cross-component CSS variable coupling.

Confidence Score: 5/5

Safe to merge — clean bug fix with no P0 or P1 issues.

All findings are P2 or lower. The core logic is correct: the ResizeObserver fires on every layout-driven width change, the closure captures the right values, the effect dependency array is unchanged from before, and the manual handleResize() call before observer.observe() ensures the initial state is correct.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx Replaces MutationObserver + window.resize with a ResizeObserver on the terminal element itself; logic is correct and simpler than before.
apps/sim/app/workspace/[workspaceId]/home/hooks/use-mothership-resize.ts Trivial: removes one inline comment explaining the purpose of cleanupRef; no functional change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Any layout change] --> B{Source}
    B --> C[Sidebar resize]
    B --> D[Workflow panel resize]
    B --> E[Mothership/chat divider]
    B --> F[Window resize]

    C --> G[Terminal element width changes]
    D --> G
    E --> G
    F --> G

    G --> H[ResizeObserver fires on terminalRef]
    H --> I[handleResize called]

    I --> J{selectedEntry?}
    J -- No --> K[Return early — no-op]
    J -- Yes --> L["maxWidth = el.getBoundingClientRect().width − BLOCK_COLUMN_WIDTH"]

    L --> M{maxWidth < MIN_OUTPUT_PANEL_WIDTH?}
    M -- Yes --> N[Close output panel]
    M -- No --> O{outputPanelWidth > maxWidth?}
    O -- Yes --> P[Clamp outputPanelWidth to maxWidth]
    O -- No --> Q[No state change]
Loading

Reviews (1): Last reviewed commit: "improvement(terminal): resize output pan..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit 003e931 into staging Apr 18, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/term branch April 18, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant