Repository navigation
fix(search): chat history leaves out inbox turns, reads newest first, and uses an indexed scan - #10560
fix(search): chat history leaves out inbox turns, reads newest first, and uses an indexed scan#10560waleedlatif1 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The latest changes appear safe to merge; no new blocking issue was found. SummaryChat history excludes inbox-linked questions and their copies, defaults to newest first, and uses bounded reads with a new question index.
Reviews (6) · Last reviewed commit: "fix(search): never show thinking cut off..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 19 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 19 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
… and uses an indexed scan
c5b6a01 to
3c70422
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 19 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 19 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
Follow-up to #10537 / #10548 from an audit of
list_my_chat_history. No privacy leak was found; each item below was checked against the code first.Summary
inboxturn origin:TurnOriginis generated from the Mothership protocol, and the anti-join already covers rows written before and after any stamp, forks included, with one rule shared with the adoption backfill (fix(insights): adoption history audit — consistent sources, buffered writer, UTC day bounds #10557)list_my_activity. Newest first by default (sortBy: 'newest' | 'oldest'; the cursor carries its order and is refused for the other one);startDateoptional, defaulting to 7 days beforeendDate; a laterendDatereads up to now; astartDatein the future says so. The Search MCP tool takeslistMyChatHistoryMcpSchema(dates viamcpDateFilter: no offset reads as UTC, and tools/list carries no long regex). The Organization Search block gets an optional Start Date and an Order fieldcopilot_messages_chat_user_created_at_idxon(chat_id, created_at, id) WHERE role = 'user' AND deleted_at IS NULL(0481,CREATE INDEX CONCURRENTLYbelow an embedded COMMIT, replay-safe as 0472; renumber at merge if needed)seqrange oncopilot_messages_chat_seq_idx: the first reply after the question and before the chat's next questionleft()before the excerpt is madesearch:readnow says it lists your own questions to SimBefore / after (seeded local Postgres, 15,000 chats and 600,000 messages, one person with 300 chats; 30-day window,
includeAnswers)Bitmap Index Scan on copilot_messages_chat_created_at_idxreturns 3,949 rows (questions and replies) and the heap scan keeps 1,968; each answer is an Incremental Sort + Nested Loop Anti Join over the chat; about 9,250 shared buffers, about 12 ms warmBitmap Index Scan on copilot_messages_chat_user_created_at_idxreturns exactly the 1,968 questions; each answer is oneIndex Scan using copilot_messages_chat_seq_idxwith aseqrange; inbox anti-join is a hash join over the (empty here) inbox tasks; about 7,200 shared buffers, about 11 ms warmType of Change
Testing
lib/knowledge/application/chat-history.integration.ts(14): adds newest-first default with an order-bound cursor (red without the order check), the default 7-day window and the future-startDaterefusal (red without the guard), and an inbox email turn plus its forked copy never listed (red without the anti-join); existing ownership, mode-access, window, paging and answer cases run onseq-numbered fixtureslib/mothership/tools/server/knowledge/chat-history.integration.ts(3): the Assistant tool lists the member's own questions, is refused outside Assistant mode (red without the mode check) and when the organization has no Search (red withoutrequireOrganizationSearchAvailable, which the Search MCP path shares through the same use case)lib/internal/organization-search/execute-tool.integration.tsstill greenlib/knowledge/mcp,lib/api/contracts,lib/mothership/tools/server,blocks,tools/organization, OAuth consent,lib/authbun run generate, generated tool catalog from the Mothership staging catalog,check:migrations, lint,check:file-names,check:boundaries,check:source-conventions,check:comment-hygiene,check:tool-effects,check:canvas-sentences,check:integration-catalog,check:unused-exports, block registry checkMothership follow-up (not in this PR)
sim-assistant-tools.generated.tsafter merge: the input schema addssortByand makesstartDateoptionalChecklist
test-auditauthoring gate)