Skip to content

[COMMS-926] Allow to search by sequence number (in semantic mode) - #24497

Open
judithroth wants to merge 4 commits into
devfrom
implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers
Open

[COMMS-926] Allow to search by sequence number (in semantic mode)#24497
judithroth wants to merge 4 commits into
devfrom
implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers

Conversation

@judithroth

@judithroth judithroth commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/COMMS-926

To prevent that people see search results which they don't understand,
searching for the ID in semantic mode requires prefixing the number with
"#". When searching for a number in classic mode, it will always match
against the ID and never against the sequence number.

If that turns out to not be good enough in the future, we have to
improve the rendering of search results and include the reason there
(e.g. the database ID if that was matching and the instance is in
semantic mode).

What are you trying to accomplish?

Improve search results by

  • allowing to search by a work packages sequence number
  • rank exact matches for the sequence number higher than other matches (therefore show those results above other results)
  • restrict searching for database ID to number prefixed with "#" - because it would be confusing to users why a work package is included in the search results when the ID matches (but the user doesn't know that when the instance is in semantic ID mode)

Screenshots

NOT IMPLEMENTED LIKE THIS, JUST FOR CLARIFICATION WHAT SHOULD NOT HAPPEN:

Screenshot from 2026-07-29 11-00-02-2 Screenshot from 2026-07-29 10-40-34-2

RESULT AFTER THIS PR:

image image image

What approach did you choose and why?

Enhance existing search filters and selects. Decide based on work packages identifiers setting what search results searching by a number should yield.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from 919422f to 040f593 Compare July 29, 2026 13:05
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/backlogs/spec/features/backlogs/start_finish_spec.rb[1:2:2:2]
  • rspec ./spec/features/placeholder_users/delete_spec.rb[1:2:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./modules/backlogs/spec/features/backlogs/start_finish_spec.rb[1:2:2:2]`
- `rspec ./spec/features/placeholder_users/delete_spec.rb[1:2:1:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch 2 times, most recently from fd2260d to 376c555 Compare July 31, 2026 14:31
@judithroth
judithroth requested a review from Copilot August 3, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds “exact match first” ranking and semantic-mode sequence-number search behavior to work package typeahead/autocomplete across API + frontend, while requiring #<number> to search by database id in semantic identifier mode to avoid confusing results.

Changes:

  • Introduces an exactMatch sort key (backed by a new ExactMatchSelect) to boost exact id/sequence-number/semantic-identifier hits when a typeahead filter is active.
  • Updates typeahead filtering to route bare numeric searches to sequence_number in semantic mode (and to id in classic mode or when prefixed with #).
  • Updates frontend autocompleters/filter pickers and adds tests, API docs notes, locale label, and a DB index on work_packages.sequence_number.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spec/requests/api/v3/work_packages/index_resource_spec.rb Adds request spec asserting exact-match ranking in work package collection responses.
spec/requests/api/v3/work_packages/available_relation_candidates_resource_spec.rb Adds request spec for exact-match ranking in relation candidate results.
spec/models/query/sort_criteria_spec.rb Verifies exact_match sort resolves to correct SQL fragments depending on typeahead filter presence.
spec/models/queries/work_packages/selects/exact_match_select_spec.rb New unit spec coverage for exact-match SQL generation and ranking behavior.
spec/models/queries/work_packages/filter/typeahead_filter_spec.rb Expands typeahead filter specs for classic vs semantic numeric search behavior and # prefix semantics.
spec/features/work_packages/table/queries/parent_field_ranking_spec.rb New feature spec ensuring Parent inline field dropdown ranks exact identifier matches first.
spec/features/work_packages/table/queries/parent_ancestor_filter_ranking_spec.rb New feature spec ensuring Parent/Ancestor filter dropdowns rank exact identifier matches first.
spec/features/work_packages/table/queries/id_filter_ranking_spec.rb New feature spec ensuring ID filter dropdown ranks exact identifier matches first.
spec/features/work_packages/table/configuration_modal/sort_by_spec.rb Ensures “Exact match” isn’t exposed as a user-selectable sort option in the modal.
spec/controllers/work_packages/auto_completes_controller_spec.rb Extends controller spec to cover exact-match ranking and blank/multi-word query handling.
modules/boards/spec/features/board_reference_work_package_ranking_spec.rb New boards feature spec ensuring “Add existing work package” ranks exact identifier matches first.
frontend/src/app/shared/components/fields/edit/field-types/work-package-edit-field.component.ts Adds exactMatch sort for Parent allowed-values fetch; tightens return type.
frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts Adds exactMatch sort to work package autocompleter requests.
frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-autocomplete/wp-relations-autocomplete.component.ts Adds exactMatch sort to relation-candidates autocomplete fetch; clarifies unsafe HAL typing with comments.
frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts Forces XHR for work-package-referencing filters and adds exactMatch sort when querying work packages.
frontend/src/app/features/boards/board/inline-add/board-inline-add-autocompleter.component.ts Adds exactMatch sort to board inline-add fetch and improves error handling; adds lint suppression comments for legacy selector/output names.
frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.ts Uses exactMatch as primary sort key in work package search path building and tightens generic casting.
frontend/src/app/core/apiv3/api-v3.service.spec.ts Updates frontend APIv3 service spec expectations for exactMatch-first sorting.
docs/api/apiv3/paths/work_packages.yml Documents availability of exactMatch sort key on the work packages endpoint.
docs/api/apiv3/paths/work_package_available_relation_candidates.yml Documents exactMatch support for relation candidates endpoint via work packages sort criteria.
db/migrate/20260728120000_add_index_on_work_package_sequence_number.rb Adds a concurrent partial index on work_packages.sequence_number for lookup performance.
config/locales/en.yml Adds exact_match translation label.
app/models/query.rb Passes query context into column sortable to allow query-dependent SQL generation.
app/models/queries/work_packages/selects/work_package_select.rb Extends sortable to accept an optional query arg and forward it into Proc-valued sortables.
app/models/queries/work_packages/selects/typeahead_select.rb Updates sortable Proc signature to accept (ignored) query argument.
app/models/queries/work_packages/selects/property_select.rb Updates sortable Proc signature to accept (ignored) query argument.
app/models/queries/work_packages/selects/exact_match_select.rb New select implementing query/typeahead-aware exact-match boost SQL.
app/models/queries/work_packages/filter/typeahead_filter.rb Routes numeric terms to id vs sequence number based on identifier mode / # prefix.
app/models/queries/work_packages.rb Registers the new ExactMatchSelect for work package queries.
app/controllers/work_packages/auto_completes_controller.rb Applies exact_match then updated_at sorting to work package autocomplete results.

Comment thread spec/requests/api/v3/work_packages/index_resource_spec.rb Outdated
Comment thread app/models/queries/work_packages/selects/exact_match_select.rb Outdated
Comment thread docs/api/apiv3/paths/work_packages.yml
Comment thread docs/api/apiv3/paths/work_package_available_relation_candidates.yml
@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from 376c555 to 3c834a5 Compare August 4, 2026 11:14
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/projects/lists/filters_spec.rb[1:6:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./spec/features/projects/lists/filters_spec.rb[1:6:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from 3c834a5 to 2b9116c Compare August 4, 2026 11:58
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]
  • rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_spec.rb[1:1]
  • rspec ./spec/features/projects/project_autocomplete_spec.rb[1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]`
- `rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_spec.rb[1:1]`
- `rspec ./spec/features/projects/project_autocomplete_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from 2b9116c to f91b8ab Compare August 4, 2026 12:29
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]
  • rspec ./spec/features/work_packages/table/queries/parent_field_ranking_spec.rb[1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]`
- `rspec ./spec/features/work_packages/table/queries/parent_field_ranking_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from f91b8ab to 3c21690 Compare August 5, 2026 10:53
https://community.openproject.org/wp/COMMS-926

To prevent that people see search results which they don't understand,
searching for the ID in semantic mode requires prefixing the number with
"#". When searching for a number in classic mode, it will always match
against the ID and never against the sequence number.

If that turns out to not be good enough in the future, we have to
improve the rendering of serach results and include the reason there
(e.g. the database ID if that was matching and the instance is in
semantic mode).
In semantic mode it could happen that a work package with an ID which is
the same as a search term is found and it would have been boosted
accidentally. Now this is gated and we only boost on ID match in classic
mode or when the search was prefixed with "#".
@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from 3c21690 to f6760f0 Compare August 5, 2026 10:59
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/activities/work_package/activities_spec.rb[1:5:2:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./spec/features/activities/work_package/activities_spec.rb[1:5:2:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the implementation/comms-926-implement-and-use-exact-matching-order-for-work-package-sequence-numbers branch from f6760f0 to 8793f52 Compare August 5, 2026 12:54
@judithroth judithroth self-assigned this Aug 5, 2026
@judithroth
judithroth requested a review from a team August 5, 2026 12:55
@judithroth
judithroth marked this pull request as ready for review August 5, 2026 12:55
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

operator: "**",
values: "COM-5"
}
context "when filtering by typeahead and sorting by exact_match to rank an identifier match first" do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This spec was just refactored for better readability

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24497, linked for reference only):

- `rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #24497. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24497 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants