Skip to content

Match chat document search on file names and clear dropdown divider artifacts - #1260

Merged
Paul Lizer (paullizer) merged 1 commit into
Developmentfrom
paullizer-legendary-memory
Aug 18, 2026
Merged

Paul Lizer (paullizer) merged 1 commit into
Developmentfrom
paullizer-legendary-memory

Conversation

@paullizer

Copy link
Copy Markdown
Contributor

Fixes #1256

What was broken

Two defects in the chat page grounded-search document picker.

File names were unsearchable. buildDocumentDescriptor() built the searchable text from the display name (title || file_name) plus the section label, so the file name never reached the matcher for any document that had extracted title metadata. Searching 200 for Quarterly_Report_200_final.pdf returned "No Matching Documents".

Filtering left orphaned separator lines. updateDropdownStructure() resolved divider visibility by scanning for the nearest visible sibling, but isVisibleItem() reported dividers as not visible, so the scan walked straight through them — and the always-visible data-search-role="action" row counted as valid content. Every orphaned divider found the same action row above it and the first surviving header below it, so all of them stayed visible.

before (filter "beta")      after
  - Select All                - Select All
  ------------------          # [Public] Beta
  ------------------          - Beta Handbook
  # [Public] Beta
  - Beta Handbook

What changed

chat-searchable-select.js

  • New shared normalizeSearchText() / matchesSearchTokens(): text and query are lowercased with _, -, . treated as word breaks, and a row matches when every typed token appears somewhere. Matching stays position-independent, so 200 still matches mid-file-name and report 200 now matches Quarterly_Report_200_final.pdf.
  • Divider visibility is now section-aware. A bound divider (one that introduces a .dropdown-header) follows that header and requires visible section content before it; an unbound divider (the static rule under "All" / "Clear All") requires visible content before and visible section content after. Always-visible action rows never count as section content. A final collapseRedundantDividers() pass guarantees no leading, trailing, or stacked separator lines regardless of future markup.

chat-documents.js / chat-onload.js / chats.css

  • The file name is added to the search label and rendered as a smaller muted line under the title when the two differ, via textContent; both lines go into the row tooltip.
  • The dropdown button label now reads .chat-document-option-title instead of the first descendant span, which would otherwise concatenate title and file name.

No backend change was needed — /api/documents, /api/group_documents, and /api/public_workspace_documents already return file_name, and the backend workspace list already matched on title or file name. No new browser assets, so the local-only asset policy and CSP are unaffected.

Blast radius

  • The Compare modal document picker inherits both fixes, since chat-messages.js relocates the same #document-dropdown field into #document-comparison-picker-controls.
  • The shared token matcher is also used by createSearchableSingleSelect, so the prompt, model, and agent selectors gain multi-word matching. This is intentional for consistency.
  • Trade-off: normalizing . means a query like a.b matches text containing a and b separately. Acceptable for a filename-oriented picker, and it is what makes report 200 work.

Validation

functional_tests/test_chat_document_search_filename_matching.py — 8/8 pass. The divider and matching checks are executable, not static: the test loads the production chat-searchable-select.js into a minimal DOM shim through Node and asserts the exact filtered output for the document, scope, and tags dropdowns, including that no leading, trailing, or adjacent separator lines survive. Skips the executable section with a warning when Node.js is unavailable.

ui_tests/test_chat_document_search_filename_and_dividers.py — 4/4 pass. Mounts the real modules with production CSS, stubs fetch with personal/group/public documents, and drives loadAllDocs(). Covers the muted file-name line (stacking, smaller font, tooltip, suppressed when it duplicates the title), file-name/multi-word/literal/title matching, no orphaned separators plus structure restored on clear, and the mobile drawer without horizontal overflow. All four fail against the pre-fix source (file-name search returns No Matching Documents), so this is genuine regression coverage.

Regression suitetest_chat_search_panel_document_row_layout.py, test_chat_document_dropdown_viewport_fit.py, test_chat_scope_selector_sync.py, test_chat_document_action_selector_labels.py, test_chat_grouped_selectors.py, test_chat_compare_modal_document_picker.py all pass (skips require SIMPLECHAT_UI_BASE_URL).

Pre-existing failures, unchanged by this PR (verified by running them against a pristine HEAD): functional_tests/test_chat_searchable_selectors.py 7/11, functional_tests/test_workspace_scope_prompts_fix.py 1/2, and ui_tests/test_workflow_cancellation_controls.py when run in a batch (a Playwright sync/asyncio isolation issue — it passes alone both with and without these changes).

Version bumped to 0.250.209, with fix documentation in docs/explanation/fixes/CHAT_DOCUMENT_SEARCH_FILENAME_AND_DIVIDER_FIX.md and release notes updated.

The chat grounded-search document picker built its searchable text from
	itle || file_name, so a file name became unsearchable as soon as a
document had extracted title metadata. Filtering also left orphaned
section separator lines behind, commonly two stacked rules under the
Select All row, because divider visibility scanned for the nearest
visible sibling while skipping other dividers and counting the
always-visible action row as content.

- Add shared
ormalizeSearchText and matchesSearchTokens helpers so
  every typed word must appear and _, -, . act as word breaks
- Include the file name in the document search label and render it as a
  muted second line when it differs from the title
- Make divider visibility section-aware and collapse leading, trailing,
  and adjacent separator lines
- Read the title span when syncing the dropdown button label

Fixes #1256

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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