Repository navigation
Feat: Move less important chat settings into a collapsible panel. - #16024
Conversation
📝 WalkthroughWalkthroughThe ChangesChat Settings and Collapse Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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.
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
📒 Files selected for processing (10)
web/src/components/collapse.tsxweb/src/components/llm-setting-items/next.tsxweb/src/pages/agent/form/agent-form/index.tsxweb/src/pages/agent/form/begin-form/index.tsxweb/src/pages/agent/form/retrieval-form/next.tsxweb/src/pages/agent/form/tool-form/retrieval-form/index.tsxweb/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsxweb/src/pages/next-chats/chat/app-settings/chat-model-settings.tsxweb/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsxweb/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
| const [currentOpen, setCurrentOpen] = useState(open); | ||
|
|
||
| useEffect(() => { | ||
| setCurrentOpen(open); | ||
| }, [open]); | ||
| if (typeof open === 'boolean') { | ||
| setCurrentOpen(open); | ||
| } else { | ||
| setCurrentOpen(defaultOpen); | ||
| } | ||
| }, [defaultOpen, open]); |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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.
| <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.
| <FormLabel tooltip="Display document metadata (e.g., title, page number, upload date) alongside retrieved text chunks"> | ||
| Show chunk metadata | ||
| </FormLabel> |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Feat: Move less important chat settings into a collapsible panel.
Type of change