Skip to content

Feat: add duplicate action to agent list (#14769)#14856

Open
Rene0422 wants to merge 2 commits into
infiniflow:mainfrom
Rene0422:feat/duplicate-agent
Open

Feat: add duplicate action to agent list (#14769)#14856
Rene0422 wants to merge 2 commits into
infiniflow:mainfrom
Rene0422:feat/duplicate-agent

Conversation

@Rene0422
Copy link
Copy Markdown

closes #14769

What problem does this PR solve?

Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 12, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7e8616d-ac38-439c-bfc1-63e408d536fe

📥 Commits

Reviewing files that changed from the base of the PR and between 5457fc5 and 2e37229.

📒 Files selected for processing (2)
  • web/src/hooks/use-agent-request.ts
  • web/src/locales/en.ts
✅ Files skipped from review due to trivial changes (1)
  • web/src/locales/en.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/hooks/use-agent-request.ts

📝 Walkthrough

Walkthrough

Adds a React Query-based useDuplicateAgent hook that clones an agent with copied DSL/config and localized "(Copy)" naming, integrates it into the agent dropdown menu via a new duplicate action with loading state management, and includes English and Chinese UI translations for the duplicate button and copy naming pattern.

Changes

Agent Duplication Feature

Layer / File(s) Summary
Agent duplication hook and localized naming
web/src/hooks/use-agent-request.ts, web/src/locales/en.ts, web/src/locales/zh.ts
useDuplicateAgent hook performs agent duplication (fetch source details, create new agent with copied DSL/config and localized "(Copy)" name suffix, invalidate agent list), returning mutation state and trigger function. Translation keys added for "Duplicate" button label and "{{name}} (Copy)" naming pattern in English (duplicate, copyOfAgentName) and Chinese locales.
Dropdown menu duplicate action wiring
web/src/pages/agents/agent-dropdown.tsx
AgentDropdown imports useDuplicateAgent hook and Copy icon, extracts mutation state, defines handleDuplicate handler that guards against concurrent requests, and wires a new menu item that triggers duplication with the current agent's id and title.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14157: Updates agent API wiring and hooks in the same files, providing context for agent request patterns and mutation handling.

Suggested labels

💞 feature, lgtm

Suggested reviewers

  • wangq8

Poem

🐰 A curious rabbit taps the key,
"Duplicate" — two agents now we see,
Copy the DSL, the avatar, the name,
A tidy clone, and nothing left to tame.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description partially fills the template with the issue reference and correctly marks it as a New Feature, but provides no explanation of what problem the PR solves. Add a brief explanation under 'What problem does this PR solve?' describing the duplicate functionality being implemented to help reviewers understand the context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature addition: a duplicate action for agents in the list view.
Linked Issues check ✅ Passed The PR implements the core duplicate agent functionality from issue #14769, including new React hook, translations, and UI integration for duplication with proper data copying and success/error handling.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the duplicate agent feature: new hook, translation keys, and dropdown menu integration with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feat/duplicate-agent

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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/hooks/use-agent-request.ts`:
- Around line 253-279: The mutationFn in useDuplicateAgent currently only shows
success and can fail silently; wrap the agentService.getAgent and
agentService.createAgent calls in a try/catch, explicitly check for missing
source (detail?.data) and non-success create responses (data?.code !== 0) and
call message.error with a translated error message (use i18n.t) in those
branches, ensure the catch logs the error and shows message.error, and return
null on failure so callers know the duplication failed; reference the
mutationFn, agentService.getAgent, agentService.createAgent, and
useDuplicateAgent when making the changes.

In `@web/src/locales/en.ts`:
- Line 2438: The translation key copyOfAgentName currently uses title case for
the parenthetical text; update the value of copyOfAgentName to use sentence case
by changing the parenthesis from '(Copy)' to '(copy)' so the string becomes
'{{name}} (copy)' to match the sentence case convention used in
src/locales/en.ts.
🪄 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: 593ce1ff-085b-42a3-ad3a-6cab5ab260f3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e46457 and 5457fc5.

📒 Files selected for processing (4)
  • web/src/hooks/use-agent-request.ts
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/agents/agent-dropdown.tsx

Comment thread web/src/hooks/use-agent-request.ts
Comment thread web/src/locales/en.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add Copy Agent / Duplicate functionality in Agent creation UI

1 participant