Skip to content

fix(prompt-editor): prevent premature variable path merge during typing - #16811

Merged
JinHai-CN merged 5 commits into
infiniflow:mainfrom
dcc123456:fix/agent-prompt-editor-error
Jul 10, 2026
Merged

JinHai-CN merged 5 commits into
infiniflow:mainfrom
dcc123456:fix/agent-prompt-editor-error

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix(prompt-editor): prevent premature variable path merge during typing

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jul 10, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 10, 2026 08:05
@dcc123456 dcc123456 added the ci Continue Integration label Jul 10, 2026
@dcc123456
dcc123456 marked this pull request as draft July 10, 2026 08:05
@dcc123456
dcc123456 marked this pull request as ready for review July 10, 2026 08:05
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

Prompt editor refinements

Layer / File(s) Summary
Selection-aware variable-path merging
web/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts
Lexical selection checks prevent merging when the variable path is incomplete or the collapsed caret is immediately after the matched suffix.
Toolbarless merge-path toggle styling
web/src/pages/agent/form/components/prompt-editor/index.tsx
The toggle label removes border and background classes while retaining cursor, rounding, padding, shadow, and backdrop blur styles.

Docker build preparation

Layer / File(s) Summary
Frontend dependency installation order
Dockerfile
The builder copies the full web directory before running npm install, replacing the active manifest-only copy step.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with a prompt to tune,
Guarding paths beneath the moon.
The caret hops, the text stays free,
Borders fade for clarity.
The build steps join the flight—
Hoppy code, neat and bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title accurately describes the main prompt-editor fix around preventing premature variable path merging while typing.
Description check ✅ Passed The description matches the required Summary section and clearly states the PR goal, though it is brief and lacks background context.

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.

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

🧹 Nitpick comments (1)
web/src/pages/agent/form/components/prompt-editor/index.tsx (1)

131-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting a shared MergePathToggle component.

The toolbar (lines 131–148) and toolbarless (lines 154–171) toggle blocks are structurally near-identical — same Tooltip/TooltipTrigger/Switch structure, 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 MergePathToggle component that accepts a className prop 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

📥 Commits

Reviewing files that changed from the base of the PR and between fb42e55 and d8aa507.

📒 Files selected for processing (2)
  • web/src/pages/agent/form/components/prompt-editor/index.tsx
  • web/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 10, 2026
@dcc123456
dcc123456 marked this pull request as draft July 10, 2026 09:11
@dcc123456
dcc123456 marked this pull request as ready for review July 10, 2026 09:11
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 10, 2026
@JinHai-CN
JinHai-CN marked this pull request as draft July 10, 2026 12:35
@JinHai-CN
JinHai-CN marked this pull request as ready for review July 10, 2026 12:35
@JinHai-CN
JinHai-CN merged commit ea9b378 into infiniflow:main Jul 10, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants