Skip to content

fix: send-request shortcut - #7853

Merged
sid-bruno merged 2 commits into
usebruno:mainfrom
shubh-bruno:fix/patch-keybindings
Apr 27, 2026
Merged

sid-bruno merged 2 commits into
usebruno:mainfrom
shubh-bruno:fix/patch-keybindings

Conversation

@shubh-bruno

@shubh-bruno shubh-bruno commented Apr 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

Fixes : #7846

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

    • Added Cmd/Ctrl+Enter shortcut to run requests from body, response, and variable editors.
  • Bug Fixes

    • Improved shortcut event handling to prevent default browser behavior and stop propagation for more reliable execution.
  • Tests

    • Added end-to-end tests covering default and remapped run shortcuts across multiple editor contexts; extended wait timeout for tab visibility checks.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds Cmd/Ctrl+Enter “run” shortcuts to CodeEditor and MultiLineEditor, updates RequestTabPanel’s sendRequest handler to prevent default/stop propagation, and extends tests to verify default and remapped sendRequest keybindings across editor contexts.

Changes

Cohort / File(s) Summary
Run Action Shortcuts
packages/bruno-app/src/components/CodeEditor/index.js, packages/bruno-app/src/components/MultiLineEditor/index.js
Added runShortcut handler and registered it on Cmd-Enter and Ctrl-Enter; handler invokes optional onRun prop or returns CodeMirror.Pass.
Request Keybinding Update
packages/bruno-app/src/components/RequestTabPanel/index.js
sendRequest keybinding now receives the event and calls event.preventDefault() and event.stopPropagation() before invoking handleRun().
Shortcut Integration Tests
tests/shortcuts/bound-actions.spec.ts
Expanded tests to exercise sendRequest via default and remapped shortcuts from JSON body editor, response body editor, and pre-request Vars editor; increased wait timeout for preferences tab closure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

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

Poem

⌨️ Keys aligned — Cmd and Ctrl say "run",
Editors whisper, "onRun" — the job is done,
Events hushed, requests take flight,
Tests nod, green lights bright ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding keyboard shortcut handlers for send-request functionality across multiple editor components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

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

🧹 Nitpick comments (2)
tests/shortcuts/bound-actions.spec.ts (2)

1898-1901: Consider moving keybinding reset into an afterEach.

If any assertion before the reset block fails, the remapped sendRequest → Shift+Enter leaks into the next test. Subsequent customized tests re-remap so they self-heal, but any follow-up test added later that relies on the default binding could silently break. A test.afterEach (or test.step('reset keybindings', ...)) for this describe block would make it fail-safe.

Also applies to: 1955-1958, 2008-2011

🤖 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 1898 - 1901, Move the
keybinding reset logic out of individual tests and into a teardown so remapped
bindings (like the custom sendRequest → Shift+Enter) can't leak; add a
test.afterEach (or a test.step called in afterEach) for the describe block that
calls openKeybindingsTab(page) and clicks the 'reset-all-keybindings-btn' test
id to restore defaults, and remove the duplicated reset blocks currently inside
tests (the occurrences around the existing openKeybindingsTab(...); await
page.getByTestId('reset-all-keybindings-btn').click(...) blocks).

1862-1876: Use the existing remapKeybinding helper to dedupe.

The three customized Shift+Enter tests repeat the same 15-line remap dance (open tab → hover row → click edit → Backspace → press Shift+Enter → close prefs). There's already a remapKeybinding helper at line 95 that does exactly this, and the customized Alt+Z reopens last closed tab test at line 830 uses it. Swapping to it would cut ~45 lines and keep the "happy path" noise down.

♻️ Proposed fix (applied to the first customized block; same pattern for the other two)
-        // Remap sendRequest to Shift+Enter
-        await openKeybindingsTab(page);
-        const row = page.getByTestId(`keybinding-row-sendRequest`);
-        await row.hover();
-        await page.getByTestId(`keybinding-edit-sendRequest`).click();
-        await expect(page.getByTestId(`keybinding-input-sendRequest`)).toBeVisible({ timeout: 2000 });
-
-        await page.keyboard.down('Backspace');
-
-        await page.keyboard.down('Shift');
-        await page.keyboard.down('Enter');
-        await page.keyboard.up('Enter');
-        await page.keyboard.up('Shift');
-
-        await closePreferencesTab(page);
+        await remapKeybinding(page, 'sendRequest', async () => {
+          await page.keyboard.press('Shift+Enter');
+        });

Also applies to: 1910-1924, 1967-1981

🤖 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 1862 - 1876, Replace the
repeated manual remap sequence with the existing helper remapKeybinding to
dedupe; specifically, in the blocks that perform the openKeybindingsTab → hover
on keybinding-row-sendRequest → click keybinding-edit-sendRequest → Backspace →
press Shift+Enter → closePreferencesTab sequence, call remapKeybinding(page,
'sendRequest', 'Shift+Enter') (and the analogous calls for the other two tests)
so the tests use the centralized remapKeybinding helper instead of duplicating
the 15-line interaction sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1898-1901: Move the keybinding reset logic out of individual tests
and into a teardown so remapped bindings (like the custom sendRequest →
Shift+Enter) can't leak; add a test.afterEach (or a test.step called in
afterEach) for the describe block that calls openKeybindingsTab(page) and clicks
the 'reset-all-keybindings-btn' test id to restore defaults, and remove the
duplicated reset blocks currently inside tests (the occurrences around the
existing openKeybindingsTab(...); await
page.getByTestId('reset-all-keybindings-btn').click(...) blocks).
- Around line 1862-1876: Replace the repeated manual remap sequence with the
existing helper remapKeybinding to dedupe; specifically, in the blocks that
perform the openKeybindingsTab → hover on keybinding-row-sendRequest → click
keybinding-edit-sendRequest → Backspace → press Shift+Enter →
closePreferencesTab sequence, call remapKeybinding(page, 'sendRequest',
'Shift+Enter') (and the analogous calls for the other two tests) so the tests
use the centralized remapKeybinding helper instead of duplicating the 15-line
interaction sequence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 74111e6f-96de-4396-afc7-cf8033687012

📥 Commits

Reviewing files that changed from the base of the PR and between c91e5fd and cdd4db1.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/CodeEditor/index.js
  • packages/bruno-app/src/components/MultiLineEditor/index.js
  • packages/bruno-app/src/components/RequestTabPanel/index.js
  • tests/shortcuts/bound-actions.spec.ts

@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

🧹 Nitpick comments (4)
tests/shortcuts/bound-actions.spec.ts (4)

1743-2012: Wrap the multi-step flows in test.step for readable reports.

Per the project's Playwright guideline ("Promote the use of test.step as much as possible so the generated reports are easier to read"), each of these tests has 4-5 distinct phases (close tabs → remap (where applicable) → create+open request → focus editor → send → assert). Wrapping each phase in test.step('...', async () => { ... }) will make trace reports far easier to triage when one of these flaky network tests fails on CI.

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 1743 - 2012, The tests in
this file lack test.step wrappers around distinct phases, making reports hard to
read; update each relevant test (e.g., tests that call createRequest,
openRequest, selectRequestPaneTab, openKeybindingsTab, and the CodeMirror
interactions) to wrap the logical phases (close tabs, remap keys when present,
create/open request, focus/type in editor, send request and assert response) in
test.step('phase name', async () => { ... }) blocks so each phase appears as a
separate step in Playwright reports; apply this to all tests in the "SHORTCUT:
Send Request..." and "SHORTCUT: Send Request (customized Shift+Enter)" suites,
keeping existing awaits and function calls inside the step callbacks.

1854-2011: Heavy duplication across the three Shift+Enter tests — reuse the existing remapKeybinding helper.

