fix(site): search box mishandles diff URLs and error overflow#26078
Draft
tracyjohnsonux wants to merge 1 commit into
Draft
fix(site): search box mishandles diff URLs and error overflow#26078tracyjohnsonux wants to merge 1 commit into
tracyjohnsonux wants to merge 1 commit into
Conversation
The chat search dialog had three related bugs around diff URLs:
1. A diff_url filter pill containing a URL produced a backend error
'query element can only contain 1 ":"' because buildQuery only
quoted values containing spaces, so 'diff_url:https://...' was
sent unquoted and the backend split it on every ':'.
2. Removing 'https' as a workaround left a scheme-less URL the
backend rejects with 'must use http or https scheme'.
3. Long error strings (which echo the offending query element) ran
past the dialog's 560px max-width with no wrap.
Centralize filter-token formatting in searchQuery.ts and quote values
containing whitespace, ':', or '"' so URL values round-trip cleanly.
Detect bare URL-like input ('https://...' or 'host.tld/path') and
route it to diff_url: instead of an always-empty title search.
Auto-prepend 'https://' to scheme-less diff_url values both when the
pill is committed and at normalization time. Add overflow-wrap:anywhere
to the ErrorAlert title/description in ChatSearchResults so long URLs
inside backend errors wrap inside the dialog.
Refs CODAGT-556.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The chat search dialog had three related bugs around diff URLs (CODAGT-556):
diff_url:filter pill produced a backend errorquery element ... can only contain 1 ':'.buildQueryonly quoted values containing spaces, sodiff_url:https://github.com/owner/repo/pull/123was sent unquoted and the backend'ssplitQueryParameterByDelimitersplit it on every:.httpsto dodge that error left a scheme-less URL the backend rejects invalidateDiffURLwithmust use http or https scheme.AlertTitle/AlertDescriptionhave nobreak-wordsand a URL has no spaces to wrap on.The fix centralizes filter-token formatting in
searchQuery.ts:formatChatSearchFilterTokenquotes values containing whitespace,:, or"so a URL filter token round-trips through the backend parser cleanly.normalizeChatDiffURLValueauto-prependshttps://to scheme-less host/path values, applied both at filter-pill commit time and inside the normalizer so the pasted URL keeps working even if the user removes the scheme.looksLikeChatDiffURLdetects bare URL paste (e.g.https://github.com/coder/coder/pull/1typed directly into the input with nodiff_url:pill) and routes it todiff_url:instead of falling through to an always-empty title search on the URL string.ChatSearchResultsadds[overflow-wrap:anywhere]to the error alert's title/description so a long URL inside a backend error wraps inside the dialog instead of overflowing it.Refs https://linear.app/codercom/issue/CODAGT-556
Test coverage
searchQuery.test.tsgains 17 new cases covering URL detection, scheme-less normalization, quoting, duplicate diff_url handling, and thelooksLikeChatDiffURL/normalizeChatDiffURLValue/formatChatSearchFilterTokenhelpers individually.ChatSearchDialog.stories.tsxgains three regression stories (ErrorStateWithLongURL,DiffURLFilterPill,BareURLAutoRoutesToDiffURL) that exercise the failing flows end to end through the dialog.Local
make pre-commit(gen, lint, build) and the storybook + vitest suites for these files all pass.