Draft
Conversation
…port Add Language and Transcription chip types to Chip.scala. Add toBackendQ parsing in SearchContext to convert chip-encoded q parameters into Elasticsearch queries with proper MIME type quoting and OR semantics for multi-value chips. Add comprehensive ChipsTest covering single/multi-value, date range, negation, and operator expansion scenarios.
Introduce chipNames.js with constants for all filter chip types and kinds (single, multi, date-range). Add chipParsing.js with parseChips() to extract structured filter chips from JSON-encoded q strings, rebuildQ() to serialize them back, and toBackendQ() to convert to Elasticsearch query syntax. Add fileTypeCategories.js mapping MIME types to human-friendly categories (PDF, Images, Spreadsheets, etc.) with memoized lookups. Include comprehensive test suitesInclude comprehensive test suitesInclude compred file type category mapping.
Update InputSupper Chip component with character-budget truncation and overflow handling. Add shared SCSS variables for filter chip colours. Import new stylesheet partials in main.scss.
Convert workspace search URL construction from the old filter-based format to the new JSON-encoded chip format, ensuring workspace searches produce chip-decorated queries.
Convert chipNames.js, chipParsing.js, and fileTypeCategories.js (plus their spec files) from JavaScript to TypeScript with proper type annotations. Add discriminated union types for chips (SingleChip, MultiChip, DateRangeChip), typed interfaces for parsed results, raw backend chips, suggested fields, polarity values, and chip filters.
- Default chipType to 'text' when element.t is undefined in chipParsing.ts - Add proper type annotations to spec helpers (q, chip functions) - Add Chip[] type annotations to const arrays passed to rebuildQ - Use type assertions for discriminated union property access (.values, .from, .to, .options) - Add non-null assertions for .find() results and toBackendQ returns - Add explicit 'any' annotations on JSON.parse callback parameters - Remove premature SCSS imports for _active-filters and _add-filter-modal (files don't exist yet)
Replace inline chip JSON in WorkspaceSummary and Workspaces with buildWorkspaceSearchQ and buildWorkspaceFolderSearchQ helpers from chipParsing.ts. This keeps the wire format defined in one place rather than duplicated at each call site.
Add isRawChip type guard function to replace ~20 instances of _isObject(el) && (el as RawChip).n patterns throughout chipParsing.ts. This narrows the type once at the guard, eliminating redundant casts and making the code shorter and safer.
- Guard InputSupper.focus() and select() with optional chaining to prevent crash when currentRef is undefined (pre-existing bug surfaced by keyboard shortcut before elements are initialised) - Revert WorkspaceSummary 'Search workspace' button to use sidebar filters (workspace URL param) instead of embedding workspace in q as a chip, since the chip-based search API integration is not yet wired up (PR3) - Restore workspace filter param in Workspaces 'Search in folder' context menu so the sidebar correctly ticks the workspace being searched
Always expand the template per-value when a chip value contains OR, regardless of how many _word_ placeholders the template has. Previously only multi-placeholder templates were expanded, meaning a Has Field chip with 'ocr OR transcript' would produce the invalid Elasticsearch query _exists_:(ocr OR transcript) instead of (_exists_:(ocr) OR _exists_:(transcript)). Update tests to reflect the corrected behaviour.
8bc39c8 to
feb167c
Compare
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.
Lays the groundwork for the search UX improvements epic #633.
Closes #634. Incidentally fixes #477, not that that matters much since we move chips out of the search bar in a subsequent branch.
Important
This is the first of five PRs in the Search UX Improvements epic. All other PRs depend on this one — it must be merged first.
Changes to the user experience
This PR is primarily infrastructure, but it does include a few visible changes:
Search bar chip improvements
..., and hovering shows the full value in a tooltip. This prevents the search bar from being stretched by very long folder paths or search terms.max-width: 100%with text overflow ellipsis, and the last chip element always reserves at least 100px for typing.Before:

After:

Having truncation rules will be useful even when we move chips out of the searchbox.
New search chip types
Backend: exclude filters
workspace_exclude[]andingestion_exclude[]query parameters, allowing results from specific workspaces or datasets to be excluded. This is plumbing for the tri-state sidebar filters in PR5 — there is no UI to trigger these yet.Bug fix
Cannot read properties of undefined (reading 'focus').Notable non-change
What's included
chipParsing.ts) — parsesqstrings into typed chips and rebuilds them. Three chip kinds are supported via a discriminated union:SingleChip,MultiChip, andDateRangeChip.chipNames.ts) — all magic strings for chip names, types, and kinds live here so typos cause import errors rather than silent runtime bugs.fileTypeCategories.ts) — maps MIME types to user-friendly categories (PDF, Images, Spreadsheets, etc.) for the File Type filter in subsequent PRs.buildWorkspaceSearchQandbuildWorkspaceFolderSearchQcentralise the construction of search queries for workspace navigation, replacing scattered inline logic.isRawChiptype guard — replaces repeated inline type assertions with a single reusable guard for narrowing raw parsed chips.InputSuppercomponent.TypeScript
All new code is written in TypeScript. Existing chip-related JS files have been converted to
.ts/.tsxwith full type annotations and discriminated union types for compile-time safety.Automated tests
Chip parsing logic is covered by unit tests in
chipParsing.spec.ts. File type category mapping is covered infileTypeCategories.spec.ts. Backend chip expansion is covered inChipsTest.scala.Manual tests