[feature] Add height parameter to st.chat_input#14165
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
Adds a new height parameter to st.chat_input() to control the widget’s minimum height via layout height config, with backend validation and frontend rendering support.
Changes:
- Backend: Add
heightparam tost.chat_input, validate it, and propagate it viaLayoutConfig. - Backend tests: Add unit tests for
height_configprotobuf behavior and invalid height values. - Frontend: Apply
heightConfigto ChatInput layout/styling and add corresponding widget tests; adjust element container behavior for stretch height.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/tests/streamlit/elements/chat_test.py |
Adds unit tests for default/explicit height_config and invalid height values. |
lib/streamlit/elements/widgets/chat.py |
Introduces height parameter, docstring docs, validation, and layout propagation. |
frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx |
Implements height behavior (stretch/pixel/content) in ChatInput rendering. |
frontend/lib/src/components/widgets/ChatInput/ChatInput.test.tsx |
Adds frontend tests for stretch/content/undefined heightConfig. |
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx |
Adjusts container config for chat input when stretch height is enabled. |
Consolidated Code ReviewSummaryThis PR adds a Both reviewers agreed the overall direction and architecture are sound — reusing Code QualityPixel height behaves as fixed height, not minimum height (High — both reviewers agree)The API documentation explicitly states pixel height is a minimum that auto-expands with content:
However, the implementation creates a fixed-height outer container:
For comparison,
|
Consolidated Code Review: PR #14165 — Add
|
| Topic | gpt-5.3-codex-high | opus-4.6-thinking | Resolution |
|---|---|---|---|
| Code quality | Good | Good | Agreed |
| Pixel-height layout | Blocking bug | Minor/acceptable | codex is correct — verified that flex: 0 0 <px> and overflow: auto are not overridden, contradicting the textArea pattern |
| Python tests | Good | Good | Agreed |
| Frontend pixel test | Weak | Weak | Agreed |
| Missing E2E tests | Noted | Noted | Agreed |
| Variable shadowing | Not flagged | Flagged (minor) | Valid minor issue |
| Backwards compat | Good | Good | Agreed |
| Security | No issues | No issues | Agreed |
Verdict
CHANGES REQUESTED: The pixel-height mode has a container layout bug where flex: 0 0 <px> and overflow: auto are not neutralized by the AUTO_HEIGHT config, preventing auto-expansion in vertical flex layouts. This contradicts the documented API behavior and is the same issue already solved in the textArea handler. The fix is small (extend AUTO_HEIGHT styleOverrides) but necessary before merge.
Consolidated review by opus-4.6-thinking. Individual reviews from gpt-5.3-codex-high and opus-4.6-thinking.
📋 Review by `gpt-5.3-codex-high`
Summary
This PR adds a new height parameter to st.chat_input, wires it through Python layout config, and updates frontend chat input layout/styling paths for content, stretch, and pixel modes. The API shape and typing updates are solid, but there is a blocking frontend layout issue in pixel mode that conflicts with the documented behavior.
Code Quality
The implementation is generally clean and follows existing patterns, but one functional issue stands out:
- Blocking: In
frontend/lib/src/components/core/Block/ElementContainerConfig.ts(STRETCH_HEIGHT/AUTO_HEIGHT) andfrontend/lib/src/components/core/Block/ElementNodeRenderer.tsx(chatInputcase), pixel mode maps toElementContainerConfig.AUTO_HEIGHT, which only overridesheight: "auto". However, the base layout engine still applies pixel-height semantics (flex: 0 0 <px>+overflow: auto) for vertical flex layouts (frontend/lib/src/components/core/Layout/useLayoutStyles.ts), so the outer container can still behave like a fixed-height scroll region rather than a true minimum-height container. - This conflicts with the public contract in
lib/streamlit/elements/widgets/chat.py, where pixelheightis documented as a minimum height that still auto-expands with text.
Test Coverage
- Python unit coverage is good for this scope: validation, proto field mapping, and typing updates are present in
lib/tests/streamlit/elements/chat_test.pyandlib/tests/streamlit/typing/chat_input_types.py. - Frontend unit tests in
frontend/lib/src/components/widgets/ChatInput/ChatInput.test.tsxdo not validate the critical pixel-mode behavior end-to-end (min-height + auto-expand semantics under renderer/container layout). Current assertions mostly check presence/style basics, so the container-layout regression path is not caught. - No e2e test coverage was added for this user-visible feature (
st.chat_input(height=...)), which leaves integration behavior under real app layout unverified.
Backwards Compatibility
The API change is additive and keyword-only, so existing callers are unlikely to break. However, the new pixel-height mode does not reliably match the documented behavior, so users adopting the new option may experience unexpected fixed-height scrolling behavior.
Security & Risk
No direct security concerns identified. Main risk is UI/behavioral regression for chat UX in pixel-height mode, especially in typical vertical container layouts.
Accessibility
No obvious new a11y violations in semantics/labels. That said, if pixel mode creates an unintended nested scroll container, keyboard navigation and screen-reader interaction can degrade versus expected auto-expanding input behavior.
Recommendations
- Update pixel-height container behavior for
chatInputto neutralize pixel-mode fixed-layout effects at the outer container level (at leastflexin vertical layout, and likelyoverflowas needed), similar to the existingtextAreahandling pattern. - Add/adjust frontend tests to assert pixel-mode runtime behavior through renderer/container layout, not only isolated
ChatInputcomponent rendering. - Add an e2e test case that exercises
st.chat_input(height=<int>)andheight="stretch"in a realistic layout to validate integration behavior.
Verdict
CHANGES REQUESTED: The feature is close, but pixel-height mode currently has a blocking layout behavior mismatch with the documented "minimum height with auto-expand" contract.
This is an automated AI review by gpt-5.3-codex-high. Please verify the feedback and use your judgment.
📋 Review by `opus-4.6-thinking`
Summary
This PR adds a height parameter to st.chat_input() that controls the minimum height of the chat input widget. It supports three modes:
Noneor"content"(default): Uses the default single-line height with auto-expand behavior (preserves current behavior)."stretch": Fills the available height of the parent container.- Integer (pixels): Sets a fixed minimum height while retaining auto-expand.
Changes span the Python backend (chat.py), frontend React components (ChatInput.tsx, styled-components.ts, ElementNodeRenderer.tsx, ElementContainerConfig.ts), and comprehensive tests (Python unit tests, frontend unit tests, and typing tests).
Code Quality
Overall: Clean implementation that follows existing patterns in the codebase. The code is well-structured and maintainable.
Good practices observed:
- Static
ElementContainerConfiginstances (STRETCH_HEIGHT,AUTO_HEIGHT) used inElementNodeRenderer.tsxfor referential stability — consistent with the AGENTS.md guidance. textareaMinHeightcorrectly computed viauseMemowith proper dependencies.- Layout/pixel calculations performed on the frontend side, following the
lib/streamlit/AGENTS.mdguideline ("Theming and layout calculations must be done in the frontend"). heightvalidation only runs whenheight is not None, preserving the default behavior.isStretchHeight && !isStackedguard inStyledTextareaWrapperproperly avoids disrupting the stacked layout behavior.
Issue — Variable shadowing (ChatInput.tsx line 801):
The local innerHeight variable on line 801 shadows the destructured innerHeight from useWindowDimensionsContext() on line 184. While functionally correct (the outer value isn't needed here), it is confusing and may trigger linting warnings. Consider renaming to something like adjustedHeight or innerMinHeight.
Test Coverage
Python unit tests (chat_test.py): Good coverage including:
- Default behavior (no
height_configfield present). - Parameterized tests for all three modes (pixel, stretch, content).
- Invalid input validation tests (string, negative, zero, float).
Typing tests (chat_input_types.py): Thorough coverage of the height parameter across all overload combinations with accept_file and accept_audio.
Frontend unit tests (ChatInput.test.tsx): Adequate but could be stronger:
- Tests stretch mode correctly applies
height: 100%. - Negative cases properly check that non-stretch modes don't get
height: 100%. - The pixel height mode test (line 912-917) only asserts the textarea element exists (
toBeInTheDocument), but does not verify that the correctmin-heightstyle is applied. This test would pass even if the pixel height logic was completely broken.
Missing E2E tests: This is a new user-facing feature, and per the project's testing strategy (AGENTS.md): "Most new user-facing features should be covered by both unit tests and E2E tests." No E2E tests were added. Given that the height behavior is visual and involves CSS flex layout interactions (especially stretch mode in containers), E2E/snapshot tests would provide valuable confidence.
Backwards Compatibility
No breaking changes. The height parameter defaults to None, which preserves the existing behavior. The height_config protobuf field is optional on the Element message and was already defined before this PR. All existing overload signatures maintain their original parameter order with height appended as the last keyword argument.
The height parameter is included in compute_and_register_element_id but not in key_as_main_identity, which means changing height won't reset widget state when a user key is provided. This is the correct design choice since height is purely visual.
Security & Risk
No security concerns identified. The height parameter is validated server-side before being sent via protobuf, rejecting invalid types and non-positive integers. The frontend handles the value defensively with Math.max(0, ...) for pixel calculations.
Low regression risk: the changes only affect ChatInput and are gated behind the new height parameter. Default behavior (None) follows the existing code path.
Accessibility
No accessibility regressions introduced. The height changes are purely CSS-based and don't affect the DOM structure, ARIA attributes, keyboard navigation, or focus management. The textarea remains fully accessible regardless of height mode.
Recommendations
-
Rename shadowed variable: In
ChatInput.tsxline 801, renameconst innerHeighttoconst adjustedHeightorconst innerMinHeightto avoid confusion with theinnerHeightfromuseWindowDimensionsContext()on line 184. -
Strengthen the pixel height test: The frontend test "renders textarea element in pixel height mode" (line 912-917) should verify the actual
min-heightstyle on the textarea root, not just that the textarea element exists. -
Add E2E tests: Consider adding E2E tests (can be in a follow-up PR) covering:
height="stretch"inside a fixed-heightst.container.height=<int>renders the widget at the specified minimum height.- Default behavior remains unchanged.
-
Note on
do-not-mergelabel: The PR currently has ado-not-mergelabel. Ensure this is removed when the PR is ready.
Verdict
APPROVED: Well-implemented feature with good backend validation, clean frontend integration following existing patterns, and adequate test coverage. The variable shadowing and weak pixel-height test are minor issues. Missing E2E tests can be addressed in a follow-up.
This is an automated AI review by opus-4.6-thinking.
Consolidated Code Review: Add
|
| Topic | gpt-5.3-codex-high |
opus-4.6-thinking |
Consensus |
|---|---|---|---|
| Code quality | Good with one regression risk | Good with minor nits | Agree: well-implemented |
| Horizontal layout flex issue | Blocking — must fix | Not mentioned as blocking | See resolution below |
| Redundant flex spread | Not mentioned | Minor nit | Valid but non-blocking |
| Missing E2E tests | Should be added | Should be added (as follow-up) | Agree: gap exists |
| Backward compatibility | Compatible | Compatible | Agree |
| Overall verdict | CHANGES_REQUESTED | APPROVED | See final verdict |
Conflict Resolution: Horizontal Layout Flex Issue
The gpt-5.3-codex-high reviewer flagged this as a blocking regression; opus-4.6-thinking acknowledged low regression risk but approved. After verifying the code:
- The concern is technically valid — the
AUTO_HEIGHTconfig differs from thetextAreapattern. - However,
st.chat_input(height=<pixels>)inside a horizontal layout is an uncommon edge case. - The default behavior (no
heightparameter) is entirely unaffected. - The fix is straightforward (use a dynamic config like
textAreadoes) and could be done as a fast follow-up.
Verdict on this issue: This is a valid but low-severity concern. It should be addressed (either before merge or as an immediate follow-up), but it does not constitute a critical regression that blocks the PR.
Recommendations
-
Address horizontal layout flex handling (priority: medium): Either switch to a dynamic config for the pixel-height case (mirroring
textArea) or add a comment explaining why the static approach is acceptable forchatInput. This can be done as a follow-up. -
Add E2E tests (priority: medium): Cover
height="stretch"inside a container with defined height andheight=<int>for visual rendering. Both reviewers flagged this gap, consistent with the project's testing strategy. -
Remove redundant flex spread (priority: low): Clean up line 89 in
styled-components.tsor add a clarifying comment if the intent is documentation. -
Strengthen pixel-height frontend test (priority: low): Consider testing
createTextAreaOverridesdirectly to verify computedminHeightvalues.
Verdict
APPROVED — The implementation is clean, well-tested at the unit level, and fully backward compatible. The horizontal layout flex concern is valid but low-severity (edge case with straightforward fix). The missing E2E tests are a notable gap per project standards but don't block merge. Both issues should be addressed as immediate follow-ups.
Consolidated review by opus-4.6-thinking. Individual reviews follow below.
📋 Review by `gpt-5.3-codex-high`
Summary
This PR adds a new height parameter to st.chat_input across backend and frontend layers, wires it into layout config/protobuf handling, and introduces Python + frontend unit tests plus typing coverage. The implementation is generally clean and consistent with existing patterns, but I found one regression risk that should be fixed before merge.
Code Quality
The code is readable and follows existing architecture well (backend API + layout config + frontend rendering).
However, there is a layout behavior regression risk:
- Potential horizontal-layout regression for pixel height mode
Infrontend/lib/src/components/core/Block/ElementContainerConfig.ts:134,AUTO_HEIGHTforcesflex: "".
Infrontend/lib/src/components/core/Block/ElementNodeRenderer.tsx:817, this config is selected forchatInputwhenheightConfig.pixelHeightis set.
In horizontal flex layouts, this clears the computed flex distribution (useLayoutStyles), which can break width behavior (e.g., items no longer participating correctly in row sizing).
This differs from the existingtextAreahandling pattern, which only neutralizesflexwhen not in horizontal layout.
Test Coverage
Coverage is improved and generally strong:
- Python unit tests validate
height_configserialization and invalid inputs inlib/tests/streamlit/elements/chat_test.py. - Typing tests validate new overload behavior in
lib/tests/streamlit/typing/chat_input_types.py. - Frontend unit tests validate stretch/content/pixel mode rendering behavior in
frontend/lib/src/components/widgets/ChatInput/ChatInput.test.tsx.
Remaining gap:
- No test currently exercises
chat_input(height=<pixel>)in a horizontal layout container, which is where the flex regression risk appears. - No e2e test was added for this new user-facing sizing behavior.
Backwards Compatibility
The API change is additive (height is optional and keyword-only), so it is broadly backwards compatible.
That said, the flex override issue above can introduce behavior changes for apps using st.chat_input(height=<int>) inside horizontal layouts.
Security & Risk
No direct security concerns identified.
Main risk is UI/layout regression in specific container configurations.
Accessibility
No new accessibility regressions are obvious from the changed code.
Existing button semantics and labels are preserved, and no new non-semantic interactive patterns were introduced by this PR.
Recommendations
- Update pixel-height container behavior so flex is only neutralized when not in horizontal layout (mirror the existing
textAreastrategy). - Add a frontend unit test that renders
ChatInputin a horizontal flex context withheightConfig.pixelHeightand asserts expected sizing/flex behavior. - Add an e2e test covering
st.chat_input(height="stretch")andst.chat_input(height=<int>)in realistic container scenarios.
Verdict
CHANGES REQUESTED: Good feature implementation overall, but the AUTO_HEIGHT flex override can regress horizontal-layout behavior and should be fixed before merge.
This is an automated AI review by gpt-5.3-codex-high. Please verify the feedback and use your judgment.
📋 Review by `opus-4.6-thinking`
Summary
This PR adds a height parameter to st.chat_input() that controls the minimum height of the chat input widget, with three modes:
Noneor"content"(default): Standard single-line height with auto-expand behavior (no change from current behavior)."stretch": Fills available height of the parent container.- Integer (pixels): Fixed minimum height with auto-expand behavior.
The implementation spans backend (Python validation, protobuf integration via existing HeightConfig), frontend (styled components, container config, textarea overrides), and test code (Python unit tests, frontend unit tests, typing tests).
Code Quality
The code is well-structured and follows existing patterns in the codebase:
-
Backend: The
heightparameter is properly added to all four overloads ofchat_input(), validated via the existingvalidate_height()utility, and flows throughLayoutConfigto the protobufHeightConfigmessage — the same pattern used by other elements. Theheightparameter defaults toNone, which is the correct backward-compatible default. -
Frontend: The
ElementContainerConfiguses static constants (STRETCH_HEIGHT,AUTO_HEIGHT) for referential stability, following the class's documented pattern. ThetextareaMinHeightcalculation correctly usesuseMemoto avoid recomputation. ThecreateTextAreaOverridesfunction cleanly integrates theminHeightOverrideparameter. -
Styled components: The
isStretchHeightprop is threaded throughStyledChatInputContainer,StyledChatInput,StyledInputRow, andStyledTextareaWrapperto correctly propagate stretch behavior down the component tree.
Minor observations:
-
Redundant flex spread in
StyledTextareaWrapper(styled-components.tsline 89): The conditional...(isStretchHeight && !isStacked && { flex: 1 })is redundant because the baseflex: isStacked ? "none" : 1already producesflex: 1when!isStacked, regardless ofisStretchHeight. The spread doesn't change the computed value. -
Stacked + stretch interaction (
styled-components.tslines 64-73, 78-90): When bothisStacked(text fills width, triggers wrapped layout) andisStretchHeightare true, the textarea wrapper getsflex: "none"withwidth: "100%". In a wrapped flex row,align-items: stretchonly stretches items to the line height, not the container height. This means the textarea won't actually fill the vertical space in stacked mode. This is likely acceptable since stacked mode implies enough text to auto-expand, but it's worth noting as a potential visual inconsistency.
Test Coverage
Python unit tests (chat_test.py): Good coverage with:
- Default height (no
height_configfield present) — validated viaHasField. - Parameterized tests for all three valid modes (pixel, stretch, content).
- Parameterized tests for invalid inputs (
"invalid",-100,0,100.5).
Frontend unit tests (ChatInput.test.tsx): Reasonable coverage with:
- Stretch mode: Validates
height: 100%is applied to the container. - Negative tests: Parameterized check that non-stretch modes don't apply
height: 100%. - Pixel height mode: The test at line 912 acknowledges it cannot verify the actual
min-heightCSS value applied through baseweb overrides. It only verifies the component renders and the textarea exists — this is a known limitation but means the pixel-height CSS path is not truly asserted.
Typing tests (chat_input_types.py): Thorough coverage of height parameter with None, "content", "stretch", and integer values across different accept_file combinations.
Missing E2E tests: The PR does not include E2E tests. Per the project's testing strategy (AGENTS.md: "Most new user-facing features should be covered by both unit tests and E2E tests"), this is a notable gap. E2E tests would verify the actual rendering behavior across all three height modes, especially stretch mode within a container with defined height and pixel-height mode visual appearance.
Backwards Compatibility
This change is fully backward compatible:
- The
heightparameter defaults toNone, which produces noheight_configfield in the protobuf message, matching pre-PR behavior exactly. - The frontend falls through to
ElementContainerConfig.DEFAULTwhen noheightConfigis present. - No existing protobuf fields or messages were modified — the
HeightConfigmessage already existed. - All existing overloads maintain their signatures;
heightis added as an optional keyword argument.
Security & Risk
No security concerns identified. The height parameter undergoes proper server-side validation:
- String values are restricted to
"stretch"and"content". - Integer values must be positive (rejects
0, negatives, and floats like100.5). - Invalid inputs raise
StreamlitInvalidHeightError.
Regression risk: Low. The default behavior is unchanged, and the feature is additive. The most complex path (pixel height with auto-expand) involves CSS min-height calculations, but these are well-isolated in useMemo and don't affect the default code path.
Accessibility
No accessibility concerns. The changes are purely visual/layout:
- No new interactive elements are added.
- All existing
aria-label,aria-describedby, and keyboard interaction patterns are preserved. - The textarea remains the same semantically; only its minimum height changes.
- Focus management is unaffected.
Recommendations
-
Add E2E tests: Create E2E tests covering the three height modes. At minimum, test
height="stretch"inside a container with defined height, andheight=<int>to verify visual rendering. This follows the project's stated testing strategy for new user-facing features. -
Remove redundant flex spread in
StyledTextareaWrapper(styled-components.tsline 89): The conditional...(isStretchHeight && !isStacked && { flex: 1 })produces the same value already set byflex: isStacked ? "none" : 1in the non-stacked case. Consider removing it or adding a comment explaining the intent if kept for documentation purposes. -
Strengthen pixel-height frontend test: While baseweb override style assertions are difficult, consider testing the
createTextAreaOverridesfunction directly to verify theminHeightvalue matches expectations (e.g.,"174px"forpixelHeight: 200). This would provide stronger coverage than only checking the component renders.
Verdict
APPROVED: Well-implemented feature with clean backend/frontend integration, proper validation, and good backward compatibility. The missing E2E tests are the main gap but don't block the merge — they should be added as a follow-up.
This is an automated AI review by opus-4.6-thinking.
I think |
It's good to include the stretch height test because I find this gets broken frequently. |
| styleOverrides: { overflow: "visible" }, | ||
| }) | ||
|
|
||
| static readonly STRETCH_HEIGHT = new ElementContainerConfig({ |
There was a problem hiding this comment.
This is too specific to be STRETCH_HEIGHT for all elements, I think the config should live just with the chat input.
| // This prevents the layout from applying a fixed height to the outer container. | ||
| // Must also neutralize flex (prevents fixed flex-basis) and overflow (prevents scroll), | ||
| // following the same pattern as textArea to enable true auto-expand behavior. | ||
| static readonly AUTO_HEIGHT = new ElementContainerConfig({ |
There was a problem hiding this comment.
I'm not sure whether this is generally applicable to all elements?
| // Must also neutralize flex (prevents fixed flex-basis) and overflow (prevents scroll), | ||
| // following the same pattern as textArea to enable true auto-expand behavior. | ||
| static readonly AUTO_HEIGHT = new ElementContainerConfig({ | ||
| styleOverrides: { height: "auto", flex: "", overflow: "visible" }, |
There was a problem hiding this comment.
I think the flex: "" shouldn't be needed for horizontal layouts since this change is needed for height, but flex-basis applies to width in a horizontal layout.
Add a new `height` parameter to `st.chat_input` that allows controlling the minimum height of the chat input widget: - `None` or `"content"` (default): Uses default single-line height and auto-expands based on text content - `"stretch"`: Height stretches to fill available parent container space - Integer (pixels): Fixed minimum height that still auto-expands This is useful for chat interfaces where the input should take up more vertical space or fill a container.
- Add frontend unit tests for heightConfig (stretch, content, undefined) - Add clarifying constant for border calculation in ChatInput.tsx - Enhance docstring to note that stretch requires parent container height
- Add static STRETCH_HEIGHT config to ElementContainerConfig for referential stability - Move inline styles to styled-components (isStretchHeight prop) - Add height parameter typing tests to chat_input_types.py
- Fix pixel-height container behavior: Added AUTO_HEIGHT config to ElementContainerConfig so pixel height acts as minimum height with auto-expand, matching documented API behavior - Fix isStacked + isStretchHeight flex conflict: Guard flex: 1 override with !isStacked to preserve stacked layout wrapping behavior - Use theme border width: Replace hardcoded CONTAINER_BORDER with theme.sizes.borderWidth for maintainability - Refactor height calculation: Convert getTextareaMinHeight to useMemo for better React patterns - Consolidate tests: Use it.each for non-stretch height mode tests
- Fix AUTO_HEIGHT to also neutralize flex and overflow, following the textArea pattern for correct pixel-height auto-expand behavior - Rename innerHeight to adjustedHeight to avoid variable shadowing with innerHeight from useWindowDimensionsContext() - Strengthen pixel height test with better assertions and documentation
e27dc58 to
75495a8
Compare
Address PR review feedback from @sfc-gh-lwilby: - Remove STRETCH_HEIGHT and AUTO_HEIGHT static configs since they're too specific to be general element configs - Create inline configs in chatInput case following the textArea pattern - Fix flex reset to only apply in vertical layouts (flex-basis affects width in horizontal layouts, not height) Co-Authored-By: Claude Opus 4.6 <[email protected]>
height parameter to st.chat_input
- Remove redundant isStretchHeight logic from StyledTextareaWrapper (flex is already 1 when !isStacked) - Remove unused isStretchHeight prop from ChatInput.tsx - Remove redundant toBeInTheDocument() assertion in test Co-Authored-By: Claude Opus 4.6 <[email protected]>
| const heightConfig = node.element.heightConfig | ||
| const chatInputConfig = new ElementContainerConfig({ | ||
| styleOverrides: heightConfig?.useStretch | ||
| ? { height: "100%", flex: "1 1 8rem" } |
There was a problem hiding this comment.
Is this consistent with text_area? One potential issue with this override is that if/when we add relative stretch widths, this will break it since it overrides the flex-grow. If this is just to introduce the 8 rem flex-basis, there is the min-width option for that.
There was a problem hiding this comment.
It's consistent with the text area, I also added the minStretchWidth that's used for the text area as well. I will play around a bit if everything works as expected with this
There was a problem hiding this comment.
OK, maybe both of them can be improved in a follow-up. I can't remember the details of why I added that now. I should have left a comment -- or maybe a comment was removed accidentally in the refactor.
I think chat input is slightly simpler because if I remember correctly, it doesn't have the resizing with dragging by the user.
There was a problem hiding this comment.
it doesn't have the resizing with dragging by the user.
yep, but it has auto-resizing by content getting added instead
|
|
||
| // Calculate minimum height for the textarea based on heightConfig. | ||
| // Subtracts container padding and border from pixel height to get inner textarea height. | ||
| const textareaMinHeight = useMemo((): string | undefined => { |
There was a problem hiding this comment.
Is this different than TextArea, I might have added something for this there that could be shared potentially?
There was a problem hiding this comment.
The calculation here is similar, but too different for sharing it
sfc-gh-lwilby
left a comment
There was a problem hiding this comment.
This looks good to me, I am just wondering if some of the overrides are still more than necessary and if we might share some of the code with TextArea
Match TextArea's behavior by adding minStretchWidth: MinStretchWidth.MEDIUM to the chat_input container config. This ensures consistent minimum width behavior when chat_input is placed in horizontal layouts (e.g., st.columns). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add visual snapshot tests for the new height parameter: - height=200 (pixel height) - height="stretch" (fills parent container) The stretch test uses a container with defined height to verify the chat input properly fills the available space. Co-Authored-By: Claude Opus 4.6 <[email protected]>
When height is set to stretch or a pixel value, the submit button should stick to the bottom of the input rather than being vertically centered. Introduces `hasExpandedHeight` which is true for both stretch and pixel heights, and uses `alignItems: flex-end` on the input row to keep buttons at the bottom. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Include autoExpand.isExtended in hasExpandedHeight calculation so the submit button sticks to the bottom when the textarea expands due to user-added newlines, not just when height is configured via props. Co-Authored-By: Claude Opus 4.6 <[email protected]>
When the chat input is expanded (multiline or configured height), use a column layout that separates the textarea from the toolbar. This creates a dedicated bottom row for buttons (file upload, mic, submit) that text doesn't flow into. - Add StyledToolbarRow component for the dedicated button row - Change StyledInputRow to column layout when hasExpandedHeight is true - Restructure JSX to conditionally wrap buttons in toolbar row Co-Authored-By: Claude Opus 4.6 <[email protected]>
When height is configured via props (stretch or pixel), disable the autoExpand height constraints and use 100% height with no maxHeight. This allows the textarea to fill the container and scroll properly instead of overflowing. - Add useFixedHeight parameter to createTextAreaOverrides - Add hasConfiguredHeight to distinguish prop-based from dynamic height - When hasConfiguredHeight is true, use height: 100% and maxHeight: none Co-Authored-By: Claude Opus 4.6 <[email protected]>
In non-expanded (single-line) mode, use CSS order: -1 on StyledLeftCluster to position the file upload button before the textarea, which is now rendered first in the DOM for the expanded mode layout. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Moves the character count indicator (e.g. "4/200") from absolutely positioned in the top-right corner to inline within StyledRightCluster. This prevents the counter from overlapping with the submit button and places it next to the audio/submit buttons in both normal and expanded height modes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove None as a valid value for the height parameter since it was equivalent to "content". This makes the API clearer and more explicit. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The test was expecting no height_config field when using the default, but with the API change (height="content" as explicit default), it should now expect use_content: true. Co-Authored-By: Claude Opus 4.6 <[email protected]>
SummaryThis PR adds a All three reviewers agreed the overall structure is clean and follows established Streamlit patterns (reusing Code QualityConsensus strengths:
Issues identified:
Test CoverageAll reviewers agreed coverage is broad:
Gaps identified (consensus between gpt-5.3-codex-high and opus-4.6-thinking):
Backwards CompatibilityAll reviewers confirmed the The Security & RiskUnanimous agreement: No security concerns. Changes are confined to UI parameter validation, CSS/layout, and protobuf field reuse. No auth, routing, websocket, embedding, or storage changes. External test recommendation
AccessibilityUnanimous agreement: No accessibility regressions. Recommendations
Reviewer Agreement Matrix
VerdictCHANGES_REQUESTED: While two of three reviewers approved, the behavior mismatch between the Consolidated review by 📋 Review by `gemini-3.1-pro`SummaryThis PR adds a Code QualityThe code changes are clean, well-structured, and follow the established patterns in the repository. The frontend changes correctly handle the different layout modes (stacked vs inline) and correctly adjust the flex and height properties based on the Test CoverageThe changes are well-tested:
Backwards CompatibilityThe changes are fully backwards compatible. The default value for the Security & RiskNo security concerns or regression risks identified. The changes are limited to UI presentation and standard parameter passing, with no impact on sensitive areas like authentication, file serving, or code execution. External test recommendation
AccessibilityThe changes do not negatively impact accessibility. The chat input remains fully functional via keyboard and screen readers, and the new layout modes correctly preserve focus management and ARIA attributes. RecommendationsNo specific recommendations for improvement. The implementation is solid and ready for merge. VerdictAPPROVED: The PR successfully implements the This is an automated AI review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR adds a new Code QualityThe overall structure follows Streamlit patterns (backend validation + layout config, frontend container config, unit/e2e updates).
Test CoverageCoverage is improved and broad:
Gap that matters for this change:
Backwards CompatibilityAPI-wise this is additive ( Security & RiskNo direct security issues identified (no auth/session/cookie/CORS/path handling/runtime execution changes). External test recommendation
AccessibilityNo new critical a11y regressions spotted in this diff. Interactive icon buttons retain accessible names ( Recommendations
VerdictCHANGES REQUESTED: The This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR adds a
The implementation spans backend (Python parameter + validation), protobuf (reuses existing Code QualityStrengths:
Concerns:
Test CoveragePython unit tests (
Python typing tests (
Frontend unit tests (
E2E tests (
Backwards Compatibility
Security & RiskNo security concerns identified. The changes are confined to:
External test recommendation
Accessibility
Recommendations
VerdictAPPROVED: Well-implemented feature that follows established Streamlit patterns for height configuration, with thorough backend validation, typing tests, and visual snapshot coverage. The main concern is JSX duplication in the expanded/non-expanded layout branches, which is a maintainability issue rather than a correctness bug. The implicit visual change to This is an automated AI review by |
Describe your changes
Adds a
heightparameter tost.chat_input()that allows controlling the minimum height of the chat input widget.Noneor"content"(default): Uses default single-line height with auto-expand"stretch": Fills available height of parent containerGithub Issues
st.chat_input#10724Testing Plan
Agent metrics