Skip to content

fix(site): search box mishandles diff URLs and error overflow#26078

Draft
tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/codagt-556-search-box-mishandles-diff-urls-and-error-overflow
Draft

fix(site): search box mishandles diff URLs and error overflow#26078
tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/codagt-556-search-box-mishandles-diff-urls-and-error-overflow

Conversation

@tracyjohnsonux
Copy link
Copy Markdown
Contributor

The chat search dialog had three related bugs around diff URLs (CODAGT-556):

  1. Pasting a diff URL into a diff_url: filter pill produced a backend error query element ... can only contain 1 ':'. buildQuery only quoted values containing spaces, so diff_url:https://github.com/owner/repo/pull/123 was sent unquoted and the backend's splitQueryParameterByDelimiter split it on every :.
  2. Removing https to dodge that error left a scheme-less URL the backend rejects in validateDiffURL with must use http or https scheme.
  3. Long backend validation errors (which echo the offending query element) ran past the dialog's 560px max-width because AlertTitle/AlertDescription have no break-words and a URL has no spaces to wrap on.

The fix centralizes filter-token formatting in searchQuery.ts:

  • formatChatSearchFilterToken quotes values containing whitespace, :, or " so a URL filter token round-trips through the backend parser cleanly.
  • normalizeChatDiffURLValue auto-prepends https:// 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.
  • looksLikeChatDiffURL detects bare URL paste (e.g. https://github.com/coder/coder/pull/1 typed directly into the input with no diff_url: pill) and routes it to diff_url: instead of falling through to an always-empty title search on the URL string.

ChatSearchResults adds [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.ts gains 17 new cases covering URL detection, scheme-less normalization, quoting, duplicate diff_url handling, and the looksLikeChatDiffURL/normalizeChatDiffURLValue/formatChatSearchFilterToken helpers individually.
  • ChatSearchDialog.stories.tsx gains 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.

Generated with Coder Agents

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.
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 4, 2026

CODAGT-556

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.

1 participant