Skip to content

fix(copilot): load workflow chat history through the windowed chat routes - #9113

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/copilot-chat-history-windowed
Oct 16, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/copilot-chat-history-windowed

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Workflow Copilot panel chats are stored as copilot chats, but the chat detail route only served mothership chats. Every panel history load got a 404 and fell back to the legacy /api/mothership/chat?chatId= read, whose response has no mode — which the history parser requires — so the panel showed "Failed to load chat history" on every load and refetch, after reading the whole transcript
  • The chat detail route now serves both chat types; its authorization (authorizeCopilotChatRow) already checks workflow read for workflow chats
  • Older pages and stream status serve copilot chats too, behind the same rule as the detail read: the workflow must still be readable, and a workspace Plan chat needs Plan mode on (requireOwnedChatReadable, sharing authorizeChatWorkflowRead / isChatModeAvailable with the detail read). Other chat use cases are unchanged for every chat that carries a workspace
  • A workflow chat row from before chats carried a workspace (nullable workspace_id, never backfilled) is scoped through its workflow while its owner may read that workflow, so these chats load their older pages and stream status instead of being refused
  • Removed the client 404 fallback and the now-unused legacy GET (app/api/copilot/chat/queries.ts, getAccessibleCopilotChat, its column set and query schemas); the list branch of that GET had no callers either. Shrunk the explicit-any, source-conventions and unused-exports baselines accordingly
  • Rollout: a new client against an old server gets a plain 404 until the deploy finishes; the fallback it loses was already failing to parse

Type of Change

  • Bug fix

Testing

  • Integration: the mothership detail route on a workflow copilot chat returns 200 with its mode and the same snapshot handling (replay-budget.integration.ts; 404 on the current code); older pages and stream status serve a workflow copilot chat including a legacy row without a workspace, and refuse one whose workflow is archived (transcript-pages.integration.ts, read-stream-status.integration.ts; the served cases fail on the current code)
  • Ran locally: focused unit tests for the chat lifecycle, detail route, chat history hook and chat application use cases (10 files, 129 tests), apps/sim type-check, biome, check:explicit-any, check:unused-exports, check:test-patterns, check:comment-hygiene, check:boundaries; type-check, full audits and integration suites run in CI

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 Oct 16, 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 Oct 16, 2026 5:28am 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.

All reported issues were addressed across 18 files

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

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/chat/lifecycle.ts
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new actionable issues found.

Summary

Workflow Copilot history now uses the windowed chat routes instead of the legacy fallback.

  • Workflow Copilot history loads through the windowed chat route.
  • Older transcript pages and stream status now include readable workflow chats.

Reviews (2) · Last reviewed commit: "test(copilot): name each workflow chat f..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/chat/application/read-older-messages.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit 5eb0b33 into staging Oct 16, 2026
52 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/copilot-chat-history-windowed branch October 16, 2026 07:53

This branch was previously deployed

1 inactive deployment
Preview — 62449f1a Deployed Oct 16, 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