Repository navigation
Conversation
…l tag 1. Replace `<section>` with `<details>` for `<think>` content so model thinking output is collapsed by default and expandable on click. 2. Use a dedicated `<retrieving>` tag for deep research retrieval status instead of reusing `<think>` markers (`start_to_think`/`end_to_think`). This prevents double "Thinking..." blocks when reasoning mode is enabled with knowledge base chat — the retrieval progress now renders as a separate "Retrieving..." collapsible, while model thinking renders as "Thinking...". Backend: - dialog_service.py: deep research callback yields `<retrieving>` / `</retrieving>` answer text instead of think marker flags. Frontend: - chat.ts: add `replaceRetrievingToSection()` alongside existing `replaceThinkToSection()`, both using `<details>` elements. - 4 tsx files: import and pipe `replaceRetrievingToSection`, whitelist `details`, `summary`, `retrieving` in DOMPurify `ADD_TAGS`. - 4 less files: `section.think` → `details.think` with `<summary>` styles; add `details.retrieving` with distinct green accent. Dark mode and RTL variants included. Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughBackend and frontend coordinate to render think and retrieving blocks as native HTML ChangesCollapsible Details Rendering for Think and Retrieving Blocks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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/pages/next-search/markdown-content/index.tsx (1)
244-247:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
detailsblocks are unstyled here due to stalesection.thinkselectors.Line 246 still styles
section.think, but the new renderer outputsdetails.think/details.retrieving. This causes a visual regression in this page for the new collapsible blocks.Suggested patch
- className="[&>section.think]:pl-[10px] [&>section.think]:text-[`#8b8b8b`] [&>section.think]:border-l-2 [&>section.think]:border-l-[`#d5d3d3`] [&>section.think]:mb-[10px] [&>section.think]:text-xs [&>blockquote]:pl-[10px] [&>blockquote]:border-l-4 [&>blockquote]:border-l-[`#ccc`] text-sm" + className="[&>details.think]:pl-[10px] [&>details.think]:text-[`#8b8b8b`] [&>details.think]:border-l-2 [&>details.think]:border-l-[`#d5d3d3`] [&>details.think]:mb-[10px] [&>details.think]:text-xs [&>details.retrieving]:pl-[10px] [&>details.retrieving]:text-[`#23a55a`] [&>details.retrieving]:border-l-2 [&>details.retrieving]:border-l-[`#23a55a`] [&>details.retrieving]:mb-[10px] [&>details.retrieving]:text-xs [&>blockquote]:pl-[10px] [&>blockquote]:border-l-4 [&>blockquote]:border-l-[`#ccc`] text-sm"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/next-search/markdown-content/index.tsx` around lines 244 - 247, The CSS selector string on the div still targets `section.think` (className in the JSX) but the renderer now uses `details.think` and `details.retrieving`; update the selector list in the className on the div to replace `section.think` with `details.think` (and add `details.retrieving` if needed) so the collapsible blocks receive the same padding, color, border and margin styles as before; keep the other selectors (e.g., `blockquote`) unchanged and ensure you update the exact className prop in this component (the JSX element that currently contains the long Tailwind-style selector).
🧹 Nitpick comments (2)
api/db/services/dialog_service.py (1)
667-669: ⚡ Quick winAdd transition logs for the new
<retrieving>streaming markers.Line 667 and Line 669 introduce a new stream state transition but don’t log start/end events, which makes retrieval-flow debugging harder.
Proposed patch
if msg.find("<START_DEEP_RESEARCH>") == 0: + logging.debug("deep_research retrieving started") yield {"answer": "<retrieving>", "reference": {}, "audio_binary": None, "final": False} elif msg.find("<END_DEEP_RESEARCH>") == 0: + logging.debug("deep_research retrieving finished") yield {"answer": "</retrieving>", "reference": {}, "audio_binary": None, "final": False} breakAs per coding guidelines,
**/*.py: Add logging for new flows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/db/services/dialog_service.py` around lines 667 - 669, Add logging calls around the new streaming markers so entering/exiting the "<retrieving>" flow is recorded: when yielding {"answer": "<retrieving>", ...} emit a start log (e.g. logger.info or process_logger.info) noting you entered the retrieving state and include the msg or dialog id/context; when yielding {"answer": "</retrieving>", ...} emit a corresponding end log indicating retrieval finished and include the same context; place these logs immediately before the two yield statements that use "<retrieving>" and "<END_DEEP_RESEARCH>" so retrieval-flow transitions are visible in the logs.web/src/utils/chat.ts (1)
81-95: ⚡ Quick winConsider renaming helpers to reflect actual output (
details, notsection).
replaceThinkToSection/replaceRetrievingToSectionnow emit<details>..., so the current names are misleading. Renaming toreplaceThinkToDetailsandreplaceRetrievingToDetailswould reduce future confusion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/utils/chat.ts` around lines 81 - 95, The helper names replaceThinkToSection and replaceRetrievingToSection are misleading because they produce <details> elements; rename both functions to replaceThinkToDetails and replaceRetrievingToDetails, update all internal references/usages and any exported names accordingly (keep the same implementation in replaceThinkToDetails and replaceRetrievingToDetails), and run a quick search across the repo to update imports/usages to the new function names to avoid breaking consumers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@web/src/pages/next-search/markdown-content/index.tsx`:
- Around line 244-247: The CSS selector string on the div still targets
`section.think` (className in the JSX) but the renderer now uses `details.think`
and `details.retrieving`; update the selector list in the className on the div
to replace `section.think` with `details.think` (and add `details.retrieving` if
needed) so the collapsible blocks receive the same padding, color, border and
margin styles as before; keep the other selectors (e.g., `blockquote`) unchanged
and ensure you update the exact className prop in this component (the JSX
element that currently contains the long Tailwind-style selector).
---
Nitpick comments:
In `@api/db/services/dialog_service.py`:
- Around line 667-669: Add logging calls around the new streaming markers so
entering/exiting the "<retrieving>" flow is recorded: when yielding {"answer":
"<retrieving>", ...} emit a start log (e.g. logger.info or process_logger.info)
noting you entered the retrieving state and include the msg or dialog
id/context; when yielding {"answer": "</retrieving>", ...} emit a corresponding
end log indicating retrieval finished and include the same context; place these
logs immediately before the two yield statements that use "<retrieving>" and
"<END_DEEP_RESEARCH>" so retrieval-flow transitions are visible in the logs.
In `@web/src/utils/chat.ts`:
- Around line 81-95: The helper names replaceThinkToSection and
replaceRetrievingToSection are misleading because they produce <details>
elements; rename both functions to replaceThinkToDetails and
replaceRetrievingToDetails, update all internal references/usages and any
exported names accordingly (keep the same implementation in
replaceThinkToDetails and replaceRetrievingToDetails), and run a quick search
across the repo to update imports/usages to the new function names to avoid
breaking consumers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b2956a2e-127c-4d98-8c2e-3fb86def1f89
📒 Files selected for processing (10)
api/db/services/dialog_service.pyweb/src/components/floating-chat-widget-markdown.tsxweb/src/components/markdown-content/index.module.lessweb/src/components/markdown-content/index.tsxweb/src/components/message-item/index.module.lessweb/src/components/next-markdown-content/index.module.lessweb/src/components/next-markdown-content/index.tsxweb/src/components/next-message-item/index.module.lessweb/src/pages/next-search/markdown-content/index.tsxweb/src/utils/chat.ts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14613 +/- ##
=======================================
Coverage 94.16% 94.16%
=======================================
Files 10 10
Lines 703 703
Branches 112 112
=======================================
Hits 662 662
Misses 25 25
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…l tag (infiniflow#14613) ## Summary - **Collapsible thinking**: Replace `<section>` with `<details>` for `<think>` content, so model thinking output is collapsed by default (click to expand). Works for all models that output `<think>` tags (Qwen3, DeepSeek, Gemini, Claude, etc.). - **Fix double thinking tags**: When reasoning/deep research mode is enabled in knowledge base chat, both the retrieval progress and model thinking were wrapped in `<think>` tags, producing two "Thinking..." blocks. Now retrieval progress uses a dedicated `<retrieving>` tag rendered as a separate "Retrieving..." collapsible with a distinct green accent. ### Before - Thinking content displayed as flat gray-bordered `<section>`, occupying significant screen space - Deep research + model thinking both use `<think>` → two identical "Thinking..." blocks ### After - Thinking content collapsed by default in a `<details>` element, click "Thinking..." to expand - Deep research shows "Retrieving..." (green border), model thinking shows "Thinking..." (gray border) ## Changes **Backend (`api/db/services/dialog_service.py`)** - Deep research callback: replace `start_to_think`/`end_to_think` marker flags with direct `<retrieving>`/`</retrieving>` answer text **Frontend** - `web/src/utils/chat.ts`: `replaceThinkToSection()` now uses `<details>` instead of `<section>`; add new `replaceRetrievingToSection()` - 4 tsx files: import and pipe `replaceRetrievingToSection`, whitelist `details`, `summary`, `retrieving` in DOMPurify `ADD_TAGS` - 4 less files: `section.think` → `details.think` with `<summary>` styles; add `details.retrieving` with green accent; dark mode and RTL variants ## Test plan - [ ] Open a chat WITHOUT knowledge base, ask a question to a model with thinking (e.g. Qwen3) → thinking content should be collapsed by default, click "Thinking..." to expand - [ ] Open a chat WITH knowledge base and reasoning enabled, ask a question → "Retrieving..." (green) shows retrieval progress, "Thinking..." (gray) shows model thinking, each independently collapsible - [ ] Verify dark mode renders correctly for both collapsible blocks - [ ] Verify RTL layout renders correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: wanghualoong <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
…l tag (infiniflow#14613) ## Summary - **Collapsible thinking**: Replace `<section>` with `<details>` for `<think>` content, so model thinking output is collapsed by default (click to expand). Works for all models that output `<think>` tags (Qwen3, DeepSeek, Gemini, Claude, etc.). - **Fix double thinking tags**: When reasoning/deep research mode is enabled in knowledge base chat, both the retrieval progress and model thinking were wrapped in `<think>` tags, producing two "Thinking..." blocks. Now retrieval progress uses a dedicated `<retrieving>` tag rendered as a separate "Retrieving..." collapsible with a distinct green accent. ### Before - Thinking content displayed as flat gray-bordered `<section>`, occupying significant screen space - Deep research + model thinking both use `<think>` → two identical "Thinking..." blocks ### After - Thinking content collapsed by default in a `<details>` element, click "Thinking..." to expand - Deep research shows "Retrieving..." (green border), model thinking shows "Thinking..." (gray border) ## Changes **Backend (`api/db/services/dialog_service.py`)** - Deep research callback: replace `start_to_think`/`end_to_think` marker flags with direct `<retrieving>`/`</retrieving>` answer text **Frontend** - `web/src/utils/chat.ts`: `replaceThinkToSection()` now uses `<details>` instead of `<section>`; add new `replaceRetrievingToSection()` - 4 tsx files: import and pipe `replaceRetrievingToSection`, whitelist `details`, `summary`, `retrieving` in DOMPurify `ADD_TAGS` - 4 less files: `section.think` → `details.think` with `<summary>` styles; add `details.retrieving` with green accent; dark mode and RTL variants ## Test plan - [ ] Open a chat WITHOUT knowledge base, ask a question to a model with thinking (e.g. Qwen3) → thinking content should be collapsed by default, click "Thinking..." to expand - [ ] Open a chat WITH knowledge base and reasoning enabled, ask a question → "Retrieving..." (green) shows retrieval progress, "Thinking..." (gray) shows model thinking, each independently collapsible - [ ] Verify dark mode renders correctly for both collapsible blocks - [ ] Verify RTL layout renders correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: wanghualoong <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
<section>with<details>for<think>content, so model thinking output is collapsed by default (click to expand). Works for all models that output<think>tags (Qwen3, DeepSeek, Gemini, Claude, etc.).<think>tags, producing two "Thinking..." blocks. Now retrieval progress uses a dedicated<retrieving>tag rendered as a separate "Retrieving..." collapsible with a distinct green accent.Before
<section>, occupying significant screen space<think>→ two identical "Thinking..." blocksAfter
<details>element, click "Thinking..." to expandChanges
Backend (
api/db/services/dialog_service.py)start_to_think/end_to_thinkmarker flags with direct<retrieving>/</retrieving>answer textFrontend
web/src/utils/chat.ts:replaceThinkToSection()now uses<details>instead of<section>; add newreplaceRetrievingToSection()replaceRetrievingToSection, whitelistdetails,summary,retrievingin DOMPurifyADD_TAGSsection.think→details.thinkwith<summary>styles; adddetails.retrievingwith green accent; dark mode and RTL variantsTest plan
🤖 Generated with Claude Code