Skip to content

feat: keybindings customisation - #7603

Merged
sid-bruno merged 12 commits into
usebruno:mainfrom
shubh-bruno:poc/keybindings-implementation
Mar 31, 2026
Merged

sid-bruno merged 12 commits into
usebruno:mainfrom
shubh-bruno:poc/keybindings-implementation

Conversation

@shubh-bruno

@shubh-bruno shubh-bruno commented Mar 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

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.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Full keybindings preferences UI with enable/disable, in-row editing, validation, reset-to-default, and OS-aware defaults.
    • Reopen recently closed tabs and move tabs left/right via keyboard.
    • New global keybinding hook to register app-wide shortcuts.
  • Improvements

    • Global hotkeys reworked to open UI/modal flows and act collection-scoped.
    • Shortcuts now reliably work while editors are focused; many UI elements gained data-testid attributes.
  • Tests

    • End-to-end suite added to verify bound keyboard actions and remapping.

@coderabbitai

coderabbitai Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Removed editor-local run/save shortcuts, added a Redux-aware useKeybinding hook and centralized Mousetrap-driven hotkey handling, rewired hotkey effects to dispatch/modal flows, introduced editable keybindings UI and mappings, and added testids and tests for shortcut behaviors.

Changes

Cohort / File(s) Summary
CodeMirror editors
packages/bruno-app/src/components/ApiSpecPanel/FileEditor/CodeEditor/index.js, packages/bruno-app/src/components/CodeEditor/index.js, packages/bruno-app/src/components/MultiLineEditor/index.js, packages/bruno-app/src/components/RequestPane/QueryEditor/index.js, packages/bruno-app/src/components/SingleLineEditor/index.js
Removed CodeMirror extraKeys run/save shortcuts; added logic to add mousetrap CSS class to editor input fields so global Mousetrap bindings can intercept while focused.
Keybinding runtime & mappings
packages/bruno-app/src/hooks/useKeybinding/index.js, packages/bruno-app/src/providers/Hotkeys/keyMappings.js
Added useKeybinding hook that binds Mousetrap combos respecting user overrides and enabled flag; restructured defaults into KEY_BINDING_SECTIONS, added toMousetrapCombo/getMergedKeyBindings, and changed lookup to accept user prefs.
Hotkeys provider & app flows
packages/bruno-app/src/providers/Hotkeys/index.js
Refactored hotkeys to use preferences, register/unregister Mousetrap handlers, and convert many immediate side effects into modal/dispatch-driven flows (scoped close/save, collection-scoped tab nav/reorder, context-aware handlers).
Preferences Keybindings UI & styles
packages/bruno-app/src/components/Preferences/Keybindings/index.js, packages/bruno-app/src/components/Preferences/Keybindings/StyledWrapper.js
Major rewrite of Keybindings UI and styling: in-row capture/editing, validation, draft state, reset, OS-reserved blocking, duplicate detection, pill/keycap rendering, and extensive CSS updates.
Redux additions
packages/bruno-app/src/providers/ReduxStore/slices/app.js, packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
Added showSidebarSearch and focusedSidebarPath with actions; added recentlyClosedTabs and reopenLastClosedTab with LIFO grouping and trimming to support reopen/tab-scoped close flows.
Sidebar & collection keyboard integration
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js, packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js, packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js
Replaced ad-hoc onKeyDown handlers with useKeybinding for clone/copy/paste/rename/import; dispatch focused path on focus/blur; adjusted paste semantics to insert as sibling; toggled sidebar search via Redux.
Tab-level keybindings
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js, packages/bruno-app/src/components/RequestTabPanel/index.js
Added useKeybinding-driven closeTab, save, and sendRequest handlers with tab-type-specific logic and conditional enablement when tab is active.
SaveRequestsModal scoping
packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
Extended modal to support tab-scoped close (forceCloseTabs, tabUidsToClose) and updated draft aggregation, save, and close/discard flows accordingly.
Tests & test helpers
tests/shortcuts/bound-actions.spec.ts, tests/collection/moving-tabs/move-tabs.spec.ts, tests/utils/page/actions.ts
Added comprehensive E2E suite for bound shortcuts; updated moving-tabs test to use bracket-based shortcuts; updated helpers to use new testids and platform-aware save shortcut.
Misc testids & small UI tweaks
packages/bruno-app/src/components/GlobalSearchModal/index.js, packages/bruno-app/src/components/Devtools/Console/TerminalTab/SessionList.js, packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js, packages/bruno-app/src/components/Sidebar/.../CloneCollectionItem/index.js, .../RenameCollectionItem/index.js, packages/bruno-app/src/components/Sidebar/NewFolder/index.js, packages/bruno-app/src/components/Sidebar/NewRequest/index.js
Added data-testid attributes to inputs, buttons, and rows to improve test targeting; session list now includes indices for stable testids.
Electron menu
packages/bruno-electron/src/app/menu-template.js
Replaced Preferences menu item with a Quit flow trigger (main:start-quit-flow) in Collection menu and set registerAccelerator: false on zoom menu items for custom accelerator handling.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Editor / Sidebar / Tab
    participant Mousetrap
    participant Hook as useKeybinding
    participant Redux as Store
    participant Handler as ActionHandler
    participant Modal as SaveRequestsModal

    User->>UI: Press shortcut
    UI->>Mousetrap: Global key event
    Mousetrap->>Hook: Bound combo triggers
    Hook->>Redux: Read keybindings & enabled flag
    Redux-->>Hook: Return prefs & overrides
    Hook->>Handler: Invoke handler (may return false)
    Handler->>Handler: Evaluate context (active tab, focus, type)
    alt Requires confirmation/save
        Handler->>Modal: Open SaveRequestsModal
        Modal-->>Handler: User decision
        Handler->>Redux: Dispatch save/close actions
    else Direct action
        Handler->>Redux: Dispatch action (open tab, run, toggle UI)
    end
    Redux-->>UI: State updates reflected
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

