Skip to content

Conversation

@sfc-gh-nbellante
Copy link
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Dec 15, 2025

Describe your changes

Simplified the ChatInput component UI by implementing a single-row layout for basic use cases. When neither file upload nor audio recording features are enabled, the component now displays a cleaner interface with the textarea and send button side-by-side in a single row, rather than the more complex two-row layout with separate action areas. This also makes it take up less height in that particular case.

Key improvements:

  • Added a new isSimpleMode condition that activates when no file upload or audio features are needed
  • Created a new StyledSimpleRow component for the simplified layout
  • Adjusted button sizing and vertical alignment for better visual consistency
  • Added new theme size variables for better component consistency

Screenshot or video (only for visual changes)

The PR updates numerous snapshot tests to reflect the new simplified UI for the chat input component.

Testing Plan

  • E2E Tests: Updated all existing snapshot tests to reflect the new UI changes
  • Manual testing: Verified the component works correctly in both simple and extended modes across different browsers

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Dec 15, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13364/streamlit-1.52.2-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13364.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0100%

  • Current PR: 86.5200% (12768 lines, 1720 missed)
  • Latest develop: 86.5100% (12765 lines, 1721 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch 3 times, most recently from 1cab02f to 8ceac1f Compare December 18, 2025 15:35
@sfc-gh-nbellante sfc-gh-nbellante added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Jan 5, 2026
@sfc-gh-nbellante sfc-gh-nbellante changed the title Refactor chat input layout per Figma specs [feat] Simplify chat input UI with single-row layout for basic configurations Jan 5, 2026
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch from ef12af3 to a96a229 Compare January 5, 2026 17:58
@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review January 5, 2026 20:46
Copilot AI review requested due to automatic review settings January 5, 2026 20:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the ChatInput component UI by introducing a single-row layout for basic configurations where neither file upload nor audio recording features are enabled. The change reduces the component's height and visual complexity in these common use cases.

Key changes:

  • Added isSimpleMode condition to detect when simplified layout should be used
  • Created new StyledSimpleRow component for single-row layout with textarea and send button side-by-side
  • Added three new theme size variables for consistent sizing across chat input elements
  • Updated button sizing to use new theme variables instead of hardcoded values

Reviewed changes

Copilot reviewed 3 out of 274 changed files in this pull request and generated 2 comments.

File Description
frontend/lib/src/theme/primitives/sizes.ts Added three new size constants for chat input: textarea min height, button size, and vertical offset
frontend/lib/src/components/widgets/ChatInput/styled-components.ts Removed gap from StyledChatInput, added StyledSimpleRow component, updated button sizing, adjusted InputInstructions positioning
frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx Added isSimpleMode logic and conditional rendering for simple vs. extended layouts with duplicated textarea configuration
e2e_playwright/__snapshots__/**/*.png Updated visual regression test snapshots to reflect new simplified UI layout

@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch from a5b8c4a to 2a6cc22 Compare January 5, 2026 21:12
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch from 2a6cc22 to 06fd5ca Compare January 5, 2026 21:19
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Summary

This PR refactors the ChatInput widget UI to use a single-row “simple mode” layout (textarea + send button side-by-side) when no file upload and no audio recording are enabled, while keeping the existing two-row layout for “extended mode”. It also introduces semantic theme size tokens for the chat input and updates a large set of Playwright snapshot images to match the new visuals.

Code Quality

Overall the refactor is clear and maintainable:

  • Good extraction: Pulling the BaseWeb UITextArea overrides into createTextAreaOverrides reduces duplication and keeps simple/extended layouts consistent (frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx L91-L141).
  • Readable mode split: The isSimpleMode conditional cleanly separates the two layouts (ChatInput.tsx L671-L874).
  • Theme tokens: Using theme sizes for chat input sizing is consistent with repo styling practices (frontend/lib/src/theme/primitives/sizes.ts L68-L72; frontend/lib/src/components/widgets/ChatInput/styled-components.ts L122-L156).

Nits / small maintainability notes:

  • Inline style in JSX: Simple mode uses an inline style={{ marginBottom: ... }} on StyledSendIconButton (ChatInput.tsx L723-L734). This is minor, but the repo generally prefers Emotion styles over inline styles; it might be cleaner to encode this via a styled prop/variant (or in StyledSimpleRow).
  • Style typing: rootLayoutStyle is typed as Record<string, string | number> (ChatInput.tsx L101-L103). Using React.CSSProperties (or a narrower type) would better constrain valid CSS values.

Test Coverage

  • E2E coverage: The PR updates many existing Playwright snapshot PNGs (notably under e2e_playwright/__snapshots__/linux/st_chat_input_test/...), which is appropriate for a primarily-visual change. No e2e test code (*_test.py) changed—only expected snapshots—so the correctness signal is limited to “visuals match expectations”.
  • Unit coverage: No TypeScript unit tests were added/updated. Given that the main functional change is layout branching, that’s acceptable, but a small RTL/Vitest test asserting the mode switch (simple vs extended) would make the behavior more robust against future refactors.

E2E best-practices note: since snapshot churn is large, it’s worth ensuring the screenshots remain as small/specific as possible (element-level where feasible) to reduce future maintenance (per .cursor/rules/e2e_playwright.mdc guidance).

Backwards Compatibility

  • No public API changes and no protobuf changes.
  • The behavior change is visual/layout only. The main compatibility risk is for users relying on custom CSS selectors/layout assumptions around stChatInput (e.g., expecting a two-row DOM structure). This seems low-risk but worth noting given the DOM re-structure in simple mode (ChatInput.tsx L704-L735 vs L737-L874).

Security & Risk

  • No obvious security impact.
  • Primary regression risk is layout/interaction (e.g., button alignment, overlap with the character counter, focus behavior). The code keeps accessible names for icon buttons via aria-label (ChatInput.tsx L727-L728, L803-L814, L838-L865), which is good.

Recommendations

  1. Remove the inline style in simple mode by moving the vertical offset into Emotion styling (e.g., a StyledSendIconButton prop or a StyledSimpleRow rule) (ChatInput.tsx L723-L734).
  2. Tighten the type of rootLayoutStyle to React.CSSProperties (or a narrower shape) to prevent accidental invalid CSS keys/values (ChatInput.tsx L101-L103).
  3. Consider adding a small frontend test that renders ChatInput in both configurations and asserts:
    • simple mode renders a submit button and textarea in the single-row container
    • extended mode renders the action row and (when enabled) mic/upload controls
      This would complement the snapshot coverage and protect the branching logic.

Verdict

APPROVED: The refactor is clean, uses semantic sizing tokens, and the snapshot updates appear consistent with a UI-only change; only minor maintainability follow-ups are suggested.


This is an automated AI review. Please verify the feedback and use your judgment.

Copy link
Collaborator

@sfc-gh-bnisco sfc-gh-bnisco left a comment

Choose a reason for hiding this comment

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

I spot-checked the snapshots and they look good and expected. One minor styled-component suggestion inline, but LGTM after!

@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch from 06fd5ca to 8bf0ca7 Compare January 6, 2026 18:25
- Move mic button to right side (next to send button)
- Reduce send button size from 40px to 32px
- Reduce textarea min height from 40px to 24px
- Add conditional single-row layout when no file/audio features
- Add semantic theme values: chatInputTextareaMinHeight, chatInputPrimaryButtonSize
- Remove conditional single-row layout (was making height 73px instead of target 104px)
- Keep two-row layout with reduced sizes:
  - Send button: 32px (was 40px)
  - Textarea min-height: 24px (was 40px)
- Mic button remains on right side in action row
- Revert character counter position to original
- Simple mode (no file upload, no audio): single-row layout with textarea and send button side by side
- Extended mode (with file upload or audio): two-row layout with content area and action row
- Mic button stays on right side in extended mode
- Add chatInputButtonVerticalOffset theme size for button centering
- Use flex-end with margin offset to center button in simple mode
- Move character counter up to avoid button overlap
- Remove gap between content and action row in extended mode
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the chat-input-layout-fixes branch from 8bf0ca7 to 1bed6b2 Compare January 6, 2026 18:58
@sfc-gh-nbellante sfc-gh-nbellante merged commit 100fed7 into develop Jan 6, 2026
44 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the chat-input-layout-fixes branch January 6, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants