Skip to content

improvement(search): smaller chat history pages with a first-page total - #10567

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/chat-history-payload
Dec 1, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/chat-history-payload

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Smaller pages. Each question is capped at 400 characters (read with left() in SQL, one character past the cap so a cut question ends in ..., code-point safe) and each answer excerpt at 300 (was 2,000 and 600). A default page was around 67k characters and 115-178k at topK 100 or with answers, over what MCP clients keep inline; a benchmark prototype with these caps answered as well or better with about 48k fewer input tokens per task
  • total on the first page. The number of the caller's questions in the window, counted with the page's own filter, on the first page only, so a model paging through no longer has to add pages up. It reads the same copilot_messages_chat_user_created_at_idx range as the page: about 10 ms warm for about 2,000 questions in a 30-day window on a seeded local DB
  • Workspace access as ids, in the query. The read no longer loads every accessible workspace's full row through listAccessibleWorkspaceRowsForUser (slow for a person with many workspaces). The organization's workspaces the caller can open are a subquery of ids in the chat read: every active workspace for an organization admin or owner, otherwise those they hold a permission on, the same rule as before
  • total is described on the Search MCP tool, the workflow tool and the Organization Search block outputs

Type of Change

  • Improvement

Testing

  • lib/knowledge/application/chat-history.integration.ts (20): adds a 2,000-character question returned as 400 characters plus ... (red without the extra read character), total on the first page only (red without it), and an organization admin seeing a workspace chat without a permission row (red without the admin branch); the answer excerpt test now bounds 300
  • lib/mothership/tools/server/knowledge/chat-history.integration.ts, lib/internal/organization-search/execute-tool.integration.ts still green
  • Unit suites: lib/knowledge/mcp, lib/mothership/tools/server, blocks, tools/organization
  • bun run generate, lint, check:file-names, check:boundaries, check:source-conventions, check:comment-hygiene, check:tool-effects, check:integration-catalog, check:unused-exports

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 10:49am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous empty-history issue is fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous empty-history issue is fixed.

Summary

This PR makes chat-history pages smaller and adds a first-page question count.

  • Chat history pages return shorter questions and answer excerpts.
  • The first chat-history page reports how many questions are in its window.
  • Chat history finds accessible workspace chats using workspace ids in its query.

No new actionable issues were found.

Reviews (2) · Last reviewed commit: "fix(search): an empty first page counts ..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit c7c8a2f into staging Dec 1, 2026
84 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-history-payload branch December 1, 2026 16:53

This branch was previously deployed

1 inactive deployment
Preview — 962699a5 Deployed Dec 1, 2026 by vercel[bot]
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.

1 participant