⌨️ Keys now sing in orderly rows,
Mousetrap listens where focus goes,
Preferences learn each custom chord,
Tabs and sidebars answer the horde,
Confirm or save before we close. 🎶

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: keybindings customisation' accurately reflects the main feature added across the changeset—a comprehensive keybinding customization system with UI, Redux state management, and hook-based keyboard handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

@shubh-bruno shubh-bruno changed the title feat: keybindings customization feat: keybindings customisation Mar 28, 2026

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

Actionable comments posted: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js (1)

85-97: ⚠️ Potential issue | 🟠 Major

Don't pull the global environment draft into a tab-scoped close.

When forCloseTabs is true, this still includes the global environment draft unconditionally. Closing tabs in one collection can therefore prompt for, save, or discard unrelated global-environment edits, and clearGlobalEnvironmentDraft() wipes that draft app-wide.

🩹 Suggested guard
-    if (globalEnvironmentDraft) {
+    if (!forCloseTabs && globalEnvironmentDraft) {
       const { environmentUid, variables } = globalEnvironmentDraft;
       const environment = globalEnvironments?.find((env) => env.uid === environmentUid);
       if (environment && variables) {
         environmentDrafts.push({
           type: 'global-environment',

If a global-environment tab is supposed to participate in tab-closing, gate it on that tab being present in tabUidsToClose instead of including it unconditionally.

Also applies to: 129-130, 175-177

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js`
around lines 85 - 97, The globalEnvironmentDraft is being added to
environmentDrafts unconditionally; change this so that when forCloseTabs is true
you only include the global-environment draft if its associated tab UID is in
tabUidsToClose (i.e., gate the push on tabUidsToClose.includes(<tabUid>));
otherwise keep current behavior when not closing specific tabs. Apply the same
conditional guard to the other occurrences that handle globalEnvironmentDraft
(the later blocks referenced) and ensure any calls that
clearGlobalEnvironmentDraft() are only invoked for drafts that were actually
part of the targeted tabUidsToClose.
🧹 Nitpick comments (4)
tests/collection/moving-tabs/move-tabs.spec.ts (1)

141-141: Consider replacing waitForTimeout with explicit assertions.

Per coding guidelines, prefer expect() Playwright calls over page.waitForTimeout(). The tab reorder should be verifiable via the subsequent expect(tabs.nth(...)) assertions without the delay.

♻️ Proposed refactor
    await page.keyboard.press(`${modifier}+BracketLeft`);
-   await page.waitForTimeout(500);
 
    // Verify order of tabs after move
    await expect(tabs.nth(0)).toHaveText('GETtest-request');

The expect().toHaveText() will auto-retry until the condition is met or times out, making the explicit delay unnecessary.

Also applies to: 150-150

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/collection/moving-tabs/move-tabs.spec.ts` at line 141, Replace the
explicit sleeps that call page.waitForTimeout(...) with relying on Playwright's
auto-retrying assertions: remove the page.waitForTimeout(500) calls and ensure
the following assertions (the expect(tabs.nth(...).toHaveText(...) checks used
right after the waits) are used as the synchronization point so they validate
the tab reorder by themselves; update any test flow that assumed the delay to
instead assert the expected tab text/position using expect(...) which will wait
until the UI reaches the expected state.
packages/bruno-app/src/components/Preferences/Keybindings/index.js (1)

618-625: Add cleanup for success flash timer on unmount.

If the component unmounts while the success timer is pending, it will attempt to update state on an unmounted component. Add a cleanup effect.

🛠️ Suggested fix
+  useEffect(() => {
+    return () => {
+      if (successTimerRef.current) clearTimeout(successTimerRef.current);
+    };
+  }, []);
+
   const showSuccessFlash = (action) => {
     if (successTimerRef.current) clearTimeout(successTimerRef.current);
     setSuccessAction(action);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/Preferences/Keybindings/index.js` around
lines 618 - 625, The showSuccessFlash function sets successTimerRef.current with
setTimeout but lacks cleanup on unmount; add a useEffect cleanup that runs on
component unmount to clearTimeout(successTimerRef.current) (and set
successTimerRef.current = null) to prevent setState on an unmounted component;
locate the Keybindings component and modify it to include a useEffect that
returns a cleanup function referencing successTimerRef and setSuccessAction to
ensure the pending timer is cleared when the component unmounts.
packages/bruno-app/src/components/Preferences/Keybindings/StyledWrapper.js (1)

182-195: Consider using theme colors for status states.

Several hardcoded hex values (#E4AE49, #CE4F3B, #2E8A54) are used for editing/error/success states. For consistency with the codebase pattern, consider using theme props like ${(props) => props.theme.status.danger.text} (which you already use on line 319).

Also applies to: 234-260

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/Preferences/Keybindings/StyledWrapper.js`
around lines 182 - 195, Replace hardcoded hex colors used for status states in
StyledWrapper (e.g., in the .shortcut-input--editing,
.shortcut-input--error.shortcut-input--editing and the success state around
lines 234-260) with theme values to match the codebase pattern; for example use
props.theme.status.warning.text for the editing outline instead of `#E4AE49`,
props.theme.status.danger.text for the error outline instead of `#CE4F3B`, and
props.theme.status.success.text for success instead of `#2E8A54`, ensuring you
reference the theme via the same arrow function pattern already used elsewhere
in this file.
tests/shortcuts/bound-actions.spec.ts (1)

83-133: Please add coverage for the unsaved-drafts close-all-tabs path.

These cases only assert the zero-draft flow, but this PR moves closeAllTabs through SaveRequestsModal. Adding one save case and one discard case with a real draft would exercise the new scoped prompt/cleanup behavior.

As per coding guidelines, "Cover both the 'happy path' and the realistically problematic paths. Validate expected success behaviour, but also validate error handling, edge cases, and degraded-mode behaviour when appropriate."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/shortcuts/bound-actions.spec.ts` around lines 83 - 133, The tests for
the "Close All Tabs" shortcut only cover the zero-draft flow; add two new test
cases that exercise the unsaved-drafts path through the SaveRequestsModal: (1)
create a real unsaved draft (e.g., openRequest with persist: false or edit an
open request), trigger the closeAllTabs shortcut and choose the "Save" option in
the SaveRequestsModal, then assert drafts were saved and tabs closed/cleaned up;
(2) repeat but choose the "Discard" option in the SaveRequestsModal and assert
drafts were removed and tabs closed/cleaned up; use the existing helpers
createRequest/openRequest, reference the keybinding trigger steps
(keyboard.down('...') sequence) and the SaveRequestsModal UI identifiers to
locate and interact with the modal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/jest/transformers/babel-with-esm-replacements.cjs`:
- Around line 3-7: The custom transformer exported by module.exports.process in
babel-with-esm-replacements.cjs is never used because your Jest transform
mapping still points to 'babel-jest'; either wire this transformer into Jest by
replacing the 'transform' mapping that references 'babel-jest' with a path to
this module so the replace of import.meta.env.MODE -> 'test' runs, or delete
this transformer file and ensure tests set the environment another way (e.g.,
mock import.meta.env.MODE in tests or adjust the existing babel-jest config);
update whichever you choose so files that use import.meta.env.MODE (e.g.,
ReduxStore, useTelemetry) see 'test' during test runs.
- Line 6: The custom Jest transformer in
packages/bruno-app/jest/transformers/babel-with-esm-replacements.cjs is never
used and its replacement call is wrong: update your Jest config to register this
transformer for the appropriate file extensions (ensure the transform map points
to this module instead of or in addition to 'babel-jest' for the files you want
transformed) and fix the replacement in transformer.process so it injects a
string literal and replaces all occurrences (replace import.meta.env.MODE with
the string "'test'" using a global replace or replaceAll). Target symbols: the
transformer module (babel-with-esm-replacements.cjs) and the
transformer.process(...) call so you locate and update the replacement logic,
and the Jest transform mapping in your jest.config.js to register the
transformer.

In
`@packages/bruno-app/src/components/Devtools/Console/TerminalTab/SessionList.js`:
- Line 116: The data-testid attributes in the SessionList component are
currently using the loop index (inside sessions.map) which makes tests flaky;
update all occurrences where data-testid uses the index (the JSX produced in the
sessions.map callback) to use a stable identifier like session.sessionId (e.g.,
replace data-testid={`...-${idx}`} with
data-testid={`...-${session.sessionId}`}), and ensure any related test selectors
referencing those testids are updated accordingly; locate this change in the
sessions.map rendering block and the other similar JSX instances in the same
component.

In `@packages/bruno-app/src/components/MultiLineEditor/index.js`:
- Around line 73-77: Fix the typo in the inline comment above the CodeMirror
input-field handling: change "mousetrap calss" to "mousetrap class" and
"Codemirror" to "CodeMirror" in the comment that precedes the code using
this.editor.getInputField() and cmInput.classList.add('mousetrap') inside the
MultiLineEditor component so the comment is consistent and correctly spelled.

In `@packages/bruno-app/src/components/RequestTabPanel/index.js`:
- Around line 63-71: The keybinding currently enables when isRequestTab is true
but handleRunRef.current may be null if item hasn't loaded; fix by either adding
a runtime guard inside the useKeybinding handler to only call
handleRunRef.current() when it is non-null (referencing handleRunRef and
useKeybinding), or tighten the enabled condition to include the item load check
(e.g., require item exists along with isRequestTab and focusedTab) so the
shortcut is only enabled when handleRunRef is guaranteed to be set.

In `@packages/bruno-app/src/providers/Hotkeys/keyMappings.js`:
- Around line 149-172: The StatusBar component calls
getKeyBindingsForActionAllOS(action) without the userKeyBindings parameter, so
user overrides (e.g., for globalSearch) are ignored; update the StatusBar
invocation to pass the current userKeyBindings (prop or context) into
getKeyBindingsForActionAllOS(action, userKeyBindings), and if StatusBar does not
receive userKeyBindings, thread the value through the parent components or read
it from the existing user settings/key-bindings context (or hook) so that
globalSearch and other actions use the user overrides.

In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1245-1273: The test remaps the collapseSidebar binding but never
invokes it and uses a brittle timeout plus a wrong assertion; after editing the
keybinding inputs (elements keybinding-row-collapseSidebar,
keybinding-edit-collapseSidebar, keybinding-input-collapseSidebar) press the new
shortcut once (e.g., page.keyboard.press('Shift+G') or a single down/up
sequence) to trigger collapse, remove page.waitForTimeout(1000), and replace the
width check on aside.sidebar with a Playwright waitable assertion such as
expect(page.locator('aside.sidebar')).toHaveCSS('width', '0px') to verify the
collapsed state.
- Around line 34-36: Tests depend on state from previous tests (use of Shift+X,
Alt+Y remaps and resources named req-1-renamed, kb-folder-renamed,
kb-collection-renamed), so make each spec self-contained by creating/remapping
the shortcuts and creating/renaming the required resources in that test or move
shared setup into a beforeAll; update the tests referencing Shift+X and Alt+Y to
perform the remap steps (or call a shared helper) before asserting behavior, and
ensure req-1-renamed, kb-folder-renamed, kb-collection-renamed are
created/renamed during setup for tests that reference them. Replace
page.waitForTimeout(1000) with explicit waits (e.g., await locator.waitFor or
expect(locator).toBeVisible()/toHaveText()) and change the fragile assertion
expect(width).not.toBe('255px') to assert the actual collapsed state (check an
aria-expanded attribute, a collapse CSS class, or a specific computed property
indicating collapsed vs expanded).

---

Outside diff comments:
In `@packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js`:
- Around line 85-97: The globalEnvironmentDraft is being added to
environmentDrafts unconditionally; change this so that when forCloseTabs is true
you only include the global-environment draft if its associated tab UID is in
tabUidsToClose (i.e., gate the push on tabUidsToClose.includes(<tabUid>));
otherwise keep current behavior when not closing specific tabs. Apply the same
conditional guard to the other occurrences that handle globalEnvironmentDraft
(the later blocks referenced) and ensure any calls that
clearGlobalEnvironmentDraft() are only invoked for drafts that were actually
part of the targeted tabUidsToClose.

---

Nitpick comments:
In `@packages/bruno-app/src/components/Preferences/Keybindings/index.js`:
- Around line 618-625: The showSuccessFlash function sets
successTimerRef.current with setTimeout but lacks cleanup on unmount; add a
useEffect cleanup that runs on component unmount to
clearTimeout(successTimerRef.current) (and set successTimerRef.current = null)
to prevent setState on an unmounted component; locate the Keybindings component
and modify it to include a useEffect that returns a cleanup function referencing
successTimerRef and setSuccessAction to ensure the pending timer is cleared when
the component unmounts.

In `@packages/bruno-app/src/components/Preferences/Keybindings/StyledWrapper.js`:
- Around line 182-195: Replace hardcoded hex colors used for status states in
StyledWrapper (e.g., in the .shortcut-input--editing,
.shortcut-input--error.shortcut-input--editing and the success state around
lines 234-260) with theme values to match the codebase pattern; for example use
props.theme.status.warning.text for the editing outline instead of `#E4AE49`,
props.theme.status.danger.text for the error outline instead of `#CE4F3B`, and
props.theme.status.success.text for success instead of `#2E8A54`, ensuring you
reference the theme via the same arrow function pattern already used elsewhere
in this file.

In `@tests/collection/moving-tabs/move-tabs.spec.ts`:
- Line 141: Replace the explicit sleeps that call page.waitForTimeout(...) with
relying on Playwright's auto-retrying assertions: remove the
page.waitForTimeout(500) calls and ensure the following assertions (the
expect(tabs.nth(...).toHaveText(...) checks used right after the waits) are used
as the synchronization point so they validate the tab reorder by themselves;
update any test flow that assumed the delay to instead assert the expected tab
text/position using expect(...) which will wait until the UI reaches the
expected state.

In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 83-133: The tests for the "Close All Tabs" shortcut only cover the
zero-draft flow; add two new test cases that exercise the unsaved-drafts path
through the SaveRequestsModal: (1) create a real unsaved draft (e.g.,
openRequest with persist: false or edit an open request), trigger the
closeAllTabs shortcut and choose the "Save" option in the SaveRequestsModal,
then assert drafts were saved and tabs closed/cleaned up; (2) repeat but choose
the "Discard" option in the SaveRequestsModal and assert drafts were removed and
tabs closed/cleaned up; use the existing helpers createRequest/openRequest,
reference the keybinding trigger steps (keyboard.down('...') sequence) and the
SaveRequestsModal UI identifiers to locate and interact with the modal.
🪄 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: 2368911e-9183-40a8-9c89-965fb120c0fd

📥 Commits

Reviewing files that changed from the base of the PR and between c01942a and 30a1ba5.

📒 Files selected for processing (31)
  • packages/bruno-app/jest/transformers/babel-with-esm-replacements.cjs
  • packages/bruno-app/src/components/ApiSpecPanel/FileEditor/CodeEditor/index.js
  • packages/bruno-app/src/components/CodeEditor/index.js
  • packages/bruno-app/src/components/Devtools/Console/TerminalTab/SessionList.js
  • packages/bruno-app/src/components/GlobalSearchModal/index.js
  • packages/bruno-app/src/components/MultiLineEditor/index.js
  • packages/bruno-app/src/components/Preferences/Keybindings/StyledWrapper.js
  • packages/bruno-app/src/components/Preferences/Keybindings/index.js
  • packages/bruno-app/src/components/Preferences/StyledWrapper.js
  • packages/bruno-app/src/components/RequestPane/QueryEditor/index.js
  • packages/bruno-app/src/components/RequestTabPanel/index.js
  • packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js
  • packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CloneCollectionItem/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RenameCollectionItem/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js
  • packages/bruno-app/src/components/Sidebar/NewFolder/index.js
  • packages/bruno-app/src/components/Sidebar/NewRequest/index.js
  • packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js
  • packages/bruno-app/src/components/SingleLineEditor/index.js
  • packages/bruno-app/src/hooks/useKeybinding/index.js
  • packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
  • packages/bruno-app/src/providers/Hotkeys/index.js
  • packages/bruno-app/src/providers/Hotkeys/keyMappings.js
  • packages/bruno-app/src/providers/ReduxStore/slices/app.js
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
  • packages/bruno-electron/src/app/menu-template.js
  • tests/collection/moving-tabs/move-tabs.spec.ts
  • tests/shortcuts/bound-actions.spec.ts
  • tests/utils/page/actions.ts
💤 Files with no reviewable changes (2)
  • packages/bruno-app/src/components/ApiSpecPanel/FileEditor/CodeEditor/index.js
  • packages/bruno-app/src/components/RequestPane/QueryEditor/index.js

Comment thread tests/shortcuts/bound-actions.spec.ts Resolved
Comment thread tests/shortcuts/bound-actions.spec.ts Resolved

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

♻️ Duplicate comments (1)
packages/bruno-app/src/components/RequestTabPanel/index.js (1)

63-67: ⚠️ Potential issue | 🟠 Major

Potential ReferenceError when item is not found.

handleRun is defined at line 284—after the early return at line 272-274 when item is missing. If the user triggers the shortcut while isRequestTab is true but item doesn't exist (e.g., deleted request), the handler will hit a TDZ error since handleRun was never initialized.

Tighten the enabled condition to also require item:

+ const item = findItemInCollection(collection, activeTabUid);
+ const isGrpcRequest = item?.type === 'grpc-request';
+ const isWsRequest = item?.type === 'ws-request';
+
  const isRequestTab = focusedTab && ['request', 'grpc-request', 'ws-request', 'graphql-request'].includes(focusedTab.type);
  useKeybinding('sendRequest', () => {
    handleRun();
    return false;
- }, { enabled: !!isRequestTab, deps: [isRequestTab] });
+ }, { enabled: !!isRequestTab && !!item, deps: [isRequestTab, item] });

This requires moving the item computation (currently at line 231) before the keybinding call, or alternatively restructuring to ensure handleRun is always in scope when the binding is active.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/RequestTabPanel/index.js` around lines 63 -
67, The keybinding can reference handleRun before it's initialized if item is
missing; fix by tightening the binding's enabled condition to also require item
(e.g., change enabled to !!isRequestTab && !!item) and include item in deps, or
move the item computation (currently below) above the useKeybinding call so
handleRun is always defined when the binding is active; update the useKeybinding
call that binds 'sendRequest' and its deps accordingly (reference: isRequestTab,
useKeybinding('sendRequest', ...), handleRun, item).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/bruno-app/src/components/RequestTabPanel/index.js`:
- Around line 63-67: The keybinding can reference handleRun before it's
initialized if item is missing; fix by tightening the binding's enabled
condition to also require item (e.g., change enabled to !!isRequestTab &&
!!item) and include item in deps, or move the item computation (currently below)
above the useKeybinding call so handleRun is always defined when the binding is
active; update the useKeybinding call that binds 'sendRequest' and its deps
accordingly (reference: isRequestTab, useKeybinding('sendRequest', ...),
handleRun, item).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0c18c35-9e07-4879-80f6-ad235a89fde2

📥 Commits

Reviewing files that changed from the base of the PR and between 30a1ba5 and 33469f1.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/RequestTabPanel/index.js

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

Actionable comments posted: 6

🧹 Nitpick comments (4)
packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js (1)

85-97: Global environment draft included regardless of tab-close scope.

When forceCloseTabs is true, the global environment draft is still included in allDrafts. This means closing a subset of tabs could prompt users about global environment changes that aren't directly related to those tabs. If this is intentional (global env is workspace-wide), consider adding a brief comment clarifying the design decision.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js`
around lines 85 - 97, The global environment draft (globalEnvironmentDraft) is
always added into environmentDrafts and thus into allDrafts even when
forceCloseTabs is true, causing unrelated global env prompts when closing a
subset of tabs; change the logic so the globalEnvironmentDraft is only collected
when the close operation targets the whole workspace (e.g., when forceCloseTabs
is false or when closing all tabs), by wrapping the existing
globalEnvironmentDraft block in a condition that checks !forceCloseTabs (or the
appropriate "closing all" flag) and still verify environment exists via
globalEnvironments.find; if including it unconditionally was intentional, add a
clarifying comment explaining that global env changes are treated as
workspace-wide and should always prompt users.
tests/shortcuts/bound-actions.spec.ts (3)

24-29: Use proper Playwright Page type instead of any.

+import { Page } from '@playwright/test';
+
-const closeTabByName = async (page: any, name: string | RegExp) => {
+const closeTabByName = async (page: Page, name: string | RegExp) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/shortcuts/bound-actions.spec.ts` around lines 24 - 29, The test helper
closeTabByName currently types the first parameter as any; update it to use
Playwright's Page type by importing Page from '@playwright/test' and changing
the signature to closeTabByName(page: Page, name: string | RegExp). Keep the
rest of the function identical (locators and assertions) so typechecking is
accurate and you get proper editor/IDE completions for methods like locator,
hover, and getByTestId.

674-710: Consider using test.step for complex multi-phase tests.

This test (and others like the terminal tests) has multiple logical phases: setup tabs, close in order, reopen and verify. Using test.step would make the generated reports easier to read.

test('default Cmd/Ctrl+Shift+T reopens multiple tab types in LIFO order', async ({ page }) => {
  await test.step('Open various tab types', async () => {
    await page.locator('.collection-name').filter({ hasText: 'kb-collection' }).dblclick();
    // ...
  });

  await test.step('Close tabs in specific order', async () => {
    await closeTabByName(page, 'kb-folder');
    // ...
  });

  await test.step('Verify LIFO reopen order', async () => {
    await page.keyboard.press(`${modifier}+Shift+KeyT`);
    // ...
  });
});

As per coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/shortcuts/bound-actions.spec.ts` around lines 674 - 710, The test
'default Cmd/Ctrl+Shift+T reopens multiple tab types in LIFO order' is
multi-phase; wrap each logical phase (setup, close, reopen/verify) in Playwright
test.step calls to improve report readability: enclose the setup actions (calls
to createFolder, page.locator/dblclick, getting tabs), the closing sequence
(calls to closeTabByName with 'kb-folder','Collection','Variables','Runner'),
and the reopen/verify sequence (page.keyboard.press with
`${modifier}+Shift+KeyT` and the corresponding expects) each in their own
test.step blocks with concise step names.

749-749: Unused createTmpDir fixture parameter.

Multiple tests (lines 749, 788, 806, 838, 864, etc.) destructure createTmpDir but never use it. Either remove the unused parameter or use it to create isolated test directories.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/shortcuts/bound-actions.spec.ts` at line 749, The tests like the one
named "default Cmd/Ctrl+F open sidebar search" destructure an unused fixture
parameter createTmpDir; remove createTmpDir from the test parameter list (e.g.,
change async ({ page, createTmpDir }) => to async ({ page }) =>) in each
affected test (same pattern at tests around the other mentioned lines) or
alternatively use createTmpDir to create an isolated directory before the test
actions — update the test functions (the async test callbacks) accordingly so
the parameter is no longer unused.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js`:
- Around line 104-113: The useEffect callback calls onClose but the onClose
function is not listed in the dependency array which can cause a stale
reference; update the effect for totalDraftsCount handling (the useEffect that
checks totalDraftsCount, forceCloseTabs, dispatch, tabUidsToClose) to include
onClose in its dependency array so the effect re-runs when onClose changes,
leaving the logic that dispatches closeTabs or completeQuitFlow and calls
onClose intact.
- Around line 179-184: The modal closes before tab cleanup finishes because
dispatch(closeTabs({ tabUids: tabUidsToClose })) is not awaited; change the
handler to await the thunk dispatch when forceCloseTabs is true (e.g., await
dispatch(closeTabs({ tabUids: tabUidsToClose }))) before calling onClose(),
ensure the enclosing function is declared async so awaiting works, and keep the
existing else branch that dispatches completeQuitFlow() unchanged.
- Around line 138-142: The dispatch(closeTabs({ tabUids: tabUidsToClose })) call
triggers an async thunk but is not awaited, so onClose() can run before cleanup
finishes; update the handler that contains dispatch(closeTabs(...)),
dispatch(completeQuitFlow()), and onClose() to await the async closeTabs thunk
(e.g., await dispatch(closeTabs({ tabUids: tabUidsToClose }))) and ensure the
enclosing function is async (or handle the returned promise) so onClose() is
only called after closeTabs resolves; keep the existing branch for
completeQuitFlow untouched but ensure any async dispatchs are awaited before
calling onClose().

In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1325-1329: After clicking the first close button, remove the fixed
sleep and instead wait explicitly for the next element to appear using
Playwright's waiting APIs: replace the waitForTimeout with awaiting the
visibility (or presence) of page.getByTestId('session-close-0') (e.g., await
expect(page.getByTestId('session-close-0')).toBeVisible({ timeout: 3000 }) or
page.getByTestId('session-close-0').waitFor({ state: 'visible' })), then click
page.getByTestId('session-close-0') and keep the existing
expect(...).not.toBeVisible assertion and final click on page.getByTitle('Close
console').
- Line 1355: Replace the flaky arbitrary sleep call page.waitForTimeout(500)
with an explicit wait for the expected condition: identify the element or
condition the test is waiting for in this spec and use Playwright's explicit
wait APIs (e.g., page.waitForSelector('...'), locator.waitFor({...}),
page.waitForResponse(...), or page.waitForFunction(...)) targeting that
selector/response/state with a sensible timeout and assertion; update the test
at the location where page.waitForTimeout(500) appears to wait for the specific
UI element/state change instead of a fixed delay.
- Around line 1378-1383: The test uses a fixed sleep after clicking
page.getByTestId('session-close-1') — replace that await
page.waitForTimeout(1000) with an explicit wait for the UI change (e.g., await
expect(page.getByTestId('session-close-1')).not.toBeVisible() or await
page.waitForSelector('[data-testid="session-close-1"]', { state: 'hidden' }) )
before proceeding to click page.getByTestId('session-close-0'); keep the
existing explicit assertion await
expect(page.getByTestId('session-close-0')).not.toBeVisible(...) and the final
page.getByTitle('Close console').click() as-is.

---

Nitpick comments:
In `@packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js`:
- Around line 85-97: The global environment draft (globalEnvironmentDraft) is
always added into environmentDrafts and thus into allDrafts even when
forceCloseTabs is true, causing unrelated global env prompts when closing a
subset of tabs; change the logic so the globalEnvironmentDraft is only collected
when the close operation targets the whole workspace (e.g., when forceCloseTabs
is false or when closing all tabs), by wrapping the existing
globalEnvironmentDraft block in a condition that checks !forceCloseTabs (or the
appropriate "closing all" flag) and still verify environment exists via
globalEnvironments.find; if including it unconditionally was intentional, add a
clarifying comment explaining that global env changes are treated as
workspace-wide and should always prompt users.

In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 24-29: The test helper closeTabByName currently types the first
parameter as any; update it to use Playwright's Page type by importing Page from
'@playwright/test' and changing the signature to closeTabByName(page: Page,
name: string | RegExp). Keep the rest of the function identical (locators and
assertions) so typechecking is accurate and you get proper editor/IDE
completions for methods like locator, hover, and getByTestId.
- Around line 674-710: The test 'default Cmd/Ctrl+Shift+T reopens multiple tab
types in LIFO order' is multi-phase; wrap each logical phase (setup, close,
reopen/verify) in Playwright test.step calls to improve report readability:
enclose the setup actions (calls to createFolder, page.locator/dblclick, getting
tabs), the closing sequence (calls to closeTabByName with
'kb-folder','Collection','Variables','Runner'), and the reopen/verify sequence
(page.keyboard.press with `${modifier}+Shift+KeyT` and the corresponding
expects) each in their own test.step blocks with concise step names.
- Line 749: The tests like the one named "default Cmd/Ctrl+F open sidebar
search" destructure an unused fixture parameter createTmpDir; remove
createTmpDir from the test parameter list (e.g., change async ({ page,
createTmpDir }) => to async ({ page }) =>) in each affected test (same pattern
at tests around the other mentioned lines) or alternatively use createTmpDir to
create an isolated directory before the test actions — update the test functions
(the async test callbacks) accordingly so the parameter is no longer unused.
🪄 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: ec0c1901-e3fc-4839-aef8-5f8b73e10ff3

📥 Commits

Reviewing files that changed from the base of the PR and between 33469f1 and 2a5ffe1.

📒 Files selected for processing (3)
  • packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
  • packages/bruno-app/src/providers/Hotkeys/index.js
  • tests/shortcuts/bound-actions.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/providers/Hotkeys/index.js

Comment thread tests/shortcuts/bound-actions.spec.ts Resolved
Comment thread tests/shortcuts/bound-actions.spec.ts Resolved
Comment thread tests/shortcuts/bound-actions.spec.ts Resolved
sid-bruno
sid-bruno previously approved these changes Mar 30, 2026

@sid-bruno sid-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, waiting on tests

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/environments/focus-retention/environment-focus.spec.ts`:
- Line 23: The test is asserting the environment-switch toast text ("Environment
changed to...") instead of the save-success toast; update the assertion to check
for the save confirmation text "Changes saved successfully" (use the same
selector pattern used now, e.g., page.getByText(/(^Changes saved
successfully)/).last() with the existing timeout) so the spec validates the
actual save behavior emitted by EnvironmentVariablesTable rather than the
environment-selection toast.
🪄 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: 469d6dac-a26d-4cd7-9876-9b43440854e2

📥 Commits

Reviewing files that changed from the base of the PR and between 2a5ffe1 and 1790284.

📒 Files selected for processing (1)
  • tests/environments/focus-retention/environment-focus.spec.ts

@sid-bruno
sid-bruno merged commit f0866be into usebruno:main Mar 31, 2026
13 of 14 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 13, 2026
6 tasks
@coderabbitai coderabbitai Bot mentioned this pull request May 25, 2026
6 tasks
maxenceleblanc pushed a commit to maxenceleblanc/curly_cats2 that referenced this pull request Jul 20, 2026
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