Skip to content

Feat: Move less important chat settings into a collapsible panel. - #16024

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required
Jun 15, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Feat: Move less important chat settings into a collapsible panel.

Type of change

  • New Feature (non-breaking change which adds functionality)

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 15, 2026
@cike8899 cike8899 added ci Continue Integration and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 15, 2026
@cike8899
cike8899 marked this pull request as draft June 15, 2026 09:03
@cike8899
cike8899 marked this pull request as ready for review June 15, 2026 09:03
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Collapse component is fixed to respect defaultOpen when open is not a boolean. LlmSettingFieldItems gains an optional showCollapse prop. ChatBasicSetting is slimmed down, ChatModelSettings is deleted, and ChatPromptEngine is substantially expanded with metadata-key fetching and new prompt-config fields. Several agent form Collapse sections are defaulted to open, and BeginForm gains typed watches and a memoized callback.

Changes

Chat Settings and Collapse Refactor

Layer / File(s) Summary
Collapse open/defaultOpen logic fix
web/src/components/collapse.tsx
useEffect now sets currentOpen from open only when open is a boolean, falling back to defaultOpen; defaultOpen added to effect dependencies.
LlmSettingFieldItems showCollapse prop
web/src/components/llm-setting-items/next.tsx
New optional showCollapse prop switches the freedom/parameter select and slider fields between a Collapse wrapper and React.Fragment.
ChatBasicSetting simplification and ChatSettings wiring
web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx, web/src/pages/next-chats/chat/app-settings/chat-model-settings.tsx, web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
ChatBasicSetting drops metadata-loading and extra fields, now renders AvatarNameDescription, LlmSettingFieldItems (with showCollapse), and KnowledgeBaseFormField. ChatModelSettings is removed. ChatSettings drops the separator and ChatModelSettings block.
ChatPromptEngine expansion with metadata and new fields
web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
Adds useWatch, useFetchKnowledgeMetadataKeys, useMemo-derived options, and a sanitizing effect. Renders a Collapse-wrapped form with new toggles (quote, keyword, TTS, TOC, Tavily, rerank, cross-language, dynamic variables) and conditional metadata MultiSelect.
Agent form defaultOpen and BeginForm improvements
web/src/pages/agent/form/agent-form/index.tsx, web/src/pages/agent/form/retrieval-form/next.tsx, web/src/pages/agent/form/tool-form/retrieval-form/index.tsx, web/src/pages/agent/form/begin-form/index.tsx
defaultOpen added to Collapse in three agent forms. BeginForm adds typed useWatch<BeginFormSchemaType>, memoized handleAddQuery, and null-safe inputs ?? [] for QueryTable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hop hop, the panels now unfold with grace,
Metadata fields appear right in their place.
The Collapse knows defaultOpen from open true,
Old ChatModelSettings bid the codebase adieu.
The rabbit tidied settings, neat and bright—
Every toggle and slider, a joy in sight! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: reorganizing chat settings by moving less important ones into a collapsible panel.
Description check ✅ Passed The description follows the template structure with both required sections completed, though the 'What problem does this PR solve?' section lacks detailed context beyond the feature title.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

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

Actionable comments posted: 3

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

Inline comments:
In `@web/src/components/collapse.tsx`:
- Around line 37-45: The currentOpen state initialization and rendering are
inconsistent with the controlled/uncontrolled pattern. In the useState
initialization of currentOpen, derive the initial value from both open and
defaultOpen parameters (use open if it is a boolean, otherwise use defaultOpen)
rather than only from open, so uncontrolled mode renders correctly from the
first render without waiting for the effect to run. Additionally, the title
highlight rendering around lines 71-73 uses the open parameter instead of
currentOpen, which causes uncontrolled toggles to not update the visual
highlight. Replace the open references in the title highlight rendering with
currentOpen to ensure the highlight always tracks the actual current state.

In `@web/src/pages/agent/form/begin-form/index.tsx`:
- Line 185: The Button component with onClick={handleAddQuery} is nested inside
a Collapse trigger, causing click events to bubble up and toggle the panel while
the modal opens. Modify the handleAddQuery handler function to call
stopPropagation() on the click event to prevent the event from bubbling to the
Collapse component and triggering the panel toggle.

In `@web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx`:
- Around line 137-139: Replace hardcoded English strings in the FormLabel
tooltip and text with internationalization keys using react-i18next. Import the
useTranslation hook from react-i18next in the chat-prompt-engine.tsx file, then
replace the tooltip prop string for "Display document metadata (e.g., title,
page number, upload date) alongside retrieved text chunks" and the label text
"Show chunk metadata" with appropriate i18n translation keys (e.g.,
t('key.name')). Apply the same pattern to all other hardcoded UI strings in this
component, then add the corresponding translation entries for all supported
languages in the i18n configuration files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6eeb65bb-92a7-49fb-9df3-17283742e690

📥 Commits

Reviewing files that changed from the base of the PR and between f6a2075 and 6a0f629.

📒 Files selected for processing (10)
  • web/src/components/collapse.tsx
  • web/src/components/llm-setting-items/next.tsx
  • web/src/pages/agent/form/agent-form/index.tsx
  • web/src/pages/agent/form/begin-form/index.tsx
  • web/src/pages/agent/form/retrieval-form/next.tsx
  • web/src/pages/agent/form/tool-form/retrieval-form/index.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-model-settings.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
