Skip to content

🐛 fix(send-message): forward topic-list filter to server response#14160

Merged
arvinxx merged 2 commits into
canaryfrom
fix/send-message-topic-filter
Apr 27, 2026
Merged

🐛 fix(send-message): forward topic-list filter to server response#14160
arvinxx merged 2 commits into
canaryfrom
fix/send-message-topic-filter

Conversation

@arvinxx

@arvinxx arvinxx commented Apr 25, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • 🐛 fix

🔗 Related Issue

N/A

🔀 Description of Change

sendMessageInServer returns the latest topic list alongside the new messages so the sidebar reflects the just-created topic. The frontend was calling it without the filter the active sidebar uses (excludeStatuses: ['completed'], excludeTriggers: ['cron','eval']), so the server replied with the unfiltered list and internal_updateTopics then wrote that list back over topicDataMap[containerKey].items — completed/cron topics flashed back into the sidebar until the next SWR revalidation.

This PR threads the filter end-to-end:

  • packages/types/src/aiChat.tsSendMessageServerParams and AiSendMessageServerSchema get an optional topicFilter: { excludeStatuses?, excludeTriggers?, includeTriggers? }.
  • src/server/routers/lambda/aiChat.ts — forwards input.topicFilter to getMessagesAndTopics.
  • src/server/services/aiChat/index.ts — accepts topicFilter and spreads it into topicModel.query; ensures it does not leak into messageModel.query.
  • src/store/chat/slices/aiChat/actions/conversationLifecycle.ts — adds private #getTopicFilter(agentId, groupId) that reads the filter from the active topicDataMap entry and passes it at both sendMessageInServer call sites (Gateway/Client main path and the heterogeneous-agent path).

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed

Repro before fix:

  1. In the chat sidebar (which filters out completed topics), send a new message.
  2. Observe that completed topics briefly appear in the list right after the response lands, then disappear after SWR revalidates.

After fix: the list returned by sendMessageInServer already respects the active filter, so completed topics never reappear.

Targeted tests added in src/server/services/aiChat/index.test.ts to cover:

  • topicFilter forwarded into topicModel.query.
  • topicFilter does not leak into messageModel.query.
bunx vitest run --silent='passed-only' \
  'src/server/services/aiChat/index.test.ts' \
  'src/server/routers/lambda/__tests__/aiChat.test.ts' \
  'src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts'
# 48 tests passed
bun run type-check  # passes

📸 Screenshots / Videos

N/A — sidebar regression, no new UI surface.

📝 Additional Information

Both call sites of sendMessageInServer are updated; the isolatedTopic skip path at conversationLifecycle.ts:640 is unchanged because that one already avoids writing to the main sidebar's topicDataMap.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Apr 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Apr 27, 2026 3:51pm

Request Review

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐛 Bug labels Apr 25, 2026

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

We've reviewed this pull request using the Sourcery rules engine

@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: 8d7c53e1de

ℹ️ 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 thread src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
@codecov

codecov Bot commented Apr 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.09%. Comparing base (d73858e) to head (cecc318).
⚠️ Report is 6 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #14160       +/-   ##
===========================================
- Coverage   82.60%   68.09%   -14.52%     
===========================================
  Files         475     2267     +1792     
  Lines       35367   194401   +159034     
  Branches     6239    20349    +14110     
===========================================
+ Hits        29216   132380   +103164     
- Misses       6021    61891    +55870     
  Partials      130      130               
Flag Coverage Δ
app 61.60% <93.93%> (?)
database 92.03% <ø> (?)
packages/agent-runtime 79.93% <ø> (ø)
packages/context-engine 83.25% <ø> (ø)
packages/conversation-flow 92.40% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 74.74% <ø> (ø)
packages/model-bank 99.89% <ø> (?)
packages/model-runtime 84.28% <ø> (ø)
packages/prompts 68.17% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 88.36% <ø> (ø)
packages/web-crawler 88.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 67.20% <92.00%> (∅)
Services 53.36% <ø> (∅)
Server 68.44% <100.00%> (∅)
Libs 53.30% <ø> (∅)
Utils 80.04% <ø> (-13.43%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

arvinxx and others added 2 commits April 27, 2026 23:33
Without this, sending a message refreshes `topicDataMap` with an
unfiltered list, so completed/cron topics flash back into the sidebar
until the next SWR revalidation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
internal_updateTopics rewrote topicDataMap[key] from scratch and dropped
excludeStatuses / excludeTriggers, so #getTopicFilter returned undefined
on the second sendMessageInServer call and stopped forwarding the filter
to the server — completed/cron topics could leak in until SWR
revalidated. Carry the filter fields forward from currentData, matching
loadMoreTopics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arvinxx arvinxx force-pushed the fix/send-message-topic-filter branch from 7ddad02 to cecc318 Compare April 27, 2026 15:33
@arvinxx arvinxx merged commit bbf2397 into canary Apr 27, 2026
35 checks passed
@arvinxx arvinxx deleted the fix/send-message-topic-filter branch April 27, 2026 16:31
sxueck pushed a commit to sxueck/lobehub that referenced this pull request Apr 28, 2026
…behub#14160)

* 🐛 fix(send-message): forward topic-list filter to server response

Without this, sending a message refreshes `topicDataMap` with an
unfiltered list, so completed/cron topics flash back into the sidebar
until the next SWR revalidation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* 🐛 fix(topic): preserve filter fields in internal_updateTopics

internal_updateTopics rewrote topicDataMap[key] from scratch and dropped
excludeStatuses / excludeTriggers, so #getTopicFilter returned undefined
on the second sendMessageInServer call and stopped forwarding the filter
to the server — completed/cron topics could leak in until SWR
revalidated. Carry the filter fields forward from currentData, matching
loadMoreTopics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mutoe pushed a commit to mutoe/lobehub that referenced this pull request May 1, 2026
…behub#14160)

* 🐛 fix(send-message): forward topic-list filter to server response

Without this, sending a message refreshes `topicDataMap` with an
unfiltered list, so completed/cron topics flash back into the sidebar
until the next SWR revalidation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* 🐛 fix(topic): preserve filter fields in internal_updateTopics

internal_updateTopics rewrote topicDataMap[key] from scratch and dropped
excludeStatuses / excludeTriggers, so #getTopicFilter returned undefined
on the second sendMessageInServer call and stopped forwarding the filter
to the server — completed/cron topics could leak in until SWR
revalidated. Carry the filter fields forward from currentData, matching
loadMoreTopics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dosubot dosubot Bot mentioned this pull request May 14, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant