Skip to content

Conversation

Dcatfly
Copy link
Contributor

@Dcatfly Dcatfly commented Jul 3, 2025

Related Issue

#4051

Description

Current Status

When users enter a custom URL in cline, if there are spaces before or after the URL, cline's interface will not display the spaces at the beginning and end, but the URL actually used internally by cline still contains the spaces. The display does not match the actual, which can cause request errors and make troubleshooting difficult.

This issue occurs when using the VSCodeTextField component with type set to URL. The involved base components are: BaseUrlField and DebouncedTextField. The affected providers include: AskSageProvider, BedrockProvider, LiteLlmProvider, OpenAICompatibleProvider, AnthropicProvider, GeminiProvider, LMStudioProvider, and OllamaProvider.

image
image

Reason

The reason for this issue is very interesting.
The VSCodeTextField component actually uses @microsoft/fast-foundation's TextField. The underlying implementation of the TextField is a web-component with two-way binding functionality. During the actual execution of value binding, it directly assigns the value to the shadow element.
If the type of this element is url, the browser environment will apply the sanitization algorithm to the value, removing spaces on both sides of the value. This is the default behavior of the browser and will only occur when the value is assigned via JavaScript. If the user enters the value directly into the input, it will not happen.

Changes

Since the package of the VSCodeTextField component is no longer maintained, this change only performs a trim operation on the value when the type is url, so that the actual value matches the displayed value, and also avoids request errors caused by spaces.

Test Procedure

  1. Verified that pasting a URL with spaces correctly sends the request.
  2. Verified that when the user deletes input, value.trim does not cause an error.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ♻️ Refactor Changes
  • 💅 Cosmetic Changes
  • 📚 Documentation update
  • 🏃 Workflow Changes

Pre-flight Checklist

  • Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
  • Tests are passing (npm test) and code is formatted and linted (npm run format && npm run lint)
  • I have created a changeset using npm run changeset (required for user-facing changes)
  • I have reviewed contributor guidelines

Screenshots

No changes on the interface

Additional Notes

In the long term, it would be more reasonable to migrate the UI components to another component library and implement input validation.


Important

Trim spaces from URL input values in BaseUrlField and DebouncedTextField to ensure consistency and prevent errors.

  • Behavior:
    • Trim spaces from URL input values in BaseUrlField and DebouncedTextField to ensure consistency between displayed and actual values.
    • Prevents request errors caused by leading or trailing spaces in URLs.
  • Components:
    • Modify onInput handler in BaseUrlField to trim URL values.
    • Modify onInput handler in DebouncedTextField to conditionally trim URL values based on type.
  • Misc:
    • Add changeset tiny-pants-train.md to document the patch.

This description was created by Ellipsis for d97a48a. You can customize this summary. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Jul 3, 2025

🦋 Changeset detected

Latest commit: d97a48a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
claude-dev Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@saoudrizwan
Copy link
Contributor

Thank you so much for your contribution 🙏 We will test and merge this right away!

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

Thank you!

@abeatrix abeatrix merged commit 25c5310 into cline:main Jul 26, 2025
4 checks passed
@Dcatfly
Copy link
Contributor Author

Dcatfly commented Jul 27, 2025

@abeatrix Thank you for reviewing and merging this PR, but the related issue has not been closed yet. I don't have the necessary permissions, could you please close this #4051?

li-yechao pushed a commit to li-yechao/cline that referenced this pull request Jul 27, 2025
* fix: trim input value for URL fields in BaseUrlField and DebouncedTextField components (cline#4051)

* chore: add changeset
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.

3 participants