Skip to content

feat: add "Duplicate as Tab" action to request tab menu#7945

Open
brunorodmoreira wants to merge 3 commits into
usebruno:mainfrom
brunorodmoreira:feature/duplicate-as-tab
Open

feat: add "Duplicate as Tab" action to request tab menu#7945
brunorodmoreira wants to merge 3 commits into
usebruno:mainfrom
brunorodmoreira:feature/duplicate-as-tab

Conversation

@brunorodmoreira
Copy link
Copy Markdown

@brunorodmoreira brunorodmoreira commented May 7, 2026

Description

Adds a "Duplicate as Tab" option to the request tab right-click menu, mirroring Postman's "Duplicate Tab" idiom.

The existing Clone Request action requires a name in a modal and persists immediately to disk — well-suited for committing a copy. This new option duplicates the request into the collection's temp directory as a transient (unsaved) tab, pre-seeded with the source request's full state (including any unsaved draft changes), and opens it in a new tab. The user only commits to a name and folder if they later choose to save via the existing transient-save flow.

Reuses Bruno's existing transient-request infrastructure (temp directory + SaveTransientRequest modal); no new IPC, no schema changes.

Demo

Screen.Recording.2026-05-07.at.10.01.48.mov

Related: #184

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • New Features

    • Added "Duplicate as Tab" action to create temporary, unsaved copies of the focused request and open them as tabs; menu enables/disables based on focused tab type.
  • Bug Fixes

    • Duplication failures now show an error toast with a descriptive message.

Copilot AI review requested due to automatic review settings May 7, 2026 13:23
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

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

Run ID: 893a88cd-15da-46ec-8485-18348fd6606a

📥 Commits

Reviewing files that changed from the base of the PR and between ecd1cfe and 90b5d61.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js

Walkthrough

Adds a "Duplicate as Tab" menu action in RequestTab that dispatches a new Redux thunk, cloneItemAsTransient, to create a collision-free transient request file in the collection temp dir and enqueue OPEN_REQUEST; the UI shows a toast on errors.

Changes

Duplicate as Tab Feature

Layer / File(s) Summary
Redux Thunk Implementation
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
New cloneItemAsTransient thunk validates collection/temp directory existence, forbids folder duplication, locates the target item, generates a unique transient filename, transforms request payload, persists it via IPC (renderer:new-request), and enqueues an OPEN_REQUEST task.
RequestTab Menu Integration
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
Imports cloneItemAsTransient and isItemARequest, derives isRequestTab from focused item, adds handleDuplicateAsTab that dispatches the thunk and surfaces errors via toast.error, inserts a "Duplicate as Tab" menu item (disabled when not a request), and updates the useMemo dependency array.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#6502: Modifies RequestTab context menu and menuItems; related to menu wiring changes extended here.
  • usebruno/bruno#7058: Touches transient-request creation/open flow and OPEN_REQUEST enqueue pattern used by the new thunk.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno
  • sid-bruno

Poem

Duplicate a tab with nimble art,
A transient twin to play a part,
Click the menu, clone and go,
If it fails, a toast will show,
New tab opens — quick workflow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 and clearly summarizes the main change: adding a 'Duplicate as Tab' action to the request tab menu, which is the core feature implemented across both modified files.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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: 1

🤖 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 `@packages/bruno-app/src/components/RequestTabs/RequestTab/index.js`:
- Around line 697-701: The duplicate handler handleDuplicateAsTab uses
currentTabItem.uid without guarding against a briefly missing currentTabItem,
which can throw; update handleDuplicateAsTab to first verify currentTabItem and
currentTabItem.uid (and optionally collection.uid) exist, return early or show a
user-friendly toast if missing, and only then call
dispatch(cloneItemAsTransient(currentTabItem.uid, collection.uid)). Ensure error
handling for the dispatch remains (toast.error on catch) so the flow is safe if
state desyncs.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1718b114-d05d-4bd7-a2ea-b5ef762dfcdd

📥 Commits

Reviewing files that changed from the base of the PR and between f8bf146 and c429c3a.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js

Comment thread packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “Duplicate as Tab” option to the request tab context menu, enabling users to duplicate the currently opened request into the collection’s transient (temp-directory) request space and open it as a new unsaved tab—similar to Postman’s “Duplicate Tab” workflow.

Changes:

  • Added a new collections thunk action (cloneItemAsTransient) that clones an existing request into the collection’s transient directory and queues it to open as a non-preview tab.
  • Added a “Duplicate as Tab” menu item to the request tab right-click menu, with basic enable/disable logic based on tab type.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js Adds cloneItemAsTransient to duplicate a request into the transient directory and open it via the existing task-queue flow.
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js Exposes the new action via a “Duplicate as Tab” entry in the request tab context menu.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/bruno-app/src/components/RequestTabs/RequestTab/index.js Outdated
brunorodmoreira added a commit to brunorodmoreira/bruno that referenced this pull request May 7, 2026
The menu item is already disabled when currentTabItem/isRequestTab is falsy,
but mirrors the defensive pattern used elsewhere in this file (e.g. the
currentTabUid guard) and prevents a theoretical NPE if state desyncs between
render and click. Per CodeRabbit review on usebruno#7945.
brunorodmoreira added a commit to brunorodmoreira/bruno that referenced this pull request May 7, 2026
Replaces an inline list of request types with the canonical isItemARequest
helper. Avoids drift if new request types are added and matches how the rest
of the codebase classifies items. Per Copilot review on usebruno#7945.
Mirrors Postman's "Duplicate Tab": creates an unsaved transient copy of the
current request in a new tab, pre-seeded with the full request state (including
unsaved draft changes). Avoids the friction of the existing Clone modal, which
requires a name and immediately persists to disk.

Reuses the existing transient-request pipeline (temp directory + SaveTransientRequest
flow); no new IPC, no schema changes.

Related: usebruno#184
The menu item is already disabled when currentTabItem/isRequestTab is falsy,
but mirrors the defensive pattern used elsewhere in this file (e.g. the
currentTabUid guard) and prevents a theoretical NPE if state desyncs between
render and click. Per CodeRabbit review on usebruno#7945.
Replaces an inline list of request types with the canonical isItemARequest
helper. Avoids drift if new request types are added and matches how the rest
of the codebase classifies items. Per Copilot review on usebruno#7945.
@brunorodmoreira brunorodmoreira force-pushed the feature/duplicate-as-tab branch from ecd1cfe to 90b5d61 Compare May 7, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants