Skip to content

fix(chat): re-measure the prompt editor when its width changes - #6380

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-input-click-dead-zone
Aug 7, 2026
Merged

fix(chat): re-measure the prompt editor when its width changes#6380
waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-input-click-dead-zone

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The chat input's textarea grows to its full content height under a mirror overlay, but it only re-measured when the text changed. Any width change after typing — window resize, sidebar toggle, resource panel opening — left the textarea at a stale inline height while the overlay rewrapped taller.
  • The spilled lines still painted and still scrolled, but had no textarea under them, so clicking there hit the scroller and never placed a caret. Measured a 260px dead zone narrowing 700px → 340px.
  • Added a ResizeObserver that re-measures on width change only — the measure writes the textarea's height, so reacting to height would feed itself.
  • Not a recent regression: introduced by fix(user-input): atomic chip selection, modifier-key handling, and stale overlay ghost #4902 (2026-06-08), which replaced the self-scrolling textarea with the full-height-in-a-scroller design. Under the old design a stale height was harmless, since every visible line was still inside the textarea's own scrollport.

Type of Change

  • Bug fix

Testing

6 unit tests in prompt-editor.test.tsx. Verified each fails against a broken implementation — removing the observer, dropping the width guard, and skipping disconnect on unmount each turn tests red.

Also reproduced and confirmed the fix in a real browser against the same CSS structure: dead zone 260px → 0, click hit target back to the textarea, caret lands correctly, and no ResizeObserver loop errors across repeated and sub-pixel width changes.

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)

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 7, 2026 6:06pm

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized chat prompt editor layout fix with unit tests; no auth, data, or API changes.

Overview
Fixes a chat input bug where the prompt textarea kept a stale inline height after the editor narrowed or widened (window resize, sidebar, panel open). Text still painted on the mirror overlay but sat outside the textarea, so clicks did not place the caret.

autosize is now a useCallback shared between the existing value-driven layout effect and a new ResizeObserver on the scroller. The observer re-measures only when width changes, because height updates from autosize would otherwise loop the observer.

Adds prompt-editor.test.tsx with six tests (mount sizing, width narrow/widen, first delivery after early width change, width-only guard, unmount disconnect) using a fake ResizeObserver and stubbed scrollHeight.

Reviewed by Cursor Bugbot for commit 8130737. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes prompt-editor sizing after container-width changes by observing the scroller and re-running autosizing on each distinct width, including the observer’s first delivery.

  • Extracts textarea height measurement into a stable callback shared by text-change and resize effects.
  • Disconnects the observer during unmount and avoids height-driven feedback loops by comparing only width.
  • Adds focused tests for mounting, narrowing, widening, first-delivery timing, unchanged-width notifications, and cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/prompt-editor.tsx Adds a width-sensitive ResizeObserver whose first notification re-measures the textarea, resolving the previously reported missed-width window.
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/prompt-editor.test.tsx Adds deterministic coverage for width remeasurement, the first asynchronous observer delivery, loop prevention, and observer cleanup.

Reviews (3): Last reviewed commit: "chore(chat): trim duplicated comments on..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 50b2c87. Configure here.

The chat input's textarea grows to its full content height under a mirror
overlay, but it only re-measured on text change. A width change after typing
(window resize, sidebar toggle, resource panel opening) left the textarea at a
stale inline height while the overlay rewrapped taller. The spilled lines still
painted and scrolled but had no textarea beneath them, so clicks landed on the
scroller and never placed a caret.

Re-measure on width change only — the measure writes the textarea's height, so
reacting to height would feed itself.
The width can change between the mount-time measure and observe(), so
treating the first notification as confirmation of the mount width dropped
that change and left the stale height in place.
The failure mode was documented in four places. Keeps one canonical
explanation next to the guard and leaves only the per-test whys the test
names do not already carry.
@waleedlatif1
waleedlatif1 force-pushed the fix/chat-input-click-dead-zone branch from 50b2c87 to 8130737 Compare August 7, 2026 18:06
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8130737. Configure here.

@waleedlatif1
waleedlatif1 merged commit d2964af into staging Aug 7, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-input-click-dead-zone branch August 7, 2026 18:29
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