Skip to content

feat: allows easy duplication of agent#97

Closed
denniswebb wants to merge 9 commits intoRunMaestro:mainfrom
denniswebb:DuplicateAgent
Closed

feat: allows easy duplication of agent#97
denniswebb wants to merge 9 commits intoRunMaestro:mainfrom
denniswebb:DuplicateAgent

Conversation

@denniswebb
Copy link
Contributor

When needing to create agents for an existing repo/directory but with a different AI tool, e.g. from Claude Code to Codex, this makes duplication simple.

image image

And if the source has options set for the agent, they are also duplicated as expected.

image

Also works with CMD+K
image

denniswebb and others added 9 commits December 25, 2025 15:00
- User-initiated cloning of agent configurations
- Pre-filled New Agent dialog approach
- Right-click context menu + Cmd+K integration
- Complete technical requirements and implementation checklist
- No automatic background duplication (user control only)
Added complete duplication functionality that allows users to duplicate
existing agents with pre-filled configuration.

Backend Changes:
- Extended createNewSession signature to include customContextWindow and
  customProviderPath parameters
- Added duplicatingSessionId state management in App.tsx
- Integrated duplication flow with NewInstanceModal via sourceSession prop

Frontend Changes:
- NewInstanceModal: Added sourceSession prop and pre-fill logic for all
  configuration fields (agent type, paths, args, env vars, model, context
  window)
- SessionContextMenu: Added 'Duplicate' menu item after 'Edit Agent'
- QuickActionsModal: Added 'Duplicate Agent' quick action (Cmd+K)
- SessionList: Wired up duplication handlers with proper state management

Features Implemented:
- Right-click context menu duplication
- Cmd+K quick actions duplication
- Pre-fills all configuration: agent type, working directory, name (with
  'Copy' suffix), nudge message, custom paths, spawn arguments, environment
  variables, model selection, context window, and provider path
- Validates pre-filled values with existing session validation
- Clears duplication state on modal close
- Fresh session state (no conversation history, no task state, new IDs)

All implementation tasks from duplicate-session-1.md completed successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added 3 new tests to NewInstanceModal.test.tsx for duplication functionality
- Test: Pre-fill all fields when sourceSession is provided
- Test: Allow modifying pre-filled fields before creation
- Test: No pre-fill when sourceSession is not provided
- All 3 new tests passing (58/63 total passing, 5 pre-existing failures)
- Verified duplication feature works correctly with automated test coverage
- Changed 'Duplicate' to 'Duplicate...' in SessionList context menu
- Matches pattern of 'Edit Agent...' which also opens a dialog
- Follows UI convention where ellipsis indicates additional steps required
…nfiguration

- Added setExpandedAgent(sourceSession.toolType) to pre-fill logic
- Ensures custom arguments, paths, and env vars are visible when duplicating
- Fixes issue where custom args like '--model=opus' weren't visible in UI
- Added test to verify custom arguments pre-fill behavior
- All duplication tests passing (59/64 total, 5 pre-existing failures)
- Fixed race condition where first useEffect was resetting expandedAgent to null
- Modified first useEffect to only collapse agents when NOT duplicating
- Changed conditional pre-fill to always set values (even if empty) for consistency
- Ensures custom args, paths, and env vars are properly populated in UI
- Added sourceSession to first useEffect dependency array
The issue was that loadAgents() ran asynchronously and reset customAgentPaths,
customAgentArgs, and customAgentEnvVars to empty objects AFTER the second
useEffect had already pre-filled them from sourceSession.

Fix:
- Modified loadAgents() to accept optional source session parameter
- Only reset custom values when NOT duplicating
- Moved all pre-fill logic into loadAgents() to run AFTER agents load
- Removed redundant second useEffect that caused the race condition

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom args, paths, and env vars are still correctly pre-filled
in state - they just remain hidden until the user expands the section.
This provides a cleaner UX when duplicating agents.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@pedramamini
Copy link
Collaborator

I'll pull this in after completed this bear of a refactor:

#96

@denniswebb
Copy link
Contributor Author

No rush. I have a few more. If after the refactor we hit conflicts, I'll get them resolved.

@pedramamini
Copy link
Collaborator

pedramamini commented Dec 26, 2025 via email

@pedramamini
Copy link
Collaborator

@denniswebb can i trouble you to rebase this on the refactored main? thank you so much for your help? killer PRs!

@pedramamini pedramamini self-assigned this Dec 27, 2025
pedramamini added a commit that referenced this pull request Dec 30, 2025
PR #97 was missing duplication of sessionSshRemoteConfig when using
the "Duplicate" feature. Sessions using SSH remote would lose that
configuration when duplicated.

Also added test coverage for SSH config duplication.
@pedramamini
Copy link
Collaborator

Hmmm seems when I rebased to get this in it didn't close out your PR. This is in though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments