Skip to content

feat(files): add "New Agent Here" to the folder right-click menu - #1301

Open
pedramamini wants to merge 1 commit into
rcfrom
feat/1300-new-agent-here-folder-context-menu
Open

feat(files): add "New Agent Here" to the folder right-click menu#1301
pedramamini wants to merge 1 commit into
rcfrom
feat/1300-new-agent-here-folder-context-menu

Conversation

@pedramamini

@pedramamini pedramamini commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #1300

What

Right-clicking a folder in the Files panel (Right Bar) now offers New Agent Here. It opens the standard New Agent modal pre-filled with that folder as the working directory, and the folder's basename as a default agent name.

Both fields stay editable, and provider / group / SSH / nudge choices are unchanged - this only removes the manual re-typing of the path that the issue calls out.

How

Plumbed via a new presetWorkingDir field on the newInstance modal data, mirroring how the Left Bar's group context menu already opens the same modal with presetGroupId rather than threading a callback down from App.tsx.

  • modalStore.ts - presetWorkingDir on NewInstanceModalData, exposed as newInstancePresetWorkingDir
  • App.tsx -> AppModals.tsx -> AppSessionModals.tsx -> NewInstanceModal - threaded alongside the existing presetGroupId
  • NewInstanceModal.tsx - seeds working dir + name on open; skipped when duplicating so the source session's cwd still wins
  • useFileContextMenu.ts - handleNewAgentHere, using joinPath() so the separator follows the workspace root (Windows-safe)
  • FileTreeContextMenu.tsx - the menu item, folder rows only

