Skip to content

♻️ refactor(ai-chat): remove simple turn fast path#15471

Merged
tjx666 merged 1 commit into
canaryfrom
refactor/remove-ai-chat-fast-path
Jun 4, 2026
Merged

♻️ refactor(ai-chat): remove simple turn fast path#15471
tjx666 merged 1 commit into
canaryfrom
refactor/remove-ai-chat-fast-path

Conversation

@tjx666

@tjx666 tjx666 commented Jun 4, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

Related to #15436.

🔀 Description of Change

Remove the simple new/existing topic fast path from aiChat and route message persistence back through the existing model-level flow:

  • resolve context in sendMessageInServer
  • create topics through TopicModel.create
  • create user/assistant message pairs through MessageModel.createUserAndAssistantMessages
  • query messages/topics through AiChatService.getMessagesAndTopics

This drops the Drizzle CTE insert().select() implementation from AiChatService so schema column drift no longer breaks this path at insert-builder construction time.

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed
bunx vitest run --silent='passed-only' src/server/services/aiChat/index.test.ts src/server/routers/lambda/__tests__/aiChat.test.ts

📸 Screenshots / Videos

N/A

📝 Additional Information

No UI changes. No cloud-specific business logic is included in this submodule change.

@sourcery-ai sourcery-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.

Sorry @tjx666, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 4, 2026
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lobehub Building Building Preview, Comment Jun 4, 2026 9:57am

Request Review

@tjx666 tjx666 merged commit b9fbad7 into canary Jun 4, 2026
34 of 36 checks passed
@tjx666 tjx666 deleted the refactor/remove-ai-chat-fast-path branch June 4, 2026 09:58

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

Copy link
Copy Markdown

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: 8928eb03a6

ℹ️ 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 on lines 296 to +299
const { assistantMessage: assistantMessageItem, userMessage: userMessageItem } =
await createMessagePairPromise;
agentTouchUpdatedAtTask
? (await Promise.all([createMessagePairPromise, agentTouchUpdatedAtTask]))[0]
: await createMessagePairPromise;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't wait on the non-critical agent touch

When creating a new topic with an agentId, this now waits for agentTouchUpdatedAtTask before returning the persisted message response. That touch is best-effort and already catches failures, but if the agents update is slow or blocked, the chat send response is delayed even though the topic and messages have already been created; the previous fire-and-forget behavior avoided putting this sidebar timestamp update on the critical path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant