Skip to content

Conversation

@sfc-gh-nbellante
Copy link
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Jan 10, 2026

Describe your changes

Reduced the maximum length of file chips in the chat input component from 36 to 14 characters to improve UI appearance. This change:

  • Updates the truncateFilename function to use a shorter default max length
  • Modifies the StyledChatUploadedFile component to have a max width of 11rem
  • Updates tests to reflect the new truncation behavior
  • Updates snapshot tests for file chip appearance in different browsers and themes

Designs

image

Screenshot or video (only for visual changes)

The PR updates several snapshot images showing the new truncated file chips in the chat input component across different browsers (Chrome, Firefox, WebKit) and themes (light/dark).

Testing Plan

  • Unit Tests: Updated existing tests for the truncateFilename function to reflect the new default max length of 14 characters
  • E2E Tests: Updated snapshot tests to capture the visual changes in file chip appearance
  • The test changes ensure that we're checking the full filename via the title attribute rather than the displayed text content, which is now truncated

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 Jan 10, 2026

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 Jan 10, 2026

✅ PR preview is ready!

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

Copy link
Contributor Author

sfc-gh-nbellante commented Jan 10, 2026

@sfc-gh-nbellante sfc-gh-nbellante added security-assessment-completed Security assessment has been completed for PR change:chore PR contains maintenance or housekeeping change impact:users PR changes affect end users labels Jan 10, 2026
@sfc-gh-nbellante sfc-gh-nbellante changed the title fix: set file chip max width to 11rem per Figma design [fix] Shorten chat input file chip display with improved truncation Jan 11, 2026
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch 2 times, most recently from 6d4d477 to dd63fd6 Compare January 11, 2026 19:08
@sfc-gh-nbellante sfc-gh-nbellante changed the title [fix] Shorten chat input file chip display with improved truncation [fix] Shorten st.chat_input file chip display to adhere to designs Jan 11, 2026
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from develop to graphite-base/13555 January 11, 2026 20:57
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch from dd63fd6 to 3ab214f Compare January 11, 2026 20:57
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/13555 to fixit/file-chip-x-button-colors-v3 January 11, 2026 20:57
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from fixit/file-chip-x-button-colors-v3 to graphite-base/13555 January 11, 2026 22:39
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch from 494ea1a to 49b1769 Compare January 11, 2026 22:46
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/13555 to fixit/file-chip-x-button-colors-v3 January 11, 2026 22:47
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from fixit/file-chip-x-button-colors-v3 to graphite-base/13555 January 11, 2026 23:01
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch from 49b1769 to 1c4a42f Compare January 11, 2026 23:18
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/13555 to fixit/file-chip-x-button-colors-v3 January 11, 2026 23:18
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from fixit/file-chip-x-button-colors-v3 to graphite-base/13555 January 12, 2026 00:06
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch from c116964 to 89fc027 Compare January 12, 2026 00:10
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/13555 to fixit/file-chip-x-button-colors-v3 January 12, 2026 00:10
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0000%

  • Current PR: 86.5900% (12826 lines, 1719 missed)
  • Latest develop: 86.5900% (12826 lines, 1719 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@sfc-gh-nbellante sfc-gh-nbellante added the ai-review If applied to PR or issue will run AI review workflow label Jan 12, 2026
@github-actions github-actions bot removed the ai-review If applied to PR or issue will run AI review workflow label Jan 12, 2026
@github-actions
Copy link
Contributor

Summary

This PR reduces the maximum display length of file chips in the st.chat_input component from 36 to 16 characters. The changes include:

  1. Core logic change: Updated DEFAULT_MAX_LENGTH constant in truncateFilename.ts from 36 to 16
  2. Styling change: Set maxWidth: "11rem" (was 100%) on StyledChatUploadedFile to constrain chip width
  3. Unit tests: Updated truncateFilename.test.ts assertions to reflect the new 16-character limit
  4. Component tests: Updated ChatInput.test.tsx to verify filenames via title attribute instead of textContent
  5. E2E snapshots: Updated visual snapshots for the truncated file chip appearance

Code Quality

The implementation is clean and well-structured:

  • truncateFilename.ts: The algorithm correctly handles middle truncation while preserving file extensions. The logic is unchanged; only the default max length constant was updated.

  • styled-components.ts (line 82): The maxWidth: "11rem" change ensures visual consistency. This works well with the minWidth: "9rem" already set, creating a reasonable size range for file chips.

  • ChatUploadedFile.tsx (lines 156-163): The existing implementation already correctly sets title={fileInfo.name} for accessibility (full filename on hover tooltip) while displaying truncateFilename(fileInfo.name) as visible text. This is proper UI/UX design.

Minor Issue - PR Description Discrepancy

File: PR description
Issue: The PR description states "from 36 to 14 characters" but the actual code uses DEFAULT_MAX_LENGTH = 16. This should be corrected for documentation accuracy.

Test Coverage

Unit Tests (Good)

  • truncateFilename.test.ts: Comprehensive test coverage including:

    • Files under max length (short filenames, exact length, no extension)
    • Files with extensions over max length
    • Files without extensions
    • Very long extensions
    • Multiple dots (tar.gz, version numbers)
    • Edge cases (empty string, single character, hidden files, UUID-style)
    • Custom max length parameter
  • ChatInput.test.tsx: The changes correctly adapt to the new truncation behavior by checking the title attribute (full filename) instead of textContent (truncated display). This is the right approach since:

    • title attribute contains the full filename for accessibility
    • Displayed text is now truncated and may not match the full filename

E2E Tests (Good)

  • Updated snapshot tests for file chip truncation across browsers (chromium, firefox, webkit)
  • The parameterized test test_file_chip_variations in st_chat_input_test.py includes a "truncated" test case with a long filename to visually verify the truncation behavior

Backwards Compatibility

No breaking changes. This is a visual-only change:

  1. The truncateFilename function's public API is unchanged (same function signature, same parameter support)
  2. The full filename is still accessible via the title attribute (tooltip on hover)
  3. The underlying data/functionality is not affected - only display presentation
  4. Users can still pass custom maxLength to truncateFilename if needed

Security & Risk

Low risk:

  1. No security concerns - this is purely a UI/visual change
  2. No changes to data handling, file upload logic, or communication protocols
  3. The truncation logic is well-tested and handles edge cases properly
  4. The change improves UX by keeping file chips more compact

Recommendations

  1. Minor: Update the PR description to correctly state "from 36 to 16 characters" instead of "14 characters" for accuracy.

  2. Observation: Line 734 in ChatInput.test.tsx still uses toHaveTextContent("docs/readme.md") which works because the filename (13 characters) is shorter than the new max (16). This is fine but could be noted for future reference if the max length is reduced further.

Verdict

APPROVED: This is a well-implemented, focused change that improves the visual appearance of file chips in the chat input component. The code follows existing patterns, has comprehensive test coverage (both unit and E2E), and is fully backwards compatible. The only minor issue is a documentation discrepancy in the PR description (14 vs 16 characters) which does not affect the code quality.


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

@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review January 12, 2026 00:36
Copy link
Contributor Author

sfc-gh-nbellante commented Jan 12, 2026

Merge activity

  • Jan 12, 4:27 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 12, 4:29 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jan 12, 4:44 PM UTC: @sfc-gh-nbellante merged this pull request with Graphite.

@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from fixit/file-chip-x-button-colors-v3 to graphite-base/13555 January 12, 2026 16:27
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/13555 to develop January 12, 2026 16:27
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the fixit/file-chip-min-max-width-v2 branch from 89fc027 to f494c0d Compare January 12, 2026 16:28
@sfc-gh-nbellante sfc-gh-nbellante merged commit ad83318 into develop Jan 12, 2026
44 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the fixit/file-chip-min-max-width-v2 branch January 12, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:chore PR contains maintenance or housekeeping change 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