The three customized tests repeat the same ~20-line remap block (open keybindings → hover row → click edit → backspace → press Shift+Enter). The file already exposes remapKeybinding (line 95) which neighbouring tests use. Same goes for the trailing "Reset Default" pair — extract a tiny resetAllKeybindings(page) helper.

♻️ Sketch
-      // Remap sendRequest to Shift+Enter
-      await openKeybindingsTab(page);
-      const row = page.getByTestId('keybinding-row-sendRequest');
-      await row.hover();
-      await page.getByTestId('keybinding-edit-sendRequest').click();
-      await expect(page.getByTestId('keybinding-input-sendRequest')).toBeVisible({ timeout: 2000 });
-
-      await page.keyboard.down('Backspace');
-
-      await page.keyboard.down('Shift');
-      await page.keyboard.down('Enter');
-      await page.keyboard.up('Enter');
-      await page.keyboard.up('Shift');
+      await remapKeybinding(page, 'sendRequest', async () => {
+        await page.keyboard.press('Shift+Enter');
+      });

Note: remapKeybinding ends with closePreferencesTab — which is what the commented-out lines (1876/1925/1981) suggest you actually wanted. Win-win.

🤖 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 1854 - 2011, Replace the
repeated 20-line keybinding remap block in the three tests with the existing
remapKeybinding helper (call remapKeybinding(page, 'sendRequest', 'Shift+Enter')
or appropriate args used elsewhere) so the tests reuse the centralized logic
(remapKeybinding already closes preferences via closePreferencesTab), and
extract the repeated "Reset Default" actions into a small
resetAllKeybindings(page) helper that clicks the reset button (call it from each
test). Update the three tests to call remapKeybinding(...) at the start and
resetAllKeybindings(page) at the end to remove duplication.

1838-1851: Comment promises a behaviour that isn't asserted.

The inline comment says "should NOT insert a newline; should fire sendRequest" — but only the second half is asserted (the 200 response). If a future regression makes Cmd/Ctrl+Enter both insert a newline and send, this test still passes. Cheap fix:

       await page.keyboard.press(`${modifier}+Enter`);

+      // Confirm the editor did not also receive a newline insertion
+      await expect(valueEditor).toContainText('val-1');
+      await expect(valueEditor).not.toContainText('val-1\nval-2\n');
       // Verify a 200 response came back
       await expect(page.getByTestId('response-status-code')).toContainText('200', { timeout: 15000 });

Same applies to the Shift+Enter Vars test at lines 1996-2005.

🤖 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 1838 - 1851, The test
comment states Cmd/Ctrl+Enter should not insert a newline but the test only
asserts the request sent; update the test to also assert the CodeMirror value
hasn't gained an extra newline after pressing `${modifier}+Enter` by reading the
value from the same valueEditor locator (the '.CodeMirror' first() used here)
and asserting it still equals the expected two-line string (e.g.
'val-1\nval-2'); apply the same additional assertion to the Shift+Enter Vars
test that uses the Vars editor so the tests fail if the key both inserts a
newline and sends.

1876-1876: Dead commented-out code — decide and delete.

// await closePreferencesTab(page); appears at lines 1876, 1925, and 1981. Either the prefs tab needs closing (in which case restore the call — recommended, since remapKeybinding does this for a reason) or it doesn't (delete the comment). Leaving it in invites cargo-culting later.

Worth confirming locally: with the prefs tab still focused after recording, does the subsequent createRequest flow actually behave the same as when the prefs tab is closed? If runs are green only because openRequest tabs over the prefs view, that's incidental and brittle.

