Skip to content

fix cross-thread order filtering in textSearch#257

Open
ianmacartney wants to merge 2 commits into
mainfrom
issue-256
Open

fix cross-thread order filtering in textSearch#257
ianmacartney wants to merge 2 commits into
mainfrom
issue-256

Conversation

@ianmacartney

@ianmacartney ianmacartney commented May 5, 2026

Copy link
Copy Markdown
Member

Fixes a bug (#256) where textSearch with searchAllMessagesForUserId incorrectly filtered out cross-thread matches by applying the target message's order as a global filter. Since message order sequences are independent per thread, a target message with a low order in a new thread was causing valid matches from older threads (which naturally have higher order values) to be excluded.

The fix scopes the order-based filter to same-thread messages only, both at the database query level and in the post-fetch filter. When searching across threads, the database-level lte(order) constraint is skipped entirely, and the post-fetch filter now checks threadId before applying the order comparison. Same-thread ordering behavior is preserved — messages after the target within the same thread are still excluded.

Two regression tests are added to cover both cases: cross-thread matches being returned correctly, and same-thread messages after the target still being filtered out.

Fixes #256

@ianmacartney ianmacartney requested a review from sethconvex May 5, 2026 08:16

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pkg-pr-new

pkg-pr-new Bot commented May 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@257

commit: cbae351

@ianmacartney ianmacartney marked this pull request as ready for review May 5, 2026 08:17
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: get-convex/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9f3b9791-4c09-4fa9-8758-eae99ada7134

📥 Commits

Reviewing files that changed from the base of the PR and between 02fa4f6 and cbae351.

📒 Files selected for processing (2)
  • src/component/messages.test.ts
  • src/component/messages.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/component/messages.test.ts
  • src/component/messages.ts

📝 Walkthrough

Walkthrough

The PR updates message search so order-based filtering is applied only within the same thread. Cross-thread matches are allowed through when searching across all threads, while same-thread results still respect order and stepOrder limits. Two regression tests were added to cover the cross-thread and same-thread cases.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: cross-thread order filtering in textSearch.
Description check ✅ Passed The description matches the code changes and regression tests in the PR.
Linked Issues check ✅ Passed The changes implement #256 by scoping order filtering to same-thread messages and preserving cross-thread results.
Out of Scope Changes check ✅ Passed The diff stays within the stated fix and regression tests, with no unrelated changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-256

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

searchOtherThreads drops valid cross-thread text search results when target message order is lower

1 participant