Notes

  • Folder rows only. Not shown on file rows or the empty-space root menu (the root menu is already the agent's own working directory).
  • Hidden over SSH. The folder path is remote, but a freshly created agent starts out local, so seeding it would silently point the new agent at a local path that doesn't exist. Making this work properly would mean pre-seeding the new agent's SSH remote config too, which felt like a separate change.

Testing

  • New unit tests: useFileContextMenu (folder path seeding incl. a Windows separator case, no-op on file rows), FileTreeContextMenu (shown for folders, hidden for files/root/SSH), NewInstanceModal (seeds dir + name, stays editable, ignored when duplicating).
  • npm run lint clean, ESLint clean, full suite green: 34,656 passed / 108 skipped.

Summary by CodeRabbit

  • New Features

    • Added a “New Agent Here” option to folder context menus.
    • Automatically opens the new-agent modal with the selected folder as the working directory.
    • Pre-fills the agent name based on the selected folder.
    • Supports nested folders and Windows paths.
  • Bug Fixes

    • Prevented the action from appearing for files, empty menus, and remote folders.
    • Preserved duplicated session settings when creating an agent from an existing session.

Right-clicking a folder in the Files panel now offers "New Agent Here",
which opens the New Agent modal pre-filled with that folder as the
working directory (and its basename as a default agent name). Both
fields stay editable, so the normal provider/name/group choices are
unchanged - this just removes the manual re-typing of the path.

Plumbed via a new `presetWorkingDir` on the newInstance modal data,
matching how the Left Bar's group menu already opens the same modal
with `presetGroupId` instead of threading a callback down from App.

Hidden over SSH: the folder path is remote, but a fresh agent starts
out local, so seeding it would point the new agent at a local path
that does not exist.

Closes #1300
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ddf3e990-1205-4bd9-bb85-7a0c3066521d

📥 Commits

Reviewing files that changed from the base of the PR and between 81e145f and d1dc356.

📒 Files selected for processing (13)
  • src/__tests__/renderer/components/FileExplorerPanel.test.tsx
  • src/__tests__/renderer/components/FileExplorerPanel/components/FileTreeContextMenu.test.tsx
  • src/__tests__/renderer/components/FileExplorerPanel/hooks/useFileContextMenu.test.ts
  • src/__tests__/renderer/components/NewInstanceModal.test.tsx
  • src/renderer/App.tsx
  • src/renderer/components/AppModals/AppModals.tsx
  • src/renderer/components/AppModals/AppSessionModals.tsx
  • src/renderer/components/FileExplorerPanel/FileExplorerPanel.tsx
  • src/renderer/components/FileExplorerPanel/components/FileTreeContextMenu.tsx
  • src/renderer/components/FileExplorerPanel/hooks/useFileContextMenu.ts
  • src/renderer/components/NewInstanceModal/NewInstanceModal.tsx
  • src/renderer/components/NewInstanceModal/types.ts
  • src/renderer/stores/modalStore.ts

📝 Walkthrough

Walkthrough

Adds a “New Agent Here” folder context-menu action that opens the new-instance modal with the selected folder as its working directory, derives the agent name from the folder basename, and preserves duplication behavior.

Changes

New Agent Here

Layer / File(s) Summary
Working-directory preset through modal flow
src/renderer/stores/modalStore.ts, src/renderer/components/NewInstanceModal/*, src/renderer/components/AppModals/*, src/renderer/App.tsx, src/__tests__/renderer/components/NewInstanceModal.test.tsx
Modal state and props carry presetWorkingDir; NewInstanceModal initializes the directory and basename-derived agent name for new sessions while ignoring the preset during duplication.
Folder context-menu action
src/renderer/components/FileExplorerPanel/*, src/__tests__/renderer/components/FileExplorerPanel/*
The folder-only, local context menu action invokes useFileContextMenu, joins platform-specific paths, opens the new-instance modal, and clears the menu. Tests cover folder, file, root, SSH, and Windows-path behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FileTreeContextMenu
  participant useFileContextMenu
  participant NewInstanceModal
  User->>FileTreeContextMenu: select New Agent Here on folder
  FileTreeContextMenu->>useFileContextMenu: invoke folder action
  useFileContextMenu->>NewInstanceModal: open with presetWorkingDir
  NewInstanceModal->>NewInstanceModal: seed working directory and agent name
Loading

Suggested labels: ready to merge

Suggested reviewers: reachrazamair, jsydorowicz21

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a "New Agent Here" action to the Files panel folder context menu.
Linked Issues check ✅ Passed The PR implements issue #1300 by adding the folder right-click "New Agent Here" action that opens a new agent scoped to the selected folder.
Out of Scope Changes check ✅ Passed The extra modal wiring, preset working-directory propagation, Windows path handling, and tests all support the requested feature.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1300-new-agent-here-folder-context-menu

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.

@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a folder-only “New Agent Here” action that opens the standard New Agent modal with the selected local folder as its editable working directory and basename-derived agent name.

  • Extends new-instance modal data with an optional working-directory preset.
  • Threads the preset through the renderer modal hierarchy.
  • Hides the action for files, root-space menus, and SSH sessions.
  • Adds coverage for menu visibility, cross-platform path joining, editable presets, and duplication precedence.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure identified.

The selected folder path is resolved consistently across POSIX and Windows roots, modal data is replaced and cleared per invocation, and duplication explicitly retains the source session’s working directory.

Important Files Changed

Filename Overview
src/renderer/components/FileExplorerPanel/hooks/useFileContextMenu.ts Resolves the selected folder against the session root with the canonical cross-platform path helper and opens the new-instance modal.
src/renderer/components/FileExplorerPanel/components/FileTreeContextMenu.tsx Adds the folder-only action while excluding root, file, and SSH contexts.
src/renderer/components/NewInstanceModal/NewInstanceModal.tsx Seeds editable working-directory and name fields without overriding duplication source values.
src/renderer/stores/modalStore.ts Extends new-instance modal data and selector output with the optional working-directory preset.
src/renderer/components/AppModals/AppSessionModals.tsx Completes propagation of the new preset into NewInstanceModal.

Sequence Diagram

sequenceDiagram
    actor User
    participant Menu as Folder Context Menu
    participant Store as Modal Store
    participant Modal as New Agent Modal
    User->>Menu: Select New Agent Here
    Menu->>Store: Open with presetWorkingDir
    Store->>Modal: Supply working-directory preset
    Modal->>Modal: Derive editable agent name from basename
    Modal-->>User: Show pre-filled form
Loading

Reviews (1): Last reviewed commit: "feat(files): add "New Agent Here" to the..." | Re-trigger Greptile

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.

1 participant