💤 Files with no reviewable changes (2)
  • web/src/pages/next-chats/chat/app-settings/chat-model-settings.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-settings.tsx

Comment on lines 37 to +45
const [currentOpen, setCurrentOpen] = useState(open);

useEffect(() => {
setCurrentOpen(open);
}, [open]);
if (typeof open === 'boolean') {
setCurrentOpen(open);
} else {
setCurrentOpen(defaultOpen);
}
}, [defaultOpen, open]);

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Initialize and render from the same derived open state.

currentOpen starts from open only, so uncontrolled usage can render with stale header state before the effect runs. Also, the title highlight uses open instead of currentOpen, so it won’t track toggles in uncontrolled mode.

Proposed fix
-  const [currentOpen, setCurrentOpen] = useState(open);
+  const [currentOpen, setCurrentOpen] = useState(
+    typeof open === 'boolean' ? open : defaultOpen,
+  );

   useEffect(() => {
     if (typeof open === 'boolean') {
       setCurrentOpen(open);
     } else {
       setCurrentOpen(defaultOpen);
     }
   }, [defaultOpen, open]);
@@
             <div
               className={cn('text-text-secondary', {
-                'text-text-primary': open,
+                'text-text-primary': currentOpen,
               })}
             >

Also applies to: 71-73

🤖 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/components/collapse.tsx` around lines 37 - 45, The currentOpen state
initialization and rendering are inconsistent with the controlled/uncontrolled
pattern. In the useState initialization of currentOpen, derive the initial value
from both open and defaultOpen parameters (use open if it is a boolean,
otherwise use defaultOpen) rather than only from open, so uncontrolled mode
renders correctly from the first render without waiting for the effect to run.
Additionally, the title highlight rendering around lines 71-73 uses the open
parameter instead of currentOpen, which causes uncontrolled toggles to not
update the visual highlight. Replace the open references in the title highlight
rendering with currentOpen to ensure the highlight always tracks the actual
current state.

showModal();
}}
>
<Button variant={'ghost'} onClick={handleAddQuery}>

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Prevent trigger toggle when clicking the add-query button.

On Line 185, the button sits inside Collapse trigger content, so its click bubbles and toggles the panel while opening the modal. Stop propagation/default in the handler.

Suggested fix
-                <Button variant={'ghost'} onClick={handleAddQuery}>
+                <Button
+                  variant={'ghost'}
+                  onClick={(e) => {
+                    e.preventDefault();
+                    e.stopPropagation();
+                    handleAddQuery();
+                  }}
+                >
                   <Plus />
                 </Button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button variant={'ghost'} onClick={handleAddQuery}>
<Button
variant={'ghost'}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleAddQuery();
}}
>
<Plus />
</Button>
🤖 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/agent/form/begin-form/index.tsx` at line 185, The Button
component with onClick={handleAddQuery} is nested inside a Collapse trigger,
causing click events to bubble up and toggle the panel while the modal opens.
Modify the handleAddQuery handler function to call stopPropagation() on the
click event to prevent the event from bubbling to the Collapse component and
triggering the panel toggle.

Comment on lines +137 to +139
<FormLabel tooltip="Display document metadata (e.g., title, page number, upload date) alongside retrieved text chunks">
Show chunk metadata
</FormLabel>

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Localize the new metadata UI strings instead of hardcoding English.

These new labels/tooltips/placeholders bypass translation and won’t render correctly across supported locales.

Proposed fix
-              <FormLabel tooltip="Display document metadata (e.g., title, page number, upload date) alongside retrieved text chunks">
-                Show chunk metadata
+              <FormLabel tooltip={t('chat.showChunkMetadataTip')}>
+                {t('chat.showChunkMetadata')}
               </FormLabel>
@@
-                <FormLabel tooltip="Select which metadata fields to display with each chunk">
+                <FormLabel tooltip={t('chat.metadataKeysTip')}>
                   {t('chat.metadataKeys')}
                 </FormLabel>
@@
-                    placeholder="Please select"
+                    placeholder={t('chat.pleaseSelect')}

As per coding guidelines, "Use react-i18next for internationalization supporting 17 languages."

Also applies to: 149-150, 157-157

🤖 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-chats/chat/app-settings/chat-prompt-engine.tsx` around
lines 137 - 139, Replace hardcoded English strings in the FormLabel tooltip and
text with internationalization keys using react-i18next. Import the
useTranslation hook from react-i18next in the chat-prompt-engine.tsx file, then
replace the tooltip prop string for "Display document metadata (e.g., title,
page number, upload date) alongside retrieved text chunks" and the label text
"Show chunk metadata" with appropriate i18n translation keys (e.g.,
t('key.name')). Apply the same pattern to all other hardcoded UI strings in this
component, then add the corresponding translation entries for all supported
languages in the i18n configuration files.

Source: Coding guidelines

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (f6a2075) to head (6a0f629).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16024   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@wangq8
wangq8 merged commit ba93ac3 into infiniflow:main Jun 15, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants