Skip to content

Fix three UI / streaming / search bugs#260

Draft
sethconvex wants to merge 4 commits into
mainfrom
bugfix-batch-ui-streaming
Draft

Fix three UI / streaming / search bugs#260
sethconvex wants to merge 4 commits into
mainfrom
bugfix-batch-ui-streaming

Conversation

@sethconvex
Copy link
Copy Markdown
Contributor

@sethconvex sethconvex commented May 9, 2026

Summary

Two small, independent bug fixes — each with the exact root cause already identified in the issue report.

  • createUserUIMessage doesn't spread partCommon on string content path #234createUserUIMessage was not spreading partCommon on the string-content path, so providerMetadata and the streaming / done state were dropped when a user message was saved with a plain string prompt. The array-content path already spread partCommon; the assistant and system variants of this function did so on both paths. Fix mirrors them.
  • searchOtherThreads drops valid cross-thread text search results when target message order is lower #256textSearch applied the targetMessage.order upper-bound to all search hits, including messages from other threads when searchAllMessagesForUserId was set. Since order is only meaningful within a single thread, valid cross-thread matches were dropped whenever the new thread's current message had a lower order. The DB-level lte(order) predicate is now skipped for cross-thread searches, and the post-filter only enforces the order constraint within the same threadId.

Closes #257

Test plan

Notes

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 9, 2026

Open in StackBlitz

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

commit: 957169e

- createUserUIMessage: spread partCommon on string content path so
  providerMetadata and streaming state survive onto text parts (#234).
- willContinue: count tool-error parts as completed outputs so the agent
  doesn't stop mid-step when a tool throws under AI SDK v6 (#240).
- textSearch: skip the targetMessage.order filter for messages from
  other threads when searching across a userId, since order is only
  meaningful within a single thread (#256).
@sethconvex sethconvex force-pushed the bugfix-batch-ui-streaming branch from d940286 to 8d389bc Compare May 10, 2026 04:05
@sethconvex
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d389bc163

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/component/messages.ts
Comment on lines +934 to 939
if (order && !args.searchAllMessagesForUserId) {
return q.and(qq, q.lte(q.field("order"), order));
}
return qq;
})
.take(args.limit);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply cutoff before limiting cross-thread text search

When searchAllMessagesForUserId is set, this condition skips the DB-level order predicate, but .take(args.limit) still runs before the in-memory filter that removes messages after targetMessage in the same thread. In workloads where many high-relevance hits are newer messages from the target thread, those hits can consume the limit and then be discarded, causing valid older/cross-thread matches to be omitted entirely. This regresses search recall for targetMessageId queries and can return far fewer than the requested limit even when enough valid matches exist.

Useful? React with 👍 / 👎.

- Adds a regression test for #256 that constructs a target message at
  order 2 in one thread and a matching message at order 5 in another
  thread under the same userId. Verified that the test fails against the
  pre-fix code (which dropped the cross-thread match via the DB-level
  lte(order) filter) and passes after the fix.
- Adds a comment in textSearch noting that with the DB-level order
  filter removed for cross-thread search, in-thread matches with order
  >= target.order can be edged out of the take-limit by cross-thread
  matches. Acceptable tradeoff for now; documented for follow-up.
Copy link
Copy Markdown
Member

@ianmacartney ianmacartney left a comment

Choose a reason for hiding this comment

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

lgtm - I had started branch issue-256 and will copy over one addition from there (where it does the same order fix, but for vector search too). I had also updated tests and fixed some lint errors will update this branch for you to inspect & land if you're happy with it

The vector-search code path in _fetchSearchMessages had the same
cross-thread defect as textSearch: when searching across threads with
searchAllMessagesForUserId, results were filtered against the target
message's order, which only makes sense within a single thread. Mirror
the textSearch fix so cross-thread vector hits pass through the
beforeMessage order check.
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.

2 participants