Repository navigation
fix(prompt-editor): prevent premature variable path merge during typing - #16811
Conversation
📝 WalkthroughWalkthroughThe prompt editor now guards variable-path merging using Lexical caret state, removes border and background styling from the toolbarless merge-path toggle, and copies the full frontend directory before Docker dependency installation. ChangesPrompt editor refinements
Docker build preparation
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
🧹 Nitpick comments (1)
web/src/pages/agent/form/components/prompt-editor/index.tsx (1)
131-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting a shared
MergePathTogglecomponent.The toolbar (lines 131–148) and toolbarless (lines 154–171) toggle blocks are structurally near-identical — same
Tooltip/TooltipTrigger/Switchstructure, differing only in wrapper layout and label styling. The change on line 156 increases divergence between the two instances, making future maintenance harder. As per coding guidelines, avoid duplicating component structures in JSX; prefer reusable components.Extracting a
MergePathTogglecomponent that accepts aclassNameprop would eliminate the duplication and centralize future styling changes.♻️ Suggested extraction
function MergePathToggle({ className, checked, onCheckedChange, }: { className?: string; checked: boolean; onCheckedChange: (checked: boolean) => void; }) { const { t } = useTranslation(); return ( <Tooltip> <TooltipTrigger asChild> <label className={cn('flex cursor-pointer items-center rounded-sm px-1 py-0.5 shadow-sm backdrop-blur-sm', className)}> <span className="sr-only">{t('flow.mergePath')}</span> <div className="origin-right scale-75"> <Switch checked={checked} onCheckedChange={onCheckedChange} aria-label={t('flow.mergePath')} /> </div> </label> </TooltipTrigger> <TooltipContent> <p>{t('flow.mergePath')}</p> <p>{t('flow.mergePathTip')}</p> </TooltipContent> </Tooltip> ); }Then use it in both locations:
// Toolbar case (line 133) - <label className="flex cursor-pointer items-center rounded-sm border border-border bg-bg-base/95 px-1 py-0.5 shadow-sm backdrop-blur-sm"> - <span className="sr-only">{t('flow.mergePath')}</span> - <div className="origin-right scale-75"> - <Switch - checked={enablePathQueryAutoMerge} - onCheckedChange={onEnablePathQueryAutoMergeChange} - aria-label={t('flow.mergePath')} - /> - </div> - </label> + <MergePathToggle + className="border border-border bg-bg-base/95" + checked={enablePathQueryAutoMerge} + onCheckedChange={onEnablePathQueryAutoMergeChange} + /> // Toolbarless case (line 156) - <label className="flex cursor-pointer items-center rounded-sm px-1 py-0.5 shadow-sm backdrop-blur-sm"> - <span className="sr-only">{t('flow.mergePath')}</span> - <div className="origin-right scale-75"> - <Switch - checked={enablePathQueryAutoMerge} - onCheckedChange={onEnablePathQueryAutoMergeChange} - aria-label={t('flow.mergePath')} - /> - </div> - </label> + <MergePathToggle + checked={enablePathQueryAutoMerge} + onCheckedChange={onEnablePathQueryAutoMergeChange} + />Also applies to: 154-171
🤖 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/components/prompt-editor/index.tsx` around lines 131 - 148, Extract the duplicated merge-path toggle JSX into a shared MergePathToggle component accepting className, checked, and onCheckedChange props. Move the shared Tooltip, Switch, labels, and translations into that component, then replace both toolbar and toolbarless instances with it while preserving their distinct wrapper styling via className.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@web/src/pages/agent/form/components/prompt-editor/index.tsx`:
- Around line 131-148: Extract the duplicated merge-path toggle JSX into a
shared MergePathToggle component accepting className, checked, and
onCheckedChange props. Move the shared Tooltip, Switch, labels, and translations
into that component, then replace both toolbar and toolbarless instances with it
while preserving their distinct wrapper styling via className.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8311e302-641a-4c56-a1eb-3a58f9101b14
📒 Files selected for processing (2)
web/src/pages/agent/form/components/prompt-editor/index.tsxweb/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts
Summary
fix(prompt-editor): prevent premature variable path merge during typing