🤖 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 1876, The commented-out calls
to closePreferencesTab(page) are dead code—either remove them or restore the
call; since remapKeybinding expects the prefs tab to be closed, the recommended
fix is to uncomment/restore closePreferencesTab(page) in the three spots where
`// await closePreferencesTab(page);` appears in
tests/shortcuts/bound-actions.spec.ts (ensure they run after the recording step
and before createRequest/openRequest flows), then run the tests locally to
verify createRequest behaves the same; if you instead delete the comments,
remove all three occurrences and add a brief test comment explaining why closing
the prefs tab is not needed and confirm tests remain green.
🤖 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/shortcuts/bound-actions.spec.ts`:
- Around line 1745-2010: The tests currently depend on the external host
https://echo.usebruno.com; replace that dependency by intercepting or stubbing
the network so the tests assert the shortcut triggers sendRequest rather than
relying on an external round-trip. Concretely, in the tests that call
createRequest/openRequest and then expect getByTestId('response-status-code') to
contain '200' (tests named like "sends request when cursor is in JSON body
editor", "...response body editor", and the Shift+Enter variants), add a
page.route(...) or a local fixture server to intercept requests to
https://echo.usebruno.com and return a deterministic 200 response (including any
body needed by response-preview), or change createRequest to point at a local
test server; ensure the interception runs before any UI actions that trigger the
request so the sendRequest flow (the keyboard.press calls) receives the mocked
200 response reliably.

---

Nitpick comments:
In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1743-2012: The tests in this file lack test.step wrappers around
distinct phases, making reports hard to read; update each relevant test (e.g.,
tests that call createRequest, openRequest, selectRequestPaneTab,
openKeybindingsTab, and the CodeMirror interactions) to wrap the logical phases
(close tabs, remap keys when present, create/open request, focus/type in editor,
send request and assert response) in test.step('phase name', async () => { ...
}) blocks so each phase appears as a separate step in Playwright reports; apply
this to all tests in the "SHORTCUT: Send Request..." and "SHORTCUT: Send Request
(customized Shift+Enter)" suites, keeping existing awaits and function calls
inside the step callbacks.
- Around line 1854-2011: Replace the repeated 20-line keybinding remap block in
the three tests with the existing remapKeybinding helper (call
remapKeybinding(page, 'sendRequest', 'Shift+Enter') or appropriate args used
elsewhere) so the tests reuse the centralized logic (remapKeybinding already
closes preferences via closePreferencesTab), and extract the repeated "Reset
Default" actions into a small resetAllKeybindings(page) helper that clicks the
reset button (call it from each test). Update the three tests to call
remapKeybinding(...) at the start and resetAllKeybindings(page) at the end to
remove duplication.
- Around line 1838-1851: The test comment states Cmd/Ctrl+Enter should not
insert a newline but the test only asserts the request sent; update the test to
also assert the CodeMirror value hasn't gained an extra newline after pressing
`${modifier}+Enter` by reading the value from the same valueEditor locator (the
'.CodeMirror' first() used here) and asserting it still equals the expected
two-line string (e.g. 'val-1\nval-2'); apply the same additional assertion to
the Shift+Enter Vars test that uses the Vars editor so the tests fail if the key
both inserts a newline and sends.
- Line 1876: The commented-out calls to closePreferencesTab(page) are dead
code—either remove them or restore the call; since remapKeybinding expects the
prefs tab to be closed, the recommended fix is to uncomment/restore
closePreferencesTab(page) in the three spots where `// await
closePreferencesTab(page);` appears in tests/shortcuts/bound-actions.spec.ts
(ensure they run after the recording step and before createRequest/openRequest
flows), then run the tests locally to verify createRequest behaves the same; if
you instead delete the comments, remove all three occurrences and add a brief
test comment explaining why closing the prefs tab is not needed and confirm
tests remain green.
🪄 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: 7a9fc4a2-9858-445e-bf48-b693c5d3348a

📥 Commits

Reviewing files that changed from the base of the PR and between cdd4db1 and 1f77e54.

📒 Files selected for processing (1)
  • tests/shortcuts/bound-actions.spec.ts

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

Copy link
Copy Markdown
Collaborator

Credits to #7845 by @phubadeepjs for the original implementation

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.

Insert a new line in the editor after sending the request via shortcut key (cmd+enter)

2 participants