Skip to content

improvement(chat): stop reloading the full transcript on every turn and event - #8328

Merged
waleedlatif1 merged 2 commits into
stagingfrom
improvement/chat-transcript-reads
Sep 26, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
improvement/chat-transcript-reads

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Each chat turn loaded the chat's full transcript through resolveOrCreateChat just to read the MCP server ids earlier user messages were tagged with. resolveOrCreateChat now never loads the transcript, and a new loadChatMcpServerIds reads only the MCP context ids with one jsonb query, in the same first-tagged order
  • Split the chat loaders: getAccessibleCopilotChatDetail (row plus authorization, no transcript) backs both resolveOrCreateChat and getAccessibleCopilotChatWithMessages. Dropped the includeTranscript option and the conversationHistory field, which nothing read
  • Client: a completed event for the viewer's own live stream no longer refetches the chat detail, because the client's own stream finalization already refetches it. renamed marks the detail stale without refetching; the lists that show titles still refetch

Type of Change

  • Improvement

Testing

  • New chat-mcp-servers.integration.ts (real Postgres), 5 tests:
    • servers from earlier turns match the old transcript-based collection
    • ordering follows seq
    • malformed contexts are ignored
    • a deleted message's server is not inherited
    • no cross-chat reads
  • Mutating each query guard turns the matching test red
  • Chat-events hook tests use a real QueryClient and count actual detail fetches. The own-stream-completion and rename tests fail on the old code; another viewer's completion still refetches
  • Type-check, lint, check:audits, and the mothership chat, v2 chat, and inbox unit suites pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • 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 Sep 26, 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 Sep 26, 2026 5:40pm UTC

Request Review

@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 11 files

Confidence score: 5/5

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

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors chat transcript loading to avoid full reloads.

The PR appears safe to merge; no new actionable issue or outstanding previous finding was identified.

Summary

The PR avoids loading the full transcript when resolving a chat, reads only previously tagged MCP server IDs, and reduces redundant chat-detail refetches on completion and rename.

  • Adds PostgreSQL coverage for MCP server inheritance and ordering.
  • Adds client tests for status-event cache behavior and stream finalization.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Resolve authorized chat detail] --> B[Load prior MCP server IDs]
  B --> C[Build current turn payload]
  D[Completed status event] --> E[Mark local optimistic detail stale]
  E --> F[Stream finalization refetches saved detail]
Loading

Reviews (2) · Last reviewed commit: "fix(chat): mark a completed live-stream ..."

Comment thread apps/sim/hooks/use-mothership-chat-events.test.ts
@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 Sep 26, 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.

All reported issues were addressed across 12 files

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

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/hooks/use-mothership-chat-events.ts
@waleedlatif1
waleedlatif1 merged commit 5a69768 into staging Sep 26, 2026
32 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/chat-transcript-reads branch September 26, 2026 20:12

This branch was previously deployed

1 inactive deployment
Preview — 39fce7c5 Deployed Sep 26, 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