Skip to content

Fix chat composer height race during sidebar open transition#218

Merged
oandregal merged 1 commit into
trunkfrom
competent-shtern-22fa6b
May 21, 2026
Merged

Fix chat composer height race during sidebar open transition#218
oandregal merged 1 commit into
trunkfrom
competent-shtern-22fa6b

Conversation

@oandregal
Copy link
Copy Markdown
Contributor

Summary

  • Fix an intermittent bug where the chat composer textarea renders at ~392px instead of 72px after reopening the sidebar panel
  • Change flex: 1 1 autoflex: 0 0 auto on .composer-input — the JS auto-resize handles all height changes, so flex-grow was redundant

Root cause

When the sidebar panel reopens, the CSS flex-basis transition starts from 0. React mounts DraftChatPanel and the useLayoutEffect in ChatComposer fires while the panel is still at ~0 width. Setting el.style.height = 'auto' during reflow lets flex-grow: 1 expand the textarea to fill the available column height (degenerate layout at 0 width). The resulting scrollHeight (e.g. 392px) gets locked in as the inline height and persists after the transition completes.

Test plan

  • Open a project → sidebar shows the chat tab with a normal-height composer
  • Close the sidebar → reopen by clicking the chat rail icon → composer stays at normal height (previously it would sometimes balloon)
  • Type multi-line text in the composer → it still auto-grows correctly
  • Add attachment chips → composer still adjusts height properly

🤖 Generated with Claude Code

The composer textarea had `flex: 1 1 auto` in a column flex container.
When the sidebar panel reopened (CSS transition from width 0 → 320px),
React mounted the DraftChatPanel and the auto-resize useLayoutEffect
fired while the panel was still near-zero width. Setting height to
`auto` let flex-grow expand the textarea to fill the degenerate layout,
and scrollHeight captured that inflated value (e.g. 392px instead of
72px). The inline height then persisted after the transition completed.

Changing to `flex: 0 0 auto` is safe because the JS auto-resize in
ChatComposer already handles all height changes — flex-grow on the
textarea was redundant and only harmful during transitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 09:27
@oandregal oandregal merged commit fa65232 into trunk May 21, 2026
@oandregal oandregal deleted the competent-shtern-22fa6b branch May 21, 2026 09:27
@oandregal oandregal review requested due to automatic review settings May 21, 2026 09:49
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