Skip to content

🤖 fix: stabilize chat input auto-resize height#3263

Merged
ammario merged 1 commit intomainfrom
chat-input-stbg
May 10, 2026
Merged

🤖 fix: stabilize chat input auto-resize height#3263
ammario merged 1 commit intomainfrom
chat-input-stbg

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes the workspace chat input collapsing to a tiny height while editing large drafts by making the auto-resize hook verify the DOM inline height before it skips a resize write.

Background

  • The recent typing-performance optimization cached the last applied textarea height. On shrink-capable updates, the hook can temporarily set the textarea height to auto; if the measured height matches the cache, the old guard skipped restoring the pixel height. Large inputs then fell back to the CSS minimum until another resize path repaired them.

Implementation

  • Keep the no-op fast path for normal insertions, but also compare the actual inline height against the desired pixel height before skipping the write.
  • Added regression coverage for capped large-text deletion and callers clearing the inline height outside the hook.

Validation

  • bun test src/browser/hooks/useAutoResizeTextarea.test.tsx
  • make static-check

Risks

  • Low. The change is scoped to the textarea resize hook and preserves the existing optimization when the DOM already has the expected inline height.

Generated with mux • Model: openai:gpt-5.5 • Thinking: xhigh • Cost: 1787684{MUX_COSTS_USD:-n/a}

Summary
- Ensure the textarea auto-resize hook reapplies the expected pixel height when the cached height matches but the DOM inline style was reset.
- Cover capped-height deletion and external inline-style clearing regressions in the hook tests.

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `1782918{MUX_COSTS_USD:-n/a}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=n/a -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammario ammario merged commit 477dfe5 into main May 10, 2026
24 checks passed
@ammario ammario deleted the chat-input-stbg branch May 10, 2026 03:09
mux-bot Bot added a commit that referenced this pull request May 10, 2026
The chat input auto-resize stabilization in #3263 added a second
`Number.parseFloat(el.style.height)` + `Number.isFinite(...)` pair to
verify that the cached pixel height still reflects the textarea's inline
style, sitting a handful of lines from the existing pair in the
canOnlyGrow first-render fallback. Both spell out the same intent --
read the textarea's inline `height` style as a finite px number, or
treat it as missing -- but as two independent expressions they were one
stray edit away from drifting on what counts as a usable inline height.

Extract a private `readInlineHeightPx(el): number | null` helper that
captures the parseFloat + isFinite pair in one place, with the rationale
captured on the helper itself. The two call sites collapse to a single
named call, and the surviving branches replace `Number.isFinite(...)`
with `=== null` / `!== null` checks (functionally identical because the
helper already filters non-finite values).

Pure refactor -- emitted writes, the canOnlyGrow grow-only semantics,
the post-resize "restore the px height after auto / external clears"
verification, and the existing 5-test `useAutoResizeTextarea` suite
(including the regression cases for capped large-text deletion and
external inline-height clears added in #3263) are all unchanged.
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.

2 participants