Repository navigation
Fix: Remove duplicate text output from the thought model on the chat page. - #14301
Conversation
📝 WalkthroughWalkthroughA targeted fix to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/hooks/logic-hooks.ts (1)
278-285:⚠️ Potential issue | 🔴 CriticalThe fix on line 278 reintroduces a regression that the backend recently fixed, causing loss of answer content in final SSE chunks.
The backend code in
async_ask()(line ~1444) andasync_chat()(line ~774) was recently fixed to includeanswerin the final SSE event with the decorated response (containing citation markers). Regression tests intest/unit_test/api/db/services/test_dialog_service_final_answer.py(lines 203–208 and 352–357) explicitly guard against re-introducingfinal["answer"] = "", which is exactly what line 278 does:const currentAnswer = d.final ? '' : d.answer || '';When
d.finalis true, this unconditionally discards the answer from the final chunk. For responses that arrive with little or no prior streamed content (short answers, buffered responses, or providers emitting only a terminal chunk),prevAnswerwill be empty and the assistant message renders blank.Consider applying the narrower condition suggested in the original comment: only suppress the final answer when it would duplicate already-accumulated content, rather than discarding it unconditionally.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@web/src/hooks/logic-hooks.ts` around lines 278 - 285, The current code unconditionally drops the final SSE chunk's answer (const currentAnswer = d.final ? '' : d.answer || ''), which reintroduces a regression; change the logic so currentAnswer defaults to d.answer || '' and only set it to '' when the final decorated answer would duplicate already-accumulated content (i.e., when d.final is true, prevAnswer is non-empty, d.answer is non-empty, and d.answer.startsWith(prevAnswer)); update the block near currentAnswer/prevAnswer in web/src/hooks/logic-hooks.ts to implement that narrower suppression using the existing symbols d.final, d.answer, and prevAnswer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@web/src/hooks/logic-hooks.ts`:
- Around line 278-285: The current code unconditionally drops the final SSE
chunk's answer (const currentAnswer = d.final ? '' : d.answer || ''), which
reintroduces a regression; change the logic so currentAnswer defaults to
d.answer || '' and only set it to '' when the final decorated answer would
duplicate already-accumulated content (i.e., when d.final is true, prevAnswer is
non-empty, d.answer is non-empty, and d.answer.startsWith(prevAnswer)); update
the block near currentAnswer/prevAnswer in web/src/hooks/logic-hooks.ts to
implement that narrower suppression using the existing symbols d.final,
d.answer, and prevAnswer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 32255fba-5df5-4e83-954d-103a3e7ab311
📒 Files selected for processing (1)
web/src/hooks/logic-hooks.ts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14301 +/- ##
=======================================
Coverage 95.97% 95.97%
=======================================
Files 10 10
Lines 695 695
Branches 111 111
=======================================
Hits 667 667
Misses 11 11
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Fix: Remove duplicate text output from the thought model on the chat page.